1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/sys/psa_crypto_hashes/main.c
2024-07-13 04:35:21 +02:00

63 lines
1.5 KiB
C

/*
* Copyright (C) 2024 HAW Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup tests
* @{
*
* @brief Test application for PSA hash configuration
*
* @author Mikolai Gütschow <mikolai.guetschow@tu-dresden.de>
* @author Lena Boeckmann <lena.boeckmann@haw-hamburg.de>
*
* @}
*/
#include <stdio.h>
#include "psa/crypto.h"
#include "ztimer.h"
extern psa_status_t example_hash(void);
extern psa_status_t example_sha3_glue(void);
int main(void)
{
bool failed = false;
psa_status_t status;
psa_crypto_init();
ztimer_acquire(ZTIMER_USEC);
ztimer_now_t start = ztimer_now(ZTIMER_USEC);
status = example_hash();
printf("Hash took %d us\n", (int)(ztimer_now(ZTIMER_USEC) - start));
if (status != PSA_SUCCESS) {
failed = true;
printf("Hash failed: %s\n", psa_status_to_humanly_readable(status));
}
start = ztimer_now(ZTIMER_USEC);
status = example_sha3_glue();
printf("SHA3 glue code test took %d us\n", (int)(ztimer_now(ZTIMER_USEC) - start));
if (status != PSA_SUCCESS) {
failed = true;
printf("SHA3 glue code failed: %s\n", psa_status_to_humanly_readable(status));
}
ztimer_release(ZTIMER_USEC);
if (failed) {
puts("Tests failed...");
}
else {
puts("All Done");
}
return 0;
}