You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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