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
a2673803
Commit
a2673803
authored
Apr 01, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
able to use ashe for both agg query and normal query
parent
3695a861
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
24 deletions
+16
-24
CURRENT.conf
conf/CURRENT.conf
+2
-2
Analysis.cc
main/Analysis.cc
+2
-2
dml_handler.cc
main/dml_handler.cc
+3
-6
rewrite_main.cc
main/rewrite_main.cc
+9
-14
No files found.
conf/CURRENT.conf
View file @
a2673803
...
...
@@ -5,8 +5,8 @@
[
onions
for
num
]
#oDET: DET RND
#oOPE: OPE RND
oAGG
:
HOM
#
oASHE: ASHE
#
oAGG: HOM
oASHE
:
ASHE
[
end
]
...
...
main/Analysis.cc
View file @
a2673803
...
...
@@ -195,8 +195,8 @@ OLK EncSet::extract_singleton() const
static
bool
needsSalt
(
SECLEVEL
l
)
{
//
return l == SECLEVEL::RND||l==SECLEVEL::ASHE;
return
l
==
SECLEVEL
::
RND
;
return
l
==
SECLEVEL
::
RND
||
l
==
SECLEVEL
::
ASHE
;
//
return l == SECLEVEL::RND;
}
bool
...
...
main/dml_handler.cc
View file @
a2673803
...
...
@@ -666,7 +666,8 @@ rewrite_proj(const Item &i, const RewritePlan &rp, Analysis &a,
//Different form INSERT, SELECT needs only one onion.
assert
(
ir
.
assigned
()
&&
ir
.
get
());
newList
->
push_back
(
ir
.
get
());
const
bool
use_salt
=
needsSalt
(
olk
.
get
());
bool
use_salt
=
needsSalt
(
olk
.
get
());
if
(
i
.
type
()
==
Item
::
SUM_FUNC_ITEM
)
use_salt
=
false
;
// This line implicity handles field aliasing for at least some cases.
// As i->name can/will be the alias.
...
...
@@ -1648,12 +1649,10 @@ nextImpl(const ResType &res, const NextParams &nparams)
std
::
pair
<
AbstractQueryExecutor
::
ResultType
,
AbstractAnything
*>
ShowTablesExecutor
::
nextImpl
(
const
ResType
&
res
,
const
NextParams
&
nparams
)
{
nextImpl
(
const
ResType
&
res
,
const
NextParams
&
nparams
){
reenter
(
this
->
corot
)
{
yield
return
CR_QUERY_AGAIN
(
nparams
.
original_query
);
TEST_ErrPkt
(
res
.
success
(),
"show tables failed"
);
yield
{
const
std
::
shared_ptr
<
const
SchemaInfo
>
&
schema
=
nparams
.
ps
.
getSchemaInfo
();
...
...
@@ -1662,14 +1661,12 @@ nextImpl(const ResType &res, const NextParams &nparams)
TEST_ErrPkt
(
dm
,
"failed to find the database '"
+
nparams
.
default_db
+
"'"
);
std
::
vector
<
std
::
vector
<
Item
*>
>
new_rows
;
for
(
const
auto
&
it
:
res
.
rows
)
{
assert
(
1
==
it
.
size
());
for
(
const
auto
&
table
:
dm
->
getChildren
())
{
assert
(
table
.
second
);
if
(
table
.
second
->
getAnonTableName
()
==
ItemToString
(
*
it
.
front
()))
{
const
IdentityMetaKey
&
plain_table_name
=
dm
->
getKey
(
*
table
.
second
.
get
());
new_rows
.
push_back
(
std
::
vector
<
Item
*>
...
...
main/rewrite_main.cc
View file @
a2673803
...
...
@@ -907,8 +907,7 @@ do_optimize_const_item(T *i, Analysis &a) {
//Layers of decryption
static
Item
*
decrypt_item_layers
(
const
Item
&
i
,
const
FieldMeta
*
const
fm
,
onion
o
,
uint64_t
IV
)
{
uint64_t
IV
)
{
assert
(
!
RiboldMYSQL
::
is_null
(
i
));
const
Item
*
dec
=
&
i
;
Item
*
out_i
=
NULL
;
...
...
@@ -919,8 +918,12 @@ decrypt_item_layers(const Item &i, const FieldMeta *const fm, onion o,
const
auto
&
enc_layers
=
om
->
getLayers
();
for
(
auto
it
=
enc_layers
.
rbegin
();
it
!=
enc_layers
.
rend
();
++
it
)
{
if
(
o
==
oASHE
)
{
if
(
dec
->
type
()
!=
Item
::
INT_ITEM
){
out_i
=
((
ASHE
&
)(
*
it
)).
decrypt_sum
(
*
dec
);
break
;
}
else
{
out_i
=
(
*
it
)
->
decrypt
(
*
dec
,
IV
);
}
}
out_i
=
(
*
it
)
->
decrypt
(
*
dec
,
IV
);
assert
(
out_i
);
...
...
@@ -1402,16 +1405,12 @@ std::string ReturnMeta::stringify() {
*
*/
ResType
Rewriter
::
decryptResults
(
const
ResType
&
dbres
,
const
ReturnMeta
&
rmeta
)
{
Rewriter
::
decryptResults
(
const
ResType
&
dbres
,
const
ReturnMeta
&
rmeta
)
{
assert
(
dbres
.
success
());
const
unsigned
int
rows
=
dbres
.
rows
.
size
();
const
unsigned
int
cols
=
dbres
.
names
.
size
();
// un-anonymize the names
std
::
vector
<
std
::
string
>
dec_names
;
for
(
auto
it
=
dbres
.
names
.
begin
();
it
!=
dbres
.
names
.
end
();
it
++
)
{
const
unsigned
int
index
=
it
-
dbres
.
names
.
begin
();
...
...
@@ -1422,14 +1421,12 @@ Rewriter::decryptResults(const ResType &dbres, const ReturnMeta &rmeta)
dec_names
.
push_back
(
rf
.
fieldCalled
());
}
}
const
unsigned
int
real_cols
=
dec_names
.
size
();
std
::
vector
<
std
::
vector
<
Item
*>
>
dec_rows
(
rows
);
for
(
unsigned
int
i
=
0
;
i
<
rows
;
i
++
)
{
dec_rows
[
i
]
=
std
::
vector
<
Item
*>
(
real_cols
);
}
//
//
fields
unsigned
int
col_index
=
0
;
for
(
unsigned
int
c
=
0
;
c
<
cols
;
c
++
)
{
const
ReturnField
&
rf
=
rmeta
.
rfmeta
.
at
(
c
);
...
...
@@ -1437,9 +1434,7 @@ Rewriter::decryptResults(const ResType &dbres, const ReturnMeta &rmeta)
continue
;
}
FieldMeta
*
const
fm
=
rf
.
getOLK
().
key
;
for
(
unsigned
int
r
=
0
;
r
<
rows
;
r
++
)
{
if
(
!
fm
||
dbres
.
rows
[
r
][
c
]
->
is_null
())
{
dec_rows
[
r
][
col_index
]
=
dbres
.
rows
[
r
][
c
];
}
else
{
...
...
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