samples: drivers: crypto: Put keys in ROM

This change reduces the RAM consumption.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
This commit is contained in:
Reto Schneider 2024-02-27 14:26:17 +01:00 committed by Fabio Baltieri
parent 61499a2c70
commit 1e11bbe1f8

View file

@ -33,7 +33,7 @@ LOG_MODULE_REGISTER(main);
#error "You need to enable one crypto device"
#endif
static uint8_t key[16] __aligned(32) = {
const static uint8_t key[16] __aligned(32) = {
0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88,
0x09, 0xcf, 0x4f, 0x3c
};
@ -111,7 +111,7 @@ int validate_hw_compatibility(const struct device *dev)
void ecb_mode(const struct device *dev)
{
/* from FIPS-197 test vectors */
uint8_t ecb_key[16] = {
const uint8_t ecb_key[16] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
};
@ -119,7 +119,7 @@ void ecb_mode(const struct device *dev)
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
};
const uint8_t ecb_ciphertext[16] = {
uint8_t ecb_ciphertext[16] = {
0x69, 0xC4, 0xE0, 0xD8, 0x6A, 0x7B, 0x04, 0x30,
0xD8, 0xCD, 0xB7, 0x80, 0x70, 0xB4, 0xC5, 0x5A
};
@ -372,7 +372,7 @@ out:
}
/* RFC 3610 test vector #1 */
static uint8_t ccm_key[16] = {
const static uint8_t ccm_key[16] = {
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb,
0xcc, 0xcd, 0xce, 0xcf
};
@ -484,7 +484,7 @@ out:
}
/* MACsec GCM-AES test vector 2.4.1 */
static uint8_t gcm_key[16] = {
const static uint8_t gcm_key[16] = {
0x07, 0x1b, 0x11, 0x3b, 0x0c, 0xa7, 0x43, 0xfe, 0xcc, 0xcf, 0x3d, 0x05,
0x1f, 0x73, 0x73, 0x82
};