xref: /linux/include/crypto/aes-ecb.h (revision d47db9bf50d28647689e6743ee93c45cb755ffc3)
1*5ab301fcSEric Biggers /* SPDX-License-Identifier: GPL-2.0 */
2*5ab301fcSEric Biggers /*
3*5ab301fcSEric Biggers  * AES-ECB unauthenticated encryption and decryption
4*5ab301fcSEric Biggers  *
5*5ab301fcSEric Biggers  * Copyright 2026 Google LLC
6*5ab301fcSEric Biggers  */
7*5ab301fcSEric Biggers #ifndef _CRYPTO_AES_ECB_H
8*5ab301fcSEric Biggers #define _CRYPTO_AES_ECB_H
9*5ab301fcSEric Biggers 
10*5ab301fcSEric Biggers #include <crypto/aes.h>
11*5ab301fcSEric Biggers 
12*5ab301fcSEric Biggers /**
13*5ab301fcSEric Biggers  * aes_ecb_encrypt() - Encrypt data using AES-ECB
14*5ab301fcSEric Biggers  * @dst: The destination buffer.  Can be in-place or out-of-place.  For other
15*5ab301fcSEric Biggers  *	 overlaps the behavior is unspecified.
16*5ab301fcSEric Biggers  * @src: The source data
17*5ab301fcSEric Biggers  * @len: Number of bytes to encrypt.  Must be a multiple of AES_BLOCK_SIZE.
18*5ab301fcSEric Biggers  * @key: The key, already prepared using aes_preparekey() or aes_prepareenckey()
19*5ab301fcSEric Biggers  *
20*5ab301fcSEric Biggers  * ECB mode is insecure by itself.  This function exists only for compatibility
21*5ab301fcSEric Biggers  * with legacy protocols and for internal use by other modes.
22*5ab301fcSEric Biggers  *
23*5ab301fcSEric Biggers  * This supports incremental encryption, but the length of each chunk must be a
24*5ab301fcSEric Biggers  * multiple of AES_BLOCK_SIZE.
25*5ab301fcSEric Biggers  *
26*5ab301fcSEric Biggers  * Context: Any context.
27*5ab301fcSEric Biggers  */
28*5ab301fcSEric Biggers void aes_ecb_encrypt(u8 *dst, const u8 *src, size_t len, aes_encrypt_arg key);
29*5ab301fcSEric Biggers 
30*5ab301fcSEric Biggers /**
31*5ab301fcSEric Biggers  * aes_ecb_decrypt() - Decrypt data using AES-ECB
32*5ab301fcSEric Biggers  * @dst: The destination buffer.  Can be in-place or out-of-place.  For other
33*5ab301fcSEric Biggers  *	 overlaps the behavior is unspecified.
34*5ab301fcSEric Biggers  * @src: The source data
35*5ab301fcSEric Biggers  * @len: Number of bytes to decrypt.  Must be a multiple of AES_BLOCK_SIZE.
36*5ab301fcSEric Biggers  * @key: The key, already prepared using aes_preparekey()
37*5ab301fcSEric Biggers  *
38*5ab301fcSEric Biggers  * ECB mode is insecure by itself.  This function exists only for compatibility
39*5ab301fcSEric Biggers  * with legacy protocols and for internal use by other modes.
40*5ab301fcSEric Biggers  *
41*5ab301fcSEric Biggers  * This supports incremental decryption, but the length of each chunk must be a
42*5ab301fcSEric Biggers  * multiple of AES_BLOCK_SIZE.
43*5ab301fcSEric Biggers  *
44*5ab301fcSEric Biggers  * Context: Any context.
45*5ab301fcSEric Biggers  */
46*5ab301fcSEric Biggers void aes_ecb_decrypt(u8 *dst, const u8 *src, size_t len,
47*5ab301fcSEric Biggers 		     const struct aes_key *key);
48*5ab301fcSEric Biggers 
49*5ab301fcSEric Biggers #endif /* _CRYPTO_AES_ECB_H */
50