* combine radio's entropy with CC310 RNG
This commit is contained in:
1 file changed
+3
-1
@@ -92,8 +92,10 @@ public:
|
|||||||
|
|
||||||
void random(uint8_t* dest, size_t sz) override {
|
void random(uint8_t* dest, size_t sz) override {
|
||||||
#ifdef USE_CC310_HW_CRYPTO
|
#ifdef USE_CC310_HW_CRYPTO
|
||||||
// CC310 TRNG is higher quality and environment-independent vs radio RSSI noise.
|
|
||||||
nRFCrypto.Random.generate(dest, (uint16_t)sz);
|
nRFCrypto.Random.generate(dest, (uint16_t)sz);
|
||||||
|
for (int i = 0; i < sz; i++) {
|
||||||
|
dest[i] ^= _radio->randomByte() ^ (::random(0, 256) & 0xFF); // combine with Radio's entropy
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
for (int i = 0; i < sz; i++) {
|
for (int i = 0; i < sz; i++) {
|
||||||
dest[i] = _radio->randomByte() ^ (::random(0, 256) & 0xFF);
|
dest[i] = _radio->randomByte() ^ (::random(0, 256) & 0xFF);
|
||||||
|
|||||||
Reference in New Issue
Block a user