diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/aes/aes.c | 40 | ||||
-rw-r--r-- | src/lib/libcrypto/aes/aes_core.c | 63 |
2 files changed, 47 insertions, 56 deletions
diff --git a/src/lib/libcrypto/aes/aes.c b/src/lib/libcrypto/aes/aes.c index d36a006360..3dc2c9a458 100644 --- a/src/lib/libcrypto/aes/aes.c +++ b/src/lib/libcrypto/aes/aes.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: aes.c,v 1.4 2024/08/11 13:02:39 jsing Exp $ */ | 1 | /* $OpenBSD: aes.c,v 1.5 2025/04/20 09:17:53 jsing Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -46,7 +46,6 @@ | |||
46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
48 | * ==================================================================== | 48 | * ==================================================================== |
49 | * | ||
50 | */ | 49 | */ |
51 | 50 | ||
52 | #include <string.h> | 51 | #include <string.h> |
@@ -61,6 +60,43 @@ static const unsigned char aes_wrap_default_iv[] = { | |||
61 | 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, | 60 | 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, |
62 | }; | 61 | }; |
63 | 62 | ||
63 | int aes_set_encrypt_key_internal(const unsigned char *userKey, const int bits, | ||
64 | AES_KEY *key); | ||
65 | int aes_set_decrypt_key_internal(const unsigned char *userKey, const int bits, | ||
66 | AES_KEY *key); | ||
67 | void aes_encrypt_internal(const unsigned char *in, unsigned char *out, | ||
68 | const AES_KEY *key); | ||
69 | void aes_decrypt_internal(const unsigned char *in, unsigned char *out, | ||
70 | const AES_KEY *key); | ||
71 | |||
72 | int | ||
73 | AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) | ||
74 | { | ||
75 | return aes_set_encrypt_key_internal(userKey, bits, key); | ||
76 | } | ||
77 | LCRYPTO_ALIAS(AES_set_encrypt_key); | ||
78 | |||
79 | int | ||
80 | AES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) | ||
81 | { | ||
82 | return aes_set_decrypt_key_internal(userKey, bits, key); | ||
83 | } | ||
84 | LCRYPTO_ALIAS(AES_set_decrypt_key); | ||
85 | |||
86 | void | ||
87 | AES_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key) | ||
88 | { | ||
89 | aes_encrypt_internal(in, out, key); | ||
90 | } | ||
91 | LCRYPTO_ALIAS(AES_encrypt); | ||
92 | |||
93 | void | ||
94 | AES_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key) | ||
95 | { | ||
96 | aes_decrypt_internal(in, out, key); | ||
97 | } | ||
98 | LCRYPTO_ALIAS(AES_decrypt); | ||
99 | |||
64 | #ifdef HAVE_AES_CBC_ENCRYPT_INTERNAL | 100 | #ifdef HAVE_AES_CBC_ENCRYPT_INTERNAL |
65 | void aes_cbc_encrypt_internal(const unsigned char *in, unsigned char *out, | 101 | void aes_cbc_encrypt_internal(const unsigned char *in, unsigned char *out, |
66 | size_t len, const AES_KEY *key, unsigned char *ivec, const int enc); | 102 | size_t len, const AES_KEY *key, unsigned char *ivec, const int enc); |
diff --git a/src/lib/libcrypto/aes/aes_core.c b/src/lib/libcrypto/aes/aes_core.c index 4383d74903..687cd60fe7 100644 --- a/src/lib/libcrypto/aes/aes_core.c +++ b/src/lib/libcrypto/aes/aes_core.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: aes_core.c,v 1.25 2024/11/13 21:00:57 tb Exp $ */ | 1 | /* $OpenBSD: aes_core.c,v 1.26 2025/04/20 09:17:53 jsing Exp $ */ |
2 | /** | 2 | /** |
3 | * rijndael-alg-fst.c | 3 | * rijndael-alg-fst.c |
4 | * | 4 | * |
@@ -633,16 +633,11 @@ static const u32 rcon[] = { | |||
633 | }; | 633 | }; |
634 | #endif | 634 | #endif |
635 | 635 | ||
636 | #ifdef HAVE_AES_SET_ENCRYPT_KEY_INTERNAL | 636 | #ifndef HAVE_AES_SET_ENCRYPT_KEY_INTERNAL |
637 | int aes_set_encrypt_key_internal(const unsigned char *userKey, const int bits, | ||
638 | AES_KEY *key); | ||
639 | |||
640 | #else | ||
641 | |||
642 | /* | 637 | /* |
643 | * Expand the cipher key into the encryption key schedule. | 638 | * Expand the cipher key into the encryption key schedule. |
644 | */ | 639 | */ |
645 | static inline int | 640 | int |
646 | aes_set_encrypt_key_internal(const unsigned char *userKey, const int bits, | 641 | aes_set_encrypt_key_internal(const unsigned char *userKey, const int bits, |
647 | AES_KEY *key) | 642 | AES_KEY *key) |
648 | { | 643 | { |
@@ -742,22 +737,11 @@ aes_set_encrypt_key_internal(const unsigned char *userKey, const int bits, | |||
742 | } | 737 | } |
743 | #endif | 738 | #endif |
744 | 739 | ||
745 | int | 740 | #ifndef HAVE_AES_SET_DECRYPT_KEY_INTERNAL |
746 | AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) | ||
747 | { | ||
748 | return aes_set_encrypt_key_internal(userKey, bits, key); | ||
749 | } | ||
750 | LCRYPTO_ALIAS(AES_set_encrypt_key); | ||
751 | |||
752 | #ifdef HAVE_AES_SET_DECRYPT_KEY_INTERNAL | ||
753 | int aes_set_decrypt_key_internal(const unsigned char *userKey, const int bits, | ||
754 | AES_KEY *key); | ||
755 | |||
756 | #else | ||
757 | /* | 741 | /* |
758 | * Expand the cipher key into the decryption key schedule. | 742 | * Expand the cipher key into the decryption key schedule. |
759 | */ | 743 | */ |
760 | static inline int | 744 | int |
761 | aes_set_decrypt_key_internal(const unsigned char *userKey, const int bits, | 745 | aes_set_decrypt_key_internal(const unsigned char *userKey, const int bits, |
762 | AES_KEY *key) | 746 | AES_KEY *key) |
763 | { | 747 | { |
@@ -815,22 +799,11 @@ aes_set_decrypt_key_internal(const unsigned char *userKey, const int bits, | |||
815 | } | 799 | } |
816 | #endif | 800 | #endif |
817 | 801 | ||
818 | int | 802 | #ifndef HAVE_AES_ENCRYPT_INTERNAL |
819 | AES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) | ||
820 | { | ||
821 | return aes_set_decrypt_key_internal(userKey, bits, key); | ||
822 | } | ||
823 | LCRYPTO_ALIAS(AES_set_decrypt_key); | ||
824 | |||
825 | #ifdef HAVE_AES_ENCRYPT_INTERNAL | ||
826 | void aes_encrypt_internal(const unsigned char *in, unsigned char *out, | ||
827 | const AES_KEY *key); | ||
828 | |||
829 | #else | ||
830 | /* | 803 | /* |
831 | * Encrypt a single block - in and out can overlap. | 804 | * Encrypt a single block - in and out can overlap. |
832 | */ | 805 | */ |
833 | static inline void | 806 | void |
834 | aes_encrypt_internal(const unsigned char *in, unsigned char *out, | 807 | aes_encrypt_internal(const unsigned char *in, unsigned char *out, |
835 | const AES_KEY *key) | 808 | const AES_KEY *key) |
836 | { | 809 | { |
@@ -1018,22 +991,11 @@ aes_encrypt_internal(const unsigned char *in, unsigned char *out, | |||
1018 | } | 991 | } |
1019 | #endif | 992 | #endif |
1020 | 993 | ||
1021 | void | 994 | #ifndef HAVE_AES_DECRYPT_INTERNAL |
1022 | AES_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key) | ||
1023 | { | ||
1024 | aes_encrypt_internal(in, out, key); | ||
1025 | } | ||
1026 | LCRYPTO_ALIAS(AES_encrypt); | ||
1027 | |||
1028 | #ifdef HAVE_AES_DECRYPT_INTERNAL | ||
1029 | void aes_decrypt_internal(const unsigned char *in, unsigned char *out, | ||
1030 | const AES_KEY *key); | ||
1031 | |||
1032 | #else | ||
1033 | /* | 995 | /* |
1034 | * Decrypt a single block - in and out can overlap. | 996 | * Decrypt a single block - in and out can overlap. |
1035 | */ | 997 | */ |
1036 | static inline void | 998 | void |
1037 | aes_decrypt_internal(const unsigned char *in, unsigned char *out, | 999 | aes_decrypt_internal(const unsigned char *in, unsigned char *out, |
1038 | const AES_KEY *key) | 1000 | const AES_KEY *key) |
1039 | { | 1001 | { |
@@ -1220,10 +1182,3 @@ aes_decrypt_internal(const unsigned char *in, unsigned char *out, | |||
1220 | crypto_store_htobe32(&out[3 * 4], s3); | 1182 | crypto_store_htobe32(&out[3 * 4], s3); |
1221 | } | 1183 | } |
1222 | #endif | 1184 | #endif |
1223 | |||
1224 | void | ||
1225 | AES_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key) | ||
1226 | { | ||
1227 | aes_decrypt_internal(in, out, key); | ||
1228 | } | ||
1229 | LCRYPTO_ALIAS(AES_decrypt); | ||