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
1eb23ca5
Commit
1eb23ca5
authored
Dec 26, 2018
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
In openssl benchmarks, use RSA_generate_key_ex.
parent
1cc82bbb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
17 deletions
+22
-17
ChangeLog
ChangeLog
+5
-0
examples/hogweed-benchmark.c
examples/hogweed-benchmark.c
+17
-17
No files found.
ChangeLog
View file @
1eb23ca5
2018-12-26 Niels Möller <nisse@lysator.liu.se>
2018-12-26 Niels Möller <nisse@lysator.liu.se>
* examples/hogweed-benchmark.c (make_openssl_rsa_ctx): New helper
function. Call openssl's RSA_generate_key_ex rather then the
deprecated RSA_generate_key.
(bench_openssl_rsa_init, bench_openssl_rsa_tr_init): Use it.
* eccdata.c (ecc_pippenger_precompute): Check that table size is
* eccdata.c (ecc_pippenger_precompute): Check that table size is
at least 2. Intended to silence warning from the clang static
at least 2. Intended to silence warning from the clang static
analyzer.
analyzer.
...
...
examples/hogweed-benchmark.c
View file @
1eb23ca5
...
@@ -59,6 +59,7 @@
...
@@ -59,6 +59,7 @@
#if WITH_OPENSSL
#if WITH_OPENSSL
#include <openssl/rsa.h>
#include <openssl/rsa.h>
#include <openssl/bn.h>
#include <openssl/ec.h>
#include <openssl/ec.h>
#include <openssl/ecdsa.h>
#include <openssl/ecdsa.h>
#include <openssl/objects.h>
#include <openssl/objects.h>
...
@@ -532,41 +533,40 @@ struct openssl_rsa_ctx
...
@@ -532,41 +533,40 @@ struct openssl_rsa_ctx
uint8_t
*
digest
;
uint8_t
*
digest
;
};
};
static
void
*
static
struct
openssl_rsa_ctx
*
bench
_openssl_rsa_
init
(
unsigned
size
)
make
_openssl_rsa_
ctx
(
unsigned
size
)
{
{
struct
openssl_rsa_ctx
*
ctx
=
xalloc
(
sizeof
(
*
ctx
));
struct
openssl_rsa_ctx
*
ctx
=
xalloc
(
sizeof
(
*
ctx
));
BIGNUM
*
e
=
BN_new
();
ctx
->
key
=
RSA_generate_key
(
size
,
65537
,
NULL
,
NULL
);
BN_set_word
(
e
,
65537
);
ctx
->
key
=
RSA_new
();
RSA_generate_key_ex
(
ctx
->
key
,
size
,
e
,
NULL
);
ctx
->
ref
=
xalloc
(
RSA_size
(
ctx
->
key
));
ctx
->
ref
=
xalloc
(
RSA_size
(
ctx
->
key
));
ctx
->
signature
=
xalloc
(
RSA_size
(
ctx
->
key
));
ctx
->
signature
=
xalloc
(
RSA_size
(
ctx
->
key
));
ctx
->
digest
=
hash_string
(
&
nettle_sha1
,
"foo"
);
ctx
->
digest
=
hash_string
(
&
nettle_sha1
,
"foo"
);
RSA_blinding_off
(
ctx
->
key
);
if
(
!
RSA_sign
(
NID_sha1
,
ctx
->
digest
,
SHA1_DIGEST_SIZE
,
if
(
!
RSA_sign
(
NID_sha1
,
ctx
->
digest
,
SHA1_DIGEST_SIZE
,
ctx
->
ref
,
&
ctx
->
siglen
,
ctx
->
key
))
ctx
->
ref
,
&
ctx
->
siglen
,
ctx
->
key
))
die
(
"OpenSSL RSA_sign failed.
\n
"
);
die
(
"OpenSSL RSA_sign failed.
\n
"
);
BN_free
(
e
);
return
ctx
;
return
ctx
;
}
}
static
void
*
static
void
*
bench_openssl_rsa_
tr_
init
(
unsigned
size
)
bench_openssl_rsa_init
(
unsigned
size
)
{
{
struct
openssl_rsa_ctx
*
ctx
=
xalloc
(
sizeof
(
*
ctx
));
struct
openssl_rsa_ctx
*
ctx
=
make_openssl_rsa_ctx
(
size
);
RSA_blinding_off
(
ctx
->
key
);
ctx
->
key
=
RSA_generate_key
(
size
,
65537
,
NULL
,
NULL
);
ctx
->
ref
=
xalloc
(
RSA_size
(
ctx
->
key
));
ctx
->
signature
=
xalloc
(
RSA_size
(
ctx
->
key
));
ctx
->
digest
=
hash_string
(
&
nettle_sha1
,
"foo"
);
if
(
!
RSA_sign
(
NID_sha1
,
ctx
->
digest
,
SHA1_DIGEST_SIZE
,
ctx
->
ref
,
&
ctx
->
siglen
,
ctx
->
key
))
die
(
"OpenSSL RSA_sign failed.
\n
"
);
return
ctx
;
return
ctx
;
}
}
static
void
*
bench_openssl_rsa_tr_init
(
unsigned
size
)
{
return
make_openssl_rsa_ctx
(
size
);
}
static
void
static
void
bench_openssl_rsa_sign
(
void
*
p
)
bench_openssl_rsa_sign
(
void
*
p
)
{
{
...
...
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