From: Stefano Babic Date: Wed, 5 Apr 2017 16:08:00 +0000 (+0200) Subject: Rename aes.h to uboot_aes.h X-Git-Tag: v2017.05-rc2~21 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b80c0b99347c52884cccc7c09775942acbcc0739;p=oweals%2Fu-boot.git Rename aes.h to uboot_aes.h aes.h is a too generic name if this file can be exported and used by a program. Rename it to avoid any conflicts with other files (for example, from openSSL). Signed-off-by: Stefano Babic --- diff --git a/arch/arm/mach-tegra/tegra20/crypto.c b/arch/arm/mach-tegra/tegra20/crypto.c index 1b82fbb591..eae79217d4 100644 --- a/arch/arm/mach-tegra/tegra20/crypto.c +++ b/arch/arm/mach-tegra/tegra20/crypto.c @@ -8,7 +8,7 @@ #include #include #include "crypto.h" -#include "aes.h" +#include "uboot_aes.h" static u8 zero_key[16]; diff --git a/cmd/aes.c b/cmd/aes.c index 76da3efffe..ee1ae13c06 100644 --- a/cmd/aes.c +++ b/cmd/aes.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/common/env_common.c b/common/env_common.c index 7fb62e8b45..6845f8d8d5 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -140,7 +140,7 @@ int set_default_vars(int nvars, char * const vars[]) } #ifdef CONFIG_ENV_AES -#include +#include /** * env_aes_cbc_get_key() - Get AES-128-CBC key for the environment * diff --git a/include/aes.h b/include/aes.h deleted file mode 100644 index 6315c02aa9..0000000000 --- a/include/aes.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2011 The Chromium OS Authors. - * (C) Copyright 2010 - 2011 NVIDIA Corporation - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#ifndef _AES_REF_H_ -#define _AES_REF_H_ - -#ifdef USE_HOSTCC -/* Define compat stuff for use in fw_* tools. */ -typedef unsigned char u8; -typedef unsigned int u32; -#define debug(...) do {} while (0) -#endif - -/* - * AES encryption library, with small code size, supporting only 128-bit AES - * - * AES is a stream cipher which works a block at a time, with each block - * in this case being AES_KEY_LENGTH bytes. - */ - -enum { - AES_STATECOLS = 4, /* columns in the state & expanded key */ - AES_KEYCOLS = 4, /* columns in a key */ - AES_ROUNDS = 10, /* rounds in encryption */ - - AES_KEY_LENGTH = 128 / 8, - AES_EXPAND_KEY_LENGTH = 4 * AES_STATECOLS * (AES_ROUNDS + 1), -}; - -/** - * aes_expand_key() - Expand the AES key - * - * Expand a key into a key schedule, which is then used for the other - * operations. - * - * @key Key, of length AES_KEY_LENGTH bytes - * @expkey Buffer to place expanded key, AES_EXPAND_KEY_LENGTH - */ -void aes_expand_key(u8 *key, u8 *expkey); - -/** - * aes_encrypt() - Encrypt single block of data with AES 128 - * - * @in Input data - * @expkey Expanded key to use for encryption (from aes_expand_key()) - * @out Output data - */ -void aes_encrypt(u8 *in, u8 *expkey, u8 *out); - -/** - * aes_decrypt() - Decrypt single block of data with AES 128 - * - * @in Input data - * @expkey Expanded key to use for decryption (from aes_expand_key()) - * @out Output data - */ -void aes_decrypt(u8 *in, u8 *expkey, u8 *out); - -/** - * Apply chain data to the destination using EOR - * - * Each array is of length AES_KEY_LENGTH. - * - * @cbc_chain_data Chain data - * @src Source data - * @dst Destination data, which is modified here - */ -void aes_apply_cbc_chain_data(u8 *cbc_chain_data, u8 *src, u8 *dst); - -/** - * aes_cbc_encrypt_blocks() - Encrypt multiple blocks of data with AES CBC. - * - * @key_exp Expanded key to use - * @src Source data to encrypt - * @dst Destination buffer - * @num_aes_blocks Number of AES blocks to encrypt - */ -void aes_cbc_encrypt_blocks(u8 *key_exp, u8 *src, u8 *dst, u32 num_aes_blocks); - -/** - * Decrypt multiple blocks of data with AES CBC. - * - * @key_exp Expanded key to use - * @src Source data to decrypt - * @dst Destination buffer - * @num_aes_blocks Number of AES blocks to decrypt - */ -void aes_cbc_decrypt_blocks(u8 *key_exp, u8 *src, u8 *dst, u32 num_aes_blocks); - -#endif /* _AES_REF_H_ */ diff --git a/include/uboot_aes.h b/include/uboot_aes.h new file mode 100644 index 0000000000..6315c02aa9 --- /dev/null +++ b/include/uboot_aes.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * (C) Copyright 2010 - 2011 NVIDIA Corporation + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef _AES_REF_H_ +#define _AES_REF_H_ + +#ifdef USE_HOSTCC +/* Define compat stuff for use in fw_* tools. */ +typedef unsigned char u8; +typedef unsigned int u32; +#define debug(...) do {} while (0) +#endif + +/* + * AES encryption library, with small code size, supporting only 128-bit AES + * + * AES is a stream cipher which works a block at a time, with each block + * in this case being AES_KEY_LENGTH bytes. + */ + +enum { + AES_STATECOLS = 4, /* columns in the state & expanded key */ + AES_KEYCOLS = 4, /* columns in a key */ + AES_ROUNDS = 10, /* rounds in encryption */ + + AES_KEY_LENGTH = 128 / 8, + AES_EXPAND_KEY_LENGTH = 4 * AES_STATECOLS * (AES_ROUNDS + 1), +}; + +/** + * aes_expand_key() - Expand the AES key + * + * Expand a key into a key schedule, which is then used for the other + * operations. + * + * @key Key, of length AES_KEY_LENGTH bytes + * @expkey Buffer to place expanded key, AES_EXPAND_KEY_LENGTH + */ +void aes_expand_key(u8 *key, u8 *expkey); + +/** + * aes_encrypt() - Encrypt single block of data with AES 128 + * + * @in Input data + * @expkey Expanded key to use for encryption (from aes_expand_key()) + * @out Output data + */ +void aes_encrypt(u8 *in, u8 *expkey, u8 *out); + +/** + * aes_decrypt() - Decrypt single block of data with AES 128 + * + * @in Input data + * @expkey Expanded key to use for decryption (from aes_expand_key()) + * @out Output data + */ +void aes_decrypt(u8 *in, u8 *expkey, u8 *out); + +/** + * Apply chain data to the destination using EOR + * + * Each array is of length AES_KEY_LENGTH. + * + * @cbc_chain_data Chain data + * @src Source data + * @dst Destination data, which is modified here + */ +void aes_apply_cbc_chain_data(u8 *cbc_chain_data, u8 *src, u8 *dst); + +/** + * aes_cbc_encrypt_blocks() - Encrypt multiple blocks of data with AES CBC. + * + * @key_exp Expanded key to use + * @src Source data to encrypt + * @dst Destination buffer + * @num_aes_blocks Number of AES blocks to encrypt + */ +void aes_cbc_encrypt_blocks(u8 *key_exp, u8 *src, u8 *dst, u32 num_aes_blocks); + +/** + * Decrypt multiple blocks of data with AES CBC. + * + * @key_exp Expanded key to use + * @src Source data to decrypt + * @dst Destination buffer + * @num_aes_blocks Number of AES blocks to decrypt + */ +void aes_cbc_decrypt_blocks(u8 *key_exp, u8 *src, u8 *dst, u32 num_aes_blocks); + +#endif /* _AES_REF_H_ */ diff --git a/lib/aes.c b/lib/aes.c index 9d7a0a1c11..d6144e61d6 100644 --- a/lib/aes.c +++ b/lib/aes.c @@ -27,7 +27,7 @@ #else #include #endif -#include "aes.h" +#include "uboot_aes.h" /* forward s-box */ static const u8 sbox[256] = { diff --git a/tools/env/fw_env.h b/tools/env/fw_env.h index 05588ab6d5..0d7130a381 100644 --- a/tools/env/fw_env.h +++ b/tools/env/fw_env.h @@ -5,7 +5,7 @@ * SPDX-License-Identifier: GPL-2.0+ */ -#include +#include #include /* Pull in the current config to define the default environment */