aes.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #ifndef OPENSSL_AES_H
  10. # define OPENSSL_AES_H
  11. # pragma once
  12. # include <openssl/macros.h>
  13. # ifndef OPENSSL_NO_DEPRECATED_3_0
  14. # define HEADER_AES_H
  15. # endif
  16. # include <openssl/opensslconf.h>
  17. # include <stddef.h>
  18. # ifdef __cplusplus
  19. extern "C" {
  20. # endif
  21. # define AES_BLOCK_SIZE 16
  22. # ifndef OPENSSL_NO_DEPRECATED_3_0
  23. # define AES_ENCRYPT 1
  24. # define AES_DECRYPT 0
  25. # define AES_MAXNR 14
  26. /* This should be a hidden type, but EVP requires that the size be known */
  27. struct aes_key_st {
  28. # ifdef AES_LONG
  29. unsigned long rd_key[4 * (AES_MAXNR + 1)];
  30. # else
  31. unsigned int rd_key[4 * (AES_MAXNR + 1)];
  32. # endif
  33. int rounds;
  34. };
  35. typedef struct aes_key_st AES_KEY;
  36. # endif
  37. # ifndef OPENSSL_NO_DEPRECATED_3_0
  38. OSSL_DEPRECATEDIN_3_0 const char *AES_options(void);
  39. OSSL_DEPRECATEDIN_3_0
  40. int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
  41. AES_KEY *key);
  42. OSSL_DEPRECATEDIN_3_0
  43. int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
  44. AES_KEY *key);
  45. OSSL_DEPRECATEDIN_3_0
  46. void AES_encrypt(const unsigned char *in, unsigned char *out,
  47. const AES_KEY *key);
  48. OSSL_DEPRECATEDIN_3_0
  49. void AES_decrypt(const unsigned char *in, unsigned char *out,
  50. const AES_KEY *key);
  51. OSSL_DEPRECATEDIN_3_0
  52. void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
  53. const AES_KEY *key, const int enc);
  54. OSSL_DEPRECATEDIN_3_0
  55. void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
  56. size_t length, const AES_KEY *key,
  57. unsigned char *ivec, const int enc);
  58. OSSL_DEPRECATEDIN_3_0
  59. void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
  60. size_t length, const AES_KEY *key,
  61. unsigned char *ivec, int *num, const int enc);
  62. OSSL_DEPRECATEDIN_3_0
  63. void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
  64. size_t length, const AES_KEY *key,
  65. unsigned char *ivec, int *num, const int enc);
  66. OSSL_DEPRECATEDIN_3_0
  67. void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
  68. size_t length, const AES_KEY *key,
  69. unsigned char *ivec, int *num, const int enc);
  70. OSSL_DEPRECATEDIN_3_0
  71. void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
  72. size_t length, const AES_KEY *key,
  73. unsigned char *ivec, int *num);
  74. /* NB: the IV is _two_ blocks long */
  75. OSSL_DEPRECATEDIN_3_0
  76. void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
  77. size_t length, const AES_KEY *key,
  78. unsigned char *ivec, const int enc);
  79. /* NB: the IV is _four_ blocks long */
  80. OSSL_DEPRECATEDIN_3_0
  81. void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
  82. size_t length, const AES_KEY *key, const AES_KEY *key2,
  83. const unsigned char *ivec, const int enc);
  84. OSSL_DEPRECATEDIN_3_0
  85. int AES_wrap_key(AES_KEY *key, const unsigned char *iv,
  86. unsigned char *out, const unsigned char *in,
  87. unsigned int inlen);
  88. OSSL_DEPRECATEDIN_3_0
  89. int AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
  90. unsigned char *out, const unsigned char *in,
  91. unsigned int inlen);
  92. # endif
  93. # ifdef __cplusplus
  94. }
  95. # endif
  96. #endif