-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add TRNG API test #7057
Add TRNG API test #7057
Conversation
TESTS/mbed_hal/trng/main.cpp
Outdated
else | ||
{ | ||
printf("compression for concatenated buffer after reset was unsuccessful"); | ||
TEST_ASSERT(false); |
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 can be ASSERT with msg (then printf not needed). I think this entire if can be turned into one assert.
Similar to: TEST_ASSERT_TRUE_MSG(compr_res < buffer_len , "failed......msg....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.
Because the test contains several parts I wanted the user to have a clear view of the progress, the assert message is only shown when the test fails.
TESTS/mbed_hal/trng/main.cpp
Outdated
(unsigned char **)htab); | ||
|
||
if (comp_res >= BUFFER_LEN) | ||
{ |
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.
Can you fix formatting (follow mbed OS code style) , this one ({
) should be attached
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.
Sorry for that, all formatting will be fixed
@@ -0,0 +1,16 @@ | |||
#include <stdint.h> |
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.
license header missing in some files (please review), not only this one
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.
Sorry for that, all license header will be added.
From the changes, looks like mbed tls and strorage teams should review this PR? |
This appears to have a GPL on it. @0xc0170 |
@ARMmbed/mbed-os-storage |
GPL is still present in this PR. We cannot integrate GPL code with Mbed OS. |
Compression lib was changed to pithy (with BSD license) |
@ARMmbed/mbed-os-crypto Mind reviewing? |
@cmonr We'll review it shortly! Could you please add the "TLS" label to the PR? |
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.
Looks good to me!
@mohammad1603 will be giving a review too and we need his approval before merging.
Thansk for the heads up @yanesca |
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.
looks good to me, some minor issues
TESTS/host_tests/trng_reset.py
Outdated
""" | ||
This script is the host script for trng test sequence, it send the | ||
step signaling sequence and receive and transmit data to the device after | ||
reset if necesarry (default lading and storing while reseting the device |
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.
typo: lading -> loading
TESTS/host_tests/trng_reset.py
Outdated
This script is the host script for trng test sequence, it send the | ||
step signaling sequence and receive and transmit data to the device after | ||
reset if necesarry (default lading and storing while reseting the device | ||
is NVstore, in case NVstore isn't enabled we'll use current infrastructure, |
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.
what do you mean "device is NVstore" ?
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.
"default lading and storing while reseting the device is NVstore", the device is the device used for testing, the NVstore is one way of storing and loading data
TESTS/host_tests/trng_reset.py
Outdated
|
||
wait_for_communication = yield | ||
|
||
if self.reset == False: |
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.
do you expect the device to reset after step1 (dummy message) ?
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.
Yes, If not an error will occur.
return BASE64_INVALID_PARAMETER; | ||
} | ||
|
||
if ((base64 >= 'A') && (base64 <= 'Z')) |
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.
Style (minor): mixed style of using {
.
if (a){
xx;
}
AND
if (a)
{ xx; }
} | ||
|
||
*writePtr = 0; | ||
while (( string[currPos] != 0 ) && |
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.
i think you should switch between the first two conditions - the current code can cause an out of bounds access.
in case the string
doesn't end with 0
you can see this behavior.
should be:
while (( currPos < stringMaxSize ) &&
( string[currPos] != 0 ) &&
( writePtr < bufferEnd ) &&
( !isEndOfString )) {
( !isEndOfString )) { | ||
uint8_t val; | ||
|
||
if (string[currPos] == 0 || currPos >= stringMaxSize) |
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.
in the while you validate this, you can avoid this checks (they will always be true)
// Check if additional bytes should have been processed but buffer isn't sufficient. | ||
if (( result == BASE64_SUCCESS ) && | ||
( !isEndOfString ) && | ||
( string[currPos] != '=' ) && |
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.
if currPos == stringMaxSize
this can be a problem as above
TESTS/mbed_hal/trng/main.cpp
Outdated
/* | ||
* The test is based on the assumption that trng will generate random data, random so | ||
* there will not be any similar patterns in it, that kind of data will be impossible to | ||
* compress, if compression will acuur the test will result in failure. |
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.
typo: acuur -> occur
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.
Before approving this PR, TPIP must be approved by Aaron
@dannybenor TPIP? |
@cmonr - TPIP == Third Party IP. This looks to be BSD, which is compatible. I'll run it past legal for a TPIP review just to be sure. |
@ChiefBureaucraticOfficer Is this good to progress? |
Hi @0xc0170 , |
/morph test |
Test : FAILUREBuild number : 2838 |
Oh, I feel silly. This needed to have been a build, not a re-test. /morph build |
Build : SUCCESSBuild number : 3067 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2679 |
/morph build |
Build : SUCCESSBuild number : 3073 Triggering tests/morph test |
Test : FAILUREBuild number : 2864 |
TRNG test seem to fail on K22F. @theamirocohen please take a look. |
Exporter Build : SUCCESSBuild number : 2686 |
/morph build |
Build : SUCCESSBuild number : 3156 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2760 |
Test : FAILUREBuild number : 2966 |
sigh It looks like failure was an intermittent network issue. /morph test |
Test : SUCCESSBuild number : 2967 |
Use TRNG api to construct different buffers and try to compress them, If the random data is not really random, the test will be able to compress it.
We also check that after device reset when we use TRNG the API will create different data.
We do use lzf lib to compress the random buffer, the library should be checked for copyrights violation by @ChiefBureaucraticOfficer , all files are documented and under the lzflib library.