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
1a5304df
Commit
1a5304df
authored
Oct 30, 2017
by
Casualet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do not install /use/lib
parent
14ac33fc
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
76 additions
and
51 deletions
+76
-51
Makefrag
crypto/Makefrag
+4
-4
Makefrag
main/Makefrag
+6
-4
dbobject.hh
main/dbobject.hh
+45
-29
schema.cc
main/schema.cc
+12
-8
schema.hh
main/schema.hh
+3
-2
setup.sh
setup.sh
+2
-0
Makefrag
util/Makefrag
+4
-4
No files found.
crypto/Makefrag
View file @
1a5304df
...
...
@@ -17,10 +17,10 @@ $(OBJDIR)/libedbcrypto.a: $(CRYPTOOBJ)
$(OBJDIR)/crypto/x: $(OBJDIR)/crypto/x.o $(OBJDIR)/libedbcrypto.so
$(CXX) $< -o $@ $(LDFLAGS) $(LDRPATH) -ledbcrypto
install: install_crypto
#
install: install_crypto
.PHONY: install_crypto
install_crypto: $(OBJDIR)/libedbcrypto.so
install -m 644 $(OBJDIR)/libedbcrypto.so /usr/lib
#
.PHONY: install_crypto
#
install_crypto: $(OBJDIR)/libedbcrypto.so
#
install -m 644 $(OBJDIR)/libedbcrypto.so /usr/lib
# vim: set noexpandtab:
main/Makefrag
View file @
1a5304df
...
...
@@ -30,10 +30,12 @@ $(OBJDIR)/libcryptdb.so: $(CRYPTDB_OBJS) \
$(CXX) -shared -g -o $@ $(CRYPTDB_OBJS) $(LDFLAGS) $(LDRPATH) \
-ledbcrypto -ledbutil -ledbparser -lntl -lcrypto
install: install_main
.PHONY: install_main
install_main: $(OBJDIR)/libcryptdb.so
install -m 644 $(OBJDIR)/libcryptdb.so /usr/lib
#install: install_main
#.PHONY: install_main
#install_main: $(OBJDIR)/libcryptdb.so
# install -m 644 $(OBJDIR)/libcryptdb.so /usr/lib
# vim: set noexpandtab:
main/dbobject.hh
View file @
1a5304df
...
...
@@ -8,20 +8,27 @@
#include <main/serializers.hh>
// FIXME: Maybe should inherit from DBObject.
// FIXME: Maybe should inherit from DBObject.(but it do not need an id??)
/*provide static factory for get a key type*/
class
AbstractMetaKey
:
public
NormalAlloc
{
public
:
AbstractMetaKey
()
{;}
virtual
~
AbstractMetaKey
()
{;}
virtual
std
::
string
getSerial
()
const
=
0
;
/* used in mappedDBmeta: factory<KeyType> */
template
<
typename
ConcreteKey
>
static
ConcreteKey
*
factory
(
std
::
string
serial
)
{
/*dummy is not used!!*/
int
dummy
=
1
;
return
new
ConcreteKey
(
dummy
,
serial
);
}
};
//we have onionMetaKey,UIntMetaKey and IdentityMetaKey for metadata hierachy
/*
*we have onionMetaKey,UIntMetaKey and IdentityMetaKey for metadata hierachy
*meta key provides KeyType and Serial
*/
template
<
typename
KeyType
>
class
MetaKey
:
public
AbstractMetaKey
{
const
KeyType
key_data
;
...
...
@@ -36,6 +43,7 @@ public:
// Build MetaKey from 'actual' key value.
MetaKey
(
KeyType
key_data
)
{;}
virtual
~
MetaKey
()
=
0
;
/*key can be inserted into a map, so it must support those operations*/
bool
operator
<
(
const
MetaKey
<
KeyType
>
&
rhs
)
const
;
bool
operator
==
(
const
MetaKey
<
KeyType
>
&
rhs
)
const
;
...
...
@@ -46,6 +54,10 @@ public:
template
<
typename
KeyType
>
MetaKey
<
KeyType
>::~
MetaKey
()
{;}
/*
*this is metakey<string>
*/
class
IdentityMetaKey
:
public
MetaKey
<
std
::
string
>
{
public
:
IdentityMetaKey
(
std
::
string
key_data
)
...
...
@@ -66,6 +78,9 @@ private:
}
};
/*
*this is metakey<onion>
*/
class
OnionMetaKey
:
public
MetaKey
<
onion
>
{
public
:
OnionMetaKey
(
onion
key_data
)
...
...
@@ -86,6 +101,10 @@ private:
}
};
/*
*this is metakey<int>,and it should be noted that onion is different from int, althogh it can be converted
*/
class
UIntMetaKey
:
public
MetaKey
<
unsigned
int
>
{
public
:
UIntMetaKey
(
unsigned
int
key_data
)
...
...
@@ -95,13 +114,11 @@ public:
~
UIntMetaKey
()
{;}
private
:
virtual
std
::
string
serialize
(
unsigned
int
i
)
{
virtual
std
::
string
serialize
(
unsigned
int
i
){
return
serialize_string
(
std
::
to_string
(
i
));
}
virtual
unsigned
int
unserialize
(
std
::
string
s
)
{
virtual
unsigned
int
unserialize
(
std
::
string
s
){
return
serial_to_uint
(
s
);
}
};
...
...
@@ -122,14 +139,11 @@ public:
explicit
DBObject
(
unsigned
int
id
)
:
id
(
id
)
{}
virtual
~
DBObject
()
{;}
unsigned
int
getDatabaseID
()
const
{
return
id
;}
// FIXME: This should possibly be a part of DBMeta.
// > Parent will definitely be DBMeta.
// > Parent-Child semantics aren't really added until DBMeta.
};
class
Connect
;
/*
* DBMeta is also a design choice about how we use Deltas.
* i) Read SchemaInfo from database, read Deltaz from database then
...
...
@@ -143,6 +157,7 @@ class Connect;
* read SchemaInfo from database.
* > Logic is in SQL.
*/
class
DBMeta
:
public
DBObject
,
public
NormalAlloc
{
public
:
DBMeta
()
{}
...
...
@@ -159,6 +174,7 @@ public:
applyToChildren
(
std
::
function
<
bool
(
const
DBMeta
&
)
>
)
const
=
0
;
/*traverse the map to get the key for the conresponding child(reference MappedDBMeta)*/
virtual
AbstractMetaKey
const
&
getKey
(
const
DBMeta
&
child
)
const
=
0
;
/*each item in the meta hierachy should be able to serialize,like tablemeta,databasemeta,onionmeta,enclayers*/
virtual
std
::
string
serialize
(
const
DBObject
&
parent
)
const
=
0
;
protected
:
std
::
vector
<
DBMeta
*>
...
...
@@ -169,23 +185,26 @@ protected:
deserialHandler
);
};
class
LeafDBMeta
:
public
DBMeta
{
public
:
LeafDBMeta
()
{}
LeafDBMeta
(
unsigned
int
id
)
:
DBMeta
(
id
)
{}
/*from DBmeta*/
std
::
vector
<
DBMeta
*>
fetchChildren
(
const
std
::
unique_ptr
<
Connect
>
&
e_conn
)
{
return
std
::
vector
<
DBMeta
*>
();
}
/*from DBmeta*/
bool
applyToChildren
(
std
::
function
<
bool
(
const
DBMeta
&
)
>
fn
)
const
{
return
true
;
}
/*if this is an abstract function, then enclayers can be acstract classes, which is not correct*/
AbstractMetaKey
const
&
getKey
(
const
DBMeta
&
child
)
const
{
// FIXME:
assert
(
false
);
}
};
...
...
@@ -215,17 +234,19 @@ public:
virtual
std
::
vector
<
DBMeta
*>
fetchChildren
(
const
std
::
unique_ptr
<
Connect
>
&
e_conn
);
/*what if we remove this declaration?*/
/*inherited from DBMeta*/
bool
applyToChildren
(
std
::
function
<
bool
(
const
DBMeta
&
)
>
fn
)
const
;
const
std
::
map
<
KeyType
,
std
::
unique_ptr
<
ChildType
>
>
&
getChildren
()
const
{
return
children
;
}
/*when is this used???*/
virtual
const
ChildType
*
getChildWithGChild
(
const
DBMeta
&
gchild
)
const
;
private
:
/*store the hirechy of metadata as a map. For example, each database has sever tables,
*then in the databasemeta stores a map of tables. The keys are of type string(metakey),
*and the values are of type DBMeta.
...
...
@@ -244,20 +265,17 @@ bool MetaKey<KeyType>::operator <(const MetaKey<KeyType> &rhs) const
}
template
<
typename
KeyType
>
bool
MetaKey
<
KeyType
>::
operator
==
(
const
MetaKey
<
KeyType
>
&
rhs
)
const
{
bool
MetaKey
<
KeyType
>::
operator
==
(
const
MetaKey
<
KeyType
>
&
rhs
)
const
{
return
key_data
==
rhs
.
key_data
;
}
template
<
typename
ChildType
,
typename
KeyType
>
bool
MappedDBMeta
<
ChildType
,
KeyType
>::
addChild
(
KeyType
key
,
std
::
unique_ptr
<
ChildType
>
meta
)
{
std
::
unique_ptr
<
ChildType
>
meta
){
if
(
childExists
(
key
))
{
return
false
;
}
children
[
key
]
=
std
::
move
(
meta
);
return
true
;
}
...
...
@@ -287,8 +305,7 @@ MappedDBMeta<ChildType, KeyType>::getChild(const KeyType &key) const
// NOTE: Slow.
template
<
typename
ChildType
,
typename
KeyType
>
KeyType
const
&
MappedDBMeta
<
ChildType
,
KeyType
>::
getKey
(
const
DBMeta
&
child
)
const
{
MappedDBMeta
<
ChildType
,
KeyType
>::
getKey
(
const
DBMeta
&
child
)
const
{
for
(
const
auto
&
it
:
children
)
{
if
(
it
.
second
.
get
()
==
&
child
)
{
return
it
.
first
;
...
...
@@ -299,12 +316,10 @@ MappedDBMeta<ChildType, KeyType>::getKey(const DBMeta &child) const
template
<
typename
ChildType
,
typename
KeyType
>
std
::
vector
<
DBMeta
*>
MappedDBMeta
<
ChildType
,
KeyType
>::
fetchChildren
(
const
std
::
unique_ptr
<
Connect
>
&
e_conn
)
{
MappedDBMeta
<
ChildType
,
KeyType
>::
fetchChildren
(
const
std
::
unique_ptr
<
Connect
>
&
e_conn
){
// Perhaps it's conceptually cleaner to have this lambda return
// pairs of keys and children and then add the children from local
// scope.
std
::
function
<
DBMeta
*
(
const
std
::
string
&
,
const
std
::
string
&
,
const
std
::
string
&
)
>
...
...
@@ -330,8 +345,7 @@ MappedDBMeta<ChildType, KeyType>::fetchChildren(const std::unique_ptr<Connect> &
template
<
typename
ChildType
,
typename
KeyType
>
bool
MappedDBMeta
<
ChildType
,
KeyType
>::
applyToChildren
(
std
::
function
<
bool
(
const
DBMeta
&
)
>
fn
)
const
{
std
::
function
<
bool
(
const
DBMeta
&
)
>
fn
)
const
{
for
(
const
auto
&
it
:
children
)
{
if
(
false
==
fn
(
*
it
.
second
.
get
()))
{
return
false
;
...
...
@@ -341,12 +355,12 @@ MappedDBMeta<ChildType, KeyType>::applyToChildren(
return
true
;
}
template
<
typename
ChildType
,
typename
KeyType
>
const
ChildType
*
MappedDBMeta
<
ChildType
,
KeyType
>::
getChildWithGChild
(
const
DBMeta
&
gchild
)
const
{
getChildWithGChild
(
const
DBMeta
&
gchild
)
const
{
bool
match
=
false
;
for
(
const
auto
&
it
:
this
->
getChildren
())
{
for
(
const
auto
&
it
:
this
->
getChildren
()){
std
::
function
<
bool
(
const
DBMeta
&
)
>
misGet
=
[
&
it
,
&
gchild
,
&
match
]
(
const
DBMeta
&
possible_match
)
{
if
(
&
possible_match
==
&
gchild
)
{
...
...
@@ -364,3 +378,5 @@ getChildWithGChild(const DBMeta &gchild) const
}
return
nullptr
;
}
main/schema.cc
View file @
1a5304df
...
...
@@ -13,20 +13,27 @@
#include <main/macro_util.hh>
//对于schemaInfo而言, 先获得自己的id, 作为parent, 可以查找底下的databasemeta的serial,key以及id
//然后通过lambda表达式,先把databasemeta加入到schemainfo的map中, 然后返回这个databasemeta供后续使用.
//然后通过lambda表达式,先把databasemeta加入到schemainfo的map中, 然后返回这写个databasemeta供后续使用.
/*
*for example, we have schemaInfo, then in this function, it first fetch it's own id, and use it as parent
*to fetch its children, the databasemeta. Then it adds those databasemeta as KV in the map, and return those
*databasemeta as a vector for recursive processing.
for this function, it only extract the dbmeta and
*/
std
::
vector
<
DBMeta
*>
DBMeta
::
doFetchChildren
(
const
std
::
unique_ptr
<
Connect
>
&
e_conn
,
std
::
function
<
DBMeta
*
(
const
std
::
string
&
,
const
std
::
string
&
,
const
std
::
string
&
)
>
deserialHandler
)
{
const
std
::
string
table_name
=
MetaData
::
Table
::
metaObject
();
deserialHandler
)
{
const
std
::
string
table_name
=
MetaData
::
Table
::
metaObject
();
// Now that we know the table exists, SELECT the data we want.
std
::
vector
<
DBMeta
*>
out_vec
;
std
::
unique_ptr
<
DBResult
>
db_res
;
//
这个id来自于dbobject
.
//
this is the id of the current class
.
const
std
::
string
parent_id
=
std
::
to_string
(
this
->
getDatabaseID
());
const
std
::
string
serials_query
=
" SELECT "
+
table_name
+
".serial_object,"
...
...
@@ -42,16 +49,13 @@ DBMeta::doFetchChildren(const std::unique_ptr<Connect> &e_conn,
while
((
row
=
mysql_fetch_row
(
db_res
->
n
)))
{
unsigned
long
*
const
l
=
mysql_fetch_lengths
(
db_res
->
n
);
assert
(
l
!=
NULL
);
const
std
::
string
child_serial_object
(
row
[
0
],
l
[
0
]);
const
std
::
string
child_key
(
row
[
1
],
l
[
1
]);
const
std
::
string
child_id
(
row
[
2
],
l
[
2
]);
DBMeta
*
const
new_old_meta
=
deserialHandler
(
child_key
,
child_serial_object
,
child_id
);
out_vec
.
push_back
(
new_old_meta
);
}
return
out_vec
;
}
...
...
main/schema.hh
View file @
1a5304df
...
...
@@ -30,11 +30,9 @@
*/
class
OnionMeta
:
public
DBMeta
{
public
:
// New.
OnionMeta
(
onion
o
,
std
::
vector
<
SECLEVEL
>
levels
,
const
AES_KEY
*
const
m_key
,
const
Create_field
&
cf
,
unsigned
long
uniq_count
,
SECLEVEL
minimum_seclevel
);
// Restore.
static
std
::
unique_ptr
<
OnionMeta
>
deserialize
(
unsigned
int
id
,
const
std
::
string
&
serial
);
...
...
@@ -49,7 +47,9 @@ public:
std
::
vector
<
DBMeta
*>
fetchChildren
(
const
std
::
unique_ptr
<
Connect
>
&
e_conn
);
bool
applyToChildren
(
std
::
function
<
bool
(
const
DBMeta
&
)
>
)
const
;
UIntMetaKey
const
&
getKey
(
const
DBMeta
&
child
)
const
;
EncLayer
*
getLayerBack
()
const
;
EncLayer
*
getLayer
(
const
SECLEVEL
&
sl
)
const
;
bool
hasEncLayer
(
const
SECLEVEL
&
sl
)
const
;
...
...
@@ -67,6 +67,7 @@ private:
const
std
::
string
onionname
;
const
unsigned
long
uniq_count
;
SECLEVEL
minimum_seclevel
;
/*what are those keys used for?*/
mutable
std
::
list
<
std
::
unique_ptr
<
UIntMetaKey
>>
generated_keys
;
};
...
...
setup.sh
0 → 100755
View file @
1a5304df
cur
=
$(
pwd
)
export
LD_LIBRARY_PATH
=
${
cur
}
/obj
util/Makefrag
View file @
1a5304df
...
...
@@ -9,11 +9,11 @@ $(OBJDIR)/libedbutil.so: $(patsubst %.cc,$(OBJDIR)/util/%.o,$(UTILSRC))
$(OBJDIR)/libedbutil.a: $(patsubst %.cc,$(OBJDIR)/util/%.o,$(UTILSRC))
$(AR) r $@ $^
install: install_util
#
install: install_util
.PHONY: install_util
install_util: $(OBJDIR)/libedbutil.so
install -m 644 $(OBJDIR)/libedbutil.so /usr/lib
#
.PHONY: install_util
#
install_util: $(OBJDIR)/libedbutil.so
#
install -m 644 $(OBJDIR)/libedbutil.so /usr/lib
$(OBJDIR)/util/version.cc: always
@mkdir -p $(@D)
...
...
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