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
ce655543
Commit
ce655543
authored
May 17, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test_enclayers
parent
30cbd3f8
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
202 additions
and
0 deletions
+202
-0
Makefile
Makefile
+5
-0
CryptoHandlers.hh
main/CryptoHandlers.hh
+12
-0
.bench_ope_int.cc.swp
test_crypto/.bench_ope_int.cc.swp
+0
-0
Makefrag
test_enclayers/Makefrag
+7
-0
test_layer_DET_str.cc
test_enclayers/test_layer_DET_str.cc
+148
-0
bench_AES.cc
test_main/bench_AES.cc
+30
-0
No files found.
Makefile
View file @
ce655543
...
...
@@ -100,6 +100,10 @@ mtl/test_main_exe/%:$(OBJDIR)/test_main/%.o
@
mkdir
-p
$
(
@D
)
$(CXX)
-g
-o
$@
$^
$(CXXFLAGS)
$(LDFLAGS)
-L
/
$(MYBUILD)
/libmysqld
-lmysqld
-laio
-lz
-ldl
-lm
-lcrypt
-lpthread
-lcryptdb
-ledbcrypto
-ledbutil
-ledbparser
-lntl
-lcrypto
mtl/test_enclayers_exe/%
:
$(OBJDIR)/test_enclayers/%.o $(OBJDIR)/libwrapper.so
@
mkdir
-p
$
(
@D
)
$(CXX)
-g
-o
$@
$<
$(CXXFLAGS)
$(LDFLAGS)
-L
/
$(MYBUILD)
/libmysqld
-lmysqld
-laio
-lz
-ldl
-lm
-lcrypt
-lpthread
-lwrapper
-lcryptdb
-ledbcrypto
-ledbutil
-ledbparser
-lntl
-lcrypto
mtl/test_redisbio_exe/%
:
$(OBJDIR)/test_redisbio/%.o $(OBJDIR)/libredisbio.so
@
mkdir
-p
$
(
@D
)
$(CXX)
-g
-o
$@
$<
$(CXXFLAGS)
$(LDFLAGS)
-lredisbio
...
...
@@ -124,6 +128,7 @@ include test_wrapper/Makefrag
include
test_util/Makefrag
include
test_parser/Makefrag
include
test_main/Makefrag
include
test_enclayers/Makefrag
include
wrapper/Makefrag
include
test_parser_helper/Makefrag
include
redisbio/Makefrag
...
...
main/CryptoHandlers.hh
View file @
ce655543
#pragma once
#include <algorithm>
#include <string>
#include <util/util.hh>
#include <crypto/prng.hh>
...
...
@@ -449,3 +450,14 @@ private:
std
::
list
<
std
::
string
>
*
tokenize
(
const
std
::
string
&
text
);
std
::
string
decrypt_AES_CBC
(
const
std
::
string
&
ctext
,
const
AES_KEY
*
deckey
,
std
::
string
salt
,
bool
dounpad
);
std
::
string
encrypt_AES_CBC
(
const
std
::
string
&
ptext
,
const
AES_KEY
*
enckey
,
std
::
string
salt
,
bool
dopad
);
std
::
string
encrypt_AES_CMC
(
const
std
::
string
&
ptext
,
const
AES_KEY
*
enckey
,
bool
dopad
);
std
::
string
decrypt_AES_CMC
(
const
std
::
string
&
ctext
,
const
AES_KEY
*
deckey
,
bool
dopad
);
test_crypto/.bench_ope_int.cc.swp
deleted
100644 → 0
View file @
30cbd3f8
File deleted
test_enclayers/Makefrag
0 → 100644
View file @
ce655543
OBJDIRS += test_enclayers
##note that xx=*.cc will not expand. wildcard *.cc will include files from other directories.
##%.o will include testall
TESTALL_OBJS := $(patsubst %.cc,$(OBJDIR)/%.o,$(wildcard test_enclayers/*.cc))
TESTALL_EXES := $(patsubst test_enclayers/%.cc,mtl/test_enclayers_exe/%,$(wildcard test_enclayers/*.cc))
all: $(TESTALL_OBJS) $(TESTALL_EXES)
test_enclayers/test_layer_DET_str.cc
0 → 100644
View file @
ce655543
#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
(
DET_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_DET_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_DET_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
;
DET_str
*
ds
=
new
DET_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
(
ds
,
plain
,
num_of_tests
,
length
*
i
)
;
}
return
0
;
}
//main/schema.cc:83 is use to create layers of encryption
test_main/bench_AES.cc
0 → 100644
View file @
ce655543
#include "main/CryptoHandlers.hh"
static
void
test_aes_cmc
(
int
num_of_tests
,
int
len
)
{
std
::
string
key
(
16
,
'a'
);
AES_KEY
*
ak
=
get_AES_dec_key
(
key
);
std
::
string
plain
(
len
,
'a'
);
std
::
string
enc
,
dec
;
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
){
enc
=
encrypt_AES_CMC
(
plain
,
ak
,
true
);
}
for
(
int
i
=
0
;
i
<
num_of_tests
;
i
++
){
dec
=
decrypt_AES_CMC
(
enc
,
ak
,
true
);
}
}
static
void
test_aes_cbc
(
int
num_of_tests
,
int
len
)
{
}
int
main
()
{
test_aes_cmc
(
10
,
10
);
test_aes_cbc
(
10
,
10
);
return
0
;
}
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