提交 bf160551 编写于 作者: R Rich Salz 提交者: Rich Salz

Rename RSA_eay_xxx to rsa_ossl_xxx

Final part of flushing out SSLEay API's.
Reviewed-by: NTim Hudson <tjh@openssl.org>
上级 a22c0124
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
*) All instances of the string "ssleay" in the public API were replaced *) All instances of the string "ssleay" in the public API were replaced
with OpenSSL (case-matching; e.g., OPENSSL_VERSION for #define's) with OpenSSL (case-matching; e.g., OPENSSL_VERSION for #define's)
Some error codes related to internal RSA_eay API's were renamed.
[Rich Salz] [Rich Salz]
*) The demo files in crypto/threads were moved to demo/threads. *) The demo files in crypto/threads were moved to demo/threads.
......
...@@ -15,11 +15,11 @@ CFLAGS= $(INCLUDES) $(CFLAG) ...@@ -15,11 +15,11 @@ CFLAGS= $(INCLUDES) $(CFLAG)
GENERAL=Makefile GENERAL=Makefile
LIB=$(TOP)/libcrypto.a LIB=$(TOP)/libcrypto.a
LIBSRC= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c \ LIBSRC= rsa_ossl.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c \
rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c rsa_null.c \ rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c rsa_null.c \
rsa_pss.c rsa_x931.c rsa_asn1.c rsa_depr.c rsa_ameth.c rsa_prn.c \ rsa_pss.c rsa_x931.c rsa_asn1.c rsa_depr.c rsa_ameth.c rsa_prn.c \
rsa_pmeth.c rsa_crpt.c rsa_x931g.c rsa_pmeth.c rsa_crpt.c rsa_x931g.c
LIBOBJ= rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o rsa_err.o \ LIBOBJ= rsa_ossl.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o rsa_err.o \
rsa_pk1.o rsa_ssl.o rsa_none.o rsa_oaep.o rsa_chk.o rsa_null.o \ rsa_pk1.o rsa_ssl.o rsa_none.o rsa_oaep.o rsa_chk.o rsa_null.o \
rsa_pss.o rsa_x931.o rsa_asn1.o rsa_depr.o rsa_ameth.o rsa_prn.o \ rsa_pss.o rsa_x931.o rsa_asn1.o rsa_depr.o rsa_ameth.o rsa_prn.o \
rsa_pmeth.o rsa_crpt.o rsa_x931g.o rsa_pmeth.o rsa_crpt.o rsa_x931g.o
...@@ -125,16 +125,6 @@ rsa_depr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h ...@@ -125,16 +125,6 @@ rsa_depr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
rsa_depr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h rsa_depr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
rsa_depr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h rsa_depr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
rsa_depr.o: ../include/internal/cryptlib.h rsa_depr.c rsa_depr.o: ../include/internal/cryptlib.h rsa_depr.c
rsa_eay.o: ../../e_os.h ../../include/openssl/asn1.h
rsa_eay.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
rsa_eay.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
rsa_eay.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
rsa_eay.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
rsa_eay.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
rsa_eay.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
rsa_eay.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
rsa_eay.o: ../../include/openssl/symhacks.h ../include/internal/bn_int.h
rsa_eay.o: ../include/internal/cryptlib.h rsa_eay.c
rsa_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h rsa_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
rsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h rsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
rsa_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h rsa_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
...@@ -199,6 +189,16 @@ rsa_oaep.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h ...@@ -199,6 +189,16 @@ rsa_oaep.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
rsa_oaep.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h rsa_oaep.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
rsa_oaep.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h rsa_oaep.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
rsa_oaep.o: ../include/internal/cryptlib.h rsa_oaep.c rsa_oaep.o: ../include/internal/cryptlib.h rsa_oaep.c
rsa_ossl.o: ../../e_os.h ../../include/openssl/asn1.h
rsa_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
rsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
rsa_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
rsa_ossl.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
rsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
rsa_ossl.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
rsa_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
rsa_ossl.o: ../../include/openssl/symhacks.h ../include/internal/bn_int.h
rsa_ossl.o: ../include/internal/cryptlib.h rsa_ossl.c
rsa_pk1.o: ../../e_os.h ../../include/internal/constant_time_locl.h rsa_pk1.o: ../../e_os.h ../../include/internal/constant_time_locl.h
rsa_pk1.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h rsa_pk1.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
rsa_pk1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h rsa_pk1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
......
...@@ -87,10 +87,10 @@ static ERR_STRING_DATA RSA_str_functs[] = { ...@@ -87,10 +87,10 @@ static ERR_STRING_DATA RSA_str_functs[] = {
{ERR_FUNC(RSA_F_RSA_CHECK_KEY), "RSA_check_key"}, {ERR_FUNC(RSA_F_RSA_CHECK_KEY), "RSA_check_key"},
{ERR_FUNC(RSA_F_RSA_CHECK_KEY_EX), "RSA_check_key_ex"}, {ERR_FUNC(RSA_F_RSA_CHECK_KEY_EX), "RSA_check_key_ex"},
{ERR_FUNC(RSA_F_RSA_CMS_DECRYPT), "rsa_cms_decrypt"}, {ERR_FUNC(RSA_F_RSA_CMS_DECRYPT), "rsa_cms_decrypt"},
{ERR_FUNC(RSA_F_RSA_EAY_PRIVATE_DECRYPT), "RSA_eay_private_decrypt"}, {ERR_FUNC(RSA_F_RSA_OSSL_PRIVATE_DECRYPT), "rsa_ossl_private_decrypt"},
{ERR_FUNC(RSA_F_RSA_EAY_PRIVATE_ENCRYPT), "RSA_eay_private_encrypt"}, {ERR_FUNC(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT), "rsa_ossl_private_encrypt"},
{ERR_FUNC(RSA_F_RSA_EAY_PUBLIC_DECRYPT), "RSA_eay_public_decrypt"}, {ERR_FUNC(RSA_F_RSA_OSSL_PUBLIC_DECRYPT), "rsa_ossl_public_decrypt"},
{ERR_FUNC(RSA_F_RSA_EAY_PUBLIC_ENCRYPT), "RSA_eay_public_encrypt"}, {ERR_FUNC(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT), "rsa_ossl_public_encrypt"},
{ERR_FUNC(RSA_F_RSA_GENERATE_KEY), "RSA_generate_key"}, {ERR_FUNC(RSA_F_RSA_GENERATE_KEY), "RSA_generate_key"},
{ERR_FUNC(RSA_F_RSA_ITEM_VERIFY), "rsa_item_verify"}, {ERR_FUNC(RSA_F_RSA_ITEM_VERIFY), "rsa_item_verify"},
{ERR_FUNC(RSA_F_RSA_MEMORY_LOCK), "RSA_memory_lock"}, {ERR_FUNC(RSA_F_RSA_MEMORY_LOCK), "RSA_memory_lock"},
...@@ -104,8 +104,7 @@ static ERR_STRING_DATA RSA_str_functs[] = { ...@@ -104,8 +104,7 @@ static ERR_STRING_DATA RSA_str_functs[] = {
{ERR_FUNC(RSA_F_RSA_NULL_PUBLIC_ENCRYPT), "RSA_null_public_encrypt"}, {ERR_FUNC(RSA_F_RSA_NULL_PUBLIC_ENCRYPT), "RSA_null_public_encrypt"},
{ERR_FUNC(RSA_F_RSA_OAEP_TO_CTX), "RSA_OAEP_TO_CTX"}, {ERR_FUNC(RSA_F_RSA_OAEP_TO_CTX), "RSA_OAEP_TO_CTX"},
{ERR_FUNC(RSA_F_RSA_PADDING_ADD_NONE), "RSA_padding_add_none"}, {ERR_FUNC(RSA_F_RSA_PADDING_ADD_NONE), "RSA_padding_add_none"},
{ERR_FUNC(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP), {ERR_FUNC(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP), "RSA_padding_add_PKCS1_OAEP"},
"RSA_padding_add_PKCS1_OAEP"},
{ERR_FUNC(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP_MGF1), {ERR_FUNC(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP_MGF1),
"RSA_padding_add_PKCS1_OAEP_mgf1"}, "RSA_padding_add_PKCS1_OAEP_mgf1"},
{ERR_FUNC(RSA_F_RSA_PADDING_ADD_PKCS1_PSS), "RSA_padding_add_PKCS1_PSS"}, {ERR_FUNC(RSA_F_RSA_PADDING_ADD_PKCS1_PSS), "RSA_padding_add_PKCS1_PSS"},
...@@ -136,8 +135,7 @@ static ERR_STRING_DATA RSA_str_functs[] = { ...@@ -136,8 +135,7 @@ static ERR_STRING_DATA RSA_str_functs[] = {
{ERR_FUNC(RSA_F_RSA_PUB_DECODE), "rsa_pub_decode"}, {ERR_FUNC(RSA_F_RSA_PUB_DECODE), "rsa_pub_decode"},
{ERR_FUNC(RSA_F_RSA_SETUP_BLINDING), "RSA_setup_blinding"}, {ERR_FUNC(RSA_F_RSA_SETUP_BLINDING), "RSA_setup_blinding"},
{ERR_FUNC(RSA_F_RSA_SIGN), "RSA_sign"}, {ERR_FUNC(RSA_F_RSA_SIGN), "RSA_sign"},
{ERR_FUNC(RSA_F_RSA_SIGN_ASN1_OCTET_STRING), {ERR_FUNC(RSA_F_RSA_SIGN_ASN1_OCTET_STRING), "RSA_sign_ASN1_OCTET_STRING"},
"RSA_sign_ASN1_OCTET_STRING"},
{ERR_FUNC(RSA_F_RSA_VERIFY), "RSA_verify"}, {ERR_FUNC(RSA_F_RSA_VERIFY), "RSA_verify"},
{ERR_FUNC(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING), {ERR_FUNC(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING),
"RSA_verify_ASN1_OCTET_STRING"}, "RSA_verify_ASN1_OCTET_STRING"},
...@@ -153,8 +151,7 @@ static ERR_STRING_DATA RSA_str_reasons[] = { ...@@ -153,8 +151,7 @@ static ERR_STRING_DATA RSA_str_reasons[] = {
{ERR_REASON(RSA_R_BAD_SIGNATURE), "bad signature"}, {ERR_REASON(RSA_R_BAD_SIGNATURE), "bad signature"},
{ERR_REASON(RSA_R_BLOCK_TYPE_IS_NOT_01), "block type is not 01"}, {ERR_REASON(RSA_R_BLOCK_TYPE_IS_NOT_01), "block type is not 01"},
{ERR_REASON(RSA_R_BLOCK_TYPE_IS_NOT_02), "block type is not 02"}, {ERR_REASON(RSA_R_BLOCK_TYPE_IS_NOT_02), "block type is not 02"},
{ERR_REASON(RSA_R_DATA_GREATER_THAN_MOD_LEN), {ERR_REASON(RSA_R_DATA_GREATER_THAN_MOD_LEN), "data greater than mod len"},
"data greater than mod len"},
{ERR_REASON(RSA_R_DATA_TOO_LARGE), "data too large"}, {ERR_REASON(RSA_R_DATA_TOO_LARGE), "data too large"},
{ERR_REASON(RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE), {ERR_REASON(RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),
"data too large for key size"}, "data too large for key size"},
...@@ -192,8 +189,7 @@ static ERR_STRING_DATA RSA_str_reasons[] = { ...@@ -192,8 +189,7 @@ static ERR_STRING_DATA RSA_str_reasons[] = {
{ERR_REASON(RSA_R_LAST_OCTET_INVALID), "last octet invalid"}, {ERR_REASON(RSA_R_LAST_OCTET_INVALID), "last octet invalid"},
{ERR_REASON(RSA_R_MODULUS_TOO_LARGE), "modulus too large"}, {ERR_REASON(RSA_R_MODULUS_TOO_LARGE), "modulus too large"},
{ERR_REASON(RSA_R_NO_PUBLIC_EXPONENT), "no public exponent"}, {ERR_REASON(RSA_R_NO_PUBLIC_EXPONENT), "no public exponent"},
{ERR_REASON(RSA_R_NULL_BEFORE_BLOCK_MISSING), {ERR_REASON(RSA_R_NULL_BEFORE_BLOCK_MISSING), "null before block missing"},
"null before block missing"},
{ERR_REASON(RSA_R_N_DOES_NOT_EQUAL_P_Q), "n does not equal p q"}, {ERR_REASON(RSA_R_N_DOES_NOT_EQUAL_P_Q), "n does not equal p q"},
{ERR_REASON(RSA_R_OAEP_DECODING_ERROR), "oaep decoding error"}, {ERR_REASON(RSA_R_OAEP_DECODING_ERROR), "oaep decoding error"},
{ERR_REASON(RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE), {ERR_REASON(RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE),
......
/* crypto/rsa/rsa_eay.c */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved. * All rights reserved.
* *
...@@ -116,29 +115,29 @@ ...@@ -116,29 +115,29 @@
#ifndef RSA_NULL #ifndef RSA_NULL
static int RSA_eay_public_encrypt(int flen, const unsigned char *from, static int rsa_ossl_public_encrypt(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding); unsigned char *to, RSA *rsa, int padding);
static int RSA_eay_private_encrypt(int flen, const unsigned char *from, static int rsa_ossl_private_encrypt(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding); unsigned char *to, RSA *rsa, int padding);
static int RSA_eay_public_decrypt(int flen, const unsigned char *from, static int rsa_ossl_public_decrypt(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding); unsigned char *to, RSA *rsa, int padding);
static int RSA_eay_private_decrypt(int flen, const unsigned char *from, static int rsa_ossl_private_decrypt(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding); unsigned char *to, RSA *rsa, int padding);
static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *i, RSA *rsa, static int rsa_ossl_mod_exp(BIGNUM *r0, const BIGNUM *i, RSA *rsa,
BN_CTX *ctx); BN_CTX *ctx);
static int RSA_eay_init(RSA *rsa); static int rsa_ossl_init(RSA *rsa);
static int RSA_eay_finish(RSA *rsa); static int rsa_ossl_finish(RSA *rsa);
static RSA_METHOD rsa_pkcs1_eay_meth = { static RSA_METHOD rsa_pkcs1_ossl_meth = {
"Eric Young's PKCS#1 RSA", "OpenSSL PKCS#1 RSA (from Eric Young)",
RSA_eay_public_encrypt, rsa_ossl_public_encrypt,
RSA_eay_public_decrypt, /* signature verification */ rsa_ossl_public_decrypt, /* signature verification */
RSA_eay_private_encrypt, /* signing */ rsa_ossl_private_encrypt, /* signing */
RSA_eay_private_decrypt, rsa_ossl_private_decrypt,
RSA_eay_mod_exp, rsa_ossl_mod_exp,
BN_mod_exp_mont, /* XXX probably we should not use Montgomery BN_mod_exp_mont, /* XXX probably we should not use Montgomery
* if e == 3 */ * if e == 3 */
RSA_eay_init, rsa_ossl_init,
RSA_eay_finish, rsa_ossl_finish,
RSA_FLAG_FIPS_METHOD, /* flags */ RSA_FLAG_FIPS_METHOD, /* flags */
NULL, NULL,
0, /* rsa_sign */ 0, /* rsa_sign */
...@@ -148,10 +147,10 @@ static RSA_METHOD rsa_pkcs1_eay_meth = { ...@@ -148,10 +147,10 @@ static RSA_METHOD rsa_pkcs1_eay_meth = {
const RSA_METHOD *RSA_PKCS1_OpenSSL(void) const RSA_METHOD *RSA_PKCS1_OpenSSL(void)
{ {
return (&rsa_pkcs1_eay_meth); return &rsa_pkcs1_ossl_meth;
} }
static int RSA_eay_public_encrypt(int flen, const unsigned char *from, static int rsa_ossl_public_encrypt(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding) unsigned char *to, RSA *rsa, int padding)
{ {
BIGNUM *f, *ret; BIGNUM *f, *ret;
...@@ -160,19 +159,19 @@ static int RSA_eay_public_encrypt(int flen, const unsigned char *from, ...@@ -160,19 +159,19 @@ static int RSA_eay_public_encrypt(int flen, const unsigned char *from,
BN_CTX *ctx = NULL; BN_CTX *ctx = NULL;
if (BN_num_bits(rsa->n) > OPENSSL_RSA_MAX_MODULUS_BITS) { if (BN_num_bits(rsa->n) > OPENSSL_RSA_MAX_MODULUS_BITS) {
RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_MODULUS_TOO_LARGE); RSAerr(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT, RSA_R_MODULUS_TOO_LARGE);
return -1; return -1;
} }
if (BN_ucmp(rsa->n, rsa->e) <= 0) { if (BN_ucmp(rsa->n, rsa->e) <= 0) {
RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_BAD_E_VALUE); RSAerr(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT, RSA_R_BAD_E_VALUE);
return -1; return -1;
} }
/* for large moduli, enforce exponent limit */ /* for large moduli, enforce exponent limit */
if (BN_num_bits(rsa->n) > OPENSSL_RSA_SMALL_MODULUS_BITS) { if (BN_num_bits(rsa->n) > OPENSSL_RSA_SMALL_MODULUS_BITS) {
if (BN_num_bits(rsa->e) > OPENSSL_RSA_MAX_PUBEXP_BITS) { if (BN_num_bits(rsa->e) > OPENSSL_RSA_MAX_PUBEXP_BITS) {
RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_BAD_E_VALUE); RSAerr(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT, RSA_R_BAD_E_VALUE);
return -1; return -1;
} }
} }
...@@ -185,7 +184,7 @@ static int RSA_eay_public_encrypt(int flen, const unsigned char *from, ...@@ -185,7 +184,7 @@ static int RSA_eay_public_encrypt(int flen, const unsigned char *from,
num = BN_num_bytes(rsa->n); num = BN_num_bytes(rsa->n);
buf = OPENSSL_malloc(num); buf = OPENSSL_malloc(num);
if (f == NULL || ret == NULL || buf == NULL) { if (f == NULL || ret == NULL || buf == NULL) {
RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, ERR_R_MALLOC_FAILURE); RSAerr(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT, ERR_R_MALLOC_FAILURE);
goto err; goto err;
} }
...@@ -203,7 +202,7 @@ static int RSA_eay_public_encrypt(int flen, const unsigned char *from, ...@@ -203,7 +202,7 @@ static int RSA_eay_public_encrypt(int flen, const unsigned char *from,
i = RSA_padding_add_none(buf, num, from, flen); i = RSA_padding_add_none(buf, num, from, flen);
break; break;
default: default:
RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_UNKNOWN_PADDING_TYPE); RSAerr(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT, RSA_R_UNKNOWN_PADDING_TYPE);
goto err; goto err;
} }
if (i <= 0) if (i <= 0)
...@@ -214,7 +213,7 @@ static int RSA_eay_public_encrypt(int flen, const unsigned char *from, ...@@ -214,7 +213,7 @@ static int RSA_eay_public_encrypt(int flen, const unsigned char *from,
if (BN_ucmp(f, rsa->n) >= 0) { if (BN_ucmp(f, rsa->n) >= 0) {
/* usually the padding functions would catch this */ /* usually the padding functions would catch this */
RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSAerr(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT,
RSA_R_DATA_TOO_LARGE_FOR_MODULUS); RSA_R_DATA_TOO_LARGE_FOR_MODULUS);
goto err; goto err;
} }
...@@ -338,7 +337,7 @@ static int rsa_blinding_invert(BN_BLINDING *b, BIGNUM *f, BIGNUM *unblind, ...@@ -338,7 +337,7 @@ static int rsa_blinding_invert(BN_BLINDING *b, BIGNUM *f, BIGNUM *unblind,
} }
/* signing */ /* signing */
static int RSA_eay_private_encrypt(int flen, const unsigned char *from, static int rsa_ossl_private_encrypt(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding) unsigned char *to, RSA *rsa, int padding)
{ {
BIGNUM *f, *ret, *res; BIGNUM *f, *ret, *res;
...@@ -362,7 +361,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from, ...@@ -362,7 +361,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
num = BN_num_bytes(rsa->n); num = BN_num_bytes(rsa->n);
buf = OPENSSL_malloc(num); buf = OPENSSL_malloc(num);
if (f == NULL || ret == NULL || buf == NULL) { if (f == NULL || ret == NULL || buf == NULL) {
RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT, ERR_R_MALLOC_FAILURE); RSAerr(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT, ERR_R_MALLOC_FAILURE);
goto err; goto err;
} }
...@@ -378,7 +377,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from, ...@@ -378,7 +377,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
break; break;
case RSA_SSLV23_PADDING: case RSA_SSLV23_PADDING:
default: default:
RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT, RSA_R_UNKNOWN_PADDING_TYPE); RSAerr(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT, RSA_R_UNKNOWN_PADDING_TYPE);
goto err; goto err;
} }
if (i <= 0) if (i <= 0)
...@@ -389,7 +388,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from, ...@@ -389,7 +388,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
if (BN_ucmp(f, rsa->n) >= 0) { if (BN_ucmp(f, rsa->n) >= 0) {
/* usually the padding functions would catch this */ /* usually the padding functions would catch this */
RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT, RSAerr(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT,
RSA_R_DATA_TOO_LARGE_FOR_MODULUS); RSA_R_DATA_TOO_LARGE_FOR_MODULUS);
goto err; goto err;
} }
...@@ -397,14 +396,14 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from, ...@@ -397,14 +396,14 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
if (!(rsa->flags & RSA_FLAG_NO_BLINDING)) { if (!(rsa->flags & RSA_FLAG_NO_BLINDING)) {
blinding = rsa_get_blinding(rsa, &local_blinding, ctx); blinding = rsa_get_blinding(rsa, &local_blinding, ctx);
if (blinding == NULL) { if (blinding == NULL) {
RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT, ERR_R_INTERNAL_ERROR); RSAerr(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT, ERR_R_INTERNAL_ERROR);
goto err; goto err;
} }
} }
if (blinding != NULL) { if (blinding != NULL) {
if (!local_blinding && ((unblind = BN_CTX_get(ctx)) == NULL)) { if (!local_blinding && ((unblind = BN_CTX_get(ctx)) == NULL)) {
RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT, ERR_R_MALLOC_FAILURE); RSAerr(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT, ERR_R_MALLOC_FAILURE);
goto err; goto err;
} }
if (!rsa_blinding_convert(blinding, f, unblind, ctx)) if (!rsa_blinding_convert(blinding, f, unblind, ctx))
...@@ -423,7 +422,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from, ...@@ -423,7 +422,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) {
local_d = d = BN_new(); local_d = d = BN_new();
if (d == NULL) { if (d == NULL) {
RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT, ERR_R_MALLOC_FAILURE); RSAerr(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT, ERR_R_MALLOC_FAILURE);
goto err; goto err;
} }
BN_with_flags(d, rsa->d, BN_FLG_CONSTTIME); BN_with_flags(d, rsa->d, BN_FLG_CONSTTIME);
...@@ -476,7 +475,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from, ...@@ -476,7 +475,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
return (r); return (r);
} }
static int RSA_eay_private_decrypt(int flen, const unsigned char *from, static int rsa_ossl_private_decrypt(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding) unsigned char *to, RSA *rsa, int padding)
{ {
BIGNUM *f, *ret; BIGNUM *f, *ret;
...@@ -501,7 +500,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from, ...@@ -501,7 +500,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
num = BN_num_bytes(rsa->n); num = BN_num_bytes(rsa->n);
buf = OPENSSL_malloc(num); buf = OPENSSL_malloc(num);
if (f == NULL || ret == NULL || buf == NULL) { if (f == NULL || ret == NULL || buf == NULL) {
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, ERR_R_MALLOC_FAILURE); RSAerr(RSA_F_RSA_OSSL_PRIVATE_DECRYPT, ERR_R_MALLOC_FAILURE);
goto err; goto err;
} }
...@@ -510,7 +509,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from, ...@@ -510,7 +509,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
* top '0' bytes * top '0' bytes
*/ */
if (flen > num) { if (flen > num) {
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, RSAerr(RSA_F_RSA_OSSL_PRIVATE_DECRYPT,
RSA_R_DATA_GREATER_THAN_MOD_LEN); RSA_R_DATA_GREATER_THAN_MOD_LEN);
goto err; goto err;
} }
...@@ -520,7 +519,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from, ...@@ -520,7 +519,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
goto err; goto err;
if (BN_ucmp(f, rsa->n) >= 0) { if (BN_ucmp(f, rsa->n) >= 0) {
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, RSAerr(RSA_F_RSA_OSSL_PRIVATE_DECRYPT,
RSA_R_DATA_TOO_LARGE_FOR_MODULUS); RSA_R_DATA_TOO_LARGE_FOR_MODULUS);
goto err; goto err;
} }
...@@ -528,14 +527,14 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from, ...@@ -528,14 +527,14 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
if (!(rsa->flags & RSA_FLAG_NO_BLINDING)) { if (!(rsa->flags & RSA_FLAG_NO_BLINDING)) {
blinding = rsa_get_blinding(rsa, &local_blinding, ctx); blinding = rsa_get_blinding(rsa, &local_blinding, ctx);
if (blinding == NULL) { if (blinding == NULL) {
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, ERR_R_INTERNAL_ERROR); RSAerr(RSA_F_RSA_OSSL_PRIVATE_DECRYPT, ERR_R_INTERNAL_ERROR);
goto err; goto err;
} }
} }
if (blinding != NULL) { if (blinding != NULL) {
if (!local_blinding && ((unblind = BN_CTX_get(ctx)) == NULL)) { if (!local_blinding && ((unblind = BN_CTX_get(ctx)) == NULL)) {
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, ERR_R_MALLOC_FAILURE); RSAerr(RSA_F_RSA_OSSL_PRIVATE_DECRYPT, ERR_R_MALLOC_FAILURE);
goto err; goto err;
} }
if (!rsa_blinding_convert(blinding, f, unblind, ctx)) if (!rsa_blinding_convert(blinding, f, unblind, ctx))
...@@ -555,7 +554,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from, ...@@ -555,7 +554,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) {
local_d = d = BN_new(); local_d = d = BN_new();
if (d == NULL) { if (d == NULL) {
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, ERR_R_MALLOC_FAILURE); RSAerr(RSA_F_RSA_OSSL_PRIVATE_DECRYPT, ERR_R_MALLOC_FAILURE);
goto err; goto err;
} }
BN_with_flags(d, rsa->d, BN_FLG_CONSTTIME); BN_with_flags(d, rsa->d, BN_FLG_CONSTTIME);
...@@ -597,11 +596,11 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from, ...@@ -597,11 +596,11 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
r = RSA_padding_check_none(to, num, buf, j, num); r = RSA_padding_check_none(to, num, buf, j, num);
break; break;
default: default:
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, RSA_R_UNKNOWN_PADDING_TYPE); RSAerr(RSA_F_RSA_OSSL_PRIVATE_DECRYPT, RSA_R_UNKNOWN_PADDING_TYPE);
goto err; goto err;
} }
if (r < 0) if (r < 0)
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, RSA_R_PADDING_CHECK_FAILED); RSAerr(RSA_F_RSA_OSSL_PRIVATE_DECRYPT, RSA_R_PADDING_CHECK_FAILED);
err: err:
if (ctx != NULL) if (ctx != NULL)
...@@ -612,7 +611,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from, ...@@ -612,7 +611,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
} }
/* signature verification */ /* signature verification */
static int RSA_eay_public_decrypt(int flen, const unsigned char *from, static int rsa_ossl_public_decrypt(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding) unsigned char *to, RSA *rsa, int padding)
{ {
BIGNUM *f, *ret; BIGNUM *f, *ret;
...@@ -622,19 +621,19 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from, ...@@ -622,19 +621,19 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
BN_CTX *ctx = NULL; BN_CTX *ctx = NULL;
if (BN_num_bits(rsa->n) > OPENSSL_RSA_MAX_MODULUS_BITS) { if (BN_num_bits(rsa->n) > OPENSSL_RSA_MAX_MODULUS_BITS) {
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_MODULUS_TOO_LARGE); RSAerr(RSA_F_RSA_OSSL_PUBLIC_DECRYPT, RSA_R_MODULUS_TOO_LARGE);
return -1; return -1;
} }
if (BN_ucmp(rsa->n, rsa->e) <= 0) { if (BN_ucmp(rsa->n, rsa->e) <= 0) {
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_BAD_E_VALUE); RSAerr(RSA_F_RSA_OSSL_PUBLIC_DECRYPT, RSA_R_BAD_E_VALUE);
return -1; return -1;
} }
/* for large moduli, enforce exponent limit */ /* for large moduli, enforce exponent limit */
if (BN_num_bits(rsa->n) > OPENSSL_RSA_SMALL_MODULUS_BITS) { if (BN_num_bits(rsa->n) > OPENSSL_RSA_SMALL_MODULUS_BITS) {
if (BN_num_bits(rsa->e) > OPENSSL_RSA_MAX_PUBEXP_BITS) { if (BN_num_bits(rsa->e) > OPENSSL_RSA_MAX_PUBEXP_BITS) {
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_BAD_E_VALUE); RSAerr(RSA_F_RSA_OSSL_PUBLIC_DECRYPT, RSA_R_BAD_E_VALUE);
return -1; return -1;
} }
} }
...@@ -647,7 +646,7 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from, ...@@ -647,7 +646,7 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
num = BN_num_bytes(rsa->n); num = BN_num_bytes(rsa->n);
buf = OPENSSL_malloc(num); buf = OPENSSL_malloc(num);
if (f == NULL || ret == NULL || buf == NULL) { if (f == NULL || ret == NULL || buf == NULL) {
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, ERR_R_MALLOC_FAILURE); RSAerr(RSA_F_RSA_OSSL_PUBLIC_DECRYPT, ERR_R_MALLOC_FAILURE);
goto err; goto err;
} }
...@@ -656,7 +655,7 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from, ...@@ -656,7 +655,7 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
* top '0' bytes * top '0' bytes
*/ */
if (flen > num) { if (flen > num) {
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_DATA_GREATER_THAN_MOD_LEN); RSAerr(RSA_F_RSA_OSSL_PUBLIC_DECRYPT, RSA_R_DATA_GREATER_THAN_MOD_LEN);
goto err; goto err;
} }
...@@ -664,7 +663,7 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from, ...@@ -664,7 +663,7 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
goto err; goto err;
if (BN_ucmp(f, rsa->n) >= 0) { if (BN_ucmp(f, rsa->n) >= 0) {
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSAerr(RSA_F_RSA_OSSL_PUBLIC_DECRYPT,
RSA_R_DATA_TOO_LARGE_FOR_MODULUS); RSA_R_DATA_TOO_LARGE_FOR_MODULUS);
goto err; goto err;
} }
...@@ -696,11 +695,11 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from, ...@@ -696,11 +695,11 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
r = RSA_padding_check_none(to, num, buf, i, num); r = RSA_padding_check_none(to, num, buf, i, num);
break; break;
default: default:
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_UNKNOWN_PADDING_TYPE); RSAerr(RSA_F_RSA_OSSL_PUBLIC_DECRYPT, RSA_R_UNKNOWN_PADDING_TYPE);
goto err; goto err;
} }
if (r < 0) if (r < 0)
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_PADDING_CHECK_FAILED); RSAerr(RSA_F_RSA_OSSL_PUBLIC_DECRYPT, RSA_R_PADDING_CHECK_FAILED);
err: err:
if (ctx != NULL) if (ctx != NULL)
...@@ -710,7 +709,7 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from, ...@@ -710,7 +709,7 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
return (r); return (r);
} }
static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) static int rsa_ossl_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
{ {
BIGNUM *r1, *m1, *vrfy; BIGNUM *r1, *m1, *vrfy;
BIGNUM *local_dmp1, *local_dmq1, *local_c, *local_r1; BIGNUM *local_dmp1, *local_dmq1, *local_c, *local_r1;
...@@ -905,13 +904,13 @@ static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) ...@@ -905,13 +904,13 @@ static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
return (ret); return (ret);
} }
static int RSA_eay_init(RSA *rsa) static int rsa_ossl_init(RSA *rsa)
{ {
rsa->flags |= RSA_FLAG_CACHE_PUBLIC | RSA_FLAG_CACHE_PRIVATE; rsa->flags |= RSA_FLAG_CACHE_PUBLIC | RSA_FLAG_CACHE_PRIVATE;
return (1); return (1);
} }
static int RSA_eay_finish(RSA *rsa) static int rsa_ossl_finish(RSA *rsa)
{ {
BN_MONT_CTX_free(rsa->_method_mod_n); BN_MONT_CTX_free(rsa->_method_mod_n);
BN_MONT_CTX_free(rsa->_method_mod_p); BN_MONT_CTX_free(rsa->_method_mod_p);
......
...@@ -535,10 +535,10 @@ void ERR_load_RSA_strings(void); ...@@ -535,10 +535,10 @@ void ERR_load_RSA_strings(void);
# define RSA_F_RSA_CHECK_KEY 123 # define RSA_F_RSA_CHECK_KEY 123
# define RSA_F_RSA_CHECK_KEY_EX 160 # define RSA_F_RSA_CHECK_KEY_EX 160
# define RSA_F_RSA_CMS_DECRYPT 159 # define RSA_F_RSA_CMS_DECRYPT 159
# define RSA_F_RSA_EAY_PRIVATE_DECRYPT 101 # define RSA_F_RSA_OSSL_PRIVATE_DECRYPT 101
# define RSA_F_RSA_EAY_PRIVATE_ENCRYPT 102 # define RSA_F_RSA_OSSL_PRIVATE_ENCRYPT 102
# define RSA_F_RSA_EAY_PUBLIC_DECRYPT 103 # define RSA_F_RSA_OSSL_PUBLIC_DECRYPT 103
# define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 104 # define RSA_F_RSA_OSSL_PUBLIC_ENCRYPT 104
# define RSA_F_RSA_GENERATE_KEY 105 # define RSA_F_RSA_GENERATE_KEY 105
# define RSA_F_RSA_ITEM_VERIFY 148 # define RSA_F_RSA_ITEM_VERIFY 148
# define RSA_F_RSA_MEMORY_LOCK 130 # define RSA_F_RSA_MEMORY_LOCK 130
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册