Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nettle
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
5
Merge Requests
5
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Nettle
nettle
Commits
6ce79cc7
Commit
6ce79cc7
authored
Jan 08, 2018
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Benchmark in-place operation separately, for cbc_decrypt and ctr_crypt.
parent
140156d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
10 deletions
+31
-10
ChangeLog
ChangeLog
+3
-0
examples/nettle-benchmark.c
examples/nettle-benchmark.c
+28
-10
No files found.
ChangeLog
View file @
6ce79cc7
2018-01-08 Niels Möller <nisse@lysator.liu.se>
2018-01-08 Niels Möller <nisse@lysator.liu.se>
* examples/nettle-benchmark.c (time_cipher): Benchmark in-place
operation separately, for cbc_decrypt and ctr_crypt.
* cbc.c (cbc_decrypt): For in-place operation (src == dst case),
* cbc.c (cbc_decrypt): For in-place operation (src == dst case),
eliminate use of src variable.
eliminate use of src variable.
* cfb.c (cfb_decrypt): Likewise.
* cfb.c (cfb_decrypt): Likewise.
...
...
examples/nettle-benchmark.c
View file @
6ce79cc7
...
@@ -209,8 +209,9 @@ struct bench_cbc_info
...
@@ -209,8 +209,9 @@ struct bench_cbc_info
void
*
ctx
;
void
*
ctx
;
nettle_cipher_func
*
crypt
;
nettle_cipher_func
*
crypt
;
uint8_t
*
data
;
const
uint8_t
*
src
;
uint8_t
*
dst
;
unsigned
block_size
;
unsigned
block_size
;
uint8_t
*
iv
;
uint8_t
*
iv
;
};
};
...
@@ -221,7 +222,7 @@ bench_cbc_encrypt(void *arg)
...
@@ -221,7 +222,7 @@ bench_cbc_encrypt(void *arg)
struct
bench_cbc_info
*
info
=
arg
;
struct
bench_cbc_info
*
info
=
arg
;
cbc_encrypt
(
info
->
ctx
,
info
->
crypt
,
cbc_encrypt
(
info
->
ctx
,
info
->
crypt
,
info
->
block_size
,
info
->
iv
,
info
->
block_size
,
info
->
iv
,
BENCH_BLOCK
,
info
->
d
ata
,
info
->
data
);
BENCH_BLOCK
,
info
->
d
st
,
info
->
src
);
}
}
static
void
static
void
...
@@ -230,7 +231,7 @@ bench_cbc_decrypt(void *arg)
...
@@ -230,7 +231,7 @@ bench_cbc_decrypt(void *arg)
struct
bench_cbc_info
*
info
=
arg
;
struct
bench_cbc_info
*
info
=
arg
;
cbc_decrypt
(
info
->
ctx
,
info
->
crypt
,
cbc_decrypt
(
info
->
ctx
,
info
->
crypt
,
info
->
block_size
,
info
->
iv
,
info
->
block_size
,
info
->
iv
,
BENCH_BLOCK
,
info
->
d
ata
,
info
->
data
);
BENCH_BLOCK
,
info
->
d
st
,
info
->
src
);
}
}
static
void
static
void
...
@@ -239,7 +240,7 @@ bench_ctr(void *arg)
...
@@ -239,7 +240,7 @@ bench_ctr(void *arg)
struct
bench_cbc_info
*
info
=
arg
;
struct
bench_cbc_info
*
info
=
arg
;
ctr_crypt
(
info
->
ctx
,
info
->
crypt
,
ctr_crypt
(
info
->
ctx
,
info
->
crypt
,
info
->
block_size
,
info
->
iv
,
info
->
block_size
,
info
->
iv
,
BENCH_BLOCK
,
info
->
d
ata
,
info
->
data
);
BENCH_BLOCK
,
info
->
d
st
,
info
->
src
);
}
}
struct
bench_aead_info
struct
bench_aead_info
...
@@ -298,7 +299,7 @@ init_nonce(unsigned length,
...
@@ -298,7 +299,7 @@ init_nonce(unsigned length,
static
void
static
void
header
(
void
)
header
(
void
)
{
{
printf
(
"%18s %1
1
s Mbyte/s%s
\n
"
,
printf
(
"%18s %1
2
s Mbyte/s%s
\n
"
,
"Algorithm"
,
"mode"
,
"Algorithm"
,
"mode"
,
frequency
>
0
.
0
?
" cycles/byte cycles/block"
:
""
);
frequency
>
0
.
0
?
" cycles/byte cycles/block"
:
""
);
}
}
...
@@ -307,7 +308,7 @@ static void
...
@@ -307,7 +308,7 @@ static void
display
(
const
char
*
name
,
const
char
*
mode
,
unsigned
block_size
,
display
(
const
char
*
name
,
const
char
*
mode
,
unsigned
block_size
,
double
time
)
double
time
)
{
{
printf
(
"%18s %1
1
s %7.2f"
,
printf
(
"%18s %1
2
s %7.2f"
,
name
,
mode
,
name
,
mode
,
BENCH_BLOCK
/
(
time
*
1048576
.
0
));
BENCH_BLOCK
/
(
time
*
1048576
.
0
));
if
(
frequency
>
0
.
0
)
if
(
frequency
>
0
.
0
)
...
@@ -478,11 +479,13 @@ time_cipher(const struct nettle_cipher *cipher)
...
@@ -478,11 +479,13 @@ time_cipher(const struct nettle_cipher *cipher)
void
*
ctx
=
xalloc
(
cipher
->
context_size
);
void
*
ctx
=
xalloc
(
cipher
->
context_size
);
uint8_t
*
key
=
xalloc
(
cipher
->
key_size
);
uint8_t
*
key
=
xalloc
(
cipher
->
key_size
);
static
uint8_t
src_data
[
BENCH_BLOCK
];
static
uint8_t
data
[
BENCH_BLOCK
];
static
uint8_t
data
[
BENCH_BLOCK
];
printf
(
"
\n
"
);
printf
(
"
\n
"
);
init_data
(
data
);
init_data
(
data
);
init_data
(
src_data
);
{
{
/* Decent initializers are a GNU extension, so don't use it here. */
/* Decent initializers are a GNU extension, so don't use it here. */
...
@@ -520,7 +523,8 @@ time_cipher(const struct nettle_cipher *cipher)
...
@@ -520,7 +523,8 @@ time_cipher(const struct nettle_cipher *cipher)
struct
bench_cbc_info
info
;
struct
bench_cbc_info
info
;
info
.
ctx
=
ctx
;
info
.
ctx
=
ctx
;
info
.
crypt
=
cipher
->
encrypt
;
info
.
crypt
=
cipher
->
encrypt
;
info
.
data
=
data
;
info
.
src
=
src_data
;
info
.
dst
=
data
;
info
.
block_size
=
cipher
->
block_size
;
info
.
block_size
=
cipher
->
block_size
;
info
.
iv
=
iv
;
info
.
iv
=
iv
;
...
@@ -536,7 +540,8 @@ time_cipher(const struct nettle_cipher *cipher)
...
@@ -536,7 +540,8 @@ time_cipher(const struct nettle_cipher *cipher)
struct
bench_cbc_info
info
;
struct
bench_cbc_info
info
;
info
.
ctx
=
ctx
;
info
.
ctx
=
ctx
;
info
.
crypt
=
cipher
->
decrypt
;
info
.
crypt
=
cipher
->
decrypt
;
info
.
data
=
data
;
info
.
src
=
src_data
;
info
.
dst
=
data
;
info
.
block_size
=
cipher
->
block_size
;
info
.
block_size
=
cipher
->
block_size
;
info
.
iv
=
iv
;
info
.
iv
=
iv
;
...
@@ -546,6 +551,12 @@ time_cipher(const struct nettle_cipher *cipher)
...
@@ -546,6 +551,12 @@ time_cipher(const struct nettle_cipher *cipher)
display
(
cipher
->
name
,
"CBC decrypt"
,
cipher
->
block_size
,
display
(
cipher
->
name
,
"CBC decrypt"
,
cipher
->
block_size
,
time_function
(
bench_cbc_decrypt
,
&
info
));
time_function
(
bench_cbc_decrypt
,
&
info
));
memset
(
iv
,
0
,
cipher
->
block_size
);
info
.
src
=
data
;
display
(
cipher
->
name
,
" (in-place)"
,
cipher
->
block_size
,
time_function
(
bench_cbc_decrypt
,
&
info
));
}
}
/* Do CTR mode */
/* Do CTR mode */
...
@@ -553,7 +564,8 @@ time_cipher(const struct nettle_cipher *cipher)
...
@@ -553,7 +564,8 @@ time_cipher(const struct nettle_cipher *cipher)
struct
bench_cbc_info
info
;
struct
bench_cbc_info
info
;
info
.
ctx
=
ctx
;
info
.
ctx
=
ctx
;
info
.
crypt
=
cipher
->
encrypt
;
info
.
crypt
=
cipher
->
encrypt
;
info
.
data
=
data
;
info
.
src
=
src_data
;
info
.
dst
=
data
;
info
.
block_size
=
cipher
->
block_size
;
info
.
block_size
=
cipher
->
block_size
;
info
.
iv
=
iv
;
info
.
iv
=
iv
;
...
@@ -563,6 +575,12 @@ time_cipher(const struct nettle_cipher *cipher)
...
@@ -563,6 +575,12 @@ time_cipher(const struct nettle_cipher *cipher)
display
(
cipher
->
name
,
"CTR"
,
cipher
->
block_size
,
display
(
cipher
->
name
,
"CTR"
,
cipher
->
block_size
,
time_function
(
bench_ctr
,
&
info
));
time_function
(
bench_ctr
,
&
info
));
memset
(
iv
,
0
,
cipher
->
block_size
);
info
.
src
=
data
;
display
(
cipher
->
name
,
" (in-place)"
,
cipher
->
block_size
,
time_function
(
bench_ctr
,
&
info
));
}
}
free
(
iv
);
free
(
iv
);
...
...
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