mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests/sys/crypto: Split test application to reduce size
This commit is contained in:
parent
f5ca90b007
commit
46a0ef07b1
@ -4,9 +4,14 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
arduino-mega2560 \
|
||||
arduino-nano \
|
||||
arduino-uno \
|
||||
atmega1284p \
|
||||
atmega328p \
|
||||
atmega328p-xplained-mini \
|
||||
atxmega-a1u-xpro \
|
||||
atxmega-a3bu-xplained \
|
||||
derfmega128 \
|
||||
mega-xplained \
|
||||
microduino-corerf \
|
||||
msb-430 \
|
||||
msb-430h \
|
||||
nucleo-f031k6 \
|
||||
@ -19,4 +24,5 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
telosb \
|
||||
waspmote-pro \
|
||||
z1 \
|
||||
zigduino \
|
||||
#
|
||||
|
33
tests/sys_crypto/README.md
Normal file
33
tests/sys_crypto/README.md
Normal file
@ -0,0 +1,33 @@
|
||||
# Overview
|
||||
|
||||
This test application tests all the components of the crypto module in RIOT.
|
||||
Specifically these are:
|
||||
|
||||
* ChaCha. Test vectors from [draft-strombergson-chacha-test-vectors-00].
|
||||
* Poly1305. Test vectors from [draft-nir-cfrg-chacha20-poly1305-06].
|
||||
* ChaCha20-Poly1305. Test vectors from [rfc7539].
|
||||
* AES-CBC. Test vectors from [SP 800-38C].
|
||||
* AES-CCM. Test vectors from [RFC3610], [SP 800-38C], [Wycheproof].
|
||||
* AES-CTR. Test vectors from [SP 800-38C].
|
||||
* AES-ECB. Test vectors from [SP 800-38C].
|
||||
* AES-OCB. Test vectors from [RFC7253].
|
||||
|
||||
To build the test application run
|
||||
|
||||
```
|
||||
make
|
||||
```
|
||||
|
||||
To execute the test run
|
||||
|
||||
```
|
||||
make term
|
||||
```
|
||||
|
||||
[draft-nir-cfrg-chacha20-poly1305-06]: https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-06#appendix-A.3
|
||||
[draft-strombergson-chacha-test-vectors-00]: https://tools.ietf.org/html/draft-strombergson-chacha-test-vectors-00
|
||||
[rfc7539]: https://tools.ietf.org/html/rfc7539#appendix-A
|
||||
[SP 800-38C]: http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
|
||||
[RFC3610]: https://tools.ietf.org/html/rfc3610
|
||||
[Wycheproof]: https://github.com/google/wycheproof/blob/master/testvectors/aes_ccm_test.json
|
||||
[RFC7253]: https://tools.ietf.org/html/rfc7253#appendix-A
|
@ -1,7 +1,10 @@
|
||||
# this file enables modules defined in Kconfig. Do not use this file for
|
||||
# application configuration. This is only needed during migration.
|
||||
|
||||
CONFIG_MODULE_CRYPTO_3DES=y
|
||||
CONFIG_MODULE_CRYPTO=y
|
||||
CONFIG_MODULE_CRYPTO_AES_128=y
|
||||
CONFIG_MODULE_CRYPTO_AES_192=y
|
||||
CONFIG_MODULE_CRYPTO_AES_256=y
|
||||
CONFIG_MODULE_CIPHER_MODES=y
|
||||
|
||||
CONFIG_MODULE_EMBUNIT=y
|
||||
|
@ -19,9 +19,6 @@ int main(void)
|
||||
TESTS_RUN(tests_crypto_aes_tests());
|
||||
TESTS_RUN(tests_crypto_cipher_tests());
|
||||
TESTS_RUN(tests_crypto_modes_ccm_tests());
|
||||
TESTS_RUN(tests_crypto_modes_ccm_tests_128());
|
||||
TESTS_RUN(tests_crypto_modes_ccm_tests_192());
|
||||
TESTS_RUN(tests_crypto_modes_ccm_tests_256());
|
||||
TESTS_RUN(tests_crypto_modes_ocb_tests());
|
||||
TESTS_RUN(tests_crypto_modes_ecb_tests());
|
||||
TESTS_RUN(tests_crypto_modes_cbc_tests());
|
||||
|
@ -13,6 +13,13 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Test Vectors for the Stream Cipher ChaCha
|
||||
* draft-strombergson-chacha-test-vectors-00
|
||||
*
|
||||
* https://tools.ietf.org/html/draft-strombergson-chacha-test-vectors-00
|
||||
*/
|
||||
|
||||
static const uint8_t TC8_KEY[32] = {
|
||||
0xc4, 0x6e, 0xc1, 0xb1, 0x8c, 0xe8, 0xa8, 0x78,
|
||||
0x72, 0x5a, 0x37, 0xe7, 0x80, 0xdf, 0xb7, 0x35,
|
||||
|
@ -15,6 +15,12 @@
|
||||
|
||||
#include "crypto/chacha20poly1305.h"
|
||||
|
||||
/*
|
||||
* Example and Test Vector for AEAD_CHACHA20_POLY1305
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7539#appendix-A
|
||||
*/
|
||||
|
||||
/* ciphertext buffer */
|
||||
uint8_t ebuf[1024];
|
||||
/* Plaintext buffer */
|
||||
|
@ -14,6 +14,12 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Poly1305 Message Authentication Code
|
||||
*
|
||||
* https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-06#appendix-A.3
|
||||
*/
|
||||
|
||||
static const uint8_t key_1[32] = { 0 };
|
||||
static const uint8_t msg_1[64] = { 0 };
|
||||
static const uint8_t tag_1[16] = { 0 };
|
||||
|
@ -59,9 +59,6 @@ static inline int compare(const uint8_t *a, const uint8_t *b, uint8_t len)
|
||||
Test* tests_crypto_aes_tests(void);
|
||||
Test* tests_crypto_cipher_tests(void);
|
||||
Test* tests_crypto_modes_ccm_tests(void);
|
||||
Test* tests_crypto_modes_ccm_tests_128(void);
|
||||
Test* tests_crypto_modes_ccm_tests_192(void);
|
||||
Test* tests_crypto_modes_ccm_tests_256(void);
|
||||
Test* tests_crypto_modes_ocb_tests(void);
|
||||
Test* tests_crypto_modes_ecb_tests(void);
|
||||
Test* tests_crypto_modes_cbc_tests(void);
|
||||
|
10
tests/sys_crypto_aes_ccm/Makefile
Normal file
10
tests/sys_crypto_aes_ccm/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
include ../Makefile.tests_common
|
||||
|
||||
USEMODULE += embunit
|
||||
|
||||
USEMODULE += cipher_modes
|
||||
USEMODULE += crypto_aes_128
|
||||
USEMODULE += crypto_aes_192
|
||||
USEMODULE += crypto_aes_256
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
28
tests/sys_crypto_aes_ccm/Makefile.ci
Normal file
28
tests/sys_crypto_aes_ccm/Makefile.ci
Normal file
@ -0,0 +1,28 @@
|
||||
BOARD_INSUFFICIENT_MEMORY := \
|
||||
arduino-duemilanove \
|
||||
arduino-leonardo \
|
||||
arduino-mega2560 \
|
||||
arduino-nano \
|
||||
arduino-uno \
|
||||
atmega1284p \
|
||||
atmega328p \
|
||||
atmega328p-xplained-mini \
|
||||
atxmega-a1u-xpro \
|
||||
atxmega-a3bu-xplained \
|
||||
derfmega128 \
|
||||
mega-xplained \
|
||||
microduino-corerf \
|
||||
msb-430 \
|
||||
msb-430h \
|
||||
nucleo-f031k6 \
|
||||
nucleo-f042k6 \
|
||||
nucleo-l011k4 \
|
||||
nucleo-l031k6 \
|
||||
samd10-xmini \
|
||||
stk3200 \
|
||||
stm32f030f4-demo \
|
||||
telosb \
|
||||
waspmote-pro \
|
||||
z1 \
|
||||
zigduino \
|
||||
#
|
18
tests/sys_crypto_aes_ccm/README.md
Normal file
18
tests/sys_crypto_aes_ccm/README.md
Normal file
@ -0,0 +1,18 @@
|
||||
# Overview
|
||||
|
||||
This test application specifically tests the AES CCM implementation for 128, 192 and 256
|
||||
bit keys. The test utilizes the [CAVP AES CCM DVTP] test vectors.
|
||||
|
||||
To build the test application run
|
||||
|
||||
```
|
||||
make
|
||||
```
|
||||
|
||||
To execute the test run
|
||||
|
||||
```
|
||||
make term
|
||||
```
|
||||
|
||||
[CAVP AES CCM DVTP]: https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/cavp-testing-block-cipher-modes
|
11
tests/sys_crypto_aes_ccm/app.config.test
Normal file
11
tests/sys_crypto_aes_ccm/app.config.test
Normal file
@ -0,0 +1,11 @@
|
||||
# this file enables modules defined in Kconfig. Do not use this file for
|
||||
# application configuration. This is only needed during migration.
|
||||
|
||||
CONFIG_MODULE_CRYPTO=y
|
||||
CONFIG_MODULE_CRYPTO_AES_128=y
|
||||
CONFIG_MODULE_CRYPTO_AES_192=y
|
||||
CONFIG_MODULE_CRYPTO_AES_256=y
|
||||
CONFIG_MODULE_CIPHER_MODES=y
|
||||
|
||||
CONFIG_MODULE_EMBUNIT=y
|
||||
CONFIG_MODULE_TEST_UTILS_INTERACTIVE_SYNC=y
|
19
tests/sys_crypto_aes_ccm/main.c
Normal file
19
tests/sys_crypto_aes_ccm/main.c
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Nils Ollrogge
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "tests-crypto.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
TESTS_START();
|
||||
TESTS_RUN(tests_crypto_modes_ccm_tests_128());
|
||||
TESTS_RUN(tests_crypto_modes_ccm_tests_192());
|
||||
TESTS_RUN(tests_crypto_modes_ccm_tests_256());
|
||||
TESTS_END();
|
||||
return 0;
|
||||
}
|
@ -20,7 +20,7 @@
|
||||
/**
|
||||
* AES CCM DVTP test vectors (SP 800-38C) for 256 bit keys.
|
||||
* https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/cavp-testing-block-cipher-modes
|
||||
*/
|
||||
*/
|
||||
|
||||
static const size_t nonce_and_len_encoding_size = 15;
|
||||
|
50
tests/sys_crypto_aes_ccm/tests-crypto.h
Normal file
50
tests/sys_crypto_aes_ccm/tests-crypto.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Freie Universität Berlin
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup unittests
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Unittests for the ``crypto`` module
|
||||
*
|
||||
* @author Nils Ollrogge <nils-ollrogge@outlook.de>
|
||||
*/
|
||||
#ifndef TESTS_CRYPTO_H
|
||||
#define TESTS_CRYPTO_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "embUnit.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static inline int compare(const uint8_t *a, const uint8_t *b, uint8_t len)
|
||||
{
|
||||
int result = 1;
|
||||
|
||||
for (uint8_t i = 0; i < len; ++i) {
|
||||
result &= a[i] == b[i];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Test *tests_crypto_modes_ccm_tests_128(void);
|
||||
Test *tests_crypto_modes_ccm_tests_192(void);
|
||||
Test *tests_crypto_modes_ccm_tests_256(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TESTS_CRYPTO_H */
|
||||
/** @} */
|
14
tests/sys_crypto_aes_ccm/tests/01-run.py
Executable file
14
tests/sys_crypto_aes_ccm/tests/01-run.py
Executable file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2019 Freie Universität Berlin
|
||||
#
|
||||
# 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.
|
||||
|
||||
import sys
|
||||
from testrunner import run_check_unittests
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(run_check_unittests())
|
Loading…
Reference in New Issue
Block a user