summaryrefslogtreecommitdiff
path: root/include/crypto/aes-ecb.h
blob: 8cac1f8794c7a0c4d8a5458ed6bcde99166f55a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * AES-ECB unauthenticated encryption and decryption
 *
 * Copyright 2026 Google LLC
 */
#ifndef _CRYPTO_AES_ECB_H
#define _CRYPTO_AES_ECB_H

#include <crypto/aes.h>

/**
 * aes_ecb_encrypt() - Encrypt data using AES-ECB
 * @dst: The destination buffer.  Can be in-place or out-of-place.  For other
 *	 overlaps the behavior is unspecified.
 * @src: The source data
 * @len: Number of bytes to encrypt.  Must be a multiple of AES_BLOCK_SIZE.
 * @key: The key, already prepared using aes_preparekey() or aes_prepareenckey()
 *
 * ECB mode is insecure by itself.  This function exists only for compatibility
 * with legacy protocols and for internal use by other modes.
 *
 * This supports incremental encryption, but the length of each chunk must be a
 * multiple of AES_BLOCK_SIZE.
 *
 * Context: Any context.
 */
void aes_ecb_encrypt(u8 *dst, const u8 *src, size_t len, aes_encrypt_arg key);

/**
 * aes_ecb_decrypt() - Decrypt data using AES-ECB
 * @dst: The destination buffer.  Can be in-place or out-of-place.  For other
 *	 overlaps the behavior is unspecified.
 * @src: The source data
 * @len: Number of bytes to decrypt.  Must be a multiple of AES_BLOCK_SIZE.
 * @key: The key, already prepared using aes_preparekey()
 *
 * ECB mode is insecure by itself.  This function exists only for compatibility
 * with legacy protocols and for internal use by other modes.
 *
 * This supports incremental decryption, but the length of each chunk must be a
 * multiple of AES_BLOCK_SIZE.
 *
 * Context: Any context.
 */
void aes_ecb_decrypt(u8 *dst, const u8 *src, size_t len,
		     const struct aes_key *key);

#endif /* _CRYPTO_AES_ECB_H */