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
b5ec3250
Commit
b5ec3250
authored
Jan 20, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
needSalt is used in final_load
parent
0ee22c25
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
16 deletions
+21
-16
final_load.cc
debug/final_load.cc
+20
-14
try_select_data.cc
debug/try_select_data.cc
+1
-2
No files found.
debug/final_load.cc
View file @
b5ec3250
...
@@ -74,29 +74,41 @@ std::shared_ptr<ReturnMeta> getReturnMeta(std::vector<FieldMeta*> fms,
...
@@ -74,29 +74,41 @@ std::shared_ptr<ReturnMeta> getReturnMeta(std::vector<FieldMeta*> fms,
int
pos
=
0
;
int
pos
=
0
;
//construct OLK
//construct OLK
for
(
auto
i
=
0u
;
i
<
tfds
.
size
();
i
++
){
for
(
auto
i
=
0u
;
i
<
tfds
.
size
();
i
++
){
//the order is DET,OPE,ASHE,AGG. other onions are not decryptable!!
int
index
=
getDecryptionOnionIndex
(
tfds
[
i
]);
int
index
=
getDecryptionOnionIndex
(
tfds
[
i
]);
if
(
index
==-
1
)
assert
(
0
);
onion
o
=
tfds
[
i
].
getChoosenOnionO
()[
index
];
onion
o
=
tfds
[
i
].
getChoosenOnionO
()[
index
];
SECLEVEL
l
=
tfds
[
i
].
getOriginalFieldMeta
()
->
getOnionMeta
(
o
)
->
getSecLevel
();
SECLEVEL
l
=
tfds
[
i
].
getOriginalFieldMeta
()
->
getOnionMeta
(
o
)
->
getSecLevel
();
FieldMeta
*
k
=
tfds
[
i
].
getOriginalFieldMeta
();
FieldMeta
*
k
=
tfds
[
i
].
getOriginalFieldMeta
();
OLK
curOLK
(
o
,
l
,
k
);
OLK
curOLK
(
o
,
l
,
k
);
addToReturn
(
myReturnMeta
.
get
(),
pos
++
,
curOLK
,
true
,
k
->
getFieldName
());
addToReturn
(
myReturnMeta
.
get
(),
pos
++
,
curOLK
,
true
,
k
->
getFieldName
());
if
(
needsSalt
(
curOLK
))
addSaltToReturn
(
myReturnMeta
.
get
(),
pos
++
);
addSaltToReturn
(
myReturnMeta
.
get
(),
pos
++
);
ggbt
.
field_types
.
push_back
(
tfds
[
i
].
getChoosenFieldTypes
()[
index
]);
ggbt
.
field_types
.
push_back
(
tfds
[
i
].
getChoosenFieldTypes
()[
index
]);
ggbt
.
field_names
.
push_back
(
tfds
[
i
].
getChoosenOnionName
()[
index
]);
ggbt
.
field_names
.
push_back
(
tfds
[
i
].
getChoosenOnionName
()[
index
]);
ggbt
.
field_lengths
.
push_back
(
tfds
[
i
].
getChoosenFieldLengths
()[
index
]);
ggbt
.
field_lengths
.
push_back
(
tfds
[
i
].
getChoosenFieldLengths
()[
index
]);
if
(
needsSalt
(
curOLK
)){
ggbt
.
field_types
.
push_back
(
tfds
[
i
].
getSaltType
());
ggbt
.
field_types
.
push_back
(
tfds
[
i
].
getSaltType
());
ggbt
.
field_names
.
push_back
(
tfds
[
i
].
getSaltName
());
ggbt
.
field_names
.
push_back
(
tfds
[
i
].
getSaltName
());
ggbt
.
field_lengths
.
push_back
(
tfds
[
i
].
getSaltLength
());
ggbt
.
field_lengths
.
push_back
(
tfds
[
i
].
getSaltLength
());
}
}
}
return
myReturnMeta
;
return
myReturnMeta
;
}
}
/*init global full backup. */
static
static
void
initGfb
(
std
::
vector
<
FieldMetaTrans
>
&
res
,
std
::
string
db
,
std
::
string
table
){
void
initGfb
(
std
::
vector
<
FieldMetaTrans
>
&
res
,
std
::
string
db
,
std
::
string
table
){
vector
<
string
>
field_names
;
vector
<
string
>
field_names
;
vector
<
int
>
field_types
;
vector
<
int
>
field_types
;
vector
<
int
>
field_lengths
;
vector
<
int
>
field_lengths
;
/*choosen onions should all be included in gfb. salt is also included
it's hard to decide whether a FieldMetaTrans has salt because the senmantic is different from that of FieldMeta.
*/
for
(
auto
&
item
:
res
){
for
(
auto
&
item
:
res
){
for
(
auto
i
:
item
.
getChoosenOnionName
()){
for
(
auto
i
:
item
.
getChoosenOnionName
()){
field_names
.
push_back
(
i
);
field_names
.
push_back
(
i
);
...
@@ -128,15 +140,14 @@ void initGfb(std::vector<FieldMetaTrans> &res,std::string db,std::string table){
...
@@ -128,15 +140,14 @@ void initGfb(std::vector<FieldMetaTrans> &res,std::string db,std::string table){
}
}
gfb
.
annoOnionNameToFileVector
[
gfb
.
field_names
[
i
]]
=
std
::
move
(
column
);
gfb
.
annoOnionNameToFileVector
[
gfb
.
field_names
[
i
]]
=
std
::
move
(
column
);
}
}
//init another map
//init another map
for
(
unsigned
int
i
=
0
;
i
<
gfb
.
field_names
.
size
();
i
++
){
for
(
unsigned
int
i
=
0
;
i
<
gfb
.
field_names
.
size
();
i
++
){
gfb
.
annoOnionNameToType
[
gfb
.
field_names
[
i
]]
=
gfb
.
field_types
[
i
];
gfb
.
annoOnionNameToType
[
gfb
.
field_names
[
i
]]
=
gfb
.
field_types
[
i
];
}
}
}
}
/*load file, decrypt, and then return data plain fields in the type ResType*/
static
ResType
load_files
(
std
::
string
db
=
"tdb"
,
std
::
string
table
=
"student"
){
static
ResType
load_files
(
std
::
string
db
,
std
::
string
table
){
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
(
embeddedDir
);
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
(
embeddedDir
);
//get all the fields in the tables.
//get all the fields in the tables.
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
,
db
,
table
);
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
,
db
,
table
);
...
@@ -157,13 +168,8 @@ static ResType load_files(std::string db="tdb", std::string table="student"){
...
@@ -157,13 +168,8 @@ static ResType load_files(std::string db="tdb", std::string table="student"){
//why do we need this??
//why do we need this??
create_embedded_thd
(
0
);
create_embedded_thd
(
0
);
rawMySQLReturnValue
resraw
;
rawMySQLReturnValue
resraw
;
//db = res_meta.get_db();
// vector<vector<string>> resss_field = loadTableFieldsForDecryption(db,
//table = res_meta.get_table();
// table,field_names, field_types, field_lengths);
//load fields in the stored file
//Fast version
vector
<
vector
<
string
>>
resss_field
=
loadTableFieldsForDecryption
(
db
,
table
,
field_names
,
field_types
,
field_lengths
);
vector
<
vector
<
string
>>
res_field
;
vector
<
vector
<
string
>>
res_field
;
for
(
auto
item
:
field_names
){
for
(
auto
item
:
field_names
){
res_field
.
push_back
(
gfb
.
annoOnionNameToFileVector
[
item
]);
res_field
.
push_back
(
gfb
.
annoOnionNameToFileVector
[
item
]);
...
...
debug/try_select_data.cc
View file @
b5ec3250
...
@@ -51,8 +51,7 @@ static void sp_next_first(const help_select &hs){
...
@@ -51,8 +51,7 @@ static void sp_next_first(const help_select &hs){
rawMySQLReturnValue
str
;
rawMySQLReturnValue
str
;
transform_to_rawMySQLReturnValue
(
str
,
const_cast
<
ResType
&>
(
againGet
));
transform_to_rawMySQLReturnValue
(
str
,
const_cast
<
ResType
&>
(
againGet
));
str
.
fieldNames
=
againGet
.
names
;
str
.
fieldNames
=
againGet
.
names
;
write_row_data
(
str
,
"tdb"
,
"student"
,
"tdata/"
);
// write_row_data(str,"tdb","student","tdata/");
//AbstractQueryExecutor::ResultType::RESULTS
//AbstractQueryExecutor::ResultType::RESULTS
const
auto
&
res
=
decryptResults
(
againGet
,
hs
.
rmeta
);
const
auto
&
res
=
decryptResults
(
againGet
,
hs
.
rmeta
);
parseResType
(
res
);
parseResType
(
res
);
...
...
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