1 #ifndef _IPXE_AES_H
2 #define _IPXE_AES_H
3 
4 /** @file
5  *
6  * AES algorithm
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <ipxe/crypto.h>
13 
14 /** AES blocksize */
15 #define AES_BLOCKSIZE 16
16 
17 /** Maximum number of AES rounds */
18 #define AES_MAX_ROUNDS 15
19 
20 /** AES matrix */
21 union aes_matrix {
22 	/** Viewed as an array of bytes */
23 	uint8_t byte[16];
24 	/** Viewed as an array of four-byte columns */
25 	uint32_t column[4];
26 } __attribute__ (( packed ));
27 
28 /** AES round keys */
29 struct aes_round_keys {
30 	/** Round keys */
31 	union aes_matrix key[AES_MAX_ROUNDS];
32 };
33 
34 /** AES context */
35 struct aes_context {
36 	/** Encryption keys */
37 	struct aes_round_keys encrypt;
38 	/** Decryption keys */
39 	struct aes_round_keys decrypt;
40 	/** Number of rounds */
41 	unsigned int rounds;
42 };
43 
44 /** AES context size */
45 #define AES_CTX_SIZE sizeof ( struct aes_context )
46 
47 extern struct cipher_algorithm aes_algorithm;
48 extern struct cipher_algorithm aes_ecb_algorithm;
49 extern struct cipher_algorithm aes_cbc_algorithm;
50 
51 int aes_wrap ( const void *kek, const void *src, void *dest, int nblk );
52 int aes_unwrap ( const void *kek, const void *src, void *dest, int nblk );
53 
54 #endif /* _IPXE_AES_H */
55