summaryrefslogtreecommitdiffstats
path: root/crypto/rand
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-11-04 12:23:19 +0100
committerRichard Levitte <levitte@openssl.org>2020-11-13 09:35:02 +0100
commit9311d0c471ca2eaa259e8c1bbbeb7c46394c7ba2 (patch)
treee82c26569e5a952980e65a746af920beed602aab /crypto/rand
parent31a6b52f6db009c639c67387a707dd235f29a430 (diff)
Convert all {NAME}err() in crypto/ to their corresponding ERR_raise() call
This includes error reporting for libcrypto sub-libraries in surprising places. This was done using util/err-to-raise Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13318)
Diffstat (limited to 'crypto/rand')
-rw-r--r--crypto/rand/rand_lib.c20
-rw-r--r--crypto/rand/randfile.c10
2 files changed, 15 insertions, 15 deletions
diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c
index d388d8908a..fdce6711ed 100644
--- a/crypto/rand/rand_lib.c
+++ b/crypto/rand/rand_lib.c
@@ -236,7 +236,7 @@ int RAND_pseudo_bytes(unsigned char *buf, int num)
if (meth != NULL && meth->pseudorand != NULL)
return meth->pseudorand(buf, num);
- RANDerr(RAND_F_RAND_PSEUDO_BYTES, RAND_R_FUNC_NOT_IMPLEMENTED);
+ ERR_raise(ERR_LIB_RAND, RAND_R_FUNC_NOT_IMPLEMENTED);
return -1;
}
# endif
@@ -274,7 +274,7 @@ int RAND_priv_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, int num)
if (meth != NULL && meth != RAND_OpenSSL()) {
if (meth->bytes != NULL)
return meth->bytes(buf, num);
- RANDerr(RAND_F_RAND_PRIV_BYTES_EX, RAND_R_FUNC_NOT_IMPLEMENTED);
+ ERR_raise(ERR_LIB_RAND, RAND_R_FUNC_NOT_IMPLEMENTED);
return -1;
}
@@ -298,7 +298,7 @@ int RAND_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, int num)
if (meth != NULL && meth != RAND_OpenSSL()) {
if (meth->bytes != NULL)
return meth->bytes(buf, num);
- RANDerr(RAND_F_RAND_BYTES_EX, RAND_R_FUNC_NOT_IMPLEMENTED);
+ ERR_raise(ERR_LIB_RAND, RAND_R_FUNC_NOT_IMPLEMENTED);
return -1;
}
@@ -465,13 +465,13 @@ static EVP_RAND_CTX *rand_new_drbg(OSSL_LIB_CTX *libctx, EVP_RAND_CTX *parent,
name = dgbl->rng_name != NULL ? dgbl->rng_name : "CTR-DRBG";
rand = EVP_RAND_fetch(libctx, name, dgbl->rng_propq);
if (rand == NULL) {
- RANDerr(0, RAND_R_UNABLE_TO_FETCH_DRBG);
+ ERR_raise(ERR_LIB_RAND, RAND_R_UNABLE_TO_FETCH_DRBG);
return NULL;
}
ctx = EVP_RAND_CTX_new(rand, parent);
EVP_RAND_free(rand);
if (ctx == NULL) {
- RANDerr(0, RAND_R_UNABLE_TO_CREATE_DRBG);
+ ERR_raise(ERR_LIB_RAND, RAND_R_UNABLE_TO_CREATE_DRBG);
return NULL;
}
@@ -495,12 +495,12 @@ static EVP_RAND_CTX *rand_new_drbg(OSSL_LIB_CTX *libctx, EVP_RAND_CTX *parent,
&reseed_time_interval);
*p = OSSL_PARAM_construct_end();
if (!EVP_RAND_set_ctx_params(ctx, params)) {
- RANDerr(0, RAND_R_ERROR_INITIALISING_DRBG);
+ ERR_raise(ERR_LIB_RAND, RAND_R_ERROR_INITIALISING_DRBG);
EVP_RAND_CTX_free(ctx);
return NULL;
}
if (!EVP_RAND_instantiate(ctx, 0, 0, NULL, 0)) {
- RANDerr(0, RAND_R_ERROR_INSTANTIATING_DRBG);
+ ERR_raise(ERR_LIB_RAND, RAND_R_ERROR_INSTANTIATING_DRBG);
EVP_RAND_CTX_free(ctx);
return NULL;
}
@@ -602,7 +602,7 @@ static int random_set_string(char **p, const char *s)
char *d = OPENSSL_strdup(s);
if (d == NULL) {
- CRYPTOerr(0, ERR_R_MALLOC_FAILURE);
+ ERR_raise(ERR_LIB_CRYPTO, ERR_R_MALLOC_FAILURE);
return 0;
}
OPENSSL_free(*p);
@@ -626,7 +626,7 @@ static int random_conf_init(CONF_IMODULE *md, const CONF *cnf)
/* Value is a section containing RANDOM configuration */
elist = NCONF_get_section(cnf, CONF_imodule_get_value(md));
if (elist == NULL) {
- CRYPTOerr(0, CRYPTO_R_RANDOM_SECTION_ERROR);
+ ERR_raise(ERR_LIB_CRYPTO, CRYPTO_R_RANDOM_SECTION_ERROR);
return 0;
}
@@ -645,7 +645,7 @@ static int random_conf_init(CONF_IMODULE *md, const CONF *cnf)
if (!random_set_string(&dgbl->rng_propq, cval->value))
return 0;
} else {
- CRYPTOerr(0, CRYPTO_R_UNKNOWN_NAME_IN_RANDOM_SECTION);
+ ERR_raise(ERR_LIB_CRYPTO, CRYPTO_R_UNKNOWN_NAME_IN_RANDOM_SECTION);
ERR_add_error_data(4, "name=", cval->name, ", value=", cval->value);
r = 0;
}
diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c
index 2bdd76c078..b104895e3a 100644
--- a/crypto/rand/randfile.c
+++ b/crypto/rand/randfile.c
@@ -94,14 +94,14 @@ int RAND_load_file(const char *file, long bytes)
return 0;
if ((in = openssl_fopen(file, "rb")) == NULL) {
- RANDerr(RAND_F_RAND_LOAD_FILE, RAND_R_CANNOT_OPEN_FILE);
+ ERR_raise(ERR_LIB_RAND, RAND_R_CANNOT_OPEN_FILE);
ERR_add_error_data(2, "Filename=", file);
return -1;
}
#ifndef OPENSSL_NO_POSIX_IO
if (fstat(fileno(in), &sb) < 0) {
- RANDerr(RAND_F_RAND_LOAD_FILE, RAND_R_INTERNAL_ERROR);
+ ERR_raise(ERR_LIB_RAND, RAND_R_INTERNAL_ERROR);
ERR_add_error_data(2, "Filename=", file);
fclose(in);
return -1;
@@ -162,7 +162,7 @@ int RAND_load_file(const char *file, long bytes)
OPENSSL_cleanse(buf, sizeof(buf));
fclose(in);
if (!RAND_status()) {
- RANDerr(RAND_F_RAND_LOAD_FILE, RAND_R_RESEED_ERROR);
+ ERR_raise(ERR_LIB_RAND, RAND_R_RESEED_ERROR);
ERR_add_error_data(2, "Filename=", file);
return -1;
}
@@ -179,7 +179,7 @@ int RAND_write_file(const char *file)
struct stat sb;
if (stat(file, &sb) >= 0 && !S_ISREG(sb.st_mode)) {
- RANDerr(RAND_F_RAND_WRITE_FILE, RAND_R_NOT_A_REGULAR_FILE);
+ ERR_raise(ERR_LIB_RAND, RAND_R_NOT_A_REGULAR_FILE);
ERR_add_error_data(2, "Filename=", file);
return -1;
}
@@ -229,7 +229,7 @@ int RAND_write_file(const char *file)
if (out == NULL)
out = openssl_fopen(file, "wb");
if (out == NULL) {
- RANDerr(RAND_F_RAND_WRITE_FILE, RAND_R_CANNOT_OPEN_FILE);
+ ERR_raise(ERR_LIB_RAND, RAND_R_CANNOT_OPEN_FILE);
ERR_add_error_data(2, "Filename=", file);
return -1;
}