iPXE
aes.h
Go to the documentation of this file.
00001 #ifndef _IPXE_AES_H
00002 #define _IPXE_AES_H
00003 
00004 /** @file
00005  *
00006  * AES algorithm
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <ipxe/crypto.h>
00013 
00014 /** AES blocksize */
00015 #define AES_BLOCKSIZE 16
00016 
00017 /** Maximum number of AES rounds */
00018 #define AES_MAX_ROUNDS 15
00019 
00020 /** AES matrix */
00021 union aes_matrix {
00022         /** Viewed as an array of bytes */
00023         uint8_t byte[16];
00024         /** Viewed as an array of four-byte columns */
00025         uint32_t column[4];
00026 } __attribute__ (( packed ));
00027 
00028 /** AES round keys */
00029 struct aes_round_keys {
00030         /** Round keys */
00031         union aes_matrix key[AES_MAX_ROUNDS];
00032 };
00033 
00034 /** AES context */
00035 struct aes_context {
00036         /** Encryption keys */
00037         struct aes_round_keys encrypt;
00038         /** Decryption keys */
00039         struct aes_round_keys decrypt;
00040         /** Number of rounds */
00041         unsigned int rounds;
00042 };
00043 
00044 /** AES context size */
00045 #define AES_CTX_SIZE sizeof ( struct aes_context )
00046 
00047 extern struct cipher_algorithm aes_algorithm;
00048 extern struct cipher_algorithm aes_ecb_algorithm;
00049 extern struct cipher_algorithm aes_cbc_algorithm;
00050 
00051 int aes_wrap ( const void *kek, const void *src, void *dest, int nblk );
00052 int aes_unwrap ( const void *kek, const void *src, void *dest, int nblk );
00053 
00054 #endif /* _IPXE_AES_H */