Source code of Windows XP (NT5)
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.

134 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. aes.h
  5. Abstract:
  6. This module contains the public data structures and API definitions
  7. needed to utilize the low-level AES encryption routines
  8. Author:
  9. Scott Field (SField) 09-October-2000
  10. Revision History:
  11. --*/
  12. #ifndef __AES_H__
  13. #define __AES_H__
  14. #ifndef RSA32API
  15. #define RSA32API __stdcall
  16. #endif
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #define AES_ROUNDS_128 (10)
  21. #define AES_ROUNDS_192 (12)
  22. #define AES_ROUNDS_256 (14)
  23. #define AES_MAXROUNDS AES_ROUNDS_256
  24. typedef struct {
  25. int rounds; // keytab data ends up padded.
  26. unsigned char keytabenc[AES_MAXROUNDS+1][4][4];
  27. unsigned char keytabdec[AES_MAXROUNDS+1][4][4];
  28. } AESTable;
  29. typedef struct {
  30. int rounds; // keytab data ends up padded.
  31. unsigned char keytabenc[AES_ROUNDS_128+1][4][4];
  32. unsigned char keytabdec[AES_ROUNDS_128+1][4][4];
  33. } AESTable_128;
  34. typedef struct {
  35. int rounds; // keytab data ends up padded.
  36. unsigned char keytabenc[AES_ROUNDS_192+1][4][4];
  37. unsigned char keytabdec[AES_ROUNDS_192+1][4][4];
  38. } AESTable_192;
  39. typedef struct {
  40. int rounds; // keytab data ends up padded.
  41. unsigned char keytabenc[AES_ROUNDS_256+1][4][4];
  42. unsigned char keytabdec[AES_ROUNDS_256+1][4][4];
  43. } AESTable_256;
  44. #define AES_TABLESIZE (sizeof(AESTable))
  45. #define AES_TABLESIZE_128 (sizeof(AESTable_128))
  46. #define AES_TABLESIZE_192 (sizeof(AESTable_192))
  47. #define AES_TABLESIZE_256 (sizeof(AESTable_256))
  48. #define AES_BLOCKLEN (16)
  49. #define AES_KEYSIZE (32)
  50. #define AES_KEYSIZE_128 (16)
  51. #define AES_KEYSIZE_192 (24)
  52. #define AES_KEYSIZE_256 (32)
  53. void
  54. RSA32API
  55. aeskey(
  56. AESTable *KeyTable,
  57. BYTE *Key,
  58. int rounds
  59. );
  60. //
  61. // generic AES crypt function -- caller can pass in keyin corresponding
  62. // to any valid keysize.
  63. //
  64. void
  65. RSA32API
  66. aes(
  67. BYTE *pbOut,
  68. BYTE *pbIn,
  69. void *keyin,
  70. int op
  71. );
  72. //
  73. // AES crypt functions that can be used by a caller that passes in a keyin
  74. // corresponding to a known keysize.
  75. //
  76. void
  77. RSA32API
  78. aes128(
  79. BYTE *pbOut,
  80. BYTE *pbIn,
  81. void *keyin,
  82. int op
  83. );
  84. void
  85. RSA32API
  86. aes256(
  87. BYTE *pbOut,
  88. BYTE *pbIn,
  89. void *keyin,
  90. int op
  91. );
  92. #ifdef __cplusplus
  93. }
  94. #endif
  95. #endif // __AES_H__