-
Notifications
You must be signed in to change notification settings - Fork 3k
Add TRNG support for KW41Z #4050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
*output_length = length; | ||
return 0; | ||
} else { | ||
return MBEDTLS_ERR_ENTROPY_SOURCE_FAILED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return -1 as documented. This mapping (HAL return codes to mbedtls) should be done in the mbedtls-HAL wrapper that is in the platform folder (it's missing as pinpointed by @stevew817 ).
Signed-off-by: Mahadevan Mahesh <[email protected]>
bda39cd
to
dfafaa8
Compare
any tests run - to be shared here? |
Ran "authcrypt" from mbed TLS Examples. Below is the log: plaintext message: 536f6d65207468696e67732061726520626574746572206c65667420756e7265616400 DONE |
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
@@ -0,0 +1,60 @@ | |||
/* | |||
* Hardware entropy collector for the K64F, using Freescale's RNGA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The target name seems to be incorrect on this line
*/ | ||
|
||
/* | ||
* Reference: "K64 Sub-Family Reference Manual, Rev. 2", chapter 34 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reference is misleading here, it would be very helpful to have the right document here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I have fixed this.
{ | ||
trng_config_t trngConfig; | ||
|
||
TRNG_GetDefaultConfig(&trngConfig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the manual this function can return with an error. Because of the API we can't propagate this error, but we still need to make it sure that if an error has happened here then any subsequent calls to trng_get_bytes()
will fail with an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error returned is in case the user passes an invalid argument (invalid uage of this API). This will not happen in mbed HAL.
/* Set sample mode of the TRNG ring oscillator to Von Neumann, for better random data.*/ | ||
trngConfig.sampleMode = kTRNG_SampleModeVonNeumann; | ||
/* Initialize TRNG */ | ||
TRNG_Init(TRNG0, &trngConfig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the manual this function can return with an error. Because of the API we can't propagate this error, but we still need to make it sure that if an error has happened here then any subsequent calls to trng_get_bytes()
will fail with an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error returned is in case the user passes an invalid argument (invalid uage of this API). This will not happen in mbed HAL.
Add support to use the TRNG module for entropy generation.
Status
**READY
Passed mbed compliance tests.