Use ERR_R_*_LIB instead of ERR_LIB_* as reason code for sub-libraries
authorRichard Levitte <levitte@openssl.org>
Thu, 11 Feb 2021 11:55:19 +0000 (12:55 +0100)
committerRichard Levitte <levitte@openssl.org>
Fri, 12 Feb 2021 13:02:06 +0000 (14:02 +0100)
Using ERR_LIB_* causes the error output to say 'reason(n)' instead of
the name of the sub-library in question.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14152)

crypto/ct/ct_log.c
crypto/rsa/rsa_gen.c
providers/implementations/signature/rsa.c
ssl/record/ssl3_record.c

index d41039e5b41359e5e84ab275c183cd0e898068d7..12e09d07a209ee9f7ca35af8b909c7a3865da7b4 100644 (file)
@@ -88,7 +88,7 @@ static int ct_v1_log_id_from_pkey(CTLOG *log, EVP_PKEY *pkey)
     }
     sha256 = EVP_MD_fetch(log->libctx, "SHA2-256", log->propq);
     if (sha256 == NULL) {
-        ERR_raise(ERR_LIB_CT, ERR_LIB_EVP);
+        ERR_raise(ERR_LIB_CT, ERR_R_EVP_LIB);
         goto err;
     }
 
index 53545edb71ac6158d3299a27458419e3c0617d34..3a124e5b6682d421690d1435fa756b40a1d1a136 100644 (file)
@@ -410,7 +410,7 @@ static int rsa_multiprime_keygen(RSA *rsa, int bits, int primes,
     ok = 1;
  err:
     if (ok == -1) {
-        ERR_raise(ERR_LIB_RSA, ERR_LIB_BN);
+        ERR_raise(ERR_LIB_RSA, ERR_R_BN_LIB);
         ok = 0;
     }
     BN_CTX_end(ctx);
index cb68de3b3ea10f440dc22a4836339f12c97f70ae..98e3a2d1f4abdc4435deffcfc4228fb8a6fbdbe8 100644 (file)
@@ -517,7 +517,7 @@ static int rsa_sign(void *vprsactx, unsigned char *sig, size_t *siglen,
                                              prsactx->rsa);
 
             if (ret <= 0) {
-                ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
+                ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB);
                 return 0;
             }
             ret = sltmp;
@@ -550,7 +550,7 @@ static int rsa_sign(void *vprsactx, unsigned char *sig, size_t *siglen,
                 ret = RSA_sign(prsactx->mdnid, tbs, tbslen, sig, &sltmp,
                                prsactx->rsa);
                 if (ret <= 0) {
-                    ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
+                    ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB);
                     return 0;
                 }
                 ret = sltmp;
@@ -592,7 +592,7 @@ static int rsa_sign(void *vprsactx, unsigned char *sig, size_t *siglen,
                                                 prsactx->tbuf, tbs,
                                                 prsactx->md, prsactx->mgf1_md,
                                                 prsactx->saltlen)) {
-                ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
+                ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB);
                 return 0;
             }
             ret = RSA_private_encrypt(RSA_size(prsactx->rsa), prsactx->tbuf,
@@ -614,7 +614,7 @@ static int rsa_sign(void *vprsactx, unsigned char *sig, size_t *siglen,
  end:
 #endif
     if (ret <= 0) {
-        ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
+        ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB);
         return 0;
     }
 
@@ -655,7 +655,7 @@ static int rsa_verify_recover(void *vprsactx,
             ret = RSA_public_decrypt(siglen, sig, prsactx->tbuf, prsactx->rsa,
                                      RSA_X931_PADDING);
             if (ret < 1) {
-                ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
+                ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB);
                 return 0;
             }
             ret--;
@@ -689,7 +689,7 @@ static int rsa_verify_recover(void *vprsactx,
                 ret = int_rsa_verify(prsactx->mdnid, NULL, 0, rout, &sltmp,
                                      sig, siglen, prsactx->rsa);
                 if (ret <= 0) {
-                    ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
+                    ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB);
                     return 0;
                 }
                 ret = sltmp;
@@ -705,7 +705,7 @@ static int rsa_verify_recover(void *vprsactx,
         ret = RSA_public_decrypt(siglen, sig, rout, prsactx->rsa,
                                  prsactx->pad_mode);
         if (ret < 0) {
-            ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
+            ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB);
             return 0;
         }
     }
@@ -733,7 +733,7 @@ static int rsa_verify(void *vprsactx, const unsigned char *sig, size_t siglen,
         case RSA_PKCS1_PADDING:
             if (!RSA_verify(prsactx->mdnid, tbs, tbslen, sig, siglen,
                             prsactx->rsa)) {
-                ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
+                ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB);
                 return 0;
             }
             return 1;
@@ -766,7 +766,7 @@ static int rsa_verify(void *vprsactx, const unsigned char *sig, size_t siglen,
                 ret = RSA_public_decrypt(siglen, sig, prsactx->tbuf,
                                          prsactx->rsa, RSA_NO_PADDING);
                 if (ret <= 0) {
-                    ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
+                    ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB);
                     return 0;
                 }
                 ret = RSA_verify_PKCS1_PSS_mgf1(prsactx->rsa, tbs,
@@ -774,7 +774,7 @@ static int rsa_verify(void *vprsactx, const unsigned char *sig, size_t siglen,
                                                 prsactx->tbuf,
                                                 prsactx->saltlen);
                 if (ret <= 0) {
-                    ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
+                    ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB);
                     return 0;
                 }
                 return 1;
@@ -790,7 +790,7 @@ static int rsa_verify(void *vprsactx, const unsigned char *sig, size_t siglen,
         rslen = RSA_public_decrypt(siglen, sig, prsactx->tbuf, prsactx->rsa,
                                    prsactx->pad_mode);
         if (rslen == 0) {
-            ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
+            ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB);
             return 0;
         }
     }
index a1b5467eabaf9f7cb7283cdae58b6c7e49152c1b..8ada3038388770d97ff2ac2245e31bc4568e8f94 100644 (file)
@@ -528,7 +528,7 @@ int ssl3_get_record(SSL *s)
         if (tmpmd != NULL) {
             imac_size = EVP_MD_size(tmpmd);
             if (!ossl_assert(imac_size >= 0 && imac_size <= EVP_MAX_MD_SIZE)) {
-                    SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_LIB_EVP);
+                    SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_EVP_LIB);
                     return -1;
             }
             mac_size = (size_t)imac_size;
@@ -1552,7 +1552,7 @@ int dtls1_process_record(SSL *s, DTLS1_BITMAP *bitmap)
         if (tmpmd != NULL) {
             imac_size = EVP_MD_size(tmpmd);
             if (!ossl_assert(imac_size >= 0 && imac_size <= EVP_MAX_MD_SIZE)) {
-                    SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_LIB_EVP);
+                    SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_EVP_LIB);
                     return -1;
             }
             mac_size = (size_t)imac_size;