-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to overwrite RNG implementation
Previously, the RNG implementation was provided by us, with no way to overwrite it. Similar to the cryptographic algorithms, users can now overwrite the RNG implementation by setting USE_SOFTWARE_RNG to false and setting the fido_get_random function in random.h accordingly. This is especially useful when using a board that provides a hardware RNG.
- Loading branch information
Showing
6 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ | |
#include "largeblob.h" | ||
#include "nfc.h" | ||
#include "param.h" | ||
#include "random.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2022 Felix Gohla, Konrad Hanff, Tobias Kantusch, | ||
* Quentin Kuth, Felix Roth. All rights reserved. | ||
* | ||
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
/** | ||
* @brief Random number generation | ||
* | ||
* @param buf Pointer to the buffer to write the random bytes to. | ||
* @param random_len Amount of random bytes to generate. | ||
* @return int FIDO_OK when the random data was written successfully | ||
*/ | ||
typedef int (*fido_get_random_t)( | ||
const uint8_t *buf, | ||
size_t random_len | ||
); | ||
|
||
/** | ||
* This is a pointer to a function for random number generation. | ||
* It can be set to other functions, for example when the platform provides | ||
* hardware support for RNGs. | ||
* | ||
* fido_get_random = &my_hardware_rng; | ||
* | ||
* You can define the macro NO_SOFTWARE_RNG to prevent the software implementation | ||
* of this algorithm to be included in the library. | ||
*/ | ||
extern fido_get_random_t fido_get_random; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters