Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Wim Lewis
nettle
Commits
60f3e677
Commit
60f3e677
authored
Mar 30, 2012
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support salsa20 in nettle-benchmark.
parent
4403177a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
6 deletions
+52
-6
ChangeLog
ChangeLog
+8
-0
examples/nettle-benchmark.c
examples/nettle-benchmark.c
+19
-2
nettle-internal.c
nettle-internal.c
+21
-1
nettle-internal.h
nettle-internal.h
+4
-3
No files found.
ChangeLog
View file @
60f3e677
2012-03-30 Niels Möller <nisse@lysator.liu.se>
* nettle-internal.c (nettle_salsa20): Cipher struct for
benchmarking only. Sets a fix zero IV, and ignores block size.
* nettle-internal.h (nettle_salsa20): Declare it.
* examples/nettle-benchmark.c (block_cipher_p): New function.
(time_cipher): Use block_cipher_p.
(main): Include salsa20 in benchmark.
* Makefile.in (soname link): Fixed logic.
(nettle_SOURCES): Removed nettle-internal.c, so that it's not
parrt of the library...
...
...
examples/nettle-benchmark.c
View file @
60f3e677
...
...
@@ -433,6 +433,23 @@ time_gcm(void)
time_function
(
bench_cipher
,
&
cinfo
));
}
static
int
prefix_p
(
const
char
*
prefix
,
const
char
*
s
)
{
size_t
i
;
for
(
i
=
0
;
prefix
[
i
];
i
++
)
if
(
prefix
[
i
]
!=
s
[
i
])
return
0
;
return
1
;
}
static
int
block_cipher_p
(
const
struct
nettle_cipher
*
cipher
)
{
/* Don't use nettle cbc and ctr for openssl ciphers. */
return
cipher
->
block_size
>
0
&&
!
prefix_p
(
"openssl"
,
cipher
->
name
);
}
static
void
time_cipher
(
const
struct
nettle_cipher
*
cipher
)
{
...
...
@@ -472,8 +489,7 @@ time_cipher(const struct nettle_cipher *cipher)
time_function
(
bench_cipher
,
&
info
));
}
/* Don't use nettle cbc to benchmark openssl ciphers */
if
(
cipher
->
block_size
&&
cipher
->
name
[
0
]
!=
'o'
)
if
(
block_cipher_p
(
cipher
))
{
uint8_t
*
iv
=
xalloc
(
cipher
->
block_size
);
...
...
@@ -619,6 +635,7 @@ main(int argc, char **argv)
&
nettle_des3
,
&
nettle_serpent256
,
&
nettle_twofish128
,
&
nettle_twofish192
,
&
nettle_twofish256
,
&
nettle_salsa20
,
NULL
};
...
...
nettle-internal.c
View file @
60f3e677
...
...
@@ -35,9 +35,10 @@
#include "blowfish.h"
#include "des.h"
#include "gcm.h"
#include "salsa20.h"
/* DES uses a different signature for the key set function. We ignore
the return value in
c
icating weak keys. */
the return value in
d
icating weak keys. */
static
void
des_set_key_hack
(
void
*
ctx
,
unsigned
length
,
const
uint8_t
*
key
)
{
...
...
@@ -77,6 +78,25 @@ nettle_des3 = {
const
struct
nettle_cipher
nettle_blowfish128
=
_NETTLE_CIPHER
(
blowfish
,
BLOWFISH
,
128
);
/* Sets a fix zero iv. For benchmarking only. */
static
void
salsa20_set_key_hack
(
void
*
ctx
,
unsigned
length
,
const
uint8_t
*
key
)
{
static
const
uint8_t
iv
[
SALSA20_IV_SIZE
];
salsa20_set_key
(
ctx
,
length
,
key
);
salsa20_set_iv
(
ctx
,
SALSA20_IV_SIZE
,
iv
);
}
/* Claim zero block size, to classify as a stream cipher. */
const
struct
nettle_cipher
nettle_salsa20
=
{
"salsa20"
,
sizeof
(
struct
salsa20_ctx
),
0
,
SALSA20_KEY_SIZE
,
salsa20_set_key_hack
,
salsa20_set_key_hack
,
(
nettle_crypt_func
*
)
salsa20_crypt
,
(
nettle_crypt_func
*
)
salsa20_crypt
};
const
struct
nettle_aead
nettle_gcm_aes128
=
_NETTLE_AEAD
(
gcm
,
GCM
,
aes
,
128
);
const
struct
nettle_aead
...
...
nettle-internal.h
View file @
60f3e677
...
...
@@ -59,9 +59,10 @@ extern const struct nettle_cipher nettle_des3;
extern
const
struct
nettle_cipher
nettle_blowfish128
;
/* Glue to openssl, for comparative benchmarking. The corresponding
* code is not included in the nettle library, as that would make the
* shared library depend on openssl. Instead, look at
/* For benchmarking only, sets no iv and lies about the block size. */
extern
const
struct
nettle_cipher
nettle_salsa20
;
/* Glue to openssl, for comparative benchmarking. Code in
* examples/nettle-openssl.c. */
extern
const
struct
nettle_cipher
nettle_openssl_aes128
;
extern
const
struct
nettle_cipher
nettle_openssl_aes192
;
...
...
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