Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
Practical-Cryptdb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Zhaozhen
Practical-Cryptdb
Commits
cacaa34f
Commit
cacaa34f
authored
Apr 25, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
final_store in tools able to support multiple tables
parent
d8521abb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
38 deletions
+75
-38
data.sql
data.sql
+0
-1
final_store.cc
tools/final_store.cc
+75
-37
No files found.
data.sql
deleted
100644 → 0
View file @
d8521abb
INSERT
INTO
`tdb`
.
`table_KBMACQBCDL`
VALUES
(
7172051510492996326
,
13597518156
,
'ۀ#p+Ow<G:< 5Fš2
\n
X
\Z
4+ tD?#>GzZJY
\0
<o؇
\r
3E ^YC[?i_3=(:uJQOB^Ma7+Ek^?2˖;UUN`iTI8?|e5am},9RL" -7D-i.%P9>
\0
6K
\'
%'
,
10597100466299340645
,
'`
\0
u-Ypy(>^U/Q'
,
4683721645241909493
,
''
,
10055494352803353658
);
tools/final_store.cc
View file @
cacaa34f
...
@@ -3,9 +3,8 @@
...
@@ -3,9 +3,8 @@
//This connection mimics the behaviour of MySQL-Proxy
//This connection mimics the behaviour of MySQL-Proxy
Connect
*
globalConn
;
Connect
*
globalConn
;
//query for testing purposes
static
static
std
::
string
get
Test
Query
(
SchemaInfo
&
schema
,
std
::
vector
<
FieldMetaTrans
>
&
tfds
,
std
::
string
get
Backup
Query
(
SchemaInfo
&
schema
,
std
::
vector
<
FieldMetaTrans
>
&
tfds
,
std
::
string
db
=
"tdb"
,
std
::
string
table
=
"student1"
){
std
::
string
db
=
"tdb"
,
std
::
string
table
=
"student1"
){
std
::
string
res
=
"SELECT "
;
std
::
string
res
=
"SELECT "
;
const
std
::
unique_ptr
<
IdentityMetaKey
>
dbmeta_key
(
new
IdentityMetaKey
(
db
));
const
std
::
unique_ptr
<
IdentityMetaKey
>
dbmeta_key
(
new
IdentityMetaKey
(
db
));
...
@@ -48,7 +47,6 @@ void write_raw_data_to_files(MySQLColumnData& resraw,std::vector<FieldMetaTrans>
...
@@ -48,7 +47,6 @@ void write_raw_data_to_files(MySQLColumnData& resraw,std::vector<FieldMetaTrans>
filenames
.
push_back
(
item
);
filenames
.
push_back
(
item
);
}
}
int
len
=
resraw
.
fieldNames
.
size
();
int
len
=
resraw
.
fieldNames
.
size
();
for
(
int
i
=
0
;
i
<
len
;
i
++
){
for
(
int
i
=
0
;
i
<
len
;
i
++
){
if
(
IS_NUM
(
resraw
.
fieldTypes
[
i
])){
if
(
IS_NUM
(
resraw
.
fieldTypes
[
i
])){
writeColumndataNum
(
resraw
.
columnData
[
i
],
filenames
[
i
]);
writeColumndataNum
(
resraw
.
columnData
[
i
],
filenames
[
i
]);
...
@@ -58,49 +56,87 @@ void write_raw_data_to_files(MySQLColumnData& resraw,std::vector<FieldMetaTrans>
...
@@ -58,49 +56,87 @@ void write_raw_data_to_files(MySQLColumnData& resraw,std::vector<FieldMetaTrans>
}
}
}
}
static
void
store
(
std
::
string
db
,
std
::
string
table
){
static
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
(
gembeddedDir
);
std
::
vector
<
std
::
string
>
//get all the fields in the tables
getDbTables
(
std
::
string
db
)
{
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
,
db
,
table
);
executeAndGetColumnData
(
globalConn
,
std
::
string
(
"use "
)
+
db
);
MySQLColumnData
resraw
=
executeAndGetColumnData
(
globalConn
,
"show tables"
);
return
resraw
.
columnData
[
0
];
}
//transform the field so that selected onions can be used
std
::
vector
<
FieldMetaTrans
>
res
;
static
for
(
auto
i
=
0u
;
i
<
fms
.
size
();
i
++
){
void
store
(
std
::
string
db
,
std
::
string
intable
){
FieldMetaTrans
ft
;
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
(
gembeddedDir
);
res
.
push_back
(
ft
);
//do this for each table
res
.
back
().
trans
(
fms
[
i
]);
std
::
vector
<
std
::
string
>
tables
;
if
(
intable
==
std
::
string
(
"-1"
)){
tables
=
getDbTables
(
db
);
std
::
map
<
std
::
string
,
int
>
annIndex
;
for
(
unsigned
int
i
=
0u
;
i
<
tables
.
size
();
++
i
)
{
annIndex
[
tables
[
i
]]
=
i
;
}
//then transform
const
std
::
unique_ptr
<
AES_KEY
>
&
TK
=
std
::
unique_ptr
<
AES_KEY
>
(
getKey
(
std
::
string
(
"113341234"
)));
Analysis
analysis
(
db
,
*
schema
,
TK
,
SECURITY_RATING
::
SENSITIVE
);
if
(
analysis
.
databaseMetaExists
(
db
)){
const
DatabaseMeta
&
dbm
=
analysis
.
getDatabaseMeta
(
db
);
auto
&
tableMetas
=
dbm
.
getChildren
();
for
(
auto
&
kvtable
:
tableMetas
){
auto
annoname
=
kvtable
.
second
->
getAnonTableName
();
auto
plainname
=
kvtable
.
first
.
getValue
();
tables
[
annIndex
[
annoname
]]
=
plainname
;
}
}
}
else
{
tables
.
push_back
(
intable
);
}
}
/*this is our strategy, each field should be able to choose the selected onion*/
for
(
auto
table
:
tables
)
{
storeStrategies
(
res
);
//get all the fields in the tables
//generate the backup query and then fetch the tuples
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
,
db
,
table
);
std
::
string
backup_query
=
getTestQuery
(
*
schema
,
res
,
db
,
table
);
//transform the field so that selected onions can be used
MySQLColumnData
resraw
=
executeAndGetColumnData
(
globalConn
,
backup_query
);
std
::
vector
<
FieldMetaTrans
>
res
;
//then we should set the type and length of FieldMetaTrans
for
(
auto
i
=
0u
;
i
<
fms
.
size
();
i
++
){
auto
types
=
resraw
.
fieldTypes
;
FieldMetaTrans
ft
;
auto
lengths
=
resraw
.
maxLengths
;
res
.
push_back
(
ft
);
int
base_types
=
0
;
res
.
back
().
trans
(
fms
[
i
]);
int
base_lengths
=
0
;
for
(
auto
&
item
:
res
){
vector
<
int
>
tempTypes
;
vector
<
int
>
tempLengths
;
for
(
unsigned
int
i
=
0u
;
i
<
item
.
getChoosenOnionName
().
size
();
i
++
){
tempTypes
.
push_back
(
types
[
base_types
++
]);
tempLengths
.
push_back
(
lengths
[
base_lengths
++
]);
}
}
item
.
setChoosenFieldTypes
(
tempTypes
);
item
.
setChoosenFieldLengths
(
tempLengths
);
/*this is our strategy, each field should be able to choose the selected onion*/
if
(
item
.
getHasSalt
()){
//also this should be changed.
storeStrategies
(
res
);
item
.
setSaltType
(
types
[
base_types
++
]);
//generate the backup query and then fetch the tuples
item
.
setSaltLength
(
lengths
[
base_lengths
++
]);
std
::
string
backup_query
=
getBackupQuery
(
*
schema
,
res
,
db
,
table
);
MySQLColumnData
resraw
=
executeAndGetColumnData
(
globalConn
,
backup_query
);
//then we should set the type and length of FieldMetaTrans
auto
types
=
resraw
.
fieldTypes
;
auto
lengths
=
resraw
.
maxLengths
;
int
base_types
=
0
;
int
base_lengths
=
0
;
for
(
auto
&
item
:
res
){
vector
<
int
>
tempTypes
;
vector
<
int
>
tempLengths
;
for
(
unsigned
int
i
=
0u
;
i
<
item
.
getChoosenOnionName
().
size
();
i
++
){
tempTypes
.
push_back
(
types
[
base_types
++
]);
tempLengths
.
push_back
(
lengths
[
base_lengths
++
]);
}
item
.
setChoosenFieldTypes
(
tempTypes
);
item
.
setChoosenFieldLengths
(
tempLengths
);
if
(
item
.
getHasSalt
()){
//also this should be changed.
item
.
setSaltType
(
types
[
base_types
++
]);
item
.
setSaltLength
(
lengths
[
base_lengths
++
]);
}
}
}
//write the tuples into files
write_raw_data_to_files
(
resraw
,
res
,
db
,
table
);
}
}
//write the tuples into files
write_raw_data_to_files
(
resraw
,
res
,
db
,
table
);
}
}
int
int
main
(
int
argc
,
char
*
argv
[]){
main
(
int
argc
,
char
*
argv
[]){
std
::
string
db
=
"tdb"
,
table
=
"
student
"
;
std
::
string
db
=
"tdb"
,
table
=
"
-1
"
;
std
::
string
ip
=
"127.0.0.1"
;
std
::
string
ip
=
"127.0.0.1"
;
int
port
=
3306
;
int
port
=
3306
;
if
(
argc
==
4
){
if
(
argc
==
4
){
...
@@ -108,7 +144,9 @@ main(int argc, char* argv[]){
...
@@ -108,7 +144,9 @@ main(int argc, char* argv[]){
db
=
std
::
string
(
argv
[
2
]);
db
=
std
::
string
(
argv
[
2
]);
table
=
std
::
string
(
argv
[
3
]);
table
=
std
::
string
(
argv
[
3
]);
}
}
/*Init globalConn to interact with MySQL Server. Init embedded MySQL to use the parser*/
globalConn
=
globalInit
(
ip
,
port
);
globalConn
=
globalInit
(
ip
,
port
);
//store data and metadata
store
(
db
,
table
);
store
(
db
,
table
);
return
0
;
return
0
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment