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
c4e206fe
Commit
c4e206fe
authored
Jan 28, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
able to verify encryption and decryption layers
parent
9ed387b1
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
136 additions
and
14 deletions
+136
-14
CURRENT.conf
conf/CURRENT.conf
+6
-4
.test_encLayers.cc.swp
debug/.test_encLayers.cc.swp
+0
-0
test_encLayers.cc
debug/test_encLayers.cc
+126
-8
mysql-proxy.cnf
mysql-proxy.cnf
+1
-1
backup.sh
packages/operation/backup.sh
+1
-1
random_insert.sh
random_insert.sh
+1
-0
xx.sql
xx.sql
+1
-0
No files found.
conf/CURRENT.conf
View file @
c4e206fe
...
...
@@ -3,10 +3,11 @@
#oAGG: HOM
#oASHE: ASHE
[
onions
for
num
]
oDET
:
DETJOIN
DET
RND
oOPE
:
OPE
FOREIGN
OPE
RND
oDET
:
DETJOIN
DET
oOPE
:
OPE
oAGG
:
HOM
#oASHE: ASHE
oASHE
:
ASHE
[
end
]
#####################################################################################
...
...
@@ -15,5 +16,6 @@ oAGG: HOM
#oOPE: OPEFOREIGN OPE RND
[
onions
for
str
]
oDET
:
DETJOIN
DET
RND
oOPE
:
OPE
FOREIGN
OPE
RND
oOPE
:
OPE
oSWP
:
SEARCH
[
end
]
debug/.test_encLayers.cc.swp
0 → 100644
View file @
c4e206fe
File added
debug/test_encLayers.cc
View file @
c4e206fe
...
...
@@ -84,17 +84,42 @@ decrypt_item_layers_raw(const Item &i, uint64_t IV, std::vector<std::unique_ptr<
return
out_i
;
}
static
Item
*
getItemInt
(
std
::
string
input
)
{
return
new
(
current_thd
->
mem_root
)
Item_int
(
static_cast
<
ulonglong
>
(
valFromStr
(
input
)));
}
int
main
()
{
init
();
create_embedded_thd
(
0
);
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
test1
(){
// create_embedded_thd(0);
Create_field
*
f
=
new
Create_field
;
f
->
sql_type
=
MYSQL_TYPE_LONG
;
f
->
flags
|=
UNSIGNED_FLAG
;
//Or we will have error range.
std
::
unique_ptr
<
EncLayer
>
el
(
EncLayerFactory
::
encLayer
(
oDET
,
SECLEVEL
::
RND
,
*
f
,
"HEHE"
));
auto
levels
=
CURRENT_NUM_LAYOUT
[
oDET
];
std
::
vector
<
std
::
unique_ptr
<
EncLayer
>
>
layers
;
const
Create_field
*
newcf
=
f
;
...
...
@@ -107,15 +132,108 @@ main() {
newcf
=
el
->
newCreateField
(
oldcf
);
layers
.
push_back
(
std
::
move
(
el
));
}
Item
*
in
=
NULL
;
encrypt_item_layers_raw
(
*
in
,
0
,
layers
);
decrypt_item_layers_raw
(
*
in
,
0
,
layers
);
Item
*
instr
=
getItemString
(
"abc"
);
(
void
)
instr
;
Item
*
inint
=
getItemInt
(
"123"
);
Item
*
intenc
=
encrypt_item_layers_raw
(
*
inint
,
0
,
layers
);
Item
*
intdec
=
decrypt_item_layers_raw
(
*
intenc
,
0
,
layers
);
(
void
)
intdec
;
(
void
)
el
;
(
void
)
f
;
//Then we should encrypt and decrypt.
}
static
std
::
vector
<
std
::
unique_ptr
<
EncLayer
>
>
getOnionLayerStr
(
onion
o
,
SECLEVEL
l
,
int
length
){
std
::
vector
<
std
::
unique_ptr
<
EncLayer
>
>
res
;
Create_field
*
f
=
getStringField
(
length
);
const
std
::
string
key
=
"plainkey"
;
std
::
unique_ptr
<
EncLayer
>
el
(
EncLayerFactory
::
encLayer
(
o
,
l
,
*
f
,
key
));
res
.
push_back
(
std
::
move
(
el
));
//std::move should be used. or we will have complier error.
return
std
::
move
(
res
);
}
static
std
::
vector
<
std
::
unique_ptr
<
EncLayer
>
>
getOnionLayerInt
(
onion
o
,
SECLEVEL
l
)
{
std
::
vector
<
std
::
unique_ptr
<
EncLayer
>
>
res
;
Create_field
*
f
=
getUnsignedIntField
();
const
std
::
string
key
=
"plainkey"
;
std
::
unique_ptr
<
EncLayer
>
el
(
EncLayerFactory
::
encLayer
(
o
,
l
,
*
f
,
key
));
res
.
push_back
(
std
::
move
(
el
));
return
std
::
move
(
res
);
}
static
void
test2
()
{
// create_embedded_thd(0);
Create_field
*
f
=
new
Create_field
;
//simulate the str mode
f
->
sql_type
=
MYSQL_TYPE_VARCHAR
;
f
->
length
=
20
;
std
::
unique_ptr
<
EncLayer
>
el
(
EncLayerFactory
::
encLayer
(
oDET
,
SECLEVEL
::
RND
,
*
f
,
"HEHE"
));
auto
levels
=
CURRENT_STR_LAYOUT
[
oDET
];
std
::
vector
<
std
::
unique_ptr
<
EncLayer
>
>
layers
;
const
Create_field
*
newcf
=
f
;
onion
o
=
oDET
;
for
(
auto
l
:
levels
)
{
const
std
::
string
key
=
"plainkey"
;
std
::
unique_ptr
<
EncLayer
>
el
(
EncLayerFactory
::
encLayer
(
o
,
l
,
*
newcf
,
key
));
const
Create_field
&
oldcf
=
*
newcf
;
newcf
=
el
->
newCreateField
(
oldcf
);
layers
.
push_back
(
std
::
move
(
el
));
}
Item
*
instr
=
getItemString
(
"abc"
);
//(void)instr;
//Item * inint = getItemInt("123");
Item
*
strenc
=
encrypt_item_layers_raw
(
*
instr
,
0
,
layers
);
Item
*
strdec
=
decrypt_item_layers_raw
(
*
strenc
,
0
,
layers
);
(
void
)
strdec
;
(
void
)
el
;
(
void
)
f
;
//Then we should encrypt and decrypt.
}
static
void
verifyLayerStr
()
{
auto
layers
=
getOnionLayerStr
(
oDET
,
SECLEVEL
::
RND
,
20
);
Item
*
input
=
getItemString
(
"hehe"
);
Item
*
enc
=
encrypt_item_layers_raw
(
*
input
,
0
,
layers
);
Item
*
dec
=
decrypt_item_layers_raw
(
*
enc
,
0
,
layers
);
(
void
)
dec
;
(
void
)(
dec
->
name
);
}
static
void
verifyLayerInt
()
{
auto
layers
=
getOnionLayerInt
(
oDET
,
SECLEVEL
::
RND
);
Item
*
input
=
getItemInt
(
"123"
);
Item
*
enc
=
encrypt_item_layers_raw
(
*
input
,
0
,
layers
);
Item
*
dec
=
decrypt_item_layers_raw
(
*
enc
,
0
,
layers
);
(
void
)
dec
;
(
void
)(((
Item_int
*
)
dec
)
->
value
);
}
int
main
()
{
init
();
create_embedded_thd
(
0
);
test1
();
test2
();
getOnionLayerStr
(
oDET
,
SECLEVEL
::
RND
,
20
);
getOnionLayerInt
(
oDET
,
SECLEVEL
::
RND
);
verifyLayerStr
();
verifyLayerInt
();
return
0
;
}
...
...
mysql-proxy.cnf
View file @
c4e206fe
[mysql-proxy]
plugins = proxy
event-threads = 4
proxy-address = 1
92.168.1.9
:3399
proxy-address = 1
27.0.0.1
:3399
proxy-backen-addresses = 127.0.0.1:3306
packages/operation/backup.sh
View file @
c4e206fe
...
...
@@ -3,5 +3,5 @@ name="all.sql"
if
[
$#
=
1
]
;
then
name
=
$1
fi
mysqldump
-uroot
-h
127
.0.0.1
-P3306
--no-create-info
--compact
tpcc1000
>
$name
mysqldump
-uroot
-h
localhost
-P3306
--no-create-info
--compact
micro_db
>
$name
random_insert.sh
View file @
c4e206fe
...
...
@@ -18,3 +18,4 @@ function generate_insert_int(){
h
=
"INSERT INTO str_table VALUES "
generate_insert_int
"
$h
"
3 100
xx.sql
0 → 100644
View file @
c4e206fe
INSERT
INTO
int_table
VALUES
(
30569
),(
20714
),(
32184
),(
219
),(
769
),(
23230
),(
12826
),(
951
),(
15940
),(
10370
),(
13504
),(
31031
),(
20070
),(
18364
),(
12901
),(
23721
),(
9104
),(
7061
),(
8484
),(
4617
),(
12972
),(
32749
),(
30288
),(
19558
),(
1609
),(
17415
),(
17857
),(
19113
),(
22409
),(
8231
),(
4591
),(
7658
),(
5483
),(
17668
),(
23917
),(
31495
),(
21785
),(
4344
),(
18119
),(
21307
),(
1337
),(
10395
),(
9305
),(
8301
),(
2051
),(
11210
),(
31071
),(
2640
),(
17143
),(
2631
),(
3705
),(
32231
),(
27056
),(
22263
),(
11398
),(
19217
),(
7343
),(
25756
),(
5625
),(
20342
),(
31769
),(
6839
),(
4509
),(
6708
),(
3091
),(
31866
),(
26183
),(
4234
),(
9746
),(
8639
),(
17798
),(
12934
),(
22402
),(
21783
),(
31087
),(
3106
),(
24391
),(
31216
),(
22373
),(
25093
),(
29764
),(
18173
),(
17477
),(
26976
),(
16001
),(
14660
),(
20130
),(
15043
),(
31096
),(
4484
),(
8336
),(
28135
),(
2222
),(
4342
),(
16962
),(
14320
),(
9895
),(
22998
),(
7717
),(
22127
);
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