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
7bded8cb
Commit
7bded8cb
authored
Dec 29, 2017
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add simple version of ashe
parent
54c275b5
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
31 deletions
+64
-31
ASHE.cc
crypto/ASHE.cc
+13
-0
ASHE.hh
crypto/ASHE.hh
+15
-0
Makefrag
crypto/Makefrag
+8
-6
blowfish.hh
crypto/blowfish.hh
+1
-0
test_ASHE.cc
debug/test_ASHE.cc
+22
-0
test_aescbc.cc
debug/test_aescbc.cc
+4
-24
tags.sh
tags.sh
+1
-1
No files found.
crypto/ASHE.cc
0 → 100644
View file @
7bded8cb
#include"crypto/ASHE.hh"
const
unsigned
long
long
ASHE
::
ASHE_MAX
=
0xffffffffffffffff
;
ASHE
::
ASHE
(
std
::
string
s
,
int
i
)
:
key
(
s
),
bf
(
s
),
IV
(
i
){}
long
ASHE
::
encrypt
(
unsigned
long
long
plaintext
){
return
(
plaintext
-
bf
.
encrypt
(
IV
)
+
bf
.
encrypt
(
IV
-
1
))
%
ASHE_MAX
;
}
unsigned
long
long
ASHE
::
decrypt
(
long
ciphertext
){
return
(
ciphertext
+
bf
.
encrypt
(
IV
)
-
bf
.
encrypt
(
IV
-
1
))
%
ASHE_MAX
;
}
crypto/ASHE.hh
0 → 100644
View file @
7bded8cb
#pragma once
#include <string>
#include "crypto/blowfish.hh"
class
ASHE
{
static
const
unsigned
long
long
ASHE_MAX
;
std
::
string
key
;
blowfish
bf
;
int
IV
;
public
:
ASHE
(
std
::
string
s
,
int
i
);
long
encrypt
(
unsigned
long
long
plaintext
);
int
getIV
();
unsigned
long
long
decrypt
(
long
ciphertext
);
};
crypto/Makefrag
View file @
7bded8cb
OBJDIRS += crypto
OBJDIRS += crypto
CRYPTOSRC := BasicCrypto.cc paillier.cc urandom.cc arc4.cc hgd.cc pbkdf2.cc \
CRYPTOSRC := BasicCrypto.cc paillier.cc urandom.cc arc4.cc hgd.cc pbkdf2.cc \
ecjoin.cc ECJoin.cc search.cc skip32.cc ffx.cc online_ope.cc mont.cc \
ecjoin.cc ECJoin.cc search.cc skip32.cc ffx.cc online_ope.cc mont.cc \
prng.cc ope.cc SWPSearch.cc
prng.cc ope.cc SWPSearch.cc ASHE.cc
CRYPTOOBJ := $(patsubst %.cc,$(OBJDIR)/crypto/%.o,$(CRYPTOSRC))
CRYPTOOBJ := $(patsubst %.cc,$(OBJDIR)/crypto/%.o,$(CRYPTOSRC))
all: $(OBJDIR)/libedbcrypto.a $(OBJDIR)/libedbcrypto.so
all: $(OBJDIR)/libedbcrypto.a $(OBJDIR)/libedbcrypto.so
...
@@ -14,13 +16,13 @@ $(OBJDIR)/libedbcrypto.a: $(CRYPTOOBJ)
...
@@ -14,13 +16,13 @@ $(OBJDIR)/libedbcrypto.a: $(CRYPTOOBJ)
$(AR) r $@ $(CRYPTOOBJ)
$(AR) r $@ $(CRYPTOOBJ)
#all: $(OBJDIR)/crypto/x
#all: $(OBJDIR)/crypto/x
$(OBJDIR)/crypto/x: $(OBJDIR)/crypto/x.o $(OBJDIR)/libedbcrypto.so
$(OBJDIR)/crypto/x: $(OBJDIR)/crypto/x.o $(OBJDIR)/libedbcrypto.so
$(CXX) $< -o $@ $(LDFLAGS) $(LDRPATH) -ledbcrypto
$(CXX) $< -o $@ $(LDFLAGS) $(LDRPATH) -ledbcrypto
#install: install_crypto
#.PHONY: install_crypto
install: install_crypto
#install_crypto: $(OBJDIR)/libedbcrypto.so
# install -m 644 $(OBJDIR)/libedbcrypto.so /usr/lib
# vim: set noexpandtab:
.PHONY: install_crypto
install_crypto: $(OBJDIR)/libedbcrypto.so
install -m 644 $(OBJDIR)/libedbcrypto.so /usr/lib
crypto/blowfish.hh
View file @
7bded8cb
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include <vector>
#include <vector>
#include <stdint.h>
#include <stdint.h>
#include <string>
/*why is this omitted?*/
#include <openssl/blowfish.h>
#include <openssl/blowfish.h>
class
blowfish
{
class
blowfish
{
...
...
debug/test_ASHE.cc
0 → 100644
View file @
7bded8cb
#include <vector>
#include <iostream>
#include "crypto/ASHE.hh"
int
main
(){
std
::
vector
<
unsigned
long
long
>
plain
{
1u
,
2u
,
3u
,
4u
,
5u
,
6u
,
7u
,
8u
,
9u
,
10u
};
std
::
vector
<
long
>
enc
;
ASHE
as
(
"2222"
,
1
);
for
(
auto
item
:
plain
){
enc
.
push_back
(
as
.
encrypt
(
item
));
}
std
::
cout
<<
"encs:plains"
<<
std
::
endl
;
for
(
auto
item
:
enc
){
std
::
cout
<<
"enc:"
<<
item
<<
"dec:"
<<
as
.
decrypt
(
item
)
<<
std
::
endl
;
}
return
0
;
}
debug/test_aescbc.cc
View file @
7bded8cb
#include <string>
#include <string>
#include <map>
#include <map>
#include <iostream>
#include <iostream>
#include <functional>
#include <memory>
#include <cctype>
#include <locale>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <main/CryptoHandlers.hh>
#include <crypto/padding.hh>
#include <util/errstream.hh>
#include <util/cryptdb_log.hh>
#include <util/enum_text.hh>
#include <util/yield.hpp>
#include "util/onions.hh"
#include <vector>
#include <iomanip>
#include <iomanip>
#include <crypto/padding.hh>
#include <crypto/prng.hh>
#include <crypto/prng.hh>
#include <crypto/BasicCrypto.hh>
#include <crypto/BasicCrypto.hh>
#include <crypto/blowfish.hh>
#include <crypto/blowfish.hh>
#include <crypto/SWPSearch.hh>
#include <crypto/BasicCrypto.hh>
#include <crypto/arc4.hh>
#include <crypto/arc4.hh>
#include <crypto/cbc.hh>
#include <crypto/cbc.hh>
#include <crypto/cmc.hh>
#include <util/util.hh>
#include <util/util.hh>
#include <util/zz.hh>
#include <cmath>
#include <NTL/ZZ.h>
#include <NTL/ZZ.h>
using
namespace
NTL
;
using
namespace
NTL
;
using
std
::
string
;
using
std
::
string
;
...
@@ -74,9 +58,6 @@ static string generateStringOfLen(int len){
...
@@ -74,9 +58,6 @@ static string generateStringOfLen(int len){
return
string
(
len
,
'a'
);
return
string
(
len
,
'a'
);
}
}
static
void
test_RNDstr
(
string
ptext
,
int
numOfTest
){
static
void
test_RNDstr
(
string
ptext
,
int
numOfTest
){
string
key
=
"123456789"
;
string
key
=
"123456789"
;
string
rawkey
=
prng_expand
(
key
,
16
);
string
rawkey
=
prng_expand
(
key
,
16
);
...
@@ -84,7 +65,6 @@ static void test_RNDstr(string ptext,int numOfTest){
...
@@ -84,7 +65,6 @@ static void test_RNDstr(string ptext,int numOfTest){
const
std
::
unique_ptr
<
const
AES_KEY
>
deckey
(
get_AES_dec_key
(
rawkey
));
const
std
::
unique_ptr
<
const
AES_KEY
>
deckey
(
get_AES_dec_key
(
rawkey
));
uint64_t
IV
=
1234567
;
uint64_t
IV
=
1234567
;
uint64_t
start
=
cur_usec
();
uint64_t
start
=
cur_usec
();
// cout<<"ptext len = "<<ptext.size()<<" : "<<"key len = "<<rawkey.size()<<endl;
string
enc
,
dec
;
string
enc
,
dec
;
for
(
int
i
=
1
;
i
<=
numOfTest
;
i
++
){
for
(
int
i
=
1
;
i
<=
numOfTest
;
i
++
){
enc
=
encrypt_AES_CBC
(
ptext
,
enckey
.
get
(),
BytesFromInt
(
IV
,
SALT_LEN_BYTES
),
true
);
enc
=
encrypt_AES_CBC
(
ptext
,
enckey
.
get
(),
BytesFromInt
(
IV
,
SALT_LEN_BYTES
),
true
);
...
...
tags.sh
View file @
7bded8cb
find
.
|
grep
'\.c$\|\.cc$
$
\|\.h$\|\.hh$'
| xargs ctags
find
.
|
grep
'\.c$\|\.cc$\|\.h$\|\.hh$'
| xargs ctags
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