Team Fortress 2 Source Code as on 22/4/2020
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.

38 lines
1.3 KiB

  1. /* Aes.h -- AES encryption / decryption
  2. 2013-01-18 : Igor Pavlov : Public domain */
  3. #ifndef __AES_H
  4. #define __AES_H
  5. #include "7zTypes.h"
  6. EXTERN_C_BEGIN
  7. #define AES_BLOCK_SIZE 16
  8. /* Call AesGenTables one time before other AES functions */
  9. void AesGenTables(void);
  10. /* UInt32 pointers must be 16-byte aligned */
  11. /* 16-byte (4 * 32-bit words) blocks: 1 (IV) + 1 (keyMode) + 15 (AES-256 roundKeys) */
  12. #define AES_NUM_IVMRK_WORDS ((1 + 1 + 15) * 4)
  13. /* aes - 16-byte aligned pointer to keyMode+roundKeys sequence */
  14. /* keySize = 16 or 24 or 32 (bytes) */
  15. typedef void (MY_FAST_CALL *AES_SET_KEY_FUNC)(UInt32 *aes, const Byte *key, unsigned keySize);
  16. void MY_FAST_CALL Aes_SetKey_Enc(UInt32 *aes, const Byte *key, unsigned keySize);
  17. void MY_FAST_CALL Aes_SetKey_Dec(UInt32 *aes, const Byte *key, unsigned keySize);
  18. /* ivAes - 16-byte aligned pointer to iv+keyMode+roundKeys sequence: UInt32[AES_NUM_IVMRK_WORDS] */
  19. void AesCbc_Init(UInt32 *ivAes, const Byte *iv); /* iv size is AES_BLOCK_SIZE */
  20. /* data - 16-byte aligned pointer to data */
  21. /* numBlocks - the number of 16-byte blocks in data array */
  22. typedef void (MY_FAST_CALL *AES_CODE_FUNC)(UInt32 *ivAes, Byte *data, size_t numBlocks);
  23. extern AES_CODE_FUNC g_AesCbc_Encode;
  24. extern AES_CODE_FUNC g_AesCbc_Decode;
  25. extern AES_CODE_FUNC g_AesCtr_Code;
  26. EXTERN_C_END
  27. #endif