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
a19b0e87
Commit
a19b0e87
authored
Dec 29, 2017
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more strong ASHE
parent
7bded8cb
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
10 deletions
+12
-10
ASHE.cc
crypto/ASHE.cc
+3
-1
ASHE.hh
crypto/ASHE.hh
+1
-1
test_ASHE.cc
debug/test_ASHE.cc
+8
-8
No files found.
crypto/ASHE.cc
View file @
a19b0e87
#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
){}
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
;
...
...
crypto/ASHE.hh
View file @
a19b0e87
...
...
@@ -6,7 +6,7 @@ class ASHE{
static
const
unsigned
long
long
ASHE_MAX
;
std
::
string
key
;
blowfish
bf
;
in
t
IV
;
uint64_
t
IV
;
public
:
ASHE
(
std
::
string
s
,
int
i
);
long
encrypt
(
unsigned
long
long
plaintext
);
...
...
debug/test_ASHE.cc
View file @
a19b0e87
#include <vector>
#include <iostream>
#include "crypto/ASHE.hh"
#include "util/util.cc"
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
)
;
std
::
vector
<
ASHE
*>
ass
;
for
(
auto
item
:
plain
){
enc
.
push_back
(
as
.
encrypt
(
item
));
uint64_t
IV
=
randomValue
();
if
(
IV
==
0
)
IV
=
1
;
ass
.
push_back
(
new
ASHE
(
"111"
,
IV
));
enc
.
push_back
(
ass
.
back
()
->
encrypt
(
item
));
}
std
::
cout
<<
"encs:plains"
<<
std
::
endl
;
for
(
auto
i
tem
:
enc
){
std
::
cout
<<
"enc:"
<<
item
<<
"dec:"
<<
as
.
decrypt
(
item
)
<<
std
::
endl
;
for
(
auto
i
=
0u
;
i
<
enc
.
size
();
++
i
){
std
::
cout
<<
"enc:"
<<
enc
[
i
]
<<
"dec:"
<<
ass
[
i
]
->
decrypt
(
enc
[
i
]
)
<<
std
::
endl
;
}
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