Skip to content

Commit

Permalink
Fix test for DeriveKey
Browse files Browse the repository at this point in the history
Update slot number and fix errors.

Display summary upon completion of tests.

Signed-off-by: Michalis Pappas <[email protected]>
  • Loading branch information
michpappas authored and jbech-linaro committed Jun 5, 2018
1 parent ee23b29 commit 548b840
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions s96at/tests/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ static int test_derivekey(void)
uint8_t ret;
uint8_t key_e[S96AT_KEY_LEN] = { 0 };

uint8_t slot = 6;
uint8_t slot = 3;

uint8_t mac_a[S96AT_MAC_LEN] = { 0 }; /* actual (atsha204a) */
uint8_t mac_e[S96AT_MAC_LEN] = { 0 }; /* expected (openssl) */
Expand All @@ -654,7 +654,7 @@ static int test_derivekey(void)
/* 1 byte: Opcode */
OPCODE_DERIVEKEY,
/* 1 byte: Param1 */
TEMPKEY_SOURCE_INPUT,
TEMPKEY_SOURCE_INPUT << 2,
/* 2 bytes: Param2[LSB], Param2[MSB] */
slot, 0x00,
/* 1 byte: SN[8] */
Expand All @@ -681,7 +681,7 @@ static int test_derivekey(void)
/* 1 byte: Opcode */
OPCODE_MAC,
/* 1 byte: Mode */
S96AT_MAC_MODE_0,
S96AT_MAC_MODE_0 | (TEMPKEY_SOURCE_INPUT << MAC_MODE_TEMPKEY_SOURCE_SHIFT),
/* 2 bytes: Param2[LSB], Param2[MSB] */
slot, 0x00,
/* 8 bytes: OTP[0:7] or zeros */
Expand Down Expand Up @@ -725,7 +725,7 @@ static int test_derivekey(void)
* Bit 7: MBZ
*/
ret = s96at_get_mac(&desc, S96AT_MAC_MODE_0, slot, challenge,
S96AT_FLAG_NONE, mac_a);
S96AT_FLAG_TEMPKEY_SOURCE_INPUT, mac_a);
CHECK_RES("MAC (actual)", ret, mac_a, ARRAY_LEN(mac_a));

sha256(sha_in, ARRAY_LEN(sha_in), key_e);
Expand Down Expand Up @@ -834,6 +834,9 @@ static int test_reset(void)
int main(int argc, char *argv[])
{
uint8_t ret;
uint32_t tests_total = 0;
uint32_t tests_pass = 0;
uint32_t tests_fail = 0;

struct atsha204a_testcase tests[] = {
{"CheckMAC: Mode 0", test_checkmac_mode0},
Expand Down Expand Up @@ -888,8 +891,14 @@ int main(int argc, char *argv[])
s96at_idle(&desc);
while (s96at_wake(&desc) != S96AT_STATUS_READY) {};
}
if (ret)
tests_fail++;
else
tests_pass++;
tests_total++;
}
printf("Done\n");
printf("All done. Total: %d Passed: %d Failed: %d\n",
tests_total, tests_pass, tests_fail);
out:
ret = s96at_cleanup(&desc);
if (ret != S96AT_STATUS_OK)
Expand Down

0 comments on commit 548b840

Please sign in to comment.