From 2285961810046956ea1b632973f0d8fa6525cc83 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 20 Feb 2023 18:22:00 +0100 Subject: [PATCH] sys/crypto: make AES_KEY struct private --- sys/crypto/aes.c | 24 ++++++++++++++++-------- sys/include/crypto/aes.h | 15 --------------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/sys/crypto/aes.c b/sys/crypto/aes.c index 22f3adb8c5..a54072c11a 100644 --- a/sys/crypto/aes.c +++ b/sys/crypto/aes.c @@ -32,8 +32,6 @@ * @} */ -#include -#include #include #include #include @@ -62,6 +60,16 @@ # define AES_KEY_SIZE(ctx) ctx->key_size #endif +/** + * @brief AES key + * @see cipher_context_t + */ +typedef struct { + /** @cond INTERNAL */ + uint32_t rd_key[4 * (AES_MAXNR + 1)]; + int rounds; + /** @endcond */ +} aes_key_t; /** * Interface to the aes cipher */ @@ -860,7 +868,7 @@ int aes_init(cipher_context_t *context, const uint8_t *key, uint8_t keySize) * Expand the cipher key into the encryption key schedule. */ static int aes_set_encrypt_key(const unsigned char *userKey, const int bits, - AES_KEY *key) + aes_key_t *key) { u32 *rk; int i = 0; @@ -979,7 +987,7 @@ static int aes_set_encrypt_key(const unsigned char *userKey, const int bits, * Expand the cipher key into the decryption key schedule. */ static int aes_set_decrypt_key(const unsigned char *userKey, const int bits, - AES_KEY *key) + aes_key_t *key) { u32 *rk; int i, j; @@ -1062,8 +1070,8 @@ int aes_encrypt(const cipher_context_t *context, const uint8_t *plainBlock, { /* setup AES_KEY */ int res; - AES_KEY aeskey; - const AES_KEY *key = &aeskey; + aes_key_t aeskey; + const aes_key_t *key = &aeskey; res = aes_set_encrypt_key((unsigned char *)context->context, AES_KEY_SIZE(context) * 8, &aeskey); @@ -1331,8 +1339,8 @@ int aes_decrypt(const cipher_context_t *context, const uint8_t *cipherBlock, { /* setup AES_KEY */ int res; - AES_KEY aeskey; - const AES_KEY *key = &aeskey; + aes_key_t aeskey; + const aes_key_t *key = &aeskey; res = aes_set_decrypt_key((unsigned char *)context->context, AES_KEY_SIZE(context) * 8, &aeskey); diff --git a/sys/include/crypto/aes.h b/sys/include/crypto/aes.h index 2055dbb76a..73496ea0f1 100644 --- a/sys/include/crypto/aes.h +++ b/sys/include/crypto/aes.h @@ -30,10 +30,6 @@ #ifndef CRYPTO_AES_H #define CRYPTO_AES_H -#include -#include -#include -#include #include #include "crypto/ciphers.h" @@ -64,17 +60,6 @@ typedef uint8_t u8; #define AES_KEY_SIZE_256 32 /** @} */ -/** - * @brief AES key - * @see cipher_context_t - */ -typedef struct aes_key_st { - /** @cond INTERNAL */ - uint32_t rd_key[4 * (AES_MAXNR + 1)]; - int rounds; - /** @endcond */ -} AES_KEY; - /** * @brief the cipher_context_t-struct adapted for AES */