]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
rand_lib.c: Use ERR_LIB_RAND with RAND_R errors
authorTeshan Kannangara <90088670+TeshanK@users.noreply.github.com>
Sat, 8 Nov 2025 14:13:09 +0000 (19:43 +0530)
committerTomas Mraz <tomas@openssl.org>
Fri, 21 Nov 2025 13:17:01 +0000 (14:17 +0100)
Use ERR_LIB_RAND when reporting RAND_R_ALREADY_INSTANTIATED from
RAND_set_DRBG_type() and RAND_set_seed_source_type() so the error
message references the RAND subsystem instead of CRYPTO.

Fixes #29039

CLA: trivial

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29109)

(cherry picked from commit e7251fa1a92bcb1fda1dad7f7e2e3ed2c0056e27)

crypto/rand/rand_lib.c

index c0f5c9effd162860d220365a0888836008668c5e..0c62109de96754850e70125e2cc4a5b29e84b7fb 100644 (file)
@@ -1058,7 +1058,7 @@ int RAND_set_DRBG_type(OSSL_LIB_CTX *ctx, const char *drbg, const char *propq,
     if (dgbl == NULL)
         return 0;
     if (dgbl->primary != NULL) {
-        ERR_raise(ERR_LIB_CRYPTO, RAND_R_ALREADY_INSTANTIATED);
+        ERR_raise(ERR_LIB_RAND, RAND_R_ALREADY_INSTANTIATED);
         return 0;
     }
     return random_set_string(&dgbl->rng_name, drbg)
@@ -1075,7 +1075,7 @@ int RAND_set_seed_source_type(OSSL_LIB_CTX *ctx, const char *seed,
     if (dgbl == NULL)
         return 0;
     if (dgbl->seed != NULL) {
-        ERR_raise(ERR_LIB_CRYPTO, RAND_R_ALREADY_INSTANTIATED);
+        ERR_raise(ERR_LIB_RAND, RAND_R_ALREADY_INSTANTIATED);
         return 0;
     }
     return random_set_string(&dgbl->seed_name, seed)