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
9c93ef99
Commit
9c93ef99
authored
May 17, 2017
by
casualet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
able to get transfield
parent
96b0d78f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
24 deletions
+92
-24
.cdb_test.cc.swp
main/.cdb_test.cc.swp
+0
-0
cdb_test.cc
main/cdb_test.cc
+92
-24
No files found.
main/.cdb_test.cc.swp
deleted
100644 → 0
View file @
96b0d78f
File deleted
main/cdb_test.cc
View file @
9c93ef99
...
@@ -42,6 +42,12 @@
...
@@ -42,6 +42,12 @@
#include <sstream>
#include <sstream>
#include <unistd.h>
#include <unistd.h>
#include <map>
using
std
::
cout
;
using
std
::
cin
;
using
std
::
endl
;
std
::
map
<
SECLEVEL
,
std
::
string
>
gmp
;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
...
@@ -354,13 +360,24 @@ void batchTogether(std::string client, std::string curQuery,unsigned long long _
...
@@ -354,13 +360,24 @@ void batchTogether(std::string client, std::string curQuery,unsigned long long _
static
void
processOnionMeta
(
OnionMeta
&
om
){
static
void
processLayers
(
const
EncLayer
&
enc
){
std
::
cout
<<
"om.getAnonOnionName(): "
<<
om
.
getAnonOnionName
()
<<
std
::
endl
;
//std::cout<<enc.serialize(enc)<<std::endl;
std
::
cout
<<
enc
.
name
()
<<
std
::
endl
;
}
static
void
processOnionMeta
(
const
OnionMeta
&
onion
){
std
::
cout
<<
GREEN_BEGIN
<<
"PRINT OnionMeta"
<<
COLOR_END
<<
std
::
endl
;
std
::
cout
<<
"onionmeta->getAnonOnionName(): "
<<
onion
.
getAnonOnionName
()
<<
std
::
endl
;
auto
&
layers
=
onion
.
getLayers
();
for
(
auto
&
slayer
:
layers
){
processLayers
(
*
(
slayer
.
get
()));
}
}
}
static
void
processFieldMeta
(
const
FieldMeta
&
field
){
static
void
processFieldMeta
(
const
FieldMeta
&
field
){
//Process general info
//Process general info
if
(
field
.
getHasSalt
()){
if
(
field
.
getHasSalt
()){
...
@@ -390,11 +407,11 @@ static void processFieldMeta(const FieldMeta &field){
...
@@ -390,11 +407,11 @@ static void processFieldMeta(const FieldMeta &field){
}
}
}
}
static
void
processTableMeta
(
const
TableMeta
&
table
){
static
void
processTableMeta
(
const
TableMeta
&
table
){
std
::
cout
<<
GREEN_BEGIN
<<
"PRINT TableMeta"
<<
COLOR_END
<<
std
::
endl
;
std
::
cout
<<
GREEN_BEGIN
<<
"PRINT TableMeta"
<<
COLOR_END
<<
std
::
endl
;
for
(
const
std
::
pair
<
const
IdentityMetaKey
,
std
::
unique_ptr
<
FieldMeta
>
>
&
field
:
table
.
getChildren
()){
for
(
FieldMeta
*
cfm
:
table
.
orderedFieldMetas
()){
std
::
cout
<<
field
.
second
->
getDatabaseID
()
<<
":"
<<
field
.
first
.
getValue
()
<<
std
::
endl
;
processFieldMeta
(
*
cfm
);
processFieldMeta
(
*
(
field
.
second
));
}
}
}
}
...
@@ -404,10 +421,6 @@ static void processDatabaseMeta(const DatabaseMeta & dbm,std::string table="stud
...
@@ -404,10 +421,6 @@ static void processDatabaseMeta(const DatabaseMeta & dbm,std::string table="stud
processTableMeta
(
tbm
);
processTableMeta
(
tbm
);
return
;
return
;
std
::
cout
<<
GREEN_BEGIN
<<
"PRINT DatabaseMeta"
<<
COLOR_END
<<
std
::
endl
;
for
(
const
std
::
pair
<
const
IdentityMetaKey
,
std
::
unique_ptr
<
TableMeta
>
>
&
table
:
dbm
.
getChildren
()){
processTableMeta
(
*
(
table
.
second
));
}
}
}
static
void
processSchemaInfo
(
SchemaInfo
&
schema
,
std
::
string
db
=
"tdb"
){
static
void
processSchemaInfo
(
SchemaInfo
&
schema
,
std
::
string
db
=
"tdb"
){
...
@@ -419,18 +432,60 @@ static void processSchemaInfo(SchemaInfo &schema,std::string db="tdb"){
...
@@ -419,18 +432,60 @@ static void processSchemaInfo(SchemaInfo &schema,std::string db="tdb"){
}
else
{
}
else
{
std
::
cout
<<
"data base not exists"
<<
std
::
endl
;
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.
for
(
const
auto
&
child
:
schema
.
getChildren
())
{
std
::
cout
<<
child
.
second
->
getDatabaseID
()
<<
":"
<<
child
.
first
.
getValue
()
<<
std
::
endl
;
processDatabaseMeta
(
*
(
child
.
second
));
}
}
}
//first step of back
static
std
::
vector
<
FieldMeta
*>
getFieldMeta
(
SchemaInfo
&
schema
,
std
::
string
db
=
"tdb"
,
std
::
string
table
=
"student1"
){
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
)){
const
DatabaseMeta
&
dbm
=
analysis
.
getDatabaseMeta
(
db
);
TableMeta
&
tbm
=
*
dbm
.
getChild
(
IdentityMetaKey
(
table
));
return
tbm
.
orderedFieldMetas
();
}
else
{
std
::
cout
<<
"data base not exists"
<<
std
::
endl
;
return
std
::
vector
<
FieldMeta
*>
();
}
}
struct
transField
{
bool
hasSalt
;
int
numOfOnions
;
//onions
std
::
vector
<
std
::
string
>
fields
;
void
show
(){
for
(
auto
item
:
fields
){
cout
<<
item
<<
"
\t
"
;
}
cout
<<
endl
;
if
(
hasSalt
){
cout
<<
"has salt"
<<
endl
;
}
else
cout
<<
"do not have salt"
<<
endl
;
}
};
static
std
::
vector
<
transField
>
getTransField
(
std
::
vector
<
FieldMeta
*>
pfms
){
std
::
vector
<
transField
>
res
;
//for every field
for
(
auto
pfm
:
pfms
){
transField
tf
;
for
(
std
::
pair
<
const
OnionMetaKey
*
,
OnionMeta
*>
&
ompair
:
pfm
->
orderedOnionMetas
()){
tf
.
numOfOnions
++
;
tf
.
fields
.
push_back
((
ompair
.
second
)
->
getAnonOnionName
());
}
if
(
pfm
->
getHasSalt
()){
tf
.
hasSalt
=
true
;
tf
.
fields
.
push_back
(
pfm
->
getSaltName
());
}
res
.
push_back
(
tf
);
}
return
res
;
}
static
std
::
unique_ptr
<
SchemaInfo
>
myLoadSchemaInfo
()
{
static
std
::
unique_ptr
<
SchemaInfo
>
myLoadSchemaInfo
()
{
std
::
unique_ptr
<
Connect
>
e_conn
(
Connect
::
getEmbedded
(
embeddedDir
));
std
::
unique_ptr
<
Connect
>
e_conn
(
Connect
::
getEmbedded
(
embeddedDir
));
std
::
unique_ptr
<
SchemaInfo
>
schema
(
new
SchemaInfo
());
std
::
unique_ptr
<
SchemaInfo
>
schema
(
new
SchemaInfo
());
...
@@ -452,6 +507,9 @@ static std::unique_ptr<SchemaInfo> myLoadSchemaInfo() {
...
@@ -452,6 +507,9 @@ static std::unique_ptr<SchemaInfo> myLoadSchemaInfo() {
}
}
static
void
static
void
addToReturn
(
ReturnMeta
*
const
rm
,
int
pos
,
const
OLK
&
constr
,
addToReturn
(
ReturnMeta
*
const
rm
,
int
pos
,
const
OLK
&
constr
,
bool
has_salt
,
const
std
::
string
&
name
)
{
bool
has_salt
,
const
std
::
string
&
name
)
{
...
@@ -895,12 +953,17 @@ startBack(){
...
@@ -895,12 +953,17 @@ startBack(){
}
}
}
}
int
int
main
()
{
main
()
{
gmp
[
SECLEVEL
::
INVALID
]
=
"INVALID"
;
gmp
[
SECLEVEL
::
PLAINVAL
]
=
"PLAINVAL"
;
gmp
[
SECLEVEL
::
OPE
]
=
"OPE"
;
gmp
[
SECLEVEL
::
DETJOIN
]
=
"DETJOIN"
;
gmp
[
SECLEVEL
::
OPEFOREIGN
]
=
"OPEFOREIGN"
;
gmp
[
SECLEVEL
::
DET
]
=
"DET"
;
gmp
[
SECLEVEL
::
SEARCH
]
=
"SEARCH"
;
gmp
[
SECLEVEL
::
HOM
]
=
"HOM"
;
gmp
[
SECLEVEL
::
RND
]
=
"RND"
;
std
::
string
client
=
"192.168.1.1:1234"
;
std
::
string
client
=
"192.168.1.1:1234"
;
//one Wrapper per user.
//one Wrapper per user.
...
@@ -935,10 +998,17 @@ main() {
...
@@ -935,10 +998,17 @@ main() {
std
::
getline
(
std
::
cin
,
curQuery
);
std
::
getline
(
std
::
cin
,
curQuery
);
continue
;
continue
;
}
}
if
(
curQuery
==
"back"
){
if
(
curQuery
==
"back
1
"
){
startBack
();
startBack
();
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
processSchemaInfo
(
*
schema
);
processSchemaInfo
(
*
schema
);
}
else
if
(
curQuery
==
"back"
){
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
auto
res
=
getTransField
(
getFieldMeta
(
*
schema
));
for
(
auto
&
item
:
res
){
item
.
show
();
}
}
else
{
}
else
{
std
::
cout
<<
GREEN_BEGIN
<<
"curQuery: "
<<
curQuery
<<
"
\n
"
<<
COLOR_END
<<
std
::
endl
;
std
::
cout
<<
GREEN_BEGIN
<<
"curQuery: "
<<
curQuery
<<
"
\n
"
<<
COLOR_END
<<
std
::
endl
;
batchTogether
(
client
,
curQuery
,
_thread_id
);
batchTogether
(
client
,
curQuery
,
_thread_id
);
...
@@ -946,7 +1016,5 @@ main() {
...
@@ -946,7 +1016,5 @@ main() {
std
::
cout
<<
GREEN_BEGIN
<<
"
\n
please input a new query:#######"
<<
COLOR_END
<<
std
::
endl
;
std
::
cout
<<
GREEN_BEGIN
<<
"
\n
please input a new query:#######"
<<
COLOR_END
<<
std
::
endl
;
std
::
getline
(
std
::
cin
,
curQuery
);
std
::
getline
(
std
::
cin
,
curQuery
);
}
}
return
0
;
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