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
2b651e0f
Commit
2b651e0f
authored
Jan 03, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify ASHE
parent
bcef3229
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
9 deletions
+9
-9
.ASHE.hh.swp
crypto/.ASHE.hh.swp
+0
-0
ASHE.cc
crypto/ASHE.cc
+4
-4
ASHE.hh
crypto/ASHE.hh
+3
-3
test_ASHE.cc
debug/test_ASHE.cc
+2
-2
No files found.
crypto/.ASHE.hh.swp
deleted
100644 → 0
View file @
bcef3229
File deleted
crypto/ASHE.cc
View file @
2b651e0f
#include"crypto/ASHE.hh"
const
unsigned
long
long
ASHE
::
ASHE_MAX
=
0xffffffffffffffff
;
const
unsigned
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
;
std
::
pair
<
long
,
uint64_t
>
ASHE
::
encrypt
(
unsigned
long
plaintext
){
return
std
::
make_pair
((
plaintext
-
bf
.
encrypt
(
IV
)
+
bf
.
encrypt
(
IV
-
1
))
%
ASHE_MAX
,
IV
);
}
unsigned
long
long
ASHE
::
decrypt
(
long
ciphertext
){
unsigned
long
ASHE
::
decrypt
(
long
ciphertext
){
return
(
ciphertext
+
bf
.
encrypt
(
IV
)
-
bf
.
encrypt
(
IV
-
1
))
%
ASHE_MAX
;
}
crypto/ASHE.hh
View file @
2b651e0f
...
...
@@ -3,13 +3,13 @@
#include <string>
#include "crypto/blowfish.hh"
class
ASHE
{
static
const
unsigned
long
long
ASHE_MAX
;
static
const
unsigned
long
ASHE_MAX
;
std
::
string
key
;
blowfish
bf
;
uint64_t
IV
;
public
:
ASHE
(
std
::
string
s
,
int
i
);
long
encrypt
(
unsigned
long
long
plaintext
);
std
::
pair
<
long
,
uint64_t
>
encrypt
(
unsigned
long
plaintext
);
int
getIV
();
unsigned
long
long
decrypt
(
long
ciphertext
);
unsigned
long
decrypt
(
long
ciphertext
);
};
debug/test_ASHE.cc
View file @
2b651e0f
...
...
@@ -5,7 +5,7 @@
int
main
(){
std
::
vector
<
unsigned
long
long
>
plain
{
1u
,
2u
,
3u
,
4u
,
5u
,
6u
,
7u
,
8u
,
9u
,
10u
};
std
::
vector
<
long
>
enc
;
std
::
vector
<
std
::
pair
<
long
,
uint64_t
>
>
enc
;
std
::
vector
<
ASHE
*>
ass
;
for
(
auto
item
:
plain
){
uint64_t
IV
=
randomValue
();
...
...
@@ -15,7 +15,7 @@ int main(){
}
std
::
cout
<<
"encs:plains"
<<
std
::
endl
;
for
(
auto
i
=
0u
;
i
<
enc
.
size
();
++
i
){
std
::
cout
<<
"enc:"
<<
enc
[
i
]
<<
"dec:"
<<
ass
[
i
]
->
decrypt
(
enc
[
i
]
)
<<
std
::
endl
;
std
::
cout
<<
"enc:"
<<
enc
[
i
]
.
first
<<
"dec:"
<<
ass
[
i
]
->
decrypt
(
enc
[
i
].
first
)
<<
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