Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dmitry Baryshkov
nettle
Commits
f2bbbc28
Commit
f2bbbc28
authored
Nov 25, 2018
by
Simo Sorce
Committed by
Niels Möller
Nov 25, 2018
Browse files
Switch rsa_compute_root to use side-channel safe variant
parent
7bc8378b
Changes
2
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
f2bbbc28
...
...
@@ -17,7 +17,10 @@
* testsuite/pkcs1-sec-decrypt-test.c (pkcs1_decrypt_for_test): Fix
valgrind marking of return value.
2018-11-08 Simo Sorce <simo@redhat.com>
2018-11-08 Simo Sorce <simo@redhat.com>
* rsa-sign.c (rsa_compute_root) [!NETTLE_USE_MINI_GMP]: Use
_rsa_sec_compute_root.
* testsuite/rsa-sec-compute-root-test.c: Add more tests for new
side-channel silent functions.
...
...
rsa-sign.c
View file @
f2bbbc28
...
...
@@ -35,9 +35,11 @@
# include "config.h"
#endif
#include
"rsa
.h
"
#include
<assert
.h
>
#include
"bignum.h"
#include
"rsa.h"
#include
"rsa-internal.h"
#include
"gmp-glue.h"
void
rsa_private_key_init
(
struct
rsa_private_key
*
key
)
...
...
@@ -90,6 +92,8 @@ rsa_private_key_prepare(struct rsa_private_key *key)
return
(
key
->
size
>
0
);
}
#if NETTLE_USE_MINI_GMP
/* Computing an rsa root. */
void
rsa_compute_root
(
const
struct
rsa_private_key
*
key
,
...
...
@@ -148,3 +152,35 @@ rsa_compute_root(const struct rsa_private_key *key,
mpz_clear
(
xp
);
mpz_clear
(
xq
);
}
#else
/* !NETTLE_USE_MINI_GMP */
/* Computing an rsa root. */
void
rsa_compute_root
(
const
struct
rsa_private_key
*
key
,
mpz_t
x
,
const
mpz_t
m
)
{
TMP_GMP_DECL
(
scratch
,
mp_limb_t
);
TMP_GMP_DECL
(
ml
,
mp_limb_t
);
mp_limb_t
*
xl
;
size_t
key_size
;
key_size
=
NETTLE_OCTET_SIZE_TO_LIMB_SIZE
(
key
->
size
);
assert
(
mpz_size
(
m
)
<=
key_size
);
/* we need a copy because m can be shorter than key_size,
* but _rsa_sec_compute_root expect all inputs to be
* normalized to a key_size long buffer length */
TMP_GMP_ALLOC
(
ml
,
key_size
);
mpz_limbs_copy
(
ml
,
m
,
key_size
);
TMP_GMP_ALLOC
(
scratch
,
_rsa_sec_compute_root_itch
(
key
));
xl
=
mpz_limbs_write
(
x
,
key_size
);
_rsa_sec_compute_root
(
key
,
xl
,
ml
,
scratch
);
mpz_limbs_finish
(
x
,
key_size
);
TMP_GMP_FREE
(
ml
);
TMP_GMP_FREE
(
scratch
);
}
#endif
/* !NETTLE_USE_MINI_GMP */
Write
Preview
Supports
Markdown
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