aes_platform.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. /*
  2. * Copyright 2019-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 OSSL_AES_PLATFORM_H
  10. # define OSSL_AES_PLATFORM_H
  11. # include "openssl/aes.h"
  12. # ifdef VPAES_ASM
  13. int vpaes_set_encrypt_key(const unsigned char *userKey, int bits,
  14. AES_KEY *key);
  15. int vpaes_set_decrypt_key(const unsigned char *userKey, int bits,
  16. AES_KEY *key);
  17. void vpaes_encrypt(const unsigned char *in, unsigned char *out,
  18. const AES_KEY *key);
  19. void vpaes_decrypt(const unsigned char *in, unsigned char *out,
  20. const AES_KEY *key);
  21. void vpaes_cbc_encrypt(const unsigned char *in,
  22. unsigned char *out,
  23. size_t length,
  24. const AES_KEY *key, unsigned char *ivec, int enc);
  25. # endif /* VPAES_ASM */
  26. # ifdef BSAES_ASM
  27. void bsaes_cbc_encrypt(const unsigned char *in, unsigned char *out,
  28. size_t length, const AES_KEY *key,
  29. unsigned char ivec[16], int enc);
  30. void bsaes_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out,
  31. size_t len, const AES_KEY *key,
  32. const unsigned char ivec[16]);
  33. void bsaes_xts_encrypt(const unsigned char *inp, unsigned char *out,
  34. size_t len, const AES_KEY *key1,
  35. const AES_KEY *key2, const unsigned char iv[16]);
  36. void bsaes_xts_decrypt(const unsigned char *inp, unsigned char *out,
  37. size_t len, const AES_KEY *key1,
  38. const AES_KEY *key2, const unsigned char iv[16]);
  39. # endif /* BSAES_ASM */
  40. # ifdef AES_CTR_ASM
  41. void AES_ctr32_encrypt(const unsigned char *in, unsigned char *out,
  42. size_t blocks, const AES_KEY *key,
  43. const unsigned char ivec[AES_BLOCK_SIZE]);
  44. # endif /* AES_CTR_ASM */
  45. # ifdef AES_XTS_ASM
  46. void AES_xts_encrypt(const unsigned char *inp, unsigned char *out, size_t len,
  47. const AES_KEY *key1, const AES_KEY *key2,
  48. const unsigned char iv[16]);
  49. void AES_xts_decrypt(const unsigned char *inp, unsigned char *out, size_t len,
  50. const AES_KEY *key1, const AES_KEY *key2,
  51. const unsigned char iv[16]);
  52. # endif /* AES_XTS_ASM */
  53. # if defined(OPENSSL_CPUID_OBJ)
  54. # if (defined(__powerpc__) || defined(__ppc__) || defined(_ARCH_PPC))
  55. # include "ppc_arch.h"
  56. # ifdef VPAES_ASM
  57. # define VPAES_CAPABLE (OPENSSL_ppccap_P & PPC_ALTIVEC)
  58. # endif
  59. # define HWAES_CAPABLE (OPENSSL_ppccap_P & PPC_CRYPTO207)
  60. # define HWAES_set_encrypt_key aes_p8_set_encrypt_key
  61. # define HWAES_set_decrypt_key aes_p8_set_decrypt_key
  62. # define HWAES_encrypt aes_p8_encrypt
  63. # define HWAES_decrypt aes_p8_decrypt
  64. # define HWAES_cbc_encrypt aes_p8_cbc_encrypt
  65. # define HWAES_ctr32_encrypt_blocks aes_p8_ctr32_encrypt_blocks
  66. # define HWAES_xts_encrypt aes_p8_xts_encrypt
  67. # define HWAES_xts_decrypt aes_p8_xts_decrypt
  68. # endif /* PPC */
  69. # if (defined(__arm__) || defined(__arm) || defined(__aarch64__))
  70. # include "arm_arch.h"
  71. # if __ARM_MAX_ARCH__>=7
  72. # if defined(BSAES_ASM)
  73. # define BSAES_CAPABLE (OPENSSL_armcap_P & ARMV7_NEON)
  74. # endif
  75. # if defined(VPAES_ASM)
  76. # define VPAES_CAPABLE (OPENSSL_armcap_P & ARMV7_NEON)
  77. # endif
  78. # define HWAES_CAPABLE (OPENSSL_armcap_P & ARMV8_AES)
  79. # define HWAES_set_encrypt_key aes_v8_set_encrypt_key
  80. # define HWAES_set_decrypt_key aes_v8_set_decrypt_key
  81. # define HWAES_encrypt aes_v8_encrypt
  82. # define HWAES_decrypt aes_v8_decrypt
  83. # define HWAES_cbc_encrypt aes_v8_cbc_encrypt
  84. # define HWAES_ecb_encrypt aes_v8_ecb_encrypt
  85. # if __ARM_MAX_ARCH__>=8
  86. # define HWAES_xts_encrypt aes_v8_xts_encrypt
  87. # define HWAES_xts_decrypt aes_v8_xts_decrypt
  88. # endif
  89. # define HWAES_ctr32_encrypt_blocks aes_v8_ctr32_encrypt_blocks
  90. # define AES_PMULL_CAPABLE ((OPENSSL_armcap_P & ARMV8_PMULL) && (OPENSSL_armcap_P & ARMV8_AES))
  91. # define AES_GCM_ENC_BYTES 512
  92. # define AES_GCM_DEC_BYTES 512
  93. # if __ARM_MAX_ARCH__>=8
  94. # define AES_gcm_encrypt armv8_aes_gcm_encrypt
  95. # define AES_gcm_decrypt armv8_aes_gcm_decrypt
  96. # define AES_GCM_ASM(gctx) ((gctx)->ctr==aes_v8_ctr32_encrypt_blocks && \
  97. (gctx)->gcm.ghash==gcm_ghash_v8)
  98. size_t aes_gcm_enc_128_kernel(const uint8_t * plaintext, uint64_t plaintext_length, uint8_t * ciphertext,
  99. uint64_t *Xi, unsigned char ivec[16], const void *key);
  100. size_t aes_gcm_enc_192_kernel(const uint8_t * plaintext, uint64_t plaintext_length, uint8_t * ciphertext,
  101. uint64_t *Xi, unsigned char ivec[16], const void *key);
  102. size_t aes_gcm_enc_256_kernel(const uint8_t * plaintext, uint64_t plaintext_length, uint8_t * ciphertext,
  103. uint64_t *Xi, unsigned char ivec[16], const void *key);
  104. size_t aes_gcm_dec_128_kernel(const uint8_t * ciphertext, uint64_t plaintext_length, uint8_t * plaintext,
  105. uint64_t *Xi, unsigned char ivec[16], const void *key);
  106. size_t aes_gcm_dec_192_kernel(const uint8_t * ciphertext, uint64_t plaintext_length, uint8_t * plaintext,
  107. uint64_t *Xi, unsigned char ivec[16], const void *key);
  108. size_t aes_gcm_dec_256_kernel(const uint8_t * ciphertext, uint64_t plaintext_length, uint8_t * plaintext,
  109. uint64_t *Xi, unsigned char ivec[16], const void *key);
  110. size_t armv8_aes_gcm_encrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key,
  111. unsigned char ivec[16], u64 *Xi);
  112. size_t armv8_aes_gcm_decrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key,
  113. unsigned char ivec[16], u64 *Xi);
  114. void gcm_ghash_v8(u64 Xi[2],const u128 Htable[16],const u8 *inp, size_t len);
  115. # endif
  116. # endif
  117. # endif
  118. # endif /* OPENSSL_CPUID_OBJ */
  119. # if defined(AES_ASM) && ( \
  120. defined(__x86_64) || defined(__x86_64__) || \
  121. defined(_M_AMD64) || defined(_M_X64) )
  122. # define AES_CBC_HMAC_SHA_CAPABLE 1
  123. # define AESNI_CBC_HMAC_SHA_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(57-32)))
  124. # endif
  125. # if defined(AES_ASM) && !defined(I386_ONLY) && ( \
  126. ((defined(__i386) || defined(__i386__) || \
  127. defined(_M_IX86)) && defined(OPENSSL_IA32_SSE2))|| \
  128. defined(__x86_64) || defined(__x86_64__) || \
  129. defined(_M_AMD64) || defined(_M_X64) )
  130. /* AES-NI section */
  131. # define AESNI_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(57-32)))
  132. # ifdef VPAES_ASM
  133. # define VPAES_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(41-32)))
  134. # endif
  135. # ifdef BSAES_ASM
  136. # define BSAES_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(41-32)))
  137. # endif
  138. # define AES_GCM_ENC_BYTES 32
  139. # define AES_GCM_DEC_BYTES 16
  140. int aesni_set_encrypt_key(const unsigned char *userKey, int bits,
  141. AES_KEY *key);
  142. int aesni_set_decrypt_key(const unsigned char *userKey, int bits,
  143. AES_KEY *key);
  144. void aesni_encrypt(const unsigned char *in, unsigned char *out,
  145. const AES_KEY *key);
  146. void aesni_decrypt(const unsigned char *in, unsigned char *out,
  147. const AES_KEY *key);
  148. void aesni_ecb_encrypt(const unsigned char *in,
  149. unsigned char *out,
  150. size_t length, const AES_KEY *key, int enc);
  151. void aesni_cbc_encrypt(const unsigned char *in,
  152. unsigned char *out,
  153. size_t length,
  154. const AES_KEY *key, unsigned char *ivec, int enc);
  155. # ifndef OPENSSL_NO_OCB
  156. void aesni_ocb_encrypt(const unsigned char *in, unsigned char *out,
  157. size_t blocks, const void *key,
  158. size_t start_block_num,
  159. unsigned char offset_i[16],
  160. const unsigned char L_[][16],
  161. unsigned char checksum[16]);
  162. void aesni_ocb_decrypt(const unsigned char *in, unsigned char *out,
  163. size_t blocks, const void *key,
  164. size_t start_block_num,
  165. unsigned char offset_i[16],
  166. const unsigned char L_[][16],
  167. unsigned char checksum[16]);
  168. # endif /* OPENSSL_NO_OCB */
  169. void aesni_ctr32_encrypt_blocks(const unsigned char *in,
  170. unsigned char *out,
  171. size_t blocks,
  172. const void *key, const unsigned char *ivec);
  173. void aesni_xts_encrypt(const unsigned char *in,
  174. unsigned char *out,
  175. size_t length,
  176. const AES_KEY *key1, const AES_KEY *key2,
  177. const unsigned char iv[16]);
  178. void aesni_xts_decrypt(const unsigned char *in,
  179. unsigned char *out,
  180. size_t length,
  181. const AES_KEY *key1, const AES_KEY *key2,
  182. const unsigned char iv[16]);
  183. void aesni_ccm64_encrypt_blocks(const unsigned char *in,
  184. unsigned char *out,
  185. size_t blocks,
  186. const void *key,
  187. const unsigned char ivec[16],
  188. unsigned char cmac[16]);
  189. void aesni_ccm64_decrypt_blocks(const unsigned char *in,
  190. unsigned char *out,
  191. size_t blocks,
  192. const void *key,
  193. const unsigned char ivec[16],
  194. unsigned char cmac[16]);
  195. # if defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)
  196. size_t aesni_gcm_encrypt(const unsigned char *in, unsigned char *out, size_t len,
  197. const void *key, unsigned char ivec[16], u64 *Xi);
  198. size_t aesni_gcm_decrypt(const unsigned char *in, unsigned char *out, size_t len,
  199. const void *key, unsigned char ivec[16], u64 *Xi);
  200. void gcm_ghash_avx(u64 Xi[2], const u128 Htable[16], const u8 *in, size_t len);
  201. # define AES_gcm_encrypt aesni_gcm_encrypt
  202. # define AES_gcm_decrypt aesni_gcm_decrypt
  203. # define AES_GCM_ASM(ctx) (ctx->ctr == aesni_ctr32_encrypt_blocks && \
  204. ctx->gcm.ghash == gcm_ghash_avx)
  205. # endif
  206. # elif defined(AES_ASM) && (defined(__sparc) || defined(__sparc__))
  207. /* Fujitsu SPARC64 X support */
  208. extern unsigned int OPENSSL_sparcv9cap_P[];
  209. # include "sparc_arch.h"
  210. # define SPARC_AES_CAPABLE (OPENSSL_sparcv9cap_P[1] & CFR_AES)
  211. # define HWAES_CAPABLE (OPENSSL_sparcv9cap_P[0] & SPARCV9_FJAESX)
  212. # define HWAES_set_encrypt_key aes_fx_set_encrypt_key
  213. # define HWAES_set_decrypt_key aes_fx_set_decrypt_key
  214. # define HWAES_encrypt aes_fx_encrypt
  215. # define HWAES_decrypt aes_fx_decrypt
  216. # define HWAES_cbc_encrypt aes_fx_cbc_encrypt
  217. # define HWAES_ctr32_encrypt_blocks aes_fx_ctr32_encrypt_blocks
  218. void aes_t4_set_encrypt_key(const unsigned char *key, int bits, AES_KEY *ks);
  219. void aes_t4_set_decrypt_key(const unsigned char *key, int bits, AES_KEY *ks);
  220. void aes_t4_encrypt(const unsigned char *in, unsigned char *out,
  221. const AES_KEY *key);
  222. void aes_t4_decrypt(const unsigned char *in, unsigned char *out,
  223. const AES_KEY *key);
  224. /*
  225. * Key-length specific subroutines were chosen for following reason.
  226. * Each SPARC T4 core can execute up to 8 threads which share core's
  227. * resources. Loading as much key material to registers allows to
  228. * minimize references to shared memory interface, as well as amount
  229. * of instructions in inner loops [much needed on T4]. But then having
  230. * non-key-length specific routines would require conditional branches
  231. * either in inner loops or on subroutines' entries. Former is hardly
  232. * acceptable, while latter means code size increase to size occupied
  233. * by multiple key-length specific subroutines, so why fight?
  234. */
  235. void aes128_t4_cbc_encrypt(const unsigned char *in, unsigned char *out,
  236. size_t len, const AES_KEY *key,
  237. unsigned char *ivec);
  238. void aes128_t4_cbc_decrypt(const unsigned char *in, unsigned char *out,
  239. size_t len, const AES_KEY *key,
  240. unsigned char *ivec);
  241. void aes192_t4_cbc_encrypt(const unsigned char *in, unsigned char *out,
  242. size_t len, const AES_KEY *key,
  243. unsigned char *ivec);
  244. void aes192_t4_cbc_decrypt(const unsigned char *in, unsigned char *out,
  245. size_t len, const AES_KEY *key,
  246. unsigned char *ivec);
  247. void aes256_t4_cbc_encrypt(const unsigned char *in, unsigned char *out,
  248. size_t len, const AES_KEY *key,
  249. unsigned char *ivec);
  250. void aes256_t4_cbc_decrypt(const unsigned char *in, unsigned char *out,
  251. size_t len, const AES_KEY *key,
  252. unsigned char *ivec);
  253. void aes128_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out,
  254. size_t blocks, const AES_KEY *key,
  255. unsigned char *ivec);
  256. void aes192_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out,
  257. size_t blocks, const AES_KEY *key,
  258. unsigned char *ivec);
  259. void aes256_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out,
  260. size_t blocks, const AES_KEY *key,
  261. unsigned char *ivec);
  262. void aes128_t4_xts_encrypt(const unsigned char *in, unsigned char *out,
  263. size_t blocks, const AES_KEY *key1,
  264. const AES_KEY *key2, const unsigned char *ivec);
  265. void aes128_t4_xts_decrypt(const unsigned char *in, unsigned char *out,
  266. size_t blocks, const AES_KEY *key1,
  267. const AES_KEY *key2, const unsigned char *ivec);
  268. void aes256_t4_xts_encrypt(const unsigned char *in, unsigned char *out,
  269. size_t blocks, const AES_KEY *key1,
  270. const AES_KEY *key2, const unsigned char *ivec);
  271. void aes256_t4_xts_decrypt(const unsigned char *in, unsigned char *out,
  272. size_t blocks, const AES_KEY *key1,
  273. const AES_KEY *key2, const unsigned char *ivec);
  274. # elif defined(OPENSSL_CPUID_OBJ) && defined(__s390__)
  275. /* IBM S390X support */
  276. # include "s390x_arch.h"
  277. /* Convert key size to function code: [16,24,32] -> [18,19,20]. */
  278. # define S390X_AES_FC(keylen) (S390X_AES_128 + ((((keylen) << 3) - 128) >> 6))
  279. /* Most modes of operation need km for partial block processing. */
  280. # define S390X_aes_128_CAPABLE (OPENSSL_s390xcap_P.km[0] & \
  281. S390X_CAPBIT(S390X_AES_128))
  282. # define S390X_aes_192_CAPABLE (OPENSSL_s390xcap_P.km[0] & \
  283. S390X_CAPBIT(S390X_AES_192))
  284. # define S390X_aes_256_CAPABLE (OPENSSL_s390xcap_P.km[0] & \
  285. S390X_CAPBIT(S390X_AES_256))
  286. # define S390X_aes_128_cbc_CAPABLE 1 /* checked by callee */
  287. # define S390X_aes_192_cbc_CAPABLE 1
  288. # define S390X_aes_256_cbc_CAPABLE 1
  289. # define S390X_aes_128_ecb_CAPABLE S390X_aes_128_CAPABLE
  290. # define S390X_aes_192_ecb_CAPABLE S390X_aes_192_CAPABLE
  291. # define S390X_aes_256_ecb_CAPABLE S390X_aes_256_CAPABLE
  292. # define S390X_aes_128_ofb_CAPABLE (S390X_aes_128_CAPABLE && \
  293. (OPENSSL_s390xcap_P.kmo[0] & \
  294. S390X_CAPBIT(S390X_AES_128)))
  295. # define S390X_aes_192_ofb_CAPABLE (S390X_aes_192_CAPABLE && \
  296. (OPENSSL_s390xcap_P.kmo[0] & \
  297. S390X_CAPBIT(S390X_AES_192)))
  298. # define S390X_aes_256_ofb_CAPABLE (S390X_aes_256_CAPABLE && \
  299. (OPENSSL_s390xcap_P.kmo[0] & \
  300. S390X_CAPBIT(S390X_AES_256)))
  301. # define S390X_aes_128_cfb_CAPABLE (S390X_aes_128_CAPABLE && \
  302. (OPENSSL_s390xcap_P.kmf[0] & \
  303. S390X_CAPBIT(S390X_AES_128)))
  304. # define S390X_aes_192_cfb_CAPABLE (S390X_aes_192_CAPABLE && \
  305. (OPENSSL_s390xcap_P.kmf[0] & \
  306. S390X_CAPBIT(S390X_AES_192)))
  307. # define S390X_aes_256_cfb_CAPABLE (S390X_aes_256_CAPABLE && \
  308. (OPENSSL_s390xcap_P.kmf[0] & \
  309. S390X_CAPBIT(S390X_AES_256)))
  310. # define S390X_aes_128_cfb8_CAPABLE (OPENSSL_s390xcap_P.kmf[0] & \
  311. S390X_CAPBIT(S390X_AES_128))
  312. # define S390X_aes_192_cfb8_CAPABLE (OPENSSL_s390xcap_P.kmf[0] & \
  313. S390X_CAPBIT(S390X_AES_192))
  314. # define S390X_aes_256_cfb8_CAPABLE (OPENSSL_s390xcap_P.kmf[0] & \
  315. S390X_CAPBIT(S390X_AES_256))
  316. # define S390X_aes_128_cfb1_CAPABLE 0
  317. # define S390X_aes_192_cfb1_CAPABLE 0
  318. # define S390X_aes_256_cfb1_CAPABLE 0
  319. # define S390X_aes_128_ctr_CAPABLE 1 /* checked by callee */
  320. # define S390X_aes_192_ctr_CAPABLE 1
  321. # define S390X_aes_256_ctr_CAPABLE 1
  322. # define S390X_aes_128_xts_CAPABLE 1 /* checked by callee */
  323. # define S390X_aes_256_xts_CAPABLE 1
  324. # define S390X_aes_128_gcm_CAPABLE (S390X_aes_128_CAPABLE && \
  325. (OPENSSL_s390xcap_P.kma[0] & \
  326. S390X_CAPBIT(S390X_AES_128)))
  327. # define S390X_aes_192_gcm_CAPABLE (S390X_aes_192_CAPABLE && \
  328. (OPENSSL_s390xcap_P.kma[0] & \
  329. S390X_CAPBIT(S390X_AES_192)))
  330. # define S390X_aes_256_gcm_CAPABLE (S390X_aes_256_CAPABLE && \
  331. (OPENSSL_s390xcap_P.kma[0] & \
  332. S390X_CAPBIT(S390X_AES_256)))
  333. # define S390X_aes_128_ccm_CAPABLE (S390X_aes_128_CAPABLE && \
  334. (OPENSSL_s390xcap_P.kmac[0] & \
  335. S390X_CAPBIT(S390X_AES_128)))
  336. # define S390X_aes_192_ccm_CAPABLE (S390X_aes_192_CAPABLE && \
  337. (OPENSSL_s390xcap_P.kmac[0] & \
  338. S390X_CAPBIT(S390X_AES_192)))
  339. # define S390X_aes_256_ccm_CAPABLE (S390X_aes_256_CAPABLE && \
  340. (OPENSSL_s390xcap_P.kmac[0] & \
  341. S390X_CAPBIT(S390X_AES_256)))
  342. # define S390X_CCM_AAD_FLAG 0x40
  343. # ifndef OPENSSL_NO_OCB
  344. # define S390X_aes_128_ocb_CAPABLE 0
  345. # define S390X_aes_192_ocb_CAPABLE 0
  346. # define S390X_aes_256_ocb_CAPABLE 0
  347. # endif /* OPENSSL_NO_OCB */
  348. # ifndef OPENSSL_NO_SIV
  349. # define S390X_aes_128_siv_CAPABLE 0
  350. # define S390X_aes_192_siv_CAPABLE 0
  351. # define S390X_aes_256_siv_CAPABLE 0
  352. # endif /* OPENSSL_NO_SIV */
  353. /* Convert key size to function code: [16,24,32] -> [18,19,20]. */
  354. # define S390X_AES_FC(keylen) (S390X_AES_128 + ((((keylen) << 3) - 128) >> 6))
  355. # endif
  356. # if defined(HWAES_CAPABLE)
  357. int HWAES_set_encrypt_key(const unsigned char *userKey, const int bits,
  358. AES_KEY *key);
  359. int HWAES_set_decrypt_key(const unsigned char *userKey, const int bits,
  360. AES_KEY *key);
  361. void HWAES_encrypt(const unsigned char *in, unsigned char *out,
  362. const AES_KEY *key);
  363. void HWAES_decrypt(const unsigned char *in, unsigned char *out,
  364. const AES_KEY *key);
  365. void HWAES_cbc_encrypt(const unsigned char *in, unsigned char *out,
  366. size_t length, const AES_KEY *key,
  367. unsigned char *ivec, const int enc);
  368. void HWAES_ecb_encrypt(const unsigned char *in, unsigned char *out,
  369. size_t length, const AES_KEY *key,
  370. const int enc);
  371. void HWAES_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out,
  372. size_t len, const void *key,
  373. const unsigned char ivec[16]);
  374. void HWAES_xts_encrypt(const unsigned char *inp, unsigned char *out,
  375. size_t len, const AES_KEY *key1,
  376. const AES_KEY *key2, const unsigned char iv[16]);
  377. void HWAES_xts_decrypt(const unsigned char *inp, unsigned char *out,
  378. size_t len, const AES_KEY *key1,
  379. const AES_KEY *key2, const unsigned char iv[16]);
  380. # ifndef OPENSSL_NO_OCB
  381. # ifdef HWAES_ocb_encrypt
  382. void HWAES_ocb_encrypt(const unsigned char *in, unsigned char *out,
  383. size_t blocks, const void *key,
  384. size_t start_block_num,
  385. unsigned char offset_i[16],
  386. const unsigned char L_[][16],
  387. unsigned char checksum[16]);
  388. # else
  389. # define HWAES_ocb_encrypt ((ocb128_f)NULL)
  390. # endif
  391. # ifdef HWAES_ocb_decrypt
  392. void HWAES_ocb_decrypt(const unsigned char *in, unsigned char *out,
  393. size_t blocks, const void *key,
  394. size_t start_block_num,
  395. unsigned char offset_i[16],
  396. const unsigned char L_[][16],
  397. unsigned char checksum[16]);
  398. # else
  399. # define HWAES_ocb_decrypt ((ocb128_f)NULL)
  400. # endif
  401. # endif /* OPENSSL_NO_OCB */
  402. # endif /* HWAES_CAPABLE */
  403. #endif /* OSSL_AES_PLATFORM_H */