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
d88fe3ef
Commit
d88fe3ef
authored
Apr 20, 2017
by
casualet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge from dive into mysqlparse, able to CURD with the new layer opeforeign
parent
d51103b4
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
97 additions
and
9 deletions
+97
-9
gdbs
gdbs
+1
-0
CryptoHandlers.cc
main/CryptoHandlers.cc
+81
-0
rewrite_main.cc
main/rewrite_main.cc
+2
-2
stopgdbs
stopgdbs
+2
-0
Makefrag
util/Makefrag
+1
-3
hello.cc
util/hello.cc
+6
-0
onions.hh
util/onions.hh
+4
-4
No files found.
gdbs
View file @
d88fe3ef
###start gdb
sudo gdb `which mysql-proxy` `ps aux | grep 'mysql-proxy.cnf' |grep -v grep | awk '{print $2}'`
main/CryptoHandlers.cc
View file @
d88fe3ef
...
...
@@ -111,6 +111,17 @@ public:
deserialize
(
unsigned
int
id
,
const
SerialLayer
&
serial
);
};
class
OPEFOREIGNFactory
:
public
LayerFactory
{
public
:
static
std
::
unique_ptr
<
EncLayer
>
create
(
const
Create_field
&
cf
,
const
std
::
string
&
key
);
static
std
::
unique_ptr
<
EncLayer
>
deserialize
(
unsigned
int
id
,
const
SerialLayer
&
serial
);
};
class
HOMFactory
:
public
LayerFactory
{
public
:
...
...
@@ -158,6 +169,7 @@ EncLayerFactory::encLayer(onion o, SECLEVEL sl, const Create_field &cf,
case
SECLEVEL
:
:
DET
:
{
return
DETFactory
::
create
(
cf
,
key
);}
case
SECLEVEL
:
:
DETJOIN
:
{
return
DETJOINFactory
::
create
(
cf
,
key
);}
case
SECLEVEL
:
:
OPE
:
{
return
OPEFactory
::
create
(
cf
,
key
);}
case
SECLEVEL
:
:
OPEFOREIGN
:
{
return
OPEFOREIGNFactory
::
create
(
cf
,
key
);}
case
SECLEVEL
:
:
HOM
:
{
return
HOMFactory
::
create
(
cf
,
key
);}
case
SECLEVEL
:
:
SEARCH
:
{
return
std
::
unique_ptr
<
EncLayer
>
(
new
Search
(
cf
,
key
));
...
...
@@ -171,6 +183,7 @@ EncLayerFactory::encLayer(onion o, SECLEVEL sl, const Create_field &cf,
FAIL_TextMessageError
(
"unknown or unimplemented security level"
);
}
//recover from the database using lambda.
std
::
unique_ptr
<
EncLayer
>
EncLayerFactory
::
deserializeLayer
(
unsigned
int
id
,
const
std
::
string
&
serial
)
...
...
@@ -188,6 +201,9 @@ EncLayerFactory::deserializeLayer(unsigned int id,
case
SECLEVEL
:
:
DETJOIN
:
return
DETJOINFactory
::
deserialize
(
id
,
li
);
case
SECLEVEL
:
:
OPEFOREIGN
:
return
OPEFOREIGNFactory
::
deserialize
(
id
,
li
);
case
SECLEVEL
:
:
OPE
:
return
OPEFactory
::
deserialize
(
id
,
li
);
...
...
@@ -1038,6 +1054,18 @@ private:
mutable
OPE
ope
;
// HACK
};
class
OPEFOREIGN_int
:
public
OPE_int
{
public
:
OPEFOREIGN_int
(
const
Create_field
&
cf
,
const
std
::
string
&
seed_key
)
:
OPE_int
(
cf
,
seed_key
){}
OPEFOREIGN_int
(
unsigned
int
id
,
const
CryptedInteger
&
cinteger
,
size_t
plain_size
,
size_t
ciph_size
)
:
OPE_int
(
id
,
cinteger
,
plain_size
,
ciph_size
){}
SECLEVEL
level
()
const
{
return
SECLEVEL
::
OPEFOREIGN
;}
std
::
string
name
()
const
{
return
"OPEFOREIGN_int"
;}
static
std
::
unique_ptr
<
OPEFOREIGN_int
>
deserialize
(
unsigned
int
id
,
const
std
::
string
&
serial
);
};
class
OPE_str
:
public
EncLayer
{
public
:
OPE_str
(
const
Create_field
&
cf
,
const
std
::
string
&
seed_key
);
...
...
@@ -1065,6 +1093,17 @@ private:
static
const
size_t
ciph_size
=
8
;
};
class
OPEFOREIGN_str
:
public
OPE_str
{
public
:
OPEFOREIGN_str
(
const
Create_field
&
cf
,
const
std
::
string
&
seed_key
)
:
OPE_str
(
cf
,
seed_key
){}
OPEFOREIGN_str
(
unsigned
int
id
,
const
std
::
string
&
serial
)
:
OPE_str
(
id
,
serial
){}
SECLEVEL
level
()
const
{
return
SECLEVEL
::
OPEFOREIGN
;}
std
::
string
name
()
const
{
return
"OPEFOREIGN_str"
;}
};
std
::
unique_ptr
<
EncLayer
>
OPEFactory
::
create
(
const
Create_field
&
cf
,
const
std
::
string
&
key
)
{
...
...
@@ -1090,6 +1129,35 @@ OPEFactory::deserialize(unsigned int id, const SerialLayer &sl)
}
}
std
::
unique_ptr
<
EncLayer
>
OPEFOREIGNFactory
::
create
(
const
Create_field
&
cf
,
const
std
::
string
&
key
)
{
if
(
isMySQLTypeNumeric
(
cf
))
{
if
(
cf
.
sql_type
==
MYSQL_TYPE_DECIMAL
||
cf
.
sql_type
==
MYSQL_TYPE_NEWDECIMAL
)
{
FAIL_TextMessageError
(
"decimal support is broken"
);
}
return
std
::
unique_ptr
<
EncLayer
>
(
new
OPEFOREIGN_int
(
cf
,
key
));
}
return
std
::
unique_ptr
<
EncLayer
>
(
new
OPEFOREIGN_str
(
cf
,
key
));
}
std
::
unique_ptr
<
EncLayer
>
OPEFOREIGNFactory
::
deserialize
(
unsigned
int
id
,
const
SerialLayer
&
sl
)
{
if
(
sl
.
name
==
"OPEFOREIGN_int"
)
{
return
OPEFOREIGN_int
::
deserialize
(
id
,
sl
.
layer_info
);
}
else
if
(
sl
.
name
==
"OPEFOREIGN_str"
)
{
return
std
::
unique_ptr
<
EncLayer
>
(
new
OPEFOREIGN_str
(
id
,
sl
.
layer_info
));
}
else
{
FAIL_TextMessageError
(
"decimal support broken"
);
}
}
static
size_t
toMultiple
(
size_t
n
,
size_t
multiple
)
{
...
...
@@ -1173,9 +1241,22 @@ OPE_int::deserialize(unsigned int id, const std::string &serial)
const
size_t
ciph_bytes
=
strtoul_
(
vec
[
1
]);
const
CryptedInteger
cint
=
CryptedInteger
::
deserialize
(
vec
[
2
]);
return
std
::
unique_ptr
<
OPE_int
>
(
new
OPE_int
(
id
,
cint
,
plain_bytes
,
ciph_bytes
)
);
}
std
::
unique_ptr
<
OPEFOREIGN_int
>
OPEFOREIGN_int
::
deserialize
(
unsigned
int
id
,
const
std
::
string
&
serial
)
{
const
std
::
vector
<
std
::
string
>
vec
=
unserialize_string
(
serial
);
const
size_t
plain_bytes
=
strtoul_
(
vec
[
0
]);
const
size_t
ciph_bytes
=
strtoul_
(
vec
[
1
]);
const
CryptedInteger
cint
=
CryptedInteger
::
deserialize
(
vec
[
2
]);
return
std
::
unique_ptr
<
OPEFOREIGN_int
>
(
new
OPEFOREIGN_int
(
id
,
cint
,
plain_bytes
,
ciph_bytes
));
}
std
::
string
OPE_int
::
doSerialize
()
const
{
...
...
main/rewrite_main.cc
View file @
d88fe3ef
...
...
@@ -680,12 +680,12 @@ buildTypeTextTranslator()
// SecLevels.
const
std
::
vector
<
std
::
string
>
seclevel_strings
{
"RND"
,
"DET"
,
"DETJOIN"
,
"OPE"
,
"HOM"
,
"SEARCH"
,
"PLAINVAL"
,
"RND"
,
"DET"
,
"DETJOIN"
,
"OPEFOREIGN"
,
"OPE"
,
"HOM"
,
"SEARCH"
,
"PLAINVAL"
,
"INVALID"
};
const
std
::
vector
<
SECLEVEL
>
seclevels
{
SECLEVEL
::
RND
,
SECLEVEL
::
DET
,
SECLEVEL
::
DETJOIN
,
SECLEVEL
::
OPE
,
SECLEVEL
::
RND
,
SECLEVEL
::
DET
,
SECLEVEL
::
DETJOIN
,
SECLEVEL
::
OPE
FOREIGN
,
SECLEVEL
::
OPE
,
SECLEVEL
::
HOM
,
SECLEVEL
::
SEARCH
,
SECLEVEL
::
PLAINVAL
,
SECLEVEL
::
INVALID
};
...
...
stopgdbs
0 → 100755
View file @
d88fe3ef
###stop gdb
ps aux|grep gdb|grep -v grep|awk '{print $2}'| while read line;do sudo kill -9 $line;done
util/Makefrag
View file @
d88fe3ef
...
...
@@ -4,9 +4,7 @@ UTILSRC := onions.cc cryptdb_log.cc ctr.cc util.cc version.cc
all: $(OBJDIR)/libedbutil.so $(OBJDIR)/libedbutil.a
$(OBJDIR)/libedbutil.so: $(patsubst %.cc,$(OBJDIR)/util/%.o,$(UTILSRC))
echo $@ $^
echo '####################################################'
$(CXX) -shared -o $@ $^ $(LDFLAGS) -lntl -lcrypto -lgmp
$(CXX) -fPIC -shared -o $@ $^ $(LDFLAGS) -lntl -lcrypto -lgmp
$(OBJDIR)/libedbutil.a: $(patsubst %.cc,$(OBJDIR)/util/%.o,$(UTILSRC))
$(AR) r $@ $^
...
...
util/hello.cc
0 → 100644
View file @
d88fe3ef
#include<stdio.h>
void
help
(){
printf
(
"help
\n
"
);
}
util/onions.hh
View file @
d88fe3ef
...
...
@@ -44,14 +44,14 @@ static onionlayout PLAIN_ONION_LAYOUT = {
static
onionlayout
NUM_ONION_LAYOUT
=
{
{
oDET
,
std
::
vector
<
SECLEVEL
>
({
SECLEVEL
::
DETJOIN
,
SECLEVEL
::
DET
,
SECLEVEL
::
RND
})},
{
oOPE
,
std
::
vector
<
SECLEVEL
>
({
SECLEVEL
::
OPE
,
SECLEVEL
::
RND
})},
{
oOPE
,
std
::
vector
<
SECLEVEL
>
({
SECLEVEL
::
OPE
FOREIGN
,
SECLEVEL
::
OPE
,
SECLEVEL
::
RND
})},
{
oAGG
,
std
::
vector
<
SECLEVEL
>
({
SECLEVEL
::
HOM
})}
};
static
onionlayout
BEST_EFFORT_NUM_ONION_LAYOUT
=
{
{
oDET
,
std
::
vector
<
SECLEVEL
>
({
SECLEVEL
::
DETJOIN
,
SECLEVEL
::
DET
,
SECLEVEL
::
RND
})},
{
oOPE
,
std
::
vector
<
SECLEVEL
>
({
SECLEVEL
::
OPE
,
SECLEVEL
::
RND
})},
{
oOPE
,
std
::
vector
<
SECLEVEL
>
({
SECLEVEL
::
OPE
FOREIGN
,
SECLEVEL
::
OPE
,
SECLEVEL
::
RND
})},
{
oAGG
,
std
::
vector
<
SECLEVEL
>
({
SECLEVEL
::
HOM
})},
// Requires SECLEVEL::DET, otherwise you will have to implement
// encoding for negative numbers in SECLEVEL::RND.
...
...
@@ -62,7 +62,7 @@ static onionlayout BEST_EFFORT_NUM_ONION_LAYOUT = {
static
onionlayout
STR_ONION_LAYOUT
=
{
{
oDET
,
std
::
vector
<
SECLEVEL
>
({
SECLEVEL
::
DETJOIN
,
SECLEVEL
::
DET
,
SECLEVEL
::
RND
})},
{
oOPE
,
std
::
vector
<
SECLEVEL
>
({
SECLEVEL
::
OPE
,
SECLEVEL
::
RND
})},
{
oOPE
,
std
::
vector
<
SECLEVEL
>
({
SECLEVEL
::
OPE
FOREIGN
,
SECLEVEL
::
OPE
,
SECLEVEL
::
RND
})},
// {oSWP, std::vector<SECLEVEL>({SECLEVEL::SEARCH})}
// {oSWP, std::vector<SECLEVEL>({SECLEVEL::PLAINVAL, SECLEVEL::DET,
// SECLEVEL::RND})}
...
...
@@ -71,7 +71,7 @@ static onionlayout STR_ONION_LAYOUT = {
static
onionlayout
BEST_EFFORT_STR_ONION_LAYOUT
=
{
{
oDET
,
std
::
vector
<
SECLEVEL
>
({
SECLEVEL
::
DETJOIN
,
SECLEVEL
::
DET
,
SECLEVEL
::
RND
})},
{
oOPE
,
std
::
vector
<
SECLEVEL
>
({
SECLEVEL
::
OPE
,
SECLEVEL
::
RND
})},
{
oOPE
,
std
::
vector
<
SECLEVEL
>
({
SECLEVEL
::
OPE
FOREIGN
,
SECLEVEL
::
OPE
,
SECLEVEL
::
RND
})},
// {oSWP, std::vector<SECLEVEL>({SECLEVEL::SEARCH})},
// {oSWP, std::vector<SECLEVEL>({SECLEVEL::PLAINVAL, SECLEVEL::DET,
// SECLEVEL::RND})},
...
...
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