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

aes.h 3.4 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. {
  21. #endif
  22. #define AES_BLOCK_SIZE 16
  23. #ifndef OPENSSL_NO_DEPRECATED_3_0
  24. #define AES_ENCRYPT 1
  25. #define AES_DECRYPT 0
  26. #define AES_MAXNR 14
  27. /* This should be a hidden type, but EVP requires that the size be known */
  28. struct aes_key_st
  29. {
  30. #ifdef AES_LONG
  31. unsigned long rd_key[4 * (AES_MAXNR + 1)];
  32. #else
  33. unsigned int rd_key[4 * (AES_MAXNR + 1)];
  34. #endif
  35. int rounds;
  36. };
  37. typedef struct aes_key_st AES_KEY;
  38. #endif
  39. #ifndef OPENSSL_NO_DEPRECATED_3_0
  40. OSSL_DEPRECATEDIN_3_0 const char* AES_options(void);
  41. OSSL_DEPRECATEDIN_3_0
  42. int AES_set_encrypt_key(const unsigned char* userKey, const int bits, AES_KEY* key);
  43. OSSL_DEPRECATEDIN_3_0
  44. int AES_set_decrypt_key(const unsigned char* userKey, const int bits, AES_KEY* key);
  45. OSSL_DEPRECATEDIN_3_0
  46. void AES_encrypt(const unsigned char* in, unsigned char* out, const AES_KEY* key);
  47. OSSL_DEPRECATEDIN_3_0
  48. void AES_decrypt(const unsigned char* in, unsigned char* out, const AES_KEY* key);
  49. OSSL_DEPRECATEDIN_3_0
  50. void AES_ecb_encrypt(const unsigned char* in, unsigned char* out, const AES_KEY* key, const int enc);
  51. OSSL_DEPRECATEDIN_3_0
  52. void AES_cbc_encrypt(const unsigned char* in, unsigned char* out, size_t length, const AES_KEY* key, unsigned char* ivec, const int enc);
  53. OSSL_DEPRECATEDIN_3_0
  54. void AES_cfb128_encrypt(const unsigned char* in, unsigned char* out, size_t length, const AES_KEY* key, unsigned char* ivec, int* num, const int enc);
  55. OSSL_DEPRECATEDIN_3_0
  56. void AES_cfb1_encrypt(const unsigned char* in, unsigned char* out, size_t length, const AES_KEY* key, unsigned char* ivec, int* num, const int enc);
  57. OSSL_DEPRECATEDIN_3_0
  58. void AES_cfb8_encrypt(const unsigned char* in, unsigned char* out, size_t length, const AES_KEY* key, unsigned char* ivec, int* num, const int enc);
  59. OSSL_DEPRECATEDIN_3_0
  60. void AES_ofb128_encrypt(const unsigned char* in, unsigned char* out, size_t length, const AES_KEY* key, unsigned char* ivec, int* num);
  61. /* NB: the IV is _two_ blocks long */
  62. OSSL_DEPRECATEDIN_3_0
  63. void AES_ige_encrypt(const unsigned char* in, unsigned char* out, size_t length, const AES_KEY* key, unsigned char* ivec, const int enc);
  64. /* NB: the IV is _four_ blocks long */
  65. OSSL_DEPRECATEDIN_3_0
  66. void AES_bi_ige_encrypt(const unsigned char* in, unsigned char* out, size_t length, const AES_KEY* key, const AES_KEY* key2, const unsigned char* ivec, const int enc);
  67. OSSL_DEPRECATEDIN_3_0
  68. int AES_wrap_key(AES_KEY* key, const unsigned char* iv, unsigned char* out, const unsigned char* in, unsigned int inlen);
  69. OSSL_DEPRECATEDIN_3_0
  70. int AES_unwrap_key(AES_KEY* key, const unsigned char* iv, unsigned char* out, const unsigned char* in, unsigned int inlen);
  71. #endif
  72. #ifdef __cplusplus
  73. }
  74. #endif
  75. #endif