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
3be49778
Commit
3be49778
authored
May 20, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
able to decrypt
parent
aa56f06e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
17 deletions
+79
-17
.sql_utils.cc.swp
parser/.sql_utils.cc.swp
+0
-0
simple_load_new.cc
tools/simple_load_new.cc
+59
-16
reuse.cc
wrapper/reuse.cc
+18
-0
reuse.hh
wrapper/reuse.hh
+2
-1
No files found.
parser/.sql_utils.cc.swp
0 → 100644
View file @
3be49778
File added
tools/simple_load_new.cc
View file @
3be49778
...
@@ -98,6 +98,56 @@ load_columns(std::vector<FieldMetaTrans> &fmts,std::string db,std::string table)
...
@@ -98,6 +98,56 @@ load_columns(std::vector<FieldMetaTrans> &fmts,std::string db,std::string table)
}
}
}
}
struct
batch
{
vector
<
string
>
field_names
;
vector
<
int
>
field_types
;
vector
<
int
>
field_lengths
;
};
batch
ggbt
;
/*should choose the right decryption onion*/
static
std
::
shared_ptr
<
ReturnMeta
>
getReturnMeta
(
std
::
vector
<
FieldMeta
*>
fms
,
std
::
vector
<
FieldMetaTrans
>
&
tfds
){
assert
(
fms
.
size
()
==
tfds
.
size
());
std
::
shared_ptr
<
ReturnMeta
>
myReturnMeta
=
std
::
make_shared
<
ReturnMeta
>
();
int
pos
=
0
;
//construct OLK
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
]);
if
(
index
==-
1
)
assert
(
0
);
onion
o
=
tfds
[
i
].
getChoosenOnionO
()[
index
];
*
glog
<<
"choosenDecryptionOnion: "
<<
TypeText
<
onion
>::
toText
(
o
)
<<
"
\n
"
;
SECLEVEL
l
=
tfds
[
i
].
getOriginalFieldMeta
()
->
getOnionMeta
(
o
)
->
getSecLevel
();
FieldMeta
*
k
=
tfds
[
i
].
getOriginalFieldMeta
();
OLK
curOLK
(
o
,
l
,
k
);
bool
use_salt
=
false
;
if
(
needsSalt
(
curOLK
))
use_salt
=
true
;
addToReturn
(
myReturnMeta
.
get
(),
pos
++
,
curOLK
,
use_salt
,
k
->
getFieldName
());
if
(
use_salt
)
addSaltToReturn
(
myReturnMeta
.
get
(),
pos
++
);
//used to record choosen field lengths, onion names , and field types
ggbt
.
field_types
.
push_back
(
tfds
[
i
].
getChoosenFieldTypes
()[
index
]);
ggbt
.
field_names
.
push_back
(
tfds
[
i
].
getChoosenOnionName
()[
index
]);
ggbt
.
field_lengths
.
push_back
(
tfds
[
i
].
getChoosenFieldLengths
()[
index
]);
if
(
use_salt
){
ggbt
.
field_types
.
push_back
(
tfds
[
i
].
getSaltType
());
ggbt
.
field_names
.
push_back
(
tfds
[
i
].
getSaltName
());
ggbt
.
field_lengths
.
push_back
(
tfds
[
i
].
getSaltLength
());
}
}
return
myReturnMeta
;
}
static
ResType
load_files_new
(
std
::
string
db
,
std
::
string
table
){
static
ResType
load_files_new
(
std
::
string
db
,
std
::
string
table
){
timer
t_load_files
;
timer
t_load_files
;
...
@@ -114,19 +164,13 @@ static ResType load_files_new(std::string db, std::string table){
...
@@ -114,19 +164,13 @@ static ResType load_files_new(std::string db, std::string table){
}
}
mf
.
show
();
mf
.
show
();
load_columns
(
fmts
,
db
,
table
);
load_columns
(
fmts
,
db
,
table
);
// initGfb(fmts,db,table);//load global columns
/*
std::shared_ptr<ReturnMeta> rm = getReturnMeta(fms,res);
*glog<<"getReturnMeta: "<<
std
::
shared_ptr
<
ReturnMeta
>
rm
=
getReturnMeta
(
fms
,
fmts
);
std::to_string(t_load_files.lap()/1000000u)<<
UNUSED
(
rm
);
"##"<<std::to_string(time(NULL))<<"\n";
vector
<
string
>
field_names
=
ggbt
.
field_names
;
vector
<
string
>
field_names
=
ggbt
.
field_names
;
vector
<
int
>
field_types
=
ggbt
.
field_types
;
vector
<
int
>
field_types
=
ggbt
.
field_types
;
vector
<
int
>
field_lengths
=
ggbt
.
field_lengths
;
vector
<
int
>
field_lengths
=
ggbt
.
field_lengths
;
//why do we need this??
create_embedded_thd
(
0
);
create_embedded_thd
(
0
);
rawMySQLReturnValue
resraw
;
rawMySQLReturnValue
resraw
;
vector
<
vector
<
string
>>
res_field
;
vector
<
vector
<
string
>>
res_field
;
...
@@ -158,18 +202,17 @@ static ResType load_files_new(std::string db, std::string table){
...
@@ -158,18 +202,17 @@ static ResType load_files_new(std::string db, std::string table){
for
(
unsigned
int
i
=
0
;
i
<
field_types
.
size
();
++
i
){
for
(
unsigned
int
i
=
0
;
i
<
field_types
.
size
();
++
i
){
resraw
.
fieldTypes
.
push_back
(
static_cast
<
enum_field_types
>
(
field_types
[
i
]));
resraw
.
fieldTypes
.
push_back
(
static_cast
<
enum_field_types
>
(
field_types
[
i
]));
}
}
ResType
rawtorestype
=
rawMySQLReturnValue_to_ResType
(
false
,
&
resraw
);
ResType
rawtorestype
=
rawMySQLReturnValue_to_ResType
(
false
,
&
resraw
);
UNUSED
(
rawtorestype
);
auto
finalresults
=
decryptResults
(
rawtorestype
,
*
rm
);
rawMySQLReturnValue
MM
;
ResTypeToRawMySQLReturnValue
(
MM
,
finalresults
);
return
finalresults
;
*glog<<"transform: "<<
/*
std::to_string(t_load_files.lap()/1000000u)<<
"##"<<std::to_string(time(NULL))<<"\n";
auto finalresults = decryptResults(rawtorestype,*rm);
*glog<<"descryption: "<<
std::to_string(t_load_files.lap()/1000000u)<<
"##"<<std::to_string(time(NULL))<<"\n";
return finalresults;
*/
*/
return
ResType
(
false
,
0
,
0
);
return
ResType
(
false
,
0
,
0
);
}
}
...
...
wrapper/reuse.cc
View file @
3be49778
...
@@ -132,6 +132,24 @@ itemNullVector(unsigned int count)
...
@@ -132,6 +132,24 @@ itemNullVector(unsigned int count)
return
out
;
return
out
;
}
}
void
ResTypeToRawMySQLReturnValue
(
rawMySQLReturnValue
&
inraw
,
ResType
&
inres
){
inraw
.
fieldNames
=
inres
.
names
;
inraw
.
fieldTypes
=
inres
.
types
;
for
(
auto
&
row
:
inres
.
rows
){
std
::
vector
<
std
::
string
>
insertRow
;
for
(
unsigned
int
i
=
0u
;
i
<
row
.
size
();
i
++
){
if
(
IS_NUM
(
inres
.
types
[
i
])){
insertRow
.
push_back
(
std
::
to_string
(
row
[
i
]
->
val_uint
()));
}
else
{
insertRow
.
push_back
(
ItemToString
(
*
row
[
i
]));
}
}
inraw
.
rowValues
.
push_back
(
insertRow
);
}
}
ResType
rawMySQLReturnValue_to_ResType
(
bool
isNULL
,
rawMySQLReturnValue
*
inRow
,
int
in_last_insert_id
){
ResType
rawMySQLReturnValue_to_ResType
(
bool
isNULL
,
rawMySQLReturnValue
*
inRow
,
int
in_last_insert_id
){
std
::
vector
<
std
::
string
>
names
;
std
::
vector
<
std
::
string
>
names
;
std
::
vector
<
enum_field_types
>
types
;
std
::
vector
<
enum_field_types
>
types
;
...
...
wrapper/reuse.hh
View file @
3be49778
...
@@ -270,4 +270,5 @@ void
...
@@ -270,4 +270,5 @@ void
loadFileNoEscapeLimitCount
(
std
::
string
filename
,
loadFileNoEscapeLimitCount
(
std
::
string
filename
,
std
::
vector
<
std
::
string
>
&
res
,
int
limit
);
std
::
vector
<
std
::
string
>
&
res
,
int
limit
);
void
ResTypeToRawMySQLReturnValue
(
rawMySQLReturnValue
&
inraw
,
ResType
&
inres
);
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