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
5398e211
Commit
5398e211
authored
May 18, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add bench in test_enclayers
parent
b7583717
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
1170 additions
and
2 deletions
+1170
-2
bench_layer_ASHE.cc
test_enclayers/bench_layer_ASHE.cc
+132
-0
bench_layer_DET_int.cc
test_enclayers/bench_layer_DET_int.cc
+142
-0
bench_layer_DET_str.cc
test_enclayers/bench_layer_DET_str.cc
+34
-2
bench_layer_HOM.cc
test_enclayers/bench_layer_HOM.cc
+131
-0
bench_layer_OPE_int.cc
test_enclayers/bench_layer_OPE_int.cc
+142
-0
bench_layer_OPE_str.cc
test_enclayers/bench_layer_OPE_str.cc
+142
-0
bench_layer_RND_int.cc
test_enclayers/bench_layer_RND_int.cc
+145
-0
bench_layer_RND_str.cc
test_enclayers/bench_layer_RND_str.cc
+154
-0
bench_layer_SWP.cc
test_enclayers/bench_layer_SWP.cc
+148
-0
No files found.
test_enclayers/bench_layer_ASHE.cc
0 → 100644
View file @
5398e211
#include "parser/sql_utils.hh"
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include "main/CryptoHandlers.hh"
#include "wrapper/reuse.hh"
#include "wrapper/common.hh"
#include "wrapper/insert_lib.hh"
#include "util/constants.hh"
#include "util/timer.hh"
#include "util/log.hh"
#include "util/onions.hh"
using
std
::
cout
;
using
std
::
cin
;
using
std
::
endl
;
using
std
::
vector
;
using
std
::
string
;
using
std
::
to_string
;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
static
std
::
map
<
std
::
string
,
WrapperState
*>
clients
;
//This connection mimics the behaviour of MySQL-Proxy
Connect
*
globalConn
;
/*for each field, convert the format to FieldMeta_Wrapper*/
static
void
init
(){
std
::
string
client
=
"192.168.1.1:1234"
;
//one Wrapper per user.
clients
[
client
]
=
new
WrapperState
();
//Connect phase
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
const
std
::
string
master_key
=
"113341234"
;
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
());
//we init embedded database here.
clients
[
client
]
->
ps
=
std
::
unique_ptr
<
ProxyState
>
(
new
ProxyState
(
*
shared_ps
));
clients
[
client
]
->
ps
->
safeCreateEmbeddedTHD
();
//Connect end!!
globalConn
=
new
Connect
(
ci
.
server
,
ci
.
user
,
ci
.
passwd
,
ci
.
port
);
}
static
Item
*
getItemInt
(
std
::
string
input
)
{
return
new
(
current_thd
->
mem_root
)
Item_int
(
static_cast
<
ulonglong
>
(
valFromStr
(
input
)));
}
/*
static
Item *
getItemString(std::string input) {
return MySQLFieldTypeToItem(MYSQL_TYPE_STRING, input);
}
static
Create_field* getStringField(int length) {
Create_field *f = new Create_field;
f->sql_type = MYSQL_TYPE_VARCHAR;
f->length = length;
return f;
}
static
Create_field* getUnsignedIntField(){
Create_field *f = new Create_field;
f->sql_type = MYSQL_TYPE_LONG;
f->flags |= UNSIGNED_FLAG;
return f;
}
*/
int
main
(
int
argc
,
char
**
argv
)
{
init
();
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
Create_field
*
cf
=
NULL
;
ASHE
*
as
=
new
ASHE
(
*
cf
,
key
);
int
num_of_tests
=
10000
;
if
(
argc
==
2
){
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
}
else
{
std
::
cout
<<
"num_of_tests"
<<
std
::
endl
;
return
0
;
}
Item
*
plain
=
getItemInt
(
"123456789"
);
std
::
cout
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
Item
*
enc
=
NULL
;
Item
*
dec
=
NULL
;
timer
t
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
enc
=
as
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"ENC_ASHE_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
dec
=
as
->
decrypt
(
*
enc
,
0u
);
}
std
::
cout
<<
"DEC_ASHE_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
(
void
)
dec
;
return
0
;
}
//main/schema.cc:83 is use to create layers of encryption
test_enclayers/bench_layer_DET_int.cc
0 → 100644
View file @
5398e211
#include "parser/sql_utils.hh"
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include "main/CryptoHandlers.hh"
#include "wrapper/reuse.hh"
#include "wrapper/common.hh"
#include "wrapper/insert_lib.hh"
#include "util/constants.hh"
#include "util/timer.hh"
#include "util/log.hh"
#include "util/onions.hh"
using
std
::
cout
;
using
std
::
cin
;
using
std
::
endl
;
using
std
::
vector
;
using
std
::
string
;
using
std
::
to_string
;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
static
std
::
map
<
std
::
string
,
WrapperState
*>
clients
;
//This connection mimics the behaviour of MySQL-Proxy
Connect
*
globalConn
;
/*for each field, convert the format to FieldMeta_Wrapper*/
static
void
init
(){
std
::
string
client
=
"192.168.1.1:1234"
;
//one Wrapper per user.
clients
[
client
]
=
new
WrapperState
();
//Connect phase
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
const
std
::
string
master_key
=
"113341234"
;
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
());
//we init embedded database here.
clients
[
client
]
->
ps
=
std
::
unique_ptr
<
ProxyState
>
(
new
ProxyState
(
*
shared_ps
));
clients
[
client
]
->
ps
->
safeCreateEmbeddedTHD
();
//Connect end!!
globalConn
=
new
Connect
(
ci
.
server
,
ci
.
user
,
ci
.
passwd
,
ci
.
port
);
}
/*
static
Item *
getItemString(std::string input) {
return MySQLFieldTypeToItem(MYSQL_TYPE_STRING, input);
}*/
static
Item
*
getItemInt
(
std
::
string
input
)
{
return
new
(
current_thd
->
mem_root
)
Item_int
(
static_cast
<
ulonglong
>
(
valFromStr
(
input
)));
}
/*
static
Item *
getItemString(std::string input) {
return MySQLFieldTypeToItem(MYSQL_TYPE_STRING, input);
}
static
Create_field* getStringField(int length) {
Create_field *f = new Create_field;
f->sql_type = MYSQL_TYPE_VARCHAR;
f->length = length;
return f;
}
*/
static
Create_field
*
getUnsignedIntField
(){
Create_field
*
f
=
new
Create_field
;
f
->
sql_type
=
MYSQL_TYPE_LONG
;
f
->
flags
|=
UNSIGNED_FLAG
;
return
f
;
}
int
main
(
int
argc
,
char
**
argv
)
{
init
();
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
Create_field
*
cf
=
getUnsignedIntField
();
DET_int
*
ds
=
new
DET_int
(
*
cf
,
key
);
int
num_of_tests
=
10000
;
if
(
argc
==
2
){
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
}
else
{
std
::
cout
<<
"num_of_tests"
<<
std
::
endl
;
return
0
;
}
Item
*
plain
=
getItemInt
(
"123456789"
);
std
::
cout
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
Item
*
enc
=
NULL
;
Item
*
dec
=
NULL
;
timer
t
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
enc
=
ds
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"DEC_DET_int_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
dec
=
ds
->
decrypt
(
*
enc
,
0u
);
}
std
::
cout
<<
"ENC_DET_int_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
(
void
)
dec
;
return
0
;
}
//main/schema.cc:83 is use to create layers of encryption
test_enclayers/
test
_layer_DET_str.cc
→
test_enclayers/
bench
_layer_DET_str.cc
View file @
5398e211
...
@@ -66,6 +66,38 @@ getItemString(std::string input) {
...
@@ -66,6 +66,38 @@ getItemString(std::string input) {
}
}
/*
static
Item *
getItemInt(std::string input) {
return new (current_thd->mem_root)
Item_int(static_cast<ulonglong>(valFromStr(input)));
}
static
Item *
getItemString(std::string input) {
return MySQLFieldTypeToItem(MYSQL_TYPE_STRING, input);
}
static
Create_field* getStringField(int length) {
Create_field *f = new Create_field;
f->sql_type = MYSQL_TYPE_VARCHAR;
f->length = length;
return f;
}
static
Create_field* getUnsignedIntField(){
Create_field *f = new Create_field;
f->sql_type = MYSQL_TYPE_LONG;
f->flags |= UNSIGNED_FLAG;
return f;
}
*/
static
static
void
control
(
DET_str
*
ds
,
Item
*
plain
,
int
num_of_tests
,
int
length
)
{
void
control
(
DET_str
*
ds
,
Item
*
plain
,
int
num_of_tests
,
int
length
)
{
Item
*
enc
=
NULL
;
Item
*
enc
=
NULL
;
...
@@ -91,7 +123,7 @@ int
...
@@ -91,7 +123,7 @@ int
main
(
int
argc
,
char
**
argv
)
{
main
(
int
argc
,
char
**
argv
)
{
init
();
init
();
create_embedded_thd
(
0
);
create_embedded_thd
(
0
);
std
::
string
key
(
16
,
'a'
)
;
std
::
string
key
=
"key"
;
Create_field
*
cf
=
NULL
;
Create_field
*
cf
=
NULL
;
DET_str
*
ds
=
new
DET_str
(
*
cf
,
key
);
DET_str
*
ds
=
new
DET_str
(
*
cf
,
key
);
...
@@ -106,7 +138,7 @@ main(int argc,char**argv) {
...
@@ -106,7 +138,7 @@ main(int argc,char**argv) {
return
0
;
return
0
;
}
}
for
(
int
i
=
1
;
i
<=
100
;
i
++
)
{
for
(
int
i
=
1
;
i
<=
100
;
i
++
)
{
std
::
string
input
=
"abc"
;
//=
ggetpRandomName(length*i);
std
::
string
input
=
ggetpRandomName
(
length
*
i
);
Item
*
plain
=
getItemString
(
input
)
;
Item
*
plain
=
getItemString
(
input
)
;
control
(
ds
,
plain
,
num_of_tests
,
length
*
i
)
;
control
(
ds
,
plain
,
num_of_tests
,
length
*
i
)
;
}
}
...
...
test_enclayers/bench_layer_HOM.cc
0 → 100644
View file @
5398e211
#include "parser/sql_utils.hh"
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include "main/CryptoHandlers.hh"
#include "wrapper/reuse.hh"
#include "wrapper/common.hh"
#include "wrapper/insert_lib.hh"
#include "util/constants.hh"
#include "util/timer.hh"
#include "util/log.hh"
#include "util/onions.hh"
using
std
::
cout
;
using
std
::
cin
;
using
std
::
endl
;
using
std
::
vector
;
using
std
::
string
;
using
std
::
to_string
;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
static
std
::
map
<
std
::
string
,
WrapperState
*>
clients
;
//This connection mimics the behaviour of MySQL-Proxy
Connect
*
globalConn
;
/*for each field, convert the format to FieldMeta_Wrapper*/
static
void
init
(){
std
::
string
client
=
"192.168.1.1:1234"
;
//one Wrapper per user.
clients
[
client
]
=
new
WrapperState
();
//Connect phase
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
const
std
::
string
master_key
=
"113341234"
;
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
());
//we init embedded database here.
clients
[
client
]
->
ps
=
std
::
unique_ptr
<
ProxyState
>
(
new
ProxyState
(
*
shared_ps
));
clients
[
client
]
->
ps
->
safeCreateEmbeddedTHD
();
//Connect end!!
globalConn
=
new
Connect
(
ci
.
server
,
ci
.
user
,
ci
.
passwd
,
ci
.
port
);
}
static
Item
*
getItemInt
(
std
::
string
input
)
{
return
new
(
current_thd
->
mem_root
)
Item_int
(
static_cast
<
ulonglong
>
(
valFromStr
(
input
)));
}
/*
static
Item *
getItemString(std::string input) {
return MySQLFieldTypeToItem(MYSQL_TYPE_STRING, input);
}
static
Create_field* getStringField(int length) {
Create_field *f = new Create_field;
f->sql_type = MYSQL_TYPE_VARCHAR;
f->length = length;
return f;
}
static
Create_field* getUnsignedIntField(){
Create_field *f = new Create_field;
f->sql_type = MYSQL_TYPE_LONG;
f->flags |= UNSIGNED_FLAG;
return f;
}
*/
int
main
(
int
argc
,
char
**
argv
)
{
init
();
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
Create_field
*
cf
=
NULL
;
HOM
*
hm
=
new
HOM
(
*
cf
,
key
);
int
num_of_tests
=
10000
;
if
(
argc
==
2
){
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
}
else
{
std
::
cout
<<
"num_of_tests"
<<
std
::
endl
;
return
0
;
}
Item
*
plain
=
getItemInt
(
"123456789"
);
Item
*
enc
=
NULL
;
Item
*
dec
=
NULL
;
std
::
cout
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
timer
t
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
enc
=
hm
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"HOM_ENC_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
dec
=
hm
->
decrypt
(
*
enc
,
0u
);
}
std
::
cout
<<
"HOM_DEC_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
(
void
)
dec
;
return
0
;
}
//main/schema.cc:83 is use to create layers of encryption
test_enclayers/bench_layer_OPE_int.cc
0 → 100644
View file @
5398e211
#include "parser/sql_utils.hh"
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include "main/CryptoHandlers.hh"
#include "wrapper/reuse.hh"
#include "wrapper/common.hh"
#include "wrapper/insert_lib.hh"
#include "util/constants.hh"
#include "util/timer.hh"
#include "util/log.hh"
#include "util/onions.hh"
using
std
::
cout
;
using
std
::
cin
;
using
std
::
endl
;
using
std
::
vector
;
using
std
::
string
;
using
std
::
to_string
;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
static
std
::
map
<
std
::
string
,
WrapperState
*>
clients
;
//This connection mimics the behaviour of MySQL-Proxy
Connect
*
globalConn
;
/*for each field, convert the format to FieldMeta_Wrapper*/
static
void
init
(){
std
::
string
client
=
"192.168.1.1:1234"
;
//one Wrapper per user.
clients
[
client
]
=
new
WrapperState
();
//Connect phase
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
const
std
::
string
master_key
=
"113341234"
;
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
());
//we init embedded database here.
clients
[
client
]
->
ps
=
std
::
unique_ptr
<
ProxyState
>
(
new
ProxyState
(
*
shared_ps
));
clients
[
client
]
->
ps
->
safeCreateEmbeddedTHD
();
//Connect end!!
globalConn
=
new
Connect
(
ci
.
server
,
ci
.
user
,
ci
.
passwd
,
ci
.
port
);
}
/*
static
Item *
getItemString(std::string input) {
return MySQLFieldTypeToItem(MYSQL_TYPE_STRING, input);
}*/
static
Item
*
getItemInt
(
std
::
string
input
)
{
return
new
(
current_thd
->
mem_root
)
Item_int
(
static_cast
<
ulonglong
>
(
valFromStr
(
input
)));
}
/*
static
Item *
getItemString(std::string input) {
return MySQLFieldTypeToItem(MYSQL_TYPE_STRING, input);
}
static
Create_field* getStringField(int length) {
Create_field *f = new Create_field;
f->sql_type = MYSQL_TYPE_VARCHAR;
f->length = length;
return f;
}
*/
static
Create_field
*
getUnsignedIntField
(){
Create_field
*
f
=
new
Create_field
;
f
->
sql_type
=
MYSQL_TYPE_LONG
;
f
->
flags
|=
UNSIGNED_FLAG
;
return
f
;
}
int
main
(
int
argc
,
char
**
argv
)
{
init
();
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
Create_field
*
cf
=
getUnsignedIntField
();
OPE_int
*
op
=
new
OPE_int
(
*
cf
,
key
);
int
num_of_tests
=
10000
;
if
(
argc
==
2
){
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
}
else
{
std
::
cout
<<
"num_of_tests:length"
<<
std
::
endl
;
return
0
;
}
std
::
cout
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
Item
*
plain
=
getItemInt
(
"123456789"
);
//getItemString("helloworld");
Item
*
enc
=
NULL
;
Item
*
dec
=
NULL
;
timer
t
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
enc
=
op
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"ENC_OPE_int_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
dec
=
op
->
decrypt
(
*
enc
,
0u
);
}
std
::
cout
<<
"DEC_OPE_int_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
(
void
)
dec
;
return
0
;
}
//main/schema.cc:83 is use to create layers of encryption
test_enclayers/bench_layer_OPE_str.cc
0 → 100644
View file @
5398e211
#include "parser/sql_utils.hh"
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include "main/CryptoHandlers.hh"
#include "wrapper/reuse.hh"
#include "wrapper/common.hh"
#include "wrapper/insert_lib.hh"
#include "util/constants.hh"
#include "util/timer.hh"
#include "util/log.hh"
#include "util/onions.hh"
using
std
::
cout
;
using
std
::
cin
;
using
std
::
endl
;
using
std
::
vector
;
using
std
::
string
;
using
std
::
to_string
;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
static
std
::
map
<
std
::
string
,
WrapperState
*>
clients
;
//This connection mimics the behaviour of MySQL-Proxy
Connect
*
globalConn
;
/*for each field, convert the format to FieldMeta_Wrapper*/
static
void
init
(){
std
::
string
client
=
"192.168.1.1:1234"
;
//one Wrapper per user.
clients
[
client
]
=
new
WrapperState
();
//Connect phase
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
const
std
::
string
master_key
=
"113341234"
;
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
());
//we init embedded database here.
clients
[
client
]
->
ps
=
std
::
unique_ptr
<
ProxyState
>
(
new
ProxyState
(
*
shared_ps
));
clients
[
client
]
->
ps
->
safeCreateEmbeddedTHD
();
//Connect end!!
globalConn
=
new
Connect
(
ci
.
server
,
ci
.
user
,
ci
.
passwd
,
ci
.
port
);
}
static
Item
*
getItemString
(
std
::
string
input
)
{
return
MySQLFieldTypeToItem
(
MYSQL_TYPE_STRING
,
input
);
}
/*
static
Item *
getItemInt(std::string input) {
return new (current_thd->mem_root)
Item_int(static_cast<ulonglong>(valFromStr(input)));
}
static
Item *
getItemString(std::string input) {
return MySQLFieldTypeToItem(MYSQL_TYPE_STRING, input);
}
static
Create_field* getStringField(int length) {
Create_field *f = new Create_field;
f->sql_type = MYSQL_TYPE_VARCHAR;
f->length = length;
return f;
}
static
Create_field* getUnsignedIntField(){
Create_field *f = new Create_field;
f->sql_type = MYSQL_TYPE_LONG;
f->flags |= UNSIGNED_FLAG;
return f;
}
*/
static
void
control
(
OPE_str
*
ds
,
Item
*
plain
,
int
num_of_tests
,
int
length
)
{
Item
*
enc
=
NULL
;
std
::
cout
<<
"length: "
<<
length
<<
std
::
endl
;
std
::
cout
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
timer
t
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
enc
=
ds
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"ENC_OPE_STR_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
std
::
cout
<<
"enclen: "
<<
enc
->
str_value
.
length
()
<<
std
::
endl
;
}
int
main
(
int
argc
,
char
**
argv
)
{
init
();
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
Create_field
*
cf
=
NULL
;
OPE_str
*
op
=
new
OPE_str
(
*
cf
,
key
);
int
num_of_tests
=
10000
;
int
length
=
16
;
if
(
argc
==
3
){
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
length
=
std
::
stoi
(
std
::
string
(
argv
[
2
]));
}
else
{
std
::
cout
<<
"num_of_tests:length"
<<
std
::
endl
;
return
0
;
}
for
(
int
i
=
1
;
i
<=
100
;
i
++
)
{
std
::
string
input
=
ggetpRandomName
(
length
*
i
);
Item
*
plain
=
getItemString
(
input
);
control
(
op
,
plain
,
num_of_tests
,
length
*
i
);
}
return
0
;
}
//main/schema.cc:83 is use to create layers of encryption
test_enclayers/bench_layer_RND_int.cc
0 → 100644
View file @
5398e211
#include "parser/sql_utils.hh"
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include "main/CryptoHandlers.hh"
#include "wrapper/reuse.hh"
#include "wrapper/common.hh"
#include "wrapper/insert_lib.hh"
#include "util/constants.hh"
#include "util/timer.hh"
#include "util/log.hh"
#include "util/onions.hh"
using
std
::
cout
;
using
std
::
cin
;
using
std
::
endl
;
using
std
::
vector
;
using
std
::
string
;
using
std
::
to_string
;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
static
std
::
map
<
std
::
string
,
WrapperState
*>
clients
;
//This connection mimics the behaviour of MySQL-Proxy
Connect
*
globalConn
;
/*for each field, convert the format to FieldMeta_Wrapper*/
static
void
init
(){
std
::
string
client
=
"192.168.1.1:1234"
;
//one Wrapper per user.
clients
[
client
]
=
new
WrapperState
();
//Connect phase
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
const
std
::
string
master_key
=
"113341234"
;
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
());
//we init embedded database here.
clients
[
client
]
->
ps
=
std
::
unique_ptr
<
ProxyState
>
(
new
ProxyState
(
*
shared_ps
));
clients
[
client
]
->
ps
->
safeCreateEmbeddedTHD
();
//Connect end!!
globalConn
=
new
Connect
(
ci
.
server
,
ci
.
user
,
ci
.
passwd
,
ci
.
port
);
}
/*
static
Item *
getItemString(std::string input) {
return MySQLFieldTypeToItem(MYSQL_TYPE_STRING, input);
}*/
static
Item
*
getItemInt
(
std
::
string
input
)
{
return
new
(
current_thd
->
mem_root
)
Item_int
(
static_cast
<
ulonglong
>
(
valFromStr
(
input
)));
}
/*
static
Item *
getItemString(std::string input) {
return MySQLFieldTypeToItem(MYSQL_TYPE_STRING, input);
}
static
Create_field* getStringField(int length) {
Create_field *f = new Create_field;
f->sql_type = MYSQL_TYPE_VARCHAR;
f->length = length;
return f;
}
*/
static
Create_field
*
getUnsignedIntField
(){
Create_field
*
f
=
new
Create_field
;
f
->
sql_type
=
MYSQL_TYPE_LONG
;
f
->
flags
|=
UNSIGNED_FLAG
;
return
f
;
}
int
main
(
int
argc
,
char
**
argv
)
{
init
();
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
Create_field
*
cf
=
getUnsignedIntField
();
RND_int
*
ri
=
new
RND_int
(
*
cf
,
key
);
int
num_of_tests
=
10000
;
if
(
argc
==
2
){
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
}
else
{
std
::
cout
<<
"num_of_tests"
<<
std
::
endl
;
return
0
;
}
Item
*
plain
=
getItemInt
(
"123456789"
);
std
::
cout
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
Item
*
enc
=
NULL
;
Item
*
dec
=
NULL
;
timer
t
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
){
enc
=
ri
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"ENC_RND_int_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
){
dec
=
ri
->
decrypt
(
*
enc
,
0u
);
}
std
::
cout
<<
"DEC_RND_int_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
(
void
)
dec
;
return
0
;
}
//main/schema.cc:83 is use to create layers of encryption
test_enclayers/bench_layer_RND_str.cc
0 → 100644
View file @
5398e211
#include "parser/sql_utils.hh"
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include "main/CryptoHandlers.hh"
#include "wrapper/reuse.hh"
#include "wrapper/common.hh"
#include "wrapper/insert_lib.hh"
#include "util/constants.hh"
#include "util/timer.hh"
#include "util/log.hh"
#include "util/onions.hh"
using
std
::
cout
;
using
std
::
cin
;
using
std
::
endl
;
using
std
::
vector
;
using
std
::
string
;
using
std
::
to_string
;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
static
std
::
map
<
std
::
string
,
WrapperState
*>
clients
;
//This connection mimics the behaviour of MySQL-Proxy
Connect
*
globalConn
;
/*for each field, convert the format to FieldMeta_Wrapper*/
static
void
init
(){
std
::
string
client
=
"192.168.1.1:1234"
;
//one Wrapper per user.
clients
[
client
]
=
new
WrapperState
();
//Connect phase
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
const
std
::
string
master_key
=
"113341234"
;
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
());
//we init embedded database here.
clients
[
client
]
->
ps
=
std
::
unique_ptr
<
ProxyState
>
(
new
ProxyState
(
*
shared_ps
));
clients
[
client
]
->
ps
->
safeCreateEmbeddedTHD
();
//Connect end!!
globalConn
=
new
Connect
(
ci
.
server
,
ci
.
user
,
ci
.
passwd
,
ci
.
port
);
}
static
Item
*
getItemString
(
std
::
string
input
)
{
return
MySQLFieldTypeToItem
(
MYSQL_TYPE_STRING
,
input
);
}
/*
static
Item *
getItemInt(std::string input) {
return new (current_thd->mem_root)
Item_int(static_cast<ulonglong>(valFromStr(input)));
}
static
Item *
getItemString(std::string input) {
return MySQLFieldTypeToItem(MYSQL_TYPE_STRING, input);
}
static
Create_field* getStringField(int length) {
Create_field *f = new Create_field;
f->sql_type = MYSQL_TYPE_VARCHAR;
f->length = length;
return f;
}
static
Create_field* getUnsignedIntField(){
Create_field *f = new Create_field;
f->sql_type = MYSQL_TYPE_LONG;
f->flags |= UNSIGNED_FLAG;
return f;
}
*/
static
void
control
(
RND_str
*
ds
,
Item
*
plain
,
int
num_of_tests
,
int
length
)
{
Item
*
enc
=
NULL
;
Item
*
dec
=
NULL
;
std
::
cout
<<
"length: "
<<
length
<<
std
::
endl
;
std
::
cout
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
timer
t
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
enc
=
ds
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"ENC_RND_STR_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
dec
=
ds
->
decrypt
(
*
enc
,
0u
);
}
std
::
cout
<<
"DEC_RND_STR_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
std
::
cout
<<
"enclen: "
<<
enc
->
str_value
.
length
()
<<
std
::
endl
;
std
::
cout
<<
"declen: "
<<
dec
->
str_value
.
length
()
<<
std
::
endl
;
}
int
main
(
int
argc
,
char
**
argv
)
{
init
();
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
Create_field
*
cf
=
NULL
;
RND_str
*
rs
=
new
RND_str
(
*
cf
,
key
);
int
num_of_tests
=
10000
;
int
length
=
16
;
if
(
argc
==
3
){
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
length
=
std
::
stoi
(
std
::
string
(
argv
[
2
]));
}
else
{
std
::
cout
<<
"num_of_tests:length"
<<
std
::
endl
;
return
0
;
}
for
(
int
i
=
1
;
i
<=
100
;
i
++
)
{
std
::
string
input
=
ggetpRandomName
(
length
*
i
);
Item
*
plain
=
getItemString
(
input
);
control
(
rs
,
plain
,
num_of_tests
,
length
*
i
);
}
return
0
;
}
//main/schema.cc:83 is use to create layers of encryption
test_enclayers/bench_layer_SWP.cc
0 → 100644
View file @
5398e211
#include "parser/sql_utils.hh"
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include "main/CryptoHandlers.hh"
#include "wrapper/reuse.hh"
#include "wrapper/common.hh"
#include "wrapper/insert_lib.hh"
#include "util/constants.hh"
#include "util/timer.hh"
#include "util/log.hh"
#include "util/onions.hh"
#include <sys/time.h>
using
std
::
cout
;
using
std
::
cin
;
using
std
::
endl
;
using
std
::
vector
;
using
std
::
string
;
using
std
::
to_string
;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
static
std
::
map
<
std
::
string
,
WrapperState
*>
clients
;
//This connection mimics the behaviour of MySQL-Proxy
Connect
*
globalConn
;
/*for each field, convert the format to FieldMeta_Wrapper*/
static
void
init
(){
std
::
string
client
=
"192.168.1.1:1234"
;
//one Wrapper per user.
clients
[
client
]
=
new
WrapperState
();
//Connect phase
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
const
std
::
string
master_key
=
"113341234"
;
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
());
//we init embedded database here.
clients
[
client
]
->
ps
=
std
::
unique_ptr
<
ProxyState
>
(
new
ProxyState
(
*
shared_ps
));
clients
[
client
]
->
ps
->
safeCreateEmbeddedTHD
();
//Connect end!!
globalConn
=
new
Connect
(
ci
.
server
,
ci
.
user
,
ci
.
passwd
,
ci
.
port
);
}
static
Item
*
getItemString
(
std
::
string
input
)
{
return
MySQLFieldTypeToItem
(
MYSQL_TYPE_STRING
,
input
);
}
/*
static
Item *
getItemInt(std::string input) {
return new (current_thd->mem_root)
Item_int(static_cast<ulonglong>(valFromStr(input)));
}
static
Item *
getItemString(std::string input) {
return MySQLFieldTypeToItem(MYSQL_TYPE_STRING, input);
}
static
Create_field* getStringField(int length) {
Create_field *f = new Create_field;
f->sql_type = MYSQL_TYPE_VARCHAR;
f->length = length;
return f;
}
static
Create_field* getUnsignedIntField(){
Create_field *f = new Create_field;
f->sql_type = MYSQL_TYPE_LONG;
f->flags |= UNSIGNED_FLAG;
return f;
}
*/
static
void
control
(
Search
*
sw
,
Item
*
plain
,
int
num_of_tests
,
int
length
,
int
token_size
)
{
Item
*
enc
=
NULL
;
std
::
cout
<<
"length: "
<<
length
<<
std
::
endl
;
std
::
cout
<<
"num_of_tests: "
<<
num_of_tests
<<
std
::
endl
;
timer
t
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
)
{
enc
=
sw
->
encrypt
(
*
plain
,
0u
);
}
std
::
cout
<<
"ENC_SWP_STR_IN_us: "
<<
t
.
lap
()
*
1.0
/
num_of_tests
<<
std
::
endl
;
std
::
cout
<<
"tokennumber: "
<<
token_size
<<
std
::
endl
;
std
::
cout
<<
"enclen: "
<<
enc
->
str_value
.
length
()
<<
std
::
endl
;
std
::
cout
<<
"plainlen: "
<<
plain
->
str_value
.
length
()
<<
std
::
endl
;
}
int
main
(
int
argc
,
char
**
argv
)
{
init
();
create_embedded_thd
(
0
);
std
::
string
key
=
"key"
;
Create_field
*
cf
=
NULL
;
Search
*
sw
=
new
Search
(
*
cf
,
key
);
int
num_of_tests
=
10000
;
int
length
=
16
;
if
(
argc
==
3
){
num_of_tests
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
length
=
std
::
stoi
(
std
::
string
(
argv
[
2
]));
}
else
{
std
::
cout
<<
"num_of_tests:length"
<<
std
::
endl
;
return
0
;
}
for
(
int
i
=
1
;
i
<=
100
;
i
++
)
{
std
::
string
input
=
ggetpRandomName
(
length
*
i
);
Item
*
plain
=
getItemString
(
input
);
auto
res
=
tokenize
(
input
);
control
(
sw
,
plain
,
num_of_tests
,
length
*
i
,
res
->
size
());
delete
res
;
}
return
0
;
}
//main/schema.cc:83 is use to create layers of encryption
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