Skip to content

Commit 15e1a74

Browse files
authored
Merge pull request #177 from jaroban/master
Add RNG for nRF52 series
2 parents 4b1709c + 71563d8 commit 15e1a74

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

platform-specific.inc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@ static int default_RNG(uint8_t *dest, unsigned size) {
7676
}
7777
#define default_RNG_defined 1
7878

79+
#elif defined(NRF52_SERIES)
80+
81+
#include "app_error.h"
82+
#include "nrf_crypto_rng.h"
83+
84+
static int default_RNG(uint8_t *dest, unsigned size)
85+
{
86+
// make sure to call nrf_crypto_init and nrf_crypto_rng_init first
87+
ret_code_t ret_code = nrf_crypto_rng_vector_generate(dest, size);
88+
return (ret_code == NRF_SUCCESS) ? 1 : 0;
89+
}
90+
#define default_RNG_defined 1
91+
7992
#endif /* platform */
8093

8194
#endif /* _UECC_PLATFORM_SPECIFIC_H_ */

uECC.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ uECC_VLI_API void uECC_vli_bytesToNative(uint8_t *native,
994994
uECC_VLI_API void uECC_vli_nativeToBytes(uint8_t *bytes,
995995
int num_bytes,
996996
const uECC_word_t *native) {
997-
wordcount_t i;
997+
int i;
998998
for (i = 0; i < num_bytes; ++i) {
999999
unsigned b = num_bytes - 1 - i;
10001000
bytes[i] = native[b / uECC_WORD_SIZE] >> (8 * (b % uECC_WORD_SIZE));
@@ -1004,7 +1004,7 @@ uECC_VLI_API void uECC_vli_nativeToBytes(uint8_t *bytes,
10041004
uECC_VLI_API void uECC_vli_bytesToNative(uECC_word_t *native,
10051005
const uint8_t *bytes,
10061006
int num_bytes) {
1007-
wordcount_t i;
1007+
int i;
10081008
uECC_vli_clear(native, (num_bytes + (uECC_WORD_SIZE - 1)) / uECC_WORD_SIZE);
10091009
for (i = 0; i < num_bytes; ++i) {
10101010
unsigned b = num_bytes - 1 - i;

0 commit comments

Comments
 (0)