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
e1a77857
Commit
e1a77857
authored
May 26, 2017
by
Casualet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add more options to mbk.cc
parent
a9b370a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
8 deletions
+78
-8
mbk.cc
main/mbk.cc
+78
-8
.main.cc.swp
packages/tls/mysqlWrapper/.main.cc.swp
+0
-0
No files found.
main/mbk.cc
View file @
e1a77857
...
...
@@ -545,11 +545,61 @@ std::string getBackupQueryWithoutSalt(SchemaInfo &schema, std::vector<transField
fieldIndex
++
;
}
}
res
=
res
.
substr
(
0
,
res
.
size
()
-
2
);
res
+=
"FROM `"
+
db
+
std
::
string
(
"`.`"
)
+
annotablename
+
"`"
;
return
res
;
}
static
std
::
string
getBackupQueryWithoutSaltHex
(
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
();
int
numOfChoosenField
=
0
;
//then a list of onion names
for
(
auto
item
:
tfds
){
for
(
auto
index
:
item
.
choosenOnions
){
res
+=
item
.
fields
[
index
];
res
+=
" , "
;
numOfChoosenField
++
;
}
}
res
=
res
.
substr
(
0
,
res
.
size
()
-
2
);
res
=
res
+
"FROM `"
+
db
+
std
::
string
(
"`.`"
)
+
annotablename
+
"` limit 1;"
;
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
res
);
assert
(
numOfChoosenField
==
(
int
)
resraw
.
fieldTypes
.
size
());
vector
<
bool
>
whetherToQuote
;
for
(
auto
i
=
0u
;
i
<
resraw
.
fieldTypes
.
size
();
i
++
){
if
(
IS_NUM
(
resraw
.
fieldTypes
[
i
]))
whetherToQuote
.
push_back
(
false
);
else
whetherToQuote
.
push_back
(
true
);
}
int
fieldIndex
=
0
;
res
=
"SELECT "
;
for
(
auto
item
:
tfds
){
for
(
auto
index
:
item
.
choosenOnions
){
if
(
whetherToQuote
[
fieldIndex
]){
res
+=
string
(
"HEX("
)
+
item
.
fields
[
index
]
+
")"
;
res
+=
" , "
;
}
else
{
res
+=
item
.
fields
[
index
];
res
+=
" , "
;
}
fieldIndex
++
;
}
}
res
=
res
.
substr
(
0
,
res
.
size
()
-
2
);
res
+=
"FROM `"
+
db
+
std
::
string
(
"`.`"
)
+
annotablename
+
"`"
;
return
res
;
}
...
...
@@ -633,11 +683,14 @@ main(int argc, char* argv[]) {
for
(
int
i
=
0
;
i
<
argc
;
i
++
){
printf
(
"%s
\n
"
,
argv
[
i
]);
}
cout
<<
"./mbk dbname tablename option"
"0. back up and decrypt"
"1. back up all"
"2. back up the first onion with out dealing with quote "
"3. back up the first onion while dealing with quote "
<<
endl
;
cout
<<
"./mbk dbname tablename option
\n
"
"0. back up and decrypt
\n
"
"1. back up all With Salt
\n
"
"2. back up the first onion with out dealing with quote With salt
\n
"
"3. back up the first onion while dealing with quote Without Salt
\n
"
"4. back up the first onion while dealing with hex Without salt
\n
"
"5. to be implemented
\n
"
<<
endl
;
return
0
;
}
gmp
[
SECLEVEL
::
INVALID
]
=
"INVALID"
;
...
...
@@ -760,8 +813,25 @@ main(int argc, char* argv[]) {
cout
<<
backq
<<
endl
;
//rawReturnValue resraw = executeAndGetResultRemote(globalConn,backq);
//getInsertQuery(*schema,res,db,table,resraw);
}
else
if
(
string
(
argv
[
3
])
==
"4"
){
std
::
string
db
(
argv
[
1
]),
table
(
argv
[
2
]);
std
::
cout
<<
db
<<
":"
<<
table
<<
std
::
endl
;
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
);
item
.
choosenOnions
.
push_back
(
0
);
}
std
::
string
backq
=
getBackupQueryWithoutSaltHex
(
*
schema
,
res
,
db
,
table
);
cout
<<
backq
<<
endl
;
//rawReturnValue resraw = executeAndGetResultRemote(globalConn,backq);
//getInsertQuery(*schema,res,db,table,resraw);
}
return
0
;
return
0
;
}
packages/tls/mysqlWrapper/.main.cc.swp
deleted
100644 → 0
View file @
a9b370a2
File deleted
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