-
Notifications
You must be signed in to change notification settings - Fork 809
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
Hmac tests #25825
Hmac tests #25825
Conversation
2c4ccd0
to
1b14ede
Compare
There was an error handling pipeline event 46043aee-f25d-4a9d-a7e1-0d28141af50f. |
c108c17
to
4cb7bc3
Compare
@moidx for visibility |
Signed-off-by: Ramesh Prakash <[email protected]>
Signed-off-by: Ramesh Prakash <[email protected]>
4cb7bc3
to
f6b510e
Compare
This reverts commit 607e841. Signed-off-by: Ramesh Prakash <[email protected]>
f6b510e
to
d066def
Compare
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.
Thanks for your work @rprakas-gsc! I've dropped a couple of suggestions.
bazel: ["//sw/device/tests:aes_force_prng_reseed_test"] | ||
} | ||
{ |
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.
Would it be possible to split this work into two PRs? As far as I understand, the changes in the chip_aes_testplan.hjson
in this commit and also in the other commit don't really belong here?
"//hw/top_earlgrey:sim_verilator": None, | ||
"//hw/top_earlgrey:fpga_cw340_sival": None, | ||
"//hw/top_earlgrey:silicon_creator": None, | ||
"//hw/top_earlgrey:sim_verilator": None, |
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 would suggest moving these changes into the same commit as the first commit in this PR?
@@ -58,7 +58,6 @@ static const char kData[142] = | |||
"one of the few honest people that I have ever " | |||
"known"; | |||
|
|||
|
|||
static uint32_t kHmacKey[8] = { |
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 also applies to this change.
@@ -211,7 +211,7 @@ | |||
stage: V2 | |||
si_stage: SV3 | |||
lc_states: ["PROD"] | |||
tests: [] | |||
tests: ["chip_sw_aes_prng_reseed"] |
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.
Similar to the other comment, I think it would be better having a separate PR for this. Moreover, it would be good to have a brief explanation why this is needed.
@@ -0,0 +1,361 @@ | |||
// Copyright lowRISC contributors (OpenTitan project). |
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.
Could you please add a subject tag to the commit message header?
} | ||
static void run_hmac_clear_interrupt(void) { | ||
uint32_t intr_state_reg_val_reset = 0x0007; | ||
abs_mmio_write32(kHmacBaseAddr + HMAC_INTR_STATE_REG_OFFSET, |
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.
@engdoreis is there a suggestion when to use abs_mmio_write32()
vs mmio_region_write32()
?
uint32_t hmacerr_reg = | ||
mmio_region_read32(hmac->base_addr, HMAC_ERROR_REG_OFFSET); | ||
LOG_INFO("REGISTER HMAC_ERROR_CODE: 0x%x Expected:0x%x", hmacerr_reg, | ||
error_code_expected); |
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.
A print (LOG_INFO()
) is not sufficient to check whether the test passed or failed. Please add something like:
TRY_CHECK(hmacerr_reg == error_code_expected, "Unexpected error was triggered.");
This applies throughout the entire code.
static void run_test_pushmsg_when_shadisabled( | ||
const dif_hmac_t *hmac, const char *data, size_t len, const uint8_t *key, | ||
const dif_hmac_digest_t *expected_digest) { | ||
uint32_t error_code_expected = 0x05; |
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 am a bit suprised that the HMAC DIF driver does not provide error codes. For example, KMAC provides this structure in the DIF:
opentitan/sw/device/lib/dif/dif_kmac.h
Lines 365 to 410 in 276caf8
typedef enum dif_kmac_error { | |
/** | |
* No error has occured. | |
*/ | |
kDifErrorNone = 0, | |
/** | |
* The Key Manager has raised an error because the secret key is not valid. | |
*/ | |
kDifErrorKeyNotValid = 1, | |
/** | |
* An attempt was made to write data into the message FIFO but the KMAC unit | |
* was not in the correct state to receive the data. | |
*/ | |
kDifErrorSoftwarePushedMessageFifo = 2, | |
/** | |
* SW issued a command while a HW application interface was using KMAC. | |
*/ | |
kDifErrorSoftwareIssuedCommandWhileAppInterfaceActive = 3, | |
/** | |
* The entropy wait timer has expired. | |
*/ | |
kDifErrorEntropyWaitTimerExpired = 4, | |
/** | |
* Incorrect entropy mode when entropy is ready. | |
*/ | |
kDifErrorEntropyModeIncorrect = 5, | |
kDifErrorUnexpectedModeStrength = 6, | |
kDifErrorIncorrectFunctionName = 7, | |
kDifErrorSoftwareCommandSequence = 8, | |
kDifErrorSoftwareHashingWithoutEntropyReady = 9, | |
kDifErrorFatalError = 0xC1, | |
kDifErrorPackerIntegrity = 0xC2, | |
kDifErrorMsgFifoIntegrity = 0xC3, | |
} dif_kmac_error_t; |
As I think adding this to the DIF is out of scope for this PR, maybe you can add a typedef for the different error codes you are expecting at the beginning of this test? Then it would be clearer what exactly error code 5 means.
@@ -198,7 +198,7 @@ | |||
si_stage: SV3 | |||
lc_states: ["PROD"] | |||
tests: [] | |||
bazel: [] | |||
bazel: ["//sw/device/tests:hmac_error_conditions_test"] |
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.
Thanks for adding tests that are not mentioned in the testplan (e.g., run_test_invalidconfig_keylength). Could you please update the testplan to document the additional tests?
for (int error_condition = 1; error_condition < 9; error_condition++) { | ||
switch (error_condition) { |
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.
A for + switch construct seems a bit unnecessary in my opinion.
@rprakas-gsc why is the test environment broken on master? I think you just need to restart the CI or rebase your work. I don't quite understand why you've opened a second, identical PR (#26049)? I'd prefer merging this one as here the review history remains preserved and it is easier for me to do a second review round. |
I tried rebasing already on the master branch, it didn't help. My issue is more related to detecting the FPGA board. I also wasted quite a bit of time going down this route - hence I started an identical PR on the earlgrey_1.0.0 branch, with this i can test this code on silicon as well. |
Thanks for your response. Not sure if I understand, but your test executes just fine here in CI: |
the tests which was executed in fpga - happened before I rebased. To fix the merge issues, I rebased it - thats when the FPGA board detection issue started showing up. |
Closing this PR - since this PR has been approved in earlgrey_1.0.0 branch and backported to master |
Added Hmac error conditions test