Skip to content
This repository was archived by the owner on Mar 5, 2024. It is now read-only.

Commit 5969b0e

Browse files
authored
Merge pull request #40 from winnietwo/side_channel_patch
Patch for #39 Sidechannel resistence of uECC_sign disabled
2 parents 484f51f + 3db4aa9 commit 5969b0e

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

lib/source/ecc_dh.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@
6060
#include <tinycrypt/utils.h>
6161
#include <string.h>
6262

63-
#if default_RNG_defined
64-
static uECC_RNG_Function g_rng_function = &default_CSPRNG;
65-
#else
66-
static uECC_RNG_Function g_rng_function = 0;
67-
#endif
68-
6963
int uECC_make_key_with_d(uint8_t *public_key, uint8_t *private_key,
7064
unsigned int *d, uECC_Curve curve)
7165
{
@@ -174,7 +168,7 @@ int uECC_shared_secret(const uint8_t *public_key, const uint8_t *private_key,
174168

175169
/* If an RNG function was specified, try to get a random initial Z value to
176170
* improve protection against side-channel attacks. */
177-
if (g_rng_function) {
171+
if (uECC_get_rng()) {
178172
if (!uECC_generate_random_int(p2[carry], curve->p, num_words)) {
179173
r = 0;
180174
goto clear_and_out;

lib/source/ecc_dsa.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@
5757
#include <tinycrypt/ecc.h>
5858
#include <tinycrypt/ecc_dsa.h>
5959

60-
#if default_RNG_defined
61-
static uECC_RNG_Function g_rng_function = &default_CSPRNG;
62-
#else
63-
static uECC_RNG_Function g_rng_function = 0;
64-
#endif
6560

6661
static void bits2int(uECC_word_t *native, const uint8_t *bits,
6762
unsigned bits_size, uECC_Curve curve)
@@ -124,7 +119,7 @@ int uECC_sign_with_k(const uint8_t *private_key, const uint8_t *message_hash,
124119

125120
/* If an RNG function was specified, get a random number
126121
to prevent side channel analysis of k. */
127-
if (!g_rng_function) {
122+
if (!uECC_get_rng()) {
128123
uECC_vli_clear(tmp, num_n_words);
129124
tmp[0] = 1;
130125
}

0 commit comments

Comments
 (0)