crypto: aes - create AES library based on the fixed time AES code
Take the existing small footprint and mostly time invariant C code and turn it into a AES library that can be used for non-performance critical, casual use of AES, and as a fallback for, e.g., SIMD code that needs a secondary path that can be taken in contexts where the SIMD unit is off limits (e.g., in hard interrupts taken from kernel context) Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
此提交包含在:
@@ -37,4 +37,38 @@ int crypto_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
|
||||
unsigned int key_len);
|
||||
int crypto_aes_expand_key(struct crypto_aes_ctx *ctx, const u8 *in_key,
|
||||
unsigned int key_len);
|
||||
|
||||
/**
|
||||
* aes_expandkey - Expands the AES key as described in FIPS-197
|
||||
* @ctx: The location where the computed key will be stored.
|
||||
* @in_key: The supplied key.
|
||||
* @key_len: The length of the supplied key.
|
||||
*
|
||||
* Returns 0 on success. The function fails only if an invalid key size (or
|
||||
* pointer) is supplied.
|
||||
* The expanded key size is 240 bytes (max of 14 rounds with a unique 16 bytes
|
||||
* key schedule plus a 16 bytes key which is used before the first round).
|
||||
* The decryption key is prepared for the "Equivalent Inverse Cipher" as
|
||||
* described in FIPS-197. The first slot (16 bytes) of each key (enc or dec) is
|
||||
* for the initial combination, the second slot for the first round and so on.
|
||||
*/
|
||||
int aes_expandkey(struct crypto_aes_ctx *ctx, const u8 *in_key,
|
||||
unsigned int key_len);
|
||||
|
||||
/**
|
||||
* aes_encrypt - Encrypt a single AES block
|
||||
* @ctx: Context struct containing the key schedule
|
||||
* @out: Buffer to store the ciphertext
|
||||
* @in: Buffer containing the plaintext
|
||||
*/
|
||||
void aes_encrypt(const struct crypto_aes_ctx *ctx, u8 *out, const u8 *in);
|
||||
|
||||
/**
|
||||
* aes_decrypt - Decrypt a single AES block
|
||||
* @ctx: Context struct containing the key schedule
|
||||
* @out: Buffer to store the plaintext
|
||||
* @in: Buffer containing the ciphertext
|
||||
*/
|
||||
void aes_decrypt(const struct crypto_aes_ctx *ctx, u8 *out, const u8 *in);
|
||||
|
||||
#endif
|
||||
|
新增問題並參考
封鎖使用者