mirror of
https://github.com/kmackay/micro-ecc.git
synced 2026-06-05 21:14:51 +00:00
Added RNG for nRF52 series. Fixed infinite for loop because of int - wordcount_t mismatch
This commit is contained in:
@@ -76,6 +76,19 @@ static int default_RNG(uint8_t *dest, unsigned size) {
|
|||||||
}
|
}
|
||||||
#define default_RNG_defined 1
|
#define default_RNG_defined 1
|
||||||
|
|
||||||
|
#elif defined(NRF52_SERIES)
|
||||||
|
|
||||||
|
#include "app_error.h"
|
||||||
|
#include "nrf_crypto_rng.h"
|
||||||
|
|
||||||
|
static int default_RNG(uint8_t *dest, unsigned size)
|
||||||
|
{
|
||||||
|
// make sure to call nrf_crypto_init and nrf_crypto_rng_init first
|
||||||
|
ret_code_t ret_code = nrf_crypto_rng_vector_generate(dest, size);
|
||||||
|
return (ret_code == NRF_SUCCESS) ? 1 : 0;
|
||||||
|
}
|
||||||
|
#define default_RNG_defined 1
|
||||||
|
|
||||||
#endif /* platform */
|
#endif /* platform */
|
||||||
|
|
||||||
#endif /* _UECC_PLATFORM_SPECIFIC_H_ */
|
#endif /* _UECC_PLATFORM_SPECIFIC_H_ */
|
||||||
|
|||||||
@@ -994,7 +994,7 @@ uECC_VLI_API void uECC_vli_bytesToNative(uint8_t *native,
|
|||||||
uECC_VLI_API void uECC_vli_nativeToBytes(uint8_t *bytes,
|
uECC_VLI_API void uECC_vli_nativeToBytes(uint8_t *bytes,
|
||||||
int num_bytes,
|
int num_bytes,
|
||||||
const uECC_word_t *native) {
|
const uECC_word_t *native) {
|
||||||
wordcount_t i;
|
int i;
|
||||||
for (i = 0; i < num_bytes; ++i) {
|
for (i = 0; i < num_bytes; ++i) {
|
||||||
unsigned b = num_bytes - 1 - i;
|
unsigned b = num_bytes - 1 - i;
|
||||||
bytes[i] = native[b / uECC_WORD_SIZE] >> (8 * (b % uECC_WORD_SIZE));
|
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,
|
|||||||
uECC_VLI_API void uECC_vli_bytesToNative(uECC_word_t *native,
|
uECC_VLI_API void uECC_vli_bytesToNative(uECC_word_t *native,
|
||||||
const uint8_t *bytes,
|
const uint8_t *bytes,
|
||||||
int num_bytes) {
|
int num_bytes) {
|
||||||
wordcount_t i;
|
int i;
|
||||||
uECC_vli_clear(native, (num_bytes + (uECC_WORD_SIZE - 1)) / uECC_WORD_SIZE);
|
uECC_vli_clear(native, (num_bytes + (uECC_WORD_SIZE - 1)) / uECC_WORD_SIZE);
|
||||||
for (i = 0; i < num_bytes; ++i) {
|
for (i = 0; i < num_bytes; ++i) {
|
||||||
unsigned b = num_bytes - 1 - i;
|
unsigned b = num_bytes - 1 - i;
|
||||||
|
|||||||
Reference in New Issue
Block a user