Skip to content

Commit 3606e9b

Browse files
daria-gausterWer-Wolf
authored andcommitted
tests/sys/psa_crypto_mac: Add tests for generic HMAC implementations
Add tests for the generic HMAC implementation. Authored-by: Daria Zatokovenko <[email protected]> Signed-off-by: Armin Wolf <[email protected]>
1 parent 5ccb81d commit 3606e9b

File tree

9 files changed

+1391
-99
lines changed

9 files changed

+1391
-99
lines changed

tests/sys/psa_crypto_mac/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
include ../Makefile.sys_common
22

3+
USEMODULE += embunit
4+
35
USEMODULE += ztimer
46
USEMODULE += ztimer_usec
57

68
USEMODULE += psa_crypto
7-
89
USEMODULE += psa_mac
10+
USEMODULE += psa_hash
11+
912
USEMODULE += psa_mac_hmac_sha_256
13+
USEMODULE += psa_mac_hmac_sha_384
14+
USEMODULE += psa_mac_hmac_sha_512
1015

1116
CFLAGS += -DCONFIG_PSA_SINGLE_KEY_COUNT=1
1217

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
BOARD_INSUFFICIENT_MEMORY := \
22
arduino-duemilanove \
3+
arduino-leonardo \
34
arduino-nano \
45
arduino-uno \
56
atmega328p \
67
atmega328p-xplained-mini \
78
atmega8 \
89
nucleo-l011k4 \
10+
samd10-xmini \
11+
stm32f030f4-demo \
912
#

tests/sys/psa_crypto_mac/example_hmac_sha256.c

Lines changed: 0 additions & 74 deletions
This file was deleted.

tests/sys/psa_crypto_mac/main.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,25 @@
2121
#include <stdio.h>
2222
#include "psa/crypto.h"
2323
#include "ztimer.h"
24-
25-
extern psa_status_t example_hmac_sha256(void);
24+
#include "tests_gen_hmac.h"
2625

2726
int main(void)
2827
{
29-
bool failed = false;
30-
psa_status_t status;
28+
ztimer_now_t start;
3129

3230
psa_crypto_init();
3331

3432
ztimer_acquire(ZTIMER_USEC);
35-
ztimer_now_t start = ztimer_now(ZTIMER_USEC);
33+
start = ztimer_now(ZTIMER_USEC);
3634

37-
status = example_hmac_sha256();
38-
printf("HMAC SHA256 took %d us\n", (int)(ztimer_now(ZTIMER_USEC) - start));
39-
if (status != PSA_SUCCESS) {
40-
failed = true;
41-
printf("HMAC SHA256 failed: %s\n", psa_status_to_humanly_readable(status));
42-
}
35+
TESTS_START();
36+
TESTS_RUN(tests_mac_hmac_sha512());
37+
TESTS_RUN(tests_mac_hmac_sha384());
38+
TESTS_RUN(tests_mac_hmac_sha256());
39+
TESTS_END();
4340

41+
printf("HMAC tests took %d us\n", (int)(ztimer_now(ZTIMER_USEC) - start));
4442
ztimer_release(ZTIMER_USEC);
4543

46-
if (failed) {
47-
puts("Tests failed...");
48-
}
49-
else {
50-
puts("All Done");
51-
}
5244
return 0;
5345
}

0 commit comments

Comments
 (0)