summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/evp/e_aes.c80
1 files changed, 24 insertions, 56 deletions
diff --git a/src/lib/libcrypto/evp/e_aes.c b/src/lib/libcrypto/evp/e_aes.c
index 274c20df60..14b39dba7d 100644
--- a/src/lib/libcrypto/evp/e_aes.c
+++ b/src/lib/libcrypto/evp/e_aes.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_aes.c,v 1.43 2022/08/02 07:51:37 jsing Exp $ */ 1/* $OpenBSD: e_aes.c,v 1.44 2022/08/04 08:00:11 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -257,26 +257,6 @@ aesni_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
257 return 1; 257 return 1;
258} 258}
259 259
260#define aesni_ofb_cipher aes_ofb_cipher
261static int aesni_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
262 const unsigned char *in, size_t len);
263
264#define aesni_cfb_cipher aes_cfb_cipher
265static int aesni_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
266 const unsigned char *in, size_t len);
267
268#define aesni_cfb8_cipher aes_cfb8_cipher
269static int aesni_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
270 const unsigned char *in, size_t len);
271
272#define aesni_cfb1_cipher aes_cfb1_cipher
273static int aesni_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
274 const unsigned char *in, size_t len);
275
276#define aesni_ctr_cipher aes_ctr_cipher
277static int aesni_ctr_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
278 const unsigned char *in, size_t len);
279
280static int 260static int
281aesni_gcm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 261aesni_gcm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
282 const unsigned char *iv, int enc) 262 const unsigned char *iv, int enc)
@@ -312,10 +292,6 @@ aesni_gcm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
312 return 1; 292 return 1;
313} 293}
314 294
315#define aesni_gcm_cipher aes_gcm_cipher
316static int aesni_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
317 const unsigned char *in, size_t len);
318
319static int 295static int
320aesni_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 296aesni_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
321 const unsigned char *iv, int enc) 297 const unsigned char *iv, int enc)
@@ -354,10 +330,6 @@ aesni_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
354 return 1; 330 return 1;
355} 331}
356 332
357#define aesni_xts_cipher aes_xts_cipher
358static int aesni_xts_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
359 const unsigned char *in, size_t len);
360
361static int 333static int
362aesni_ccm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 334aesni_ccm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
363 const unsigned char *iv, int enc) 335 const unsigned char *iv, int enc)
@@ -381,10 +353,6 @@ aesni_ccm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
381 return 1; 353 return 1;
382} 354}
383 355
384#define aesni_ccm_cipher aes_ccm_cipher
385static int aesni_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
386 const unsigned char *in, size_t len);
387
388#endif 356#endif
389 357
390static int 358static int
@@ -645,7 +613,7 @@ static const EVP_CIPHER aesni_128_ofb = {
645 .iv_len = 16, 613 .iv_len = 16,
646 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_OFB_MODE, 614 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_OFB_MODE,
647 .init = aesni_init_key, 615 .init = aesni_init_key,
648 .do_cipher = aesni_ofb_cipher, 616 .do_cipher = aes_ofb_cipher,
649 .ctx_size = sizeof(EVP_AES_KEY), 617 .ctx_size = sizeof(EVP_AES_KEY),
650}; 618};
651#endif 619#endif
@@ -679,7 +647,7 @@ static const EVP_CIPHER aesni_128_cfb = {
679 .iv_len = 16, 647 .iv_len = 16,
680 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CFB_MODE, 648 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CFB_MODE,
681 .init = aesni_init_key, 649 .init = aesni_init_key,
682 .do_cipher = aesni_cfb_cipher, 650 .do_cipher = aes_cfb_cipher,
683 .ctx_size = sizeof(EVP_AES_KEY), 651 .ctx_size = sizeof(EVP_AES_KEY),
684}; 652};
685#endif 653#endif
@@ -713,7 +681,7 @@ static const EVP_CIPHER aesni_128_cfb1 = {
713 .iv_len = 16, 681 .iv_len = 16,
714 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CFB_MODE, 682 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CFB_MODE,
715 .init = aesni_init_key, 683 .init = aesni_init_key,
716 .do_cipher = aesni_cfb1_cipher, 684 .do_cipher = aes_cfb1_cipher,
717 .ctx_size = sizeof(EVP_AES_KEY), 685 .ctx_size = sizeof(EVP_AES_KEY),
718}; 686};
719#endif 687#endif
@@ -747,7 +715,7 @@ static const EVP_CIPHER aesni_128_cfb8 = {
747 .iv_len = 16, 715 .iv_len = 16,
748 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CFB_MODE, 716 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CFB_MODE,
749 .init = aesni_init_key, 717 .init = aesni_init_key,
750 .do_cipher = aesni_cfb8_cipher, 718 .do_cipher = aes_cfb8_cipher,
751 .ctx_size = sizeof(EVP_AES_KEY), 719 .ctx_size = sizeof(EVP_AES_KEY),
752}; 720};
753#endif 721#endif
@@ -781,7 +749,7 @@ static const EVP_CIPHER aesni_128_ctr = {
781 .iv_len = 16, 749 .iv_len = 16,
782 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CTR_MODE, 750 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CTR_MODE,
783 .init = aesni_init_key, 751 .init = aesni_init_key,
784 .do_cipher = aesni_ctr_cipher, 752 .do_cipher = aes_ctr_cipher,
785 .ctx_size = sizeof(EVP_AES_KEY), 753 .ctx_size = sizeof(EVP_AES_KEY),
786}; 754};
787#endif 755#endif
@@ -884,7 +852,7 @@ static const EVP_CIPHER aesni_192_ofb = {
884 .iv_len = 16, 852 .iv_len = 16,
885 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_OFB_MODE, 853 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_OFB_MODE,
886 .init = aesni_init_key, 854 .init = aesni_init_key,
887 .do_cipher = aesni_ofb_cipher, 855 .do_cipher = aes_ofb_cipher,
888 .ctx_size = sizeof(EVP_AES_KEY), 856 .ctx_size = sizeof(EVP_AES_KEY),
889}; 857};
890#endif 858#endif
@@ -918,7 +886,7 @@ static const EVP_CIPHER aesni_192_cfb = {
918 .iv_len = 16, 886 .iv_len = 16,
919 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CFB_MODE, 887 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CFB_MODE,
920 .init = aesni_init_key, 888 .init = aesni_init_key,
921 .do_cipher = aesni_cfb_cipher, 889 .do_cipher = aes_cfb_cipher,
922 .ctx_size = sizeof(EVP_AES_KEY), 890 .ctx_size = sizeof(EVP_AES_KEY),
923}; 891};
924#endif 892#endif
@@ -952,7 +920,7 @@ static const EVP_CIPHER aesni_192_cfb1 = {
952 .iv_len = 16, 920 .iv_len = 16,
953 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CFB_MODE, 921 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CFB_MODE,
954 .init = aesni_init_key, 922 .init = aesni_init_key,
955 .do_cipher = aesni_cfb1_cipher, 923 .do_cipher = aes_cfb1_cipher,
956 .ctx_size = sizeof(EVP_AES_KEY), 924 .ctx_size = sizeof(EVP_AES_KEY),
957}; 925};
958#endif 926#endif
@@ -986,7 +954,7 @@ static const EVP_CIPHER aesni_192_cfb8 = {
986 .iv_len = 16, 954 .iv_len = 16,
987 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CFB_MODE, 955 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CFB_MODE,
988 .init = aesni_init_key, 956 .init = aesni_init_key,
989 .do_cipher = aesni_cfb8_cipher, 957 .do_cipher = aes_cfb8_cipher,
990 .ctx_size = sizeof(EVP_AES_KEY), 958 .ctx_size = sizeof(EVP_AES_KEY),
991}; 959};
992#endif 960#endif
@@ -1020,7 +988,7 @@ static const EVP_CIPHER aesni_192_ctr = {
1020 .iv_len = 16, 988 .iv_len = 16,
1021 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CTR_MODE, 989 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CTR_MODE,
1022 .init = aesni_init_key, 990 .init = aesni_init_key,
1023 .do_cipher = aesni_ctr_cipher, 991 .do_cipher = aes_ctr_cipher,
1024 .ctx_size = sizeof(EVP_AES_KEY), 992 .ctx_size = sizeof(EVP_AES_KEY),
1025}; 993};
1026#endif 994#endif
@@ -1123,7 +1091,7 @@ static const EVP_CIPHER aesni_256_ofb = {
1123 .iv_len = 16, 1091 .iv_len = 16,
1124 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_OFB_MODE, 1092 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_OFB_MODE,
1125 .init = aesni_init_key, 1093 .init = aesni_init_key,
1126 .do_cipher = aesni_ofb_cipher, 1094 .do_cipher = aes_ofb_cipher,
1127 .ctx_size = sizeof(EVP_AES_KEY), 1095 .ctx_size = sizeof(EVP_AES_KEY),
1128}; 1096};
1129#endif 1097#endif
@@ -1157,7 +1125,7 @@ static const EVP_CIPHER aesni_256_cfb = {
1157 .iv_len = 16, 1125 .iv_len = 16,
1158 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CFB_MODE, 1126 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CFB_MODE,
1159 .init = aesni_init_key, 1127 .init = aesni_init_key,
1160 .do_cipher = aesni_cfb_cipher, 1128 .do_cipher = aes_cfb_cipher,
1161 .ctx_size = sizeof(EVP_AES_KEY), 1129 .ctx_size = sizeof(EVP_AES_KEY),
1162}; 1130};
1163#endif 1131#endif
@@ -1191,7 +1159,7 @@ static const EVP_CIPHER aesni_256_cfb1 = {
1191 .iv_len = 16, 1159 .iv_len = 16,
1192 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CFB_MODE, 1160 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CFB_MODE,
1193 .init = aesni_init_key, 1161 .init = aesni_init_key,
1194 .do_cipher = aesni_cfb1_cipher, 1162 .do_cipher = aes_cfb1_cipher,
1195 .ctx_size = sizeof(EVP_AES_KEY), 1163 .ctx_size = sizeof(EVP_AES_KEY),
1196}; 1164};
1197#endif 1165#endif
@@ -1225,7 +1193,7 @@ static const EVP_CIPHER aesni_256_cfb8 = {
1225 .iv_len = 16, 1193 .iv_len = 16,
1226 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CFB_MODE, 1194 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CFB_MODE,
1227 .init = aesni_init_key, 1195 .init = aesni_init_key,
1228 .do_cipher = aesni_cfb8_cipher, 1196 .do_cipher = aes_cfb8_cipher,
1229 .ctx_size = sizeof(EVP_AES_KEY), 1197 .ctx_size = sizeof(EVP_AES_KEY),
1230}; 1198};
1231#endif 1199#endif
@@ -1259,7 +1227,7 @@ static const EVP_CIPHER aesni_256_ctr = {
1259 .iv_len = 16, 1227 .iv_len = 16,
1260 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CTR_MODE, 1228 .flags = EVP_CIPH_FLAG_FIPS | EVP_CIPH_CTR_MODE,
1261 .init = aesni_init_key, 1229 .init = aesni_init_key,
1262 .do_cipher = aesni_ctr_cipher, 1230 .do_cipher = aes_ctr_cipher,
1263 .ctx_size = sizeof(EVP_AES_KEY), 1231 .ctx_size = sizeof(EVP_AES_KEY),
1264}; 1232};
1265#endif 1233#endif
@@ -1673,7 +1641,7 @@ static const EVP_CIPHER aesni_128_gcm = {
1673 .iv_len = 12, 1641 .iv_len = 12,
1674 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS | EVP_CIPH_GCM_MODE, 1642 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS | EVP_CIPH_GCM_MODE,
1675 .init = aesni_gcm_init_key, 1643 .init = aesni_gcm_init_key,
1676 .do_cipher = aesni_gcm_cipher, 1644 .do_cipher = aes_gcm_cipher,
1677 .cleanup = aes_gcm_cleanup, 1645 .cleanup = aes_gcm_cleanup,
1678 .ctx_size = sizeof(EVP_AES_GCM_CTX), 1646 .ctx_size = sizeof(EVP_AES_GCM_CTX),
1679 .ctrl = aes_gcm_ctrl, 1647 .ctrl = aes_gcm_ctrl,
@@ -1715,7 +1683,7 @@ static const EVP_CIPHER aesni_192_gcm = {
1715 .iv_len = 12, 1683 .iv_len = 12,
1716 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS | EVP_CIPH_GCM_MODE, 1684 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS | EVP_CIPH_GCM_MODE,
1717 .init = aesni_gcm_init_key, 1685 .init = aesni_gcm_init_key,
1718 .do_cipher = aesni_gcm_cipher, 1686 .do_cipher = aes_gcm_cipher,
1719 .cleanup = aes_gcm_cleanup, 1687 .cleanup = aes_gcm_cleanup,
1720 .ctx_size = sizeof(EVP_AES_GCM_CTX), 1688 .ctx_size = sizeof(EVP_AES_GCM_CTX),
1721 .ctrl = aes_gcm_ctrl, 1689 .ctrl = aes_gcm_ctrl,
@@ -1757,7 +1725,7 @@ static const EVP_CIPHER aesni_256_gcm = {
1757 .iv_len = 12, 1725 .iv_len = 12,
1758 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS | EVP_CIPH_GCM_MODE, 1726 .flags = EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS | EVP_CIPH_GCM_MODE,
1759 .init = aesni_gcm_init_key, 1727 .init = aesni_gcm_init_key,
1760 .do_cipher = aesni_gcm_cipher, 1728 .do_cipher = aes_gcm_cipher,
1761 .cleanup = aes_gcm_cleanup, 1729 .cleanup = aes_gcm_cleanup,
1762 .ctx_size = sizeof(EVP_AES_GCM_CTX), 1730 .ctx_size = sizeof(EVP_AES_GCM_CTX),
1763 .ctrl = aes_gcm_ctrl, 1731 .ctrl = aes_gcm_ctrl,
@@ -1929,7 +1897,7 @@ static const EVP_CIPHER aesni_128_xts = {
1929 .iv_len = 16, 1897 .iv_len = 16,
1930 .flags = EVP_CIPH_FLAG_FIPS|XTS_FLAGS | EVP_CIPH_XTS_MODE, 1898 .flags = EVP_CIPH_FLAG_FIPS|XTS_FLAGS | EVP_CIPH_XTS_MODE,
1931 .init = aesni_xts_init_key, 1899 .init = aesni_xts_init_key,
1932 .do_cipher = aesni_xts_cipher, 1900 .do_cipher = aes_xts_cipher,
1933 .cleanup = aes_xts_cleanup, 1901 .cleanup = aes_xts_cleanup,
1934 .ctx_size = sizeof(EVP_AES_XTS_CTX), 1902 .ctx_size = sizeof(EVP_AES_XTS_CTX),
1935 .ctrl = aes_xts_ctrl, 1903 .ctrl = aes_xts_ctrl,
@@ -1971,7 +1939,7 @@ static const EVP_CIPHER aesni_256_xts = {
1971 .iv_len = 16, 1939 .iv_len = 16,
1972 .flags = EVP_CIPH_FLAG_FIPS|XTS_FLAGS | EVP_CIPH_XTS_MODE, 1940 .flags = EVP_CIPH_FLAG_FIPS|XTS_FLAGS | EVP_CIPH_XTS_MODE,
1973 .init = aesni_xts_init_key, 1941 .init = aesni_xts_init_key,
1974 .do_cipher = aesni_xts_cipher, 1942 .do_cipher = aes_xts_cipher,
1975 .cleanup = aes_xts_cleanup, 1943 .cleanup = aes_xts_cleanup,
1976 .ctx_size = sizeof(EVP_AES_XTS_CTX), 1944 .ctx_size = sizeof(EVP_AES_XTS_CTX),
1977 .ctrl = aes_xts_ctrl, 1945 .ctrl = aes_xts_ctrl,
@@ -2174,7 +2142,7 @@ static const EVP_CIPHER aesni_128_ccm = {
2174 .iv_len = 12, 2142 .iv_len = 12,
2175 .flags = EVP_CIPH_FLAG_FIPS|CUSTOM_FLAGS | EVP_CIPH_CCM_MODE, 2143 .flags = EVP_CIPH_FLAG_FIPS|CUSTOM_FLAGS | EVP_CIPH_CCM_MODE,
2176 .init = aesni_ccm_init_key, 2144 .init = aesni_ccm_init_key,
2177 .do_cipher = aesni_ccm_cipher, 2145 .do_cipher = aes_ccm_cipher,
2178 .cleanup = aes_ccm_cleanup, 2146 .cleanup = aes_ccm_cleanup,
2179 .ctx_size = sizeof(EVP_AES_CCM_CTX), 2147 .ctx_size = sizeof(EVP_AES_CCM_CTX),
2180 .ctrl = aes_ccm_ctrl, 2148 .ctrl = aes_ccm_ctrl,
@@ -2216,7 +2184,7 @@ static const EVP_CIPHER aesni_192_ccm = {
2216 .iv_len = 12, 2184 .iv_len = 12,
2217 .flags = EVP_CIPH_FLAG_FIPS|CUSTOM_FLAGS | EVP_CIPH_CCM_MODE, 2185 .flags = EVP_CIPH_FLAG_FIPS|CUSTOM_FLAGS | EVP_CIPH_CCM_MODE,
2218 .init = aesni_ccm_init_key, 2186 .init = aesni_ccm_init_key,
2219 .do_cipher = aesni_ccm_cipher, 2187 .do_cipher = aes_ccm_cipher,
2220 .cleanup = aes_ccm_cleanup, 2188 .cleanup = aes_ccm_cleanup,
2221 .ctx_size = sizeof(EVP_AES_CCM_CTX), 2189 .ctx_size = sizeof(EVP_AES_CCM_CTX),
2222 .ctrl = aes_ccm_ctrl, 2190 .ctrl = aes_ccm_ctrl,
@@ -2258,7 +2226,7 @@ static const EVP_CIPHER aesni_256_ccm = {
2258 .iv_len = 12, 2226 .iv_len = 12,
2259 .flags = EVP_CIPH_FLAG_FIPS|CUSTOM_FLAGS | EVP_CIPH_CCM_MODE, 2227 .flags = EVP_CIPH_FLAG_FIPS|CUSTOM_FLAGS | EVP_CIPH_CCM_MODE,
2260 .init = aesni_ccm_init_key, 2228 .init = aesni_ccm_init_key,
2261 .do_cipher = aesni_ccm_cipher, 2229 .do_cipher = aes_ccm_cipher,
2262 .cleanup = aes_ccm_cleanup, 2230 .cleanup = aes_ccm_cleanup,
2263 .ctx_size = sizeof(EVP_AES_CCM_CTX), 2231 .ctx_size = sizeof(EVP_AES_CCM_CTX),
2264 .ctrl = aes_ccm_ctrl, 2232 .ctrl = aes_ccm_ctrl,