Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Wim Lewis
nettle
Commits
a520be22
Commit
a520be22
authored
Jun 29, 2011
by
Niels Möller
Browse files
(bench_ctr): New function.
(time_cipher): Also benchmark CTR mode. Rev: nettle/examples/nettle-benchmark.c:1.21
parent
9946d3df
Changes
1
Hide whitespace changes
Inline
Side-by-side
examples/nettle-benchmark.c
View file @
a520be22
...
...
@@ -43,6 +43,7 @@
#include
"blowfish.h"
#include
"cast128.h"
#include
"cbc.h"
#include
"ctr.h"
#include
"des.h"
#include
"gcm.h"
#include
"memxor.h"
...
...
@@ -269,6 +270,15 @@ bench_cbc_decrypt(void *arg)
BENCH_BLOCK
,
info
->
data
,
info
->
data
);
}
static
void
bench_ctr
(
void
*
arg
)
{
struct
bench_cbc_info
*
info
=
arg
;
ctr_crypt
(
info
->
ctx
,
info
->
crypt
,
info
->
block_size
,
info
->
iv
,
BENCH_BLOCK
,
info
->
data
,
info
->
data
);
}
/* Set data[i] = floor(sqrt(i)) */
static
void
init_data
(
uint8_t
*
data
)
...
...
@@ -499,6 +509,24 @@ time_cipher(const struct nettle_cipher *cipher)
display
(
cipher
->
name
,
"CBC decrypt"
,
cipher
->
block_size
,
time_function
(
bench_cbc_decrypt
,
&
info
));
}
/* Do CTR mode */
{
struct
bench_cbc_info
info
;
info
.
ctx
=
ctx
;
info
.
crypt
=
cipher
->
encrypt
;
info
.
data
=
data
;
info
.
block_size
=
cipher
->
block_size
;
info
.
iv
=
iv
;
memset
(
iv
,
0
,
sizeof
(
iv
));
cipher
->
set_encrypt_key
(
ctx
,
cipher
->
key_size
,
key
);
display
(
cipher
->
name
,
"CTR"
,
cipher
->
block_size
,
time_function
(
bench_ctr
,
&
info
));
}
free
(
iv
);
}
free
(
ctx
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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