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
f74196e9
Commit
f74196e9
authored
May 21, 2017
by
casualet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
able to choose all the onions
parent
dfb8ad27
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
12 deletions
+64
-12
mbk.cc
main/mbk.cc
+64
-12
No files found.
main/mbk.cc
View file @
f74196e9
...
...
@@ -47,6 +47,7 @@
using
std
::
cout
;
using
std
::
cin
;
using
std
::
endl
;
using
std
::
vector
;
std
::
map
<
SECLEVEL
,
std
::
string
>
gmp
;
std
::
map
<
onion
,
std
::
string
>
gmp2
;
...
...
@@ -258,6 +259,7 @@ static std::vector<FieldMeta *> getFieldMeta(SchemaInfo &schema,std::string db =
struct
transField
{
bool
hasSalt
;
FieldMeta
*
originalFm
;
vector
<
int
>
choosenOnions
;
int
onionIndex
=
0
;
int
numOfOnions
=
0
;
//onions
...
...
@@ -464,7 +466,35 @@ std::shared_ptr<ReturnMeta> getReturnMeta(std::vector<FieldMeta*> fms, std::vect
}
static
std
::
string
getBackupQuery
(
SchemaInfo
&
schema
,
std
::
vector
<
transField
>
&
tfds
,
std
::
string
db
=
"tdb"
,
std
::
string
table
=
"student1"
){
std
::
string
getBackupQuery
(
SchemaInfo
&
schema
,
std
::
vector
<
transField
>
&
tfds
,
std
::
string
db
=
"tdb"
,
std
::
string
table
=
"student1"
){
std
::
string
res
=
"SELECT "
;
const
std
::
unique_ptr
<
IdentityMetaKey
>
dbmeta_key
(
new
IdentityMetaKey
(
db
));
//get databaseMeta, search in the map
DatabaseMeta
*
dbm
=
schema
.
getChild
(
*
dbmeta_key
);
const
TableMeta
&
tbm
=
*
((
*
dbm
).
getChild
(
IdentityMetaKey
(
table
)));
std
::
string
annotablename
=
tbm
.
getAnonTableName
();
//then a list of onion names
for
(
auto
item
:
tfds
){
for
(
auto
index
:
item
.
choosenOnions
){
res
+=
item
.
fields
[
index
];
res
+=
" , "
;
}
if
(
item
.
hasSalt
){
res
+=
item
.
originalFm
->
getSaltName
()
+
" , "
;
}
}
res
=
res
.
substr
(
0
,
res
.
size
()
-
2
);
res
=
res
+
"FROM `"
+
db
+
std
::
string
(
"`.`"
)
+
annotablename
+
"`"
;
return
res
;
}
/*
static
std::string getBackupQueryAll(SchemaInfo &schema, std::vector<transField> &tfds,
std::string db="tdb",std::string table="student1"){
std::string res = "SELECT ";
const std::unique_ptr<IdentityMetaKey> dbmeta_key(new IdentityMetaKey(db));
//get databaseMeta, search in the map
...
...
@@ -484,6 +514,9 @@ std::string getBackupQuery(SchemaInfo &schema, std::vector<transField> &tfds,std
res = res + "FROM `"+db+std::string("`.`")+annotablename+"`";
return res;
}
*/
int
...
...
@@ -512,14 +545,11 @@ main() {
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
//const std::string master_key = "113341234";
const
std
::
string
master_key
=
"113341234HEHE"
;
char
*
buffer
;
if
((
buffer
=
getcwd
(
NULL
,
0
))
==
NULL
){
perror
(
"getcwd error"
);
}
embeddedDir
=
std
::
string
(
buffer
)
+
"/shadow"
;
SharedProxyState
*
shared_ps
=
new
SharedProxyState
(
ci
,
embeddedDir
,
master_key
,
determineSecurityRating
());
assert
(
0
==
mysql_thread_init
());
...
...
@@ -545,6 +575,7 @@ main() {
std
::
cout
<<
"please input table name "
<<
std
::
endl
;
cin
>>
table
;
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
//get all the fields in the tables.
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
,
db
,
table
);
auto
res
=
getTransField
(
fms
);
for
(
auto
&
item
:
res
){
...
...
@@ -558,7 +589,28 @@ main() {
ResType
rawtorestype
=
MygetResTypeFromLuaTable
(
false
,
&
resraw
);
auto
finalresults
=
decryptResults
(
rawtorestype
,
*
rm
);
parseResType
(
finalresults
);
}
else
if
(
curQuery
==
"backall"
){
std
::
string
db
,
table
;
std
::
cout
<<
"please input dbname "
<<
std
::
endl
;
cin
>>
db
;
std
::
cout
<<
"please input table name "
<<
std
::
endl
;
cin
>>
table
;
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
//get all the fields in the tables.
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
,
db
,
table
);
auto
res
=
getTransField
(
fms
);
//for each filed, we choose all the onions and salts.
for
(
auto
&
item
:
res
){
assert
(
item
.
choosenOnions
.
size
()
==
0u
);
assert
(
item
.
onions
.
size
()
==
item
.
originalOm
.
size
());
assert
(
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
||
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
+
1
);
for
(
unsigned
int
i
=
0u
;
i
<
item
.
onions
.
size
();
i
++
){
item
.
choosenOnions
.
push_back
(
i
);
}
}
std
::
string
backq
=
getBackupQuery
(
*
schema
,
res
,
db
,
table
);
cout
<<
backq
<<
endl
;
}
std
::
cout
<<
GREEN_BEGIN
<<
"
\n
please input a new query:#######"
<<
COLOR_END
<<
std
::
endl
;
std
::
getline
(
std
::
cin
,
curQuery
);
...
...
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