summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2023-07-07 10:11:23 +0000
committerjsing <>2023-07-07 10:11:23 +0000
commitf8c386b4497320d43da02ba9bffc5aa7062baa43 (patch)
treed0cbe250a19bca37eff232d9064039f3fa2c5225 /src
parent6ea82145ffd926a08c6b5ef08a38133add7d8f14 (diff)
downloadopenbsd-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.c77
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
124static int RSA_eay_public_encrypt(int flen, const unsigned char *from,
125 unsigned char *to, RSA *rsa, int padding);
126static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
127 unsigned char *to, RSA *rsa, int padding);
128static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
129 unsigned char *to, RSA *rsa, int padding);
130static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
131 unsigned char *to, RSA *rsa, int padding);
132static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *i, RSA *rsa, BN_CTX *ctx);
133static int RSA_eay_init(RSA *rsa);
134static int RSA_eay_finish(RSA *rsa);
135
136static 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
148const RSA_METHOD *
149RSA_PKCS1_OpenSSL(void)
150{
151 return &rsa_pkcs1_eay_meth;
152}
153
154const RSA_METHOD *
155RSA_PKCS1_SSLeay(void)
156{
157 return &rsa_pkcs1_eay_meth;
158}
159
160static int 124static int
161RSA_eay_public_encrypt(int flen, const unsigned char *from, unsigned char *to, 125rsa_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 */
350static int 314static int
351RSA_eay_private_encrypt(int flen, const unsigned char *from, unsigned char *to, 315rsa_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
478static int 442static int
479RSA_eay_private_decrypt(int flen, const unsigned char *from, unsigned char *to, 443rsa_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 */
603static int 567static int
604RSA_eay_public_decrypt(int flen, const unsigned char *from, unsigned char *to, 568rsa_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
703static int 667static int
704RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) 668rsa_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
854static int 818static int
855RSA_eay_init(RSA *rsa) 819rsa_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
861static int 825static int
862RSA_eay_finish(RSA *rsa) 826rsa_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
835static 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
847const RSA_METHOD *
848RSA_PKCS1_OpenSSL(void)
849{
850 return &rsa_pkcs1_meth;
851}
852
853const RSA_METHOD *
854RSA_PKCS1_SSLeay(void)
855{
856 return RSA_PKCS1_OpenSSL();
857}
858