david/ipxe
david
/
ipxe
Archived
1
0
Fork 0
This repository has been archived on 2020-12-06. You can view files and clone it, but cannot push or open issues or pull requests.
ipxe/src/include/ipxe/aes.h

55 lines
1.1 KiB
C

#ifndef _IPXE_AES_H
#define _IPXE_AES_H
/** @file
*
* AES algorithm
*
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/crypto.h>
/** AES blocksize */
#define AES_BLOCKSIZE 16
/** Maximum number of AES rounds */
#define AES_MAX_ROUNDS 15
/** AES matrix */
union aes_matrix {
/** Viewed as an array of bytes */
uint8_t byte[16];
/** Viewed as an array of four-byte columns */
uint32_t column[4];
} __attribute__ (( packed ));
/** AES round keys */
struct aes_round_keys {
/** Round keys */
union aes_matrix key[AES_MAX_ROUNDS];
};
/** AES context */
struct aes_context {
/** Encryption keys */
struct aes_round_keys encrypt;
/** Decryption keys */
struct aes_round_keys decrypt;
/** Number of rounds */
unsigned int rounds;
};
/** AES context size */
#define AES_CTX_SIZE sizeof ( struct aes_context )
extern struct cipher_algorithm aes_algorithm;
extern struct cipher_algorithm aes_ecb_algorithm;
extern struct cipher_algorithm aes_cbc_algorithm;
int aes_wrap ( const void *kek, const void *src, void *dest, int nblk );
int aes_unwrap ( const void *kek, const void *src, void *dest, int nblk );
#endif /* _IPXE_AES_H */