Simplify cipher and digest lookup in PKCS#7 code.
authorDr. Stephen Henson <steve@openssl.org>
Sat, 11 Oct 2003 16:46:40 +0000 (16:46 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Sat, 11 Oct 2003 16:46:40 +0000 (16:46 +0000)
crypto/pkcs7/pk7_doit.c

index e7bc3b2..f0d1174 100644 (file)
@@ -103,7 +103,7 @@ static ASN1_OCTET_STRING *PKCS7_get_octet_string(PKCS7 *p7)
 
 BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
        {
-       int i,j;
+       int i;
        BIO *out=NULL,*btmp=NULL;
        X509_ALGOR *xa;
        const EVP_MD *evp_md;
@@ -161,8 +161,7 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
                                goto err;
                                }
 
-                       j=OBJ_obj2nid(xa->algorithm);
-                       evp_md=EVP_get_digestbyname(OBJ_nid2sn(j));
+                       evp_md=EVP_get_digestbyobj(xa->algorithm);
                        if (evp_md == NULL)
                                {
                                PKCS7err(PKCS7_F_PKCS7_DATAINIT,PKCS7_R_UNKNOWN_DIGEST_TYPE);
@@ -314,7 +313,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
                md_sk=p7->d.signed_and_enveloped->md_algs;
                data_body=p7->d.signed_and_enveloped->enc_data->enc_data;
                enc_alg=p7->d.signed_and_enveloped->enc_data->algorithm;
-               evp_cipher=EVP_get_cipherbyname(OBJ_nid2sn(OBJ_obj2nid(enc_alg->algorithm)));
+               evp_cipher=EVP_get_cipherbyobj(enc_alg->algorithm);
                if (evp_cipher == NULL)
                        {
                        PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CIPHER_TYPE);
@@ -326,7 +325,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
                rsk=p7->d.enveloped->recipientinfo;
                enc_alg=p7->d.enveloped->enc_data->algorithm;
                data_body=p7->d.enveloped->enc_data->enc_data;
-               evp_cipher=EVP_get_cipherbyname(OBJ_nid2sn(OBJ_obj2nid(enc_alg->algorithm)));
+               evp_cipher=EVP_get_cipherbyobj(enc_alg->algorithm);
                if (evp_cipher == NULL)
                        {
                        PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CIPHER_TYPE);
@@ -352,7 +351,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
                                }
 
                        j=OBJ_obj2nid(xa->algorithm);
-                       evp_md=EVP_get_digestbyname(OBJ_nid2sn(j));
+                       evp_md=EVP_get_digestbynid(j);
                        if (evp_md == NULL)
                                {
                                PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNKNOWN_DIGEST_TYPE);