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
5d6dce4d
Commit
5d6dce4d
authored
May 16, 2017
by
casualet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add back
parent
aa2e1394
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
23 deletions
+35
-23
Analysis.hh
main/Analysis.hh
+8
-9
cdb_test.cc
main/cdb_test.cc
+27
-14
No files found.
main/Analysis.hh
View file @
5d6dce4d
...
...
@@ -279,9 +279,11 @@ public:
master_key
(
analysis
.
getMasterKey
()),
default_sec_rating
(
analysis
.
getDefaultSecurityRating
())
{}
unsigned
int
pos
;
//
>
a counter indicating how many projection
unsigned
int
pos
;
// a counter indicating how many projection
// fields have been analyzed so far
//each field may or may not has a salt field
std
::
map
<
const
FieldMeta
*
,
const
salt_type
>
salts
;
//each Item has a rewrite plain, which lists possible way to encrypt this item, that is OLKs!
std
::
map
<
const
Item
*
,
std
::
unique_ptr
<
RewritePlan
>
>
rewritePlans
;
std
::
map
<
std
::
string
,
std
::
map
<
const
std
::
string
,
const
std
::
string
>>
table_aliases
;
...
...
@@ -316,6 +318,7 @@ public:
TableMeta
&
getTableMeta
(
const
std
::
string
&
db
,
const
std
::
string
&
table
)
const
;
DatabaseMeta
&
getDatabaseMeta
(
const
std
::
string
&
db
)
const
;
bool
tableMetaExists
(
const
std
::
string
&
db
,
...
...
@@ -326,12 +329,11 @@ public:
std
::
string
getAnonTableName
(
const
std
::
string
&
db
,
const
std
::
string
&
table
,
bool
*
const
is_alias
=
NULL
)
const
;
std
::
string
translateNonAliasPlainToAnonTableName
(
const
std
::
string
&
db
,
const
std
::
string
&
table
)
const
;
//use this function to rewrite functions
std
::
string
getAnonIndexName
(
const
std
::
string
&
db
,
const
std
::
string
&
table
,
const
std
::
string
&
index_name
,
...
...
@@ -341,6 +343,7 @@ public:
onion
o
)
const
;
static
const
EncLayer
&
getBackEncLayer
(
const
OnionMeta
&
om
);
static
SECLEVEL
getOnionLevel
(
const
OnionMeta
&
om
);
SECLEVEL
getOnionLevel
(
const
FieldMeta
&
fm
,
onion
o
);
...
...
@@ -348,24 +351,20 @@ public:
getEncLayers
(
const
OnionMeta
&
om
);
const
SchemaInfo
&
getSchema
()
const
{
return
schema
;}
std
::
vector
<
std
::
unique_ptr
<
Delta
>
>
deltas
;
std
::
string
getDatabaseName
()
const
{
return
db_name
;}
const
std
::
unique_ptr
<
AES_KEY
>
&
getMasterKey
()
const
{
return
master_key
;}
SECURITY_RATING
getDefaultSecurityRating
()
const
{
return
default_sec_rating
;}
// access to isAlias(...)
friend
class
MultiDeleteHandler
;
private
:
//name for the default db
const
std
::
string
db_name
;
const
SchemaInfo
&
schema
;
const
std
::
unique_ptr
<
AES_KEY
>
&
master_key
;
const
SECURITY_RATING
default_sec_rating
;
bool
isAlias
(
const
std
::
string
&
db
,
const
std
::
string
&
table
)
const
;
std
::
string
unAliasTable
(
const
std
::
string
&
db
,
...
...
main/cdb_test.cc
View file @
5d6dce4d
...
...
@@ -43,11 +43,6 @@
#include <sstream>
#include <unistd.h>
FILE
*
fr
,
*
fw
;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
//My WrapperState.
...
...
@@ -360,7 +355,7 @@ void batchTogether(std::string client, std::string curQuery,unsigned long long _
static
void
processFieldMeta
(
const
FieldMeta
&
field
){
std
::
cout
<<
GREEN_BEGIN
<<
"PRINT FieldMeta"
<<
COLOR_END
<<
std
::
endl
;
for
(
const
auto
&
onion
:
field
.
getChildren
()){
for
(
const
OnionMeta
&
onion
:
field
.
getChildren
()){
std
::
cout
<<
onion
.
second
->
getDatabaseID
()
<<
":"
<<
onion
.
first
.
getValue
()
<<
std
::
endl
;
}
std
::
cout
<<
GREEN_BEGIN
<<
"end FieldMeta"
<<
COLOR_END
<<
std
::
endl
;
...
...
@@ -368,21 +363,34 @@ static void processFieldMeta(const FieldMeta &field){
static
void
processTableMeta
(
const
TableMeta
&
table
){
std
::
cout
<<
GREEN_BEGIN
<<
"PRINT TableMeta"
<<
COLOR_END
<<
std
::
endl
;
for
(
const
auto
&
field
:
table
.
getChildren
()){
for
(
const
FieldMeta
&
field
:
table
.
getChildren
()){
std
::
cout
<<
field
.
second
->
getDatabaseID
()
<<
":"
<<
field
.
first
.
getValue
()
<<
std
::
endl
;
processFieldMeta
(
*
(
field
.
second
));
}
}
static
void
processDatabaseMeta
(
const
DatabaseMeta
&
db
)
{
static
void
processDatabaseMeta
(
const
DatabaseMeta
&
dbm
,
std
::
string
table
=
"student1"
)
{
TableMeta
&
tbm
=
*
dbm
.
getChild
(
IdentityMetaKey
(
table
));
processTableMeta
(
tbm
);
return
;
std
::
cout
<<
GREEN_BEGIN
<<
"PRINT DatabaseMeta"
<<
COLOR_END
<<
std
::
endl
;
for
(
const
auto
&
table
:
db
.
getChildren
()){
for
(
const
auto
&
table
:
db
m
.
getChildren
()){
processTableMeta
(
*
(
table
.
second
));
}
}
static
void
processSchemaInfo
(
SchemaInfo
&
schema
){
static
void
processSchemaInfo
(
SchemaInfo
&
schema
,
std
::
string
db
=
"tdb"
){
const
std
::
unique_ptr
<
AES_KEY
>
&
TK
=
std
::
unique_ptr
<
AES_KEY
>
(
getKey
(
std
::
string
(
"113341234"
)));
Analysis
analysis
(
db
,
schema
,
TK
,
SECURITY_RATING
::
SENSITIVE
);
if
(
analysis
.
databaseMetaExists
(
db
)){
processDatabaseMeta
(
analysis
.
getDatabaseMeta
(
db
));
}
else
{
std
::
cout
<<
"data base not exists"
<<
std
::
endl
;
}
return
;
//we have a map here
std
::
cout
<<
GREEN_BEGIN
<<
"PRINT SchemaInfo"
<<
COLOR_END
<<
std
::
endl
;
//only const auto & is allowed, now copying. or we meet use of deleted function.
...
...
@@ -392,6 +400,8 @@ static void processSchemaInfo(SchemaInfo &schema){
}
}
static
std
::
unique_ptr
<
SchemaInfo
>
myLoadSchemaInfo
()
{
std
::
unique_ptr
<
Connect
>
e_conn
(
Connect
::
getEmbedded
(
embeddedDir
));
std
::
unique_ptr
<
SchemaInfo
>
schema
(
new
SchemaInfo
());
...
...
@@ -832,6 +842,7 @@ static std::string logicBackUp(std::string database, std::string table,SchemaInf
static
void
startBack
(){
return
;
//only for testing backup module
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
processSchemaInfo
(
*
schema
);
...
...
@@ -859,8 +870,8 @@ startBack(){
int
main
()
{
fr
=
fopen
((
const
char
*
)
"readFile"
,(
const
char
*
)
"r"
);
fw
=
fopen
((
const
char
*
)
"writeFile"
,(
const
char
*
)
"a"
);
std
::
string
client
=
"192.168.1.1:1234"
;
//one Wrapper per user.
...
...
@@ -897,14 +908,16 @@ main() {
}
if
(
curQuery
==
"back"
){
startBack
();
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
processSchemaInfo
(
*
schema
);
}
else
{
std
::
cout
<<
GREEN_BEGIN
<<
"curQuery: "
<<
curQuery
<<
"
\n
"
<<
COLOR_END
<<
std
::
endl
;
batchTogether
(
client
,
curQuery
,
_thread_id
);
}
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
processSchemaInfo
(
*
schema
);
std
::
cout
<<
GREEN_BEGIN
<<
"
\n
please input a new query:#######"
<<
COLOR_END
<<
std
::
endl
;
std
::
getline
(
std
::
cin
,
curQuery
);
}
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