diff options
author | jsing <> | 2023-07-07 10:11:23 +0000 |
---|---|---|
committer | jsing <> | 2023-07-07 10:11:23 +0000 |
commit | f8c386b4497320d43da02ba9bffc5aa7062baa43 (patch) | |
tree | d0cbe250a19bca37eff232d9064039f3fa2c5225 /src | |
parent | 6ea82145ffd926a08c6b5ef08a38133add7d8f14 (diff) | |
download | openbsd-f8c386b4497320d43da02ba9bffc5aa7062baa43.tar.gz openbsd-f8c386b4497320d43da02ba9bffc5aa7062baa43.tar.bz2 openbsd-f8c386b4497320d43da02ba9bffc5aa7062baa43.zip |
Rename RSA_eay_* to rsa_*.
Rename all of the RSA_eay_* functions to rsa_*, as well as changing the
method name (and naming). Reorder things slightly so that we can remove
all of the prototypes for static functions.
ok tb@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_eay.c | 77 |
1 files changed, 33 insertions, 44 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_eay.c b/src/lib/libcrypto/rsa/rsa_eay.c index 6db563f2a4..cb44288c9a 100644 --- a/src/lib/libcrypto/rsa/rsa_eay.c +++ b/src/lib/libcrypto/rsa/rsa_eay.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: rsa_eay.c,v 1.60 2023/05/05 12:21:44 tb Exp $ */ | 1 | /* $OpenBSD: rsa_eay.c,v 1.61 2023/07/07 10:11:23 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -121,44 +121,8 @@ | |||
121 | #include "bn_local.h" | 121 | #include "bn_local.h" |
122 | #include "rsa_local.h" | 122 | #include "rsa_local.h" |
123 | 123 | ||
124 | static int RSA_eay_public_encrypt(int flen, const unsigned char *from, | ||
125 | unsigned char *to, RSA *rsa, int padding); | ||
126 | static int RSA_eay_private_encrypt(int flen, const unsigned char *from, | ||
127 | unsigned char *to, RSA *rsa, int padding); | ||
128 | static int RSA_eay_public_decrypt(int flen, const unsigned char *from, | ||
129 | unsigned char *to, RSA *rsa, int padding); | ||
130 | static int RSA_eay_private_decrypt(int flen, const unsigned char *from, | ||
131 | unsigned char *to, RSA *rsa, int padding); | ||
132 | static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *i, RSA *rsa, BN_CTX *ctx); | ||
133 | static int RSA_eay_init(RSA *rsa); | ||
134 | static int RSA_eay_finish(RSA *rsa); | ||
135 | |||
136 | static RSA_METHOD rsa_pkcs1_eay_meth = { | ||
137 | .name = "Eric Young's PKCS#1 RSA", | ||
138 | .rsa_pub_enc = RSA_eay_public_encrypt, | ||
139 | .rsa_pub_dec = RSA_eay_public_decrypt, /* signature verification */ | ||
140 | .rsa_priv_enc = RSA_eay_private_encrypt, /* signing */ | ||
141 | .rsa_priv_dec = RSA_eay_private_decrypt, | ||
142 | .rsa_mod_exp = RSA_eay_mod_exp, | ||
143 | .bn_mod_exp = BN_mod_exp_mont_ct, /* XXX probably we should not use Montgomery if e == 3 */ | ||
144 | .init = RSA_eay_init, | ||
145 | .finish = RSA_eay_finish, | ||
146 | }; | ||
147 | |||
148 | const RSA_METHOD * | ||
149 | RSA_PKCS1_OpenSSL(void) | ||
150 | { | ||
151 | return &rsa_pkcs1_eay_meth; | ||
152 | } | ||
153 | |||
154 | const RSA_METHOD * | ||
155 | RSA_PKCS1_SSLeay(void) | ||
156 | { | ||
157 | return &rsa_pkcs1_eay_meth; | ||
158 | } | ||
159 | |||
160 | static int | 124 | static int |
161 | RSA_eay_public_encrypt(int flen, const unsigned char *from, unsigned char *to, | 125 | rsa_public_encrypt(int flen, const unsigned char *from, unsigned char *to, |
162 | RSA *rsa, int padding) | 126 | RSA *rsa, int padding) |
163 | { | 127 | { |
164 | BIGNUM *f, *ret; | 128 | BIGNUM *f, *ret; |
@@ -348,7 +312,7 @@ rsa_blinding_invert(BN_BLINDING *b, BIGNUM *f, BIGNUM *unblind, BN_CTX *ctx) | |||
348 | 312 | ||
349 | /* signing */ | 313 | /* signing */ |
350 | static int | 314 | static int |
351 | RSA_eay_private_encrypt(int flen, const unsigned char *from, unsigned char *to, | 315 | rsa_private_encrypt(int flen, const unsigned char *from, unsigned char *to, |
352 | RSA *rsa, int padding) | 316 | RSA *rsa, int padding) |
353 | { | 317 | { |
354 | BIGNUM *f, *ret, *res; | 318 | BIGNUM *f, *ret, *res; |
@@ -476,7 +440,7 @@ err: | |||
476 | } | 440 | } |
477 | 441 | ||
478 | static int | 442 | static int |
479 | RSA_eay_private_decrypt(int flen, const unsigned char *from, unsigned char *to, | 443 | rsa_private_decrypt(int flen, const unsigned char *from, unsigned char *to, |
480 | RSA *rsa, int padding) | 444 | RSA *rsa, int padding) |
481 | { | 445 | { |
482 | BIGNUM *f, *ret; | 446 | BIGNUM *f, *ret; |
@@ -601,7 +565,7 @@ err: | |||
601 | 565 | ||
602 | /* signature verification */ | 566 | /* signature verification */ |
603 | static int | 567 | static int |
604 | RSA_eay_public_decrypt(int flen, const unsigned char *from, unsigned char *to, | 568 | rsa_public_decrypt(int flen, const unsigned char *from, unsigned char *to, |
605 | RSA *rsa, int padding) | 569 | RSA *rsa, int padding) |
606 | { | 570 | { |
607 | BIGNUM *f, *ret; | 571 | BIGNUM *f, *ret; |
@@ -701,7 +665,7 @@ err: | |||
701 | } | 665 | } |
702 | 666 | ||
703 | static int | 667 | static int |
704 | RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) | 668 | rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) |
705 | { | 669 | { |
706 | BIGNUM *r1, *m1, *vrfy; | 670 | BIGNUM *r1, *m1, *vrfy; |
707 | BIGNUM dmp1, dmq1, c, pr1; | 671 | BIGNUM dmp1, dmq1, c, pr1; |
@@ -852,14 +816,14 @@ err: | |||
852 | } | 816 | } |
853 | 817 | ||
854 | static int | 818 | static int |
855 | RSA_eay_init(RSA *rsa) | 819 | rsa_init(RSA *rsa) |
856 | { | 820 | { |
857 | rsa->flags |= RSA_FLAG_CACHE_PUBLIC | RSA_FLAG_CACHE_PRIVATE; | 821 | rsa->flags |= RSA_FLAG_CACHE_PUBLIC | RSA_FLAG_CACHE_PRIVATE; |
858 | return 1; | 822 | return 1; |
859 | } | 823 | } |
860 | 824 | ||
861 | static int | 825 | static int |
862 | RSA_eay_finish(RSA *rsa) | 826 | rsa_finish(RSA *rsa) |
863 | { | 827 | { |
864 | BN_MONT_CTX_free(rsa->_method_mod_n); | 828 | BN_MONT_CTX_free(rsa->_method_mod_n); |
865 | BN_MONT_CTX_free(rsa->_method_mod_p); | 829 | BN_MONT_CTX_free(rsa->_method_mod_p); |
@@ -867,3 +831,28 @@ RSA_eay_finish(RSA *rsa) | |||
867 | 831 | ||
868 | return 1; | 832 | return 1; |
869 | } | 833 | } |
834 | |||
835 | static const RSA_METHOD rsa_pkcs1_meth = { | ||
836 | .name = "OpenSSL PKCS#1 RSA", | ||
837 | .rsa_pub_enc = rsa_public_encrypt, | ||
838 | .rsa_pub_dec = rsa_public_decrypt, /* signature verification */ | ||
839 | .rsa_priv_enc = rsa_private_encrypt, /* signing */ | ||
840 | .rsa_priv_dec = rsa_private_decrypt, | ||
841 | .rsa_mod_exp = rsa_mod_exp, | ||
842 | .bn_mod_exp = BN_mod_exp_mont_ct, /* XXX probably we should not use Montgomery if e == 3 */ | ||
843 | .init = rsa_init, | ||
844 | .finish = rsa_finish, | ||
845 | }; | ||
846 | |||
847 | const RSA_METHOD * | ||
848 | RSA_PKCS1_OpenSSL(void) | ||
849 | { | ||
850 | return &rsa_pkcs1_meth; | ||
851 | } | ||
852 | |||
853 | const RSA_METHOD * | ||
854 | RSA_PKCS1_SSLeay(void) | ||
855 | { | ||
856 | return RSA_PKCS1_OpenSSL(); | ||
857 | } | ||
858 | |||