Commit bf160551 authored by Rich Salz's avatar Rich Salz Committed by Rich Salz
Browse files

Rename RSA_eay_xxx to rsa_ossl_xxx



Final part of flushing out SSLEay API's.

Reviewed-by: default avatarTim Hudson <tjh@openssl.org>
parent a22c0124
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

  *) All instances of the string "ssleay" in the public API were replaced
     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]

  *) The demo files in crypto/threads were moved to demo/threads.
+12 −12
Original line number Diff line number Diff line
@@ -15,11 +15,11 @@ CFLAGS= $(INCLUDES) $(CFLAG)
GENERAL=Makefile

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_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
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_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
@@ -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/stack.h ../../include/openssl/symhacks.h
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/crypto.h ../../include/openssl/e_os2.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
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/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: ../../include/openssl/asn1.h ../../include/openssl/bio.h
rsa_pk1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
+8 −12
Original line number Diff line number Diff line
@@ -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_EX), "RSA_check_key_ex"},
    {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_EAY_PRIVATE_ENCRYPT), "RSA_eay_private_encrypt"},
    {ERR_FUNC(RSA_F_RSA_EAY_PUBLIC_DECRYPT), "RSA_eay_public_decrypt"},
    {ERR_FUNC(RSA_F_RSA_EAY_PUBLIC_ENCRYPT), "RSA_eay_public_encrypt"},
    {ERR_FUNC(RSA_F_RSA_OSSL_PRIVATE_DECRYPT), "rsa_ossl_private_decrypt"},
    {ERR_FUNC(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT), "rsa_ossl_private_encrypt"},
    {ERR_FUNC(RSA_F_RSA_OSSL_PUBLIC_DECRYPT), "rsa_ossl_public_decrypt"},
    {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_ITEM_VERIFY), "rsa_item_verify"},
    {ERR_FUNC(RSA_F_RSA_MEMORY_LOCK), "RSA_memory_lock"},
@@ -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_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_PKCS1_OAEP),
     "RSA_padding_add_PKCS1_OAEP"},
    {ERR_FUNC(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP), "RSA_padding_add_PKCS1_OAEP"},
    {ERR_FUNC(RSA_F_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"},
@@ -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_SETUP_BLINDING), "RSA_setup_blinding"},
    {ERR_FUNC(RSA_F_RSA_SIGN), "RSA_sign"},
    {ERR_FUNC(RSA_F_RSA_SIGN_ASN1_OCTET_STRING),
     "RSA_sign_ASN1_OCTET_STRING"},
    {ERR_FUNC(RSA_F_RSA_SIGN_ASN1_OCTET_STRING), "RSA_sign_ASN1_OCTET_STRING"},
    {ERR_FUNC(RSA_F_RSA_VERIFY), "RSA_verify"},
    {ERR_FUNC(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING),
     "RSA_verify_ASN1_OCTET_STRING"},
@@ -153,8 +151,7 @@ static ERR_STRING_DATA RSA_str_reasons[] = {
    {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_02), "block type is not 02"},
    {ERR_REASON(RSA_R_DATA_GREATER_THAN_MOD_LEN),
     "data greater than mod len"},
    {ERR_REASON(RSA_R_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_FOR_KEY_SIZE),
     "data too large for key size"},
@@ -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_MODULUS_TOO_LARGE), "modulus too large"},
    {ERR_REASON(RSA_R_NO_PUBLIC_EXPONENT), "no public exponent"},
    {ERR_REASON(RSA_R_NULL_BEFORE_BLOCK_MISSING),
     "null before block missing"},
    {ERR_REASON(RSA_R_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_OAEP_DECODING_ERROR), "oaep decoding error"},
    {ERR_REASON(RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE),
+52 −53
Original line number Diff line number Diff line
/* crypto/rsa/rsa_eay.c */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
@@ -116,29 +115,29 @@

#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);
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);
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);
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);
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);
static int RSA_eay_init(RSA *rsa);
static int RSA_eay_finish(RSA *rsa);
static RSA_METHOD rsa_pkcs1_eay_meth = {
    "Eric Young's PKCS#1 RSA",
    RSA_eay_public_encrypt,
    RSA_eay_public_decrypt,     /* signature verification */
    RSA_eay_private_encrypt,    /* signing */
    RSA_eay_private_decrypt,
    RSA_eay_mod_exp,
static int rsa_ossl_init(RSA *rsa);
static int rsa_ossl_finish(RSA *rsa);
static RSA_METHOD rsa_pkcs1_ossl_meth = {
    "OpenSSL PKCS#1 RSA (from Eric Young)",
    rsa_ossl_public_encrypt,
    rsa_ossl_public_decrypt,     /* signature verification */
    rsa_ossl_private_encrypt,    /* signing */
    rsa_ossl_private_decrypt,
    rsa_ossl_mod_exp,
    BN_mod_exp_mont,            /* XXX probably we should not use Montgomery
                                 * if e == 3 */
    RSA_eay_init,
    RSA_eay_finish,
    rsa_ossl_init,
    rsa_ossl_finish,
    RSA_FLAG_FIPS_METHOD,       /* flags */
    NULL,
    0,                          /* rsa_sign */
@@ -148,10 +147,10 @@ static RSA_METHOD rsa_pkcs1_eay_meth = {

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)
{
    BIGNUM *f, *ret;
@@ -160,19 +159,19 @@ static int RSA_eay_public_encrypt(int flen, const unsigned char *from,
    BN_CTX *ctx = NULL;

    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;
    }

    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;
    }

    /* for large moduli, enforce exponent limit */
    if (BN_num_bits(rsa->n) > OPENSSL_RSA_SMALL_MODULUS_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;
        }
    }
@@ -185,7 +184,7 @@ static int RSA_eay_public_encrypt(int flen, const unsigned char *from,
    num = BN_num_bytes(rsa->n);
    buf = OPENSSL_malloc(num);
    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;
    }

@@ -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);
        break;
    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;
    }
    if (i <= 0)
@@ -214,7 +213,7 @@ static int RSA_eay_public_encrypt(int flen, const unsigned char *from,

    if (BN_ucmp(f, rsa->n) >= 0) {
        /* 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);
        goto err;
    }
@@ -338,7 +337,7 @@ static int rsa_blinding_invert(BN_BLINDING *b, BIGNUM *f, BIGNUM *unblind,
}

/* 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)
{
    BIGNUM *f, *ret, *res;
@@ -362,7 +361,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
    num = BN_num_bytes(rsa->n);
    buf = OPENSSL_malloc(num);
    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;
    }

@@ -378,7 +377,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
        break;
    case RSA_SSLV23_PADDING:
    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;
    }
    if (i <= 0)
@@ -389,7 +388,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,

    if (BN_ucmp(f, rsa->n) >= 0) {
        /* 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);
        goto err;
    }
@@ -397,14 +396,14 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
    if (!(rsa->flags & RSA_FLAG_NO_BLINDING)) {
        blinding = rsa_get_blinding(rsa, &local_blinding, ctx);
        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;
        }
    }

    if (blinding != 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;
        }
        if (!rsa_blinding_convert(blinding, f, unblind, ctx))
@@ -423,7 +422,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
        if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) {
            local_d = d = BN_new();
            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;
            }
            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,
    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)
{
    BIGNUM *f, *ret;
@@ -501,7 +500,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
    num = BN_num_bytes(rsa->n);
    buf = OPENSSL_malloc(num);
    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;
    }

@@ -510,7 +509,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
     * top '0' bytes
     */
    if (flen > num) {
        RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,
        RSAerr(RSA_F_RSA_OSSL_PRIVATE_DECRYPT,
               RSA_R_DATA_GREATER_THAN_MOD_LEN);
        goto err;
    }
@@ -520,7 +519,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
        goto err;

    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);
        goto err;
    }
@@ -528,14 +527,14 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
    if (!(rsa->flags & RSA_FLAG_NO_BLINDING)) {
        blinding = rsa_get_blinding(rsa, &local_blinding, ctx);
        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;
        }
    }

    if (blinding != 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;
        }
        if (!rsa_blinding_convert(blinding, f, unblind, ctx))
@@ -555,7 +554,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
        if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) {
            local_d = d = BN_new();
            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;
            }
            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,
        r = RSA_padding_check_none(to, num, buf, j, num);
        break;
    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;
    }
    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:
    if (ctx != NULL)
@@ -612,7 +611,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
}

/* 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)
{
    BIGNUM *f, *ret;
@@ -622,19 +621,19 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
    BN_CTX *ctx = NULL;

    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;
    }

    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;
    }

    /* for large moduli, enforce exponent limit */
    if (BN_num_bits(rsa->n) > OPENSSL_RSA_SMALL_MODULUS_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;
        }
    }
@@ -647,7 +646,7 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
    num = BN_num_bytes(rsa->n);
    buf = OPENSSL_malloc(num);
    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;
    }

@@ -656,7 +655,7 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
     * top '0' bytes
     */
    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;
    }

@@ -664,7 +663,7 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
        goto err;

    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);
        goto err;
    }
@@ -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);
        break;
    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;
    }
    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:
    if (ctx != NULL)
@@ -710,7 +709,7 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
    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 *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)
    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;
    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_p);
+4 −4
Original line number Diff line number Diff line
@@ -535,10 +535,10 @@ void ERR_load_RSA_strings(void);
# define RSA_F_RSA_CHECK_KEY                              123
# define RSA_F_RSA_CHECK_KEY_EX                           160
# define RSA_F_RSA_CMS_DECRYPT                            159
# define RSA_F_RSA_EAY_PRIVATE_DECRYPT                    101
# define RSA_F_RSA_EAY_PRIVATE_ENCRYPT                    102
# define RSA_F_RSA_EAY_PUBLIC_DECRYPT                     103
# define RSA_F_RSA_EAY_PUBLIC_ENCRYPT                     104
# define RSA_F_RSA_OSSL_PRIVATE_DECRYPT                   101
# define RSA_F_RSA_OSSL_PRIVATE_ENCRYPT                   102
# define RSA_F_RSA_OSSL_PUBLIC_DECRYPT                    103
# define RSA_F_RSA_OSSL_PUBLIC_ENCRYPT                    104
# define RSA_F_RSA_GENERATE_KEY                           105
# define RSA_F_RSA_ITEM_VERIFY                            148
# define RSA_F_RSA_MEMORY_LOCK                            130