Commit 8c6635c3 authored by yiwenshao's avatar yiwenshao

add

parent 5398e211
...@@ -96,9 +96,7 @@ main(int argc,char** argv) { ...@@ -96,9 +96,7 @@ main(int argc,char** argv) {
std::string key = "key"; std::string key = "key";
Create_field *cf = NULL; Create_field *cf = NULL;
ASHE* as = new ASHE(*cf, key); ASHE* as = new ASHE(*cf, key);
int num_of_tests = 10000; int num_of_tests = 10000;
if(argc==2){ if(argc==2){
num_of_tests = std::stoi(std::string(argv[1])); num_of_tests = std::stoi(std::string(argv[1]));
}else{ }else{
...@@ -106,27 +104,19 @@ main(int argc,char** argv) { ...@@ -106,27 +104,19 @@ main(int argc,char** argv) {
return 0; return 0;
} }
Item * plain = getItemInt("123456789"); Item * plain = getItemInt("123456789");
std::cout<<"num_of_tests: "<<num_of_tests<<std::endl; std::cout<<"num_of_tests: "<<num_of_tests<<std::endl;
Item* enc = NULL; Item* enc = NULL;
Item* dec = NULL; Item* dec = NULL;
timer t; timer t;
for(int i=0;i<num_of_tests;i++) { for(int i=0;i<num_of_tests;i++) {
enc = as->encrypt(*plain,0u); enc = as->encrypt(*plain,0u);
} }
std::cout<<"ENC_ASHE_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl; std::cout<<"ENC_ASHE_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
for(int i=0;i<num_of_tests;i++) { for(int i=0;i<num_of_tests;i++) {
dec = as->decrypt(*enc,0u); dec = as->decrypt(*enc,0u);
} }
std::cout<<"DEC_ASHE_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl; std::cout<<"DEC_ASHE_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
(void)dec; (void)dec;
return 0; return 0;
} }
//main/schema.cc:83 is use to create layers of encryption
...@@ -31,10 +31,8 @@ static std::map<std::string, WrapperState*> clients; ...@@ -31,10 +31,8 @@ static std::map<std::string, WrapperState*> clients;
//This connection mimics the behaviour of MySQL-Proxy //This connection mimics the behaviour of MySQL-Proxy
Connect *globalConn; Connect *globalConn;
/*for each field, convert the format to FieldMeta_Wrapper*/ /*for each field, convert the format to FieldMeta_Wrapper*/
static void init(){ static void init(){
std::string client="192.168.1.1:1234"; std::string client="192.168.1.1:1234";
//one Wrapper per user. //one Wrapper per user.
...@@ -66,38 +64,6 @@ getItemString(std::string input) { ...@@ -66,38 +64,6 @@ 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;
...@@ -137,6 +103,7 @@ main(int argc,char**argv) { ...@@ -137,6 +103,7 @@ main(int argc,char**argv) {
std::cout<<"num_of_tests:length"<<std::endl; std::cout<<"num_of_tests:length"<<std::endl;
return 0; return 0;
} }
for(int i=1;i<=100;i++) { for(int i=1;i<=100;i++) {
std::string input = ggetpRandomName(length*i); std::string input = ggetpRandomName(length*i);
Item* plain = getItemString(input) ; Item* plain = getItemString(input) ;
......
...@@ -25,16 +25,10 @@ using std::vector; ...@@ -25,16 +25,10 @@ using std::vector;
using std::string; using std::string;
using std::to_string; using std::to_string;
static std::string embeddedDir="/t/cryt/shadow"; static std::string embeddedDir="/t/cryt/shadow";
static std::map<std::string, WrapperState*> clients; static std::map<std::string, WrapperState*> clients;
//This connection mimics the behaviour of MySQL-Proxy //This connection mimics the behaviour of MySQL-Proxy
Connect *globalConn; Connect *globalConn;
/*for each field, convert the format to FieldMeta_Wrapper*/ /*for each field, convert the format to FieldMeta_Wrapper*/
static void init(){ static void init(){
std::string client="192.168.1.1:1234"; std::string client="192.168.1.1:1234";
//one Wrapper per user. //one Wrapper per user.
...@@ -57,37 +51,12 @@ static void init(){ ...@@ -57,37 +51,12 @@ static void init(){
//Connect end!! //Connect end!!
globalConn = new Connect(ci.server, ci.user, ci.passwd, ci.port); globalConn = new Connect(ci.server, ci.user, ci.passwd, ci.port);
} }
static static
Item * Item *
getItemInt(std::string input) { getItemInt(std::string input) {
return new (current_thd->mem_root) return new (current_thd->mem_root)
Item_int(static_cast<ulonglong>(valFromStr(input))); 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 int
main(int argc,char**argv) { main(int argc,char**argv) {
...@@ -96,7 +65,6 @@ main(int argc,char**argv) { ...@@ -96,7 +65,6 @@ main(int argc,char**argv) {
std::string key = "key"; std::string key = "key";
Create_field *cf = NULL; Create_field *cf = NULL;
HOM* hm = new HOM(*cf, key); HOM* hm = new HOM(*cf, key);
int num_of_tests = 10000; int num_of_tests = 10000;
if(argc==2){ if(argc==2){
num_of_tests = std::stoi(std::string(argv[1])); num_of_tests = std::stoi(std::string(argv[1]));
...@@ -107,25 +75,16 @@ main(int argc,char**argv) { ...@@ -107,25 +75,16 @@ main(int argc,char**argv) {
Item* plain = getItemInt("123456789"); Item* plain = getItemInt("123456789");
Item *enc = NULL; Item *enc = NULL;
Item *dec = NULL; Item *dec = NULL;
std::cout<<"num_of_tests: "<<num_of_tests <<std::endl; std::cout<<"num_of_tests: "<<num_of_tests <<std::endl;
timer t; timer t;
for(int i=0;i<num_of_tests;i++) { for(int i=0;i<num_of_tests;i++) {
enc = hm->encrypt(*plain,0u); enc = hm->encrypt(*plain,0u);
} }
std::cout<<"HOM_ENC_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl; std::cout<<"HOM_ENC_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
for(int i=0;i<num_of_tests;i++) { for(int i=0;i<num_of_tests;i++) {
dec = hm->decrypt(*enc,0u); dec = hm->decrypt(*enc,0u);
} }
std::cout<<"HOM_DEC_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl; std::cout<<"HOM_DEC_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
(void)dec; (void)dec;
return 0; return 0;
} }
//main/schema.cc:83 is use to create layers of encryption
...@@ -113,7 +113,7 @@ main(int argc,char** argv) { ...@@ -113,7 +113,7 @@ main(int argc,char** argv) {
if(argc==2){ if(argc==2){
num_of_tests = std::stoi(std::string(argv[1])); num_of_tests = std::stoi(std::string(argv[1]));
}else{ }else{
std::cout<<"num_of_tests:length"<<std::endl; std::cout<<"num_of_tests"<<std::endl;
return 0; return 0;
} }
......
...@@ -118,10 +118,8 @@ main(int argc,char** argv) { ...@@ -118,10 +118,8 @@ main(int argc,char** argv) {
std::string key = "key"; std::string key = "key";
Create_field *cf = NULL; Create_field *cf = NULL;
OPE_str* op = new OPE_str(*cf, key); OPE_str* op = new OPE_str(*cf, key);
int num_of_tests = 10000; int num_of_tests = 10000;
int length = 16; int length = 16;
if(argc==3){ if(argc==3){
num_of_tests = std::stoi(std::string(argv[1])); num_of_tests = std::stoi(std::string(argv[1]));
length = std::stoi(std::string(argv[2])); length = std::stoi(std::string(argv[2]));
...@@ -135,8 +133,6 @@ main(int argc,char** argv) { ...@@ -135,8 +133,6 @@ main(int argc,char** argv) {
Item* plain = getItemString(input); Item* plain = getItemString(input);
control(op, plain, num_of_tests, length*i); control(op, plain, num_of_tests, length*i);
} }
return 0; return 0;
} }
//main/schema.cc:83 is use to create layers of encryption
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment