Convert all {NAME}err() in providers/ to their corresponding ERR_raise() call

This was done using util/err-to-raise

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/13319)
This commit is contained in:
Richard Levitte 2020-11-04 12:26:49 +01:00
parent c48ffbcca1
commit 6debc6ab74
8 changed files with 64 additions and 64 deletions

View File

@ -155,13 +155,13 @@ static int rsa_encrypt(void *vprsactx, unsigned char *out, size_t *outlen,
unsigned char *tbuf; unsigned char *tbuf;
if ((tbuf = OPENSSL_malloc(rsasize)) == NULL) { if ((tbuf = OPENSSL_malloc(rsasize)) == NULL) {
PROVerr(0, ERR_R_MALLOC_FAILURE); ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
return 0; return 0;
} }
if (prsactx->oaep_md == NULL) { if (prsactx->oaep_md == NULL) {
OPENSSL_free(tbuf); OPENSSL_free(tbuf);
prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, "SHA-1", NULL); prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, "SHA-1", NULL);
PROVerr(0, ERR_R_INTERNAL_ERROR); ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
return 0; return 0;
} }
ret = ret =
@ -230,7 +230,7 @@ static int rsa_decrypt(void *vprsactx, unsigned char *out, size_t *outlen,
unsigned char *tbuf; unsigned char *tbuf;
if ((tbuf = OPENSSL_malloc(len)) == NULL) { if ((tbuf = OPENSSL_malloc(len)) == NULL) {
PROVerr(0, ERR_R_MALLOC_FAILURE); ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
return 0; return 0;
} }
ret = RSA_private_decrypt(inlen, in, tbuf, prsactx->rsa, ret = RSA_private_decrypt(inlen, in, tbuf, prsactx->rsa,
@ -248,7 +248,7 @@ static int rsa_decrypt(void *vprsactx, unsigned char *out, size_t *outlen,
if (prsactx->oaep_md == NULL) { if (prsactx->oaep_md == NULL) {
prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, "SHA-1", NULL); prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, "SHA-1", NULL);
if (prsactx->oaep_md == NULL) { if (prsactx->oaep_md == NULL) {
PROVerr(0, ERR_R_INTERNAL_ERROR); ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
return 0; return 0;
} }
} }

View File

@ -138,7 +138,7 @@ static int tdes_wrap_cipher(void *vctx,
return 0; return 0;
if (outsize < inl) { if (outsize < inl) {
PROVerr(0, PROV_R_OUTPUT_BUFFER_TOO_SMALL); ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
return 0; return 0;
} }
@ -158,12 +158,12 @@ static int tdes_wrap_update(void *vctx, unsigned char *out, size_t *outl,
if (inl == 0) if (inl == 0)
return 1; return 1;
if (outsize < inl) { if (outsize < inl) {
PROVerr(0, PROV_R_OUTPUT_BUFFER_TOO_SMALL); ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
return 0; return 0;
} }
if (!tdes_wrap_cipher(vctx, out, outl, outsize, in, inl)) { if (!tdes_wrap_cipher(vctx, out, outl, outsize, in, inl)) {
PROVerr(0, PROV_R_CIPHER_OPERATION_FAILED); ERR_raise(ERR_LIB_PROV, PROV_R_CIPHER_OPERATION_FAILED);
return 0; return 0;
} }
return 1; return 1;

View File

@ -417,7 +417,7 @@ static int scrypt_alg(const char *pass, size_t passlen,
return 0; return 0;
/* Check p * r < SCRYPT_PR_MAX avoiding overflow */ /* Check p * r < SCRYPT_PR_MAX avoiding overflow */
if (p > SCRYPT_PR_MAX / r) { if (p > SCRYPT_PR_MAX / r) {
EVPerr(EVP_F_SCRYPT_ALG, EVP_R_MEMORY_LIMIT_EXCEEDED); ERR_raise(ERR_LIB_EVP, EVP_R_MEMORY_LIMIT_EXCEEDED);
return 0; return 0;
} }
@ -428,7 +428,7 @@ static int scrypt_alg(const char *pass, size_t passlen,
if (16 * r <= LOG2_UINT64_MAX) { if (16 * r <= LOG2_UINT64_MAX) {
if (N >= (((uint64_t)1) << (16 * r))) { if (N >= (((uint64_t)1) << (16 * r))) {
EVPerr(EVP_F_SCRYPT_ALG, EVP_R_MEMORY_LIMIT_EXCEEDED); ERR_raise(ERR_LIB_EVP, EVP_R_MEMORY_LIMIT_EXCEEDED);
return 0; return 0;
} }
} }
@ -446,7 +446,7 @@ static int scrypt_alg(const char *pass, size_t passlen,
* have to be revised when/if PKCS5_PBKDF2_HMAC accepts size_t.] * have to be revised when/if PKCS5_PBKDF2_HMAC accepts size_t.]
*/ */
if (Blen > INT_MAX) { if (Blen > INT_MAX) {
EVPerr(EVP_F_SCRYPT_ALG, EVP_R_MEMORY_LIMIT_EXCEEDED); ERR_raise(ERR_LIB_EVP, EVP_R_MEMORY_LIMIT_EXCEEDED);
return 0; return 0;
} }
@ -456,14 +456,14 @@ static int scrypt_alg(const char *pass, size_t passlen,
*/ */
i = UINT64_MAX / (32 * sizeof(uint32_t)); i = UINT64_MAX / (32 * sizeof(uint32_t));
if (N + 2 > i / r) { if (N + 2 > i / r) {
EVPerr(EVP_F_SCRYPT_ALG, EVP_R_MEMORY_LIMIT_EXCEEDED); ERR_raise(ERR_LIB_EVP, EVP_R_MEMORY_LIMIT_EXCEEDED);
return 0; return 0;
} }
Vlen = 32 * r * (N + 2) * sizeof(uint32_t); Vlen = 32 * r * (N + 2) * sizeof(uint32_t);
/* check total allocated size fits in uint64_t */ /* check total allocated size fits in uint64_t */
if (Blen > UINT64_MAX - Vlen) { if (Blen > UINT64_MAX - Vlen) {
EVPerr(EVP_F_SCRYPT_ALG, EVP_R_MEMORY_LIMIT_EXCEEDED); ERR_raise(ERR_LIB_EVP, EVP_R_MEMORY_LIMIT_EXCEEDED);
return 0; return 0;
} }
@ -472,7 +472,7 @@ static int scrypt_alg(const char *pass, size_t passlen,
maxmem = SIZE_MAX; maxmem = SIZE_MAX;
if (Blen + Vlen > maxmem) { if (Blen + Vlen > maxmem) {
EVPerr(EVP_F_SCRYPT_ALG, EVP_R_MEMORY_LIMIT_EXCEEDED); ERR_raise(ERR_LIB_EVP, EVP_R_MEMORY_LIMIT_EXCEEDED);
return 0; return 0;
} }
@ -482,7 +482,7 @@ static int scrypt_alg(const char *pass, size_t passlen,
B = OPENSSL_malloc((size_t)(Blen + Vlen)); B = OPENSSL_malloc((size_t)(Blen + Vlen));
if (B == NULL) { if (B == NULL) {
EVPerr(EVP_F_SCRYPT_ALG, ERR_R_MALLOC_FAILURE); ERR_raise(ERR_LIB_EVP, ERR_R_MALLOC_FAILURE);
return 0; return 0;
} }
X = (uint32_t *)(B + Blen); X = (uint32_t *)(B + Blen);
@ -501,7 +501,7 @@ static int scrypt_alg(const char *pass, size_t passlen,
rv = 1; rv = 1;
err: err:
if (rv == 0) if (rv == 0)
EVPerr(EVP_F_SCRYPT_ALG, EVP_R_PBKDF2_ERROR); ERR_raise(ERR_LIB_EVP, EVP_R_PBKDF2_ERROR);
OPENSSL_clear_free(B, (size_t)(Blen + Vlen)); OPENSSL_clear_free(B, (size_t)(Blen + Vlen));
return rv; return rv;

View File

@ -252,7 +252,7 @@ static int kmac_init(void *vmacctx)
/* Check key has been set */ /* Check key has been set */
if (kctx->key_len == 0) { if (kctx->key_len == 0) {
EVPerr(EVP_F_KMAC_INIT, EVP_R_NO_KEY_SET); ERR_raise(ERR_LIB_EVP, EVP_R_NO_KEY_SET);
return 0; return 0;
} }
if (!EVP_DigestInit_ex(kctx->ctx, ossl_prov_digest_md(&kctx->digest), if (!EVP_DigestInit_ex(kctx->ctx, ossl_prov_digest_md(&kctx->digest),

View File

@ -161,7 +161,7 @@ static size_t prov_drbg_get_entropy(PROV_DRBG *drbg, unsigned char **pout,
* We currently don't support the algorithm from NIST SP 800-90C * We currently don't support the algorithm from NIST SP 800-90C
* 10.1.2 to use a weaker DRBG as source * 10.1.2 to use a weaker DRBG as source
*/ */
RANDerr(0, PROV_R_PARENT_STRENGTH_TOO_WEAK); ERR_raise(ERR_LIB_RAND, PROV_R_PARENT_STRENGTH_TOO_WEAK);
return 0; return 0;
} }
} }
@ -402,7 +402,7 @@ int ossl_prov_drbg_instantiate(PROV_DRBG *drbg, unsigned int strength,
return 0; return 0;
if (strength > drbg->strength) { if (strength > drbg->strength) {
PROVerr(0, PROV_R_INSUFFICIENT_DRBG_STRENGTH); ERR_raise(ERR_LIB_PROV, PROV_R_INSUFFICIENT_DRBG_STRENGTH);
goto end; goto end;
} }
min_entropy = drbg->strength; min_entropy = drbg->strength;
@ -414,15 +414,15 @@ int ossl_prov_drbg_instantiate(PROV_DRBG *drbg, unsigned int strength,
perslen = sizeof(ossl_pers_string); perslen = sizeof(ossl_pers_string);
} }
if (perslen > drbg->max_perslen) { if (perslen > drbg->max_perslen) {
PROVerr(0, PROV_R_PERSONALISATION_STRING_TOO_LONG); ERR_raise(ERR_LIB_PROV, PROV_R_PERSONALISATION_STRING_TOO_LONG);
goto end; goto end;
} }
if (drbg->state != EVP_RAND_STATE_UNINITIALISED) { if (drbg->state != EVP_RAND_STATE_UNINITIALISED) {
if (drbg->state == EVP_RAND_STATE_ERROR) if (drbg->state == EVP_RAND_STATE_ERROR)
PROVerr(0, PROV_R_IN_ERROR_STATE); ERR_raise(ERR_LIB_PROV, PROV_R_IN_ERROR_STATE);
else else
PROVerr(0, PROV_R_ALREADY_INSTANTIATED); ERR_raise(ERR_LIB_PROV, PROV_R_ALREADY_INSTANTIATED);
goto end; goto end;
} }
@ -434,19 +434,19 @@ int ossl_prov_drbg_instantiate(PROV_DRBG *drbg, unsigned int strength,
drbg->min_noncelen, drbg->min_noncelen,
drbg->max_noncelen); drbg->max_noncelen);
if (noncelen == 0) { if (noncelen == 0) {
PROVerr(0, PROV_R_ERROR_RETRIEVING_NONCE); ERR_raise(ERR_LIB_PROV, PROV_R_ERROR_RETRIEVING_NONCE);
goto end; goto end;
} }
nonce = OPENSSL_malloc(noncelen); nonce = OPENSSL_malloc(noncelen);
if (nonce == NULL) { if (nonce == NULL) {
PROVerr(0, PROV_R_ERROR_RETRIEVING_NONCE); ERR_raise(ERR_LIB_PROV, PROV_R_ERROR_RETRIEVING_NONCE);
goto end; goto end;
} }
if (noncelen != drbg->parent_nonce(drbg->parent, nonce, if (noncelen != drbg->parent_nonce(drbg->parent, nonce,
drbg->strength, drbg->strength,
drbg->min_noncelen, drbg->min_noncelen,
drbg->max_noncelen)) { drbg->max_noncelen)) {
PROVerr(0, PROV_R_ERROR_RETRIEVING_NONCE); ERR_raise(ERR_LIB_PROV, PROV_R_ERROR_RETRIEVING_NONCE);
goto end; goto end;
} }
#ifndef PROV_RAND_GET_RANDOM_NONCE #ifndef PROV_RAND_GET_RANDOM_NONCE
@ -470,7 +470,7 @@ int ossl_prov_drbg_instantiate(PROV_DRBG *drbg, unsigned int strength,
drbg->max_noncelen); drbg->max_noncelen);
if (noncelen < drbg->min_noncelen if (noncelen < drbg->min_noncelen
|| noncelen > drbg->max_noncelen) { || noncelen > drbg->max_noncelen) {
PROVerr(0, PROV_R_ERROR_RETRIEVING_NONCE); ERR_raise(ERR_LIB_PROV, PROV_R_ERROR_RETRIEVING_NONCE);
goto end; goto end;
} }
} }
@ -489,13 +489,13 @@ int ossl_prov_drbg_instantiate(PROV_DRBG *drbg, unsigned int strength,
prediction_resistance); prediction_resistance);
if (entropylen < min_entropylen if (entropylen < min_entropylen
|| entropylen > max_entropylen) { || entropylen > max_entropylen) {
PROVerr(0, PROV_R_ERROR_RETRIEVING_ENTROPY); ERR_raise(ERR_LIB_PROV, PROV_R_ERROR_RETRIEVING_ENTROPY);
goto end; goto end;
} }
if (!drbg->instantiate(drbg, entropy, entropylen, nonce, noncelen, if (!drbg->instantiate(drbg, entropy, entropylen, nonce, noncelen,
pers, perslen)) { pers, perslen)) {
PROVerr(0, PROV_R_ERROR_INSTANTIATING_DRBG); ERR_raise(ERR_LIB_PROV, PROV_R_ERROR_INSTANTIATING_DRBG);
goto end; goto end;
} }
@ -548,23 +548,23 @@ int ossl_prov_drbg_reseed(PROV_DRBG *drbg, int prediction_resistance,
rand_drbg_restart(drbg); rand_drbg_restart(drbg);
if (drbg->state == EVP_RAND_STATE_ERROR) { if (drbg->state == EVP_RAND_STATE_ERROR) {
PROVerr(0, PROV_R_IN_ERROR_STATE); ERR_raise(ERR_LIB_PROV, PROV_R_IN_ERROR_STATE);
return 0; return 0;
} }
if (drbg->state == EVP_RAND_STATE_UNINITIALISED) { if (drbg->state == EVP_RAND_STATE_UNINITIALISED) {
PROVerr(0, PROV_R_NOT_INSTANTIATED); ERR_raise(ERR_LIB_PROV, PROV_R_NOT_INSTANTIATED);
return 0; return 0;
} }
} }
if (ent != NULL) { if (ent != NULL) {
if (ent_len < drbg->min_entropylen) { if (ent_len < drbg->min_entropylen) {
RANDerr(0, RAND_R_ENTROPY_OUT_OF_RANGE); ERR_raise(ERR_LIB_RAND, RAND_R_ENTROPY_OUT_OF_RANGE);
drbg->state = EVP_RAND_STATE_ERROR; drbg->state = EVP_RAND_STATE_ERROR;
return 0; return 0;
} }
if (ent_len > drbg->max_entropylen) { if (ent_len > drbg->max_entropylen) {
RANDerr(0, RAND_R_ENTROPY_INPUT_TOO_LONG); ERR_raise(ERR_LIB_RAND, RAND_R_ENTROPY_INPUT_TOO_LONG);
drbg->state = EVP_RAND_STATE_ERROR; drbg->state = EVP_RAND_STATE_ERROR;
return 0; return 0;
} }
@ -573,7 +573,7 @@ int ossl_prov_drbg_reseed(PROV_DRBG *drbg, int prediction_resistance,
if (adin == NULL) { if (adin == NULL) {
adinlen = 0; adinlen = 0;
} else if (adinlen > drbg->max_adinlen) { } else if (adinlen > drbg->max_adinlen) {
PROVerr(0, PROV_R_ADDITIONAL_INPUT_TOO_LONG); ERR_raise(ERR_LIB_PROV, PROV_R_ADDITIONAL_INPUT_TOO_LONG);
return 0; return 0;
} }
@ -616,7 +616,7 @@ int ossl_prov_drbg_reseed(PROV_DRBG *drbg, int prediction_resistance,
prediction_resistance); prediction_resistance);
if (entropylen < drbg->min_entropylen if (entropylen < drbg->min_entropylen
|| entropylen > drbg->max_entropylen) { || entropylen > drbg->max_entropylen) {
PROVerr(0, PROV_R_ERROR_RETRIEVING_ENTROPY); ERR_raise(ERR_LIB_PROV, PROV_R_ERROR_RETRIEVING_ENTROPY);
goto end; goto end;
} }
@ -662,25 +662,25 @@ int ossl_prov_drbg_generate(PROV_DRBG *drbg, unsigned char *out, size_t outlen,
rand_drbg_restart(drbg); rand_drbg_restart(drbg);
if (drbg->state == EVP_RAND_STATE_ERROR) { if (drbg->state == EVP_RAND_STATE_ERROR) {
PROVerr(0, PROV_R_IN_ERROR_STATE); ERR_raise(ERR_LIB_PROV, PROV_R_IN_ERROR_STATE);
return 0; return 0;
} }
if (drbg->state == EVP_RAND_STATE_UNINITIALISED) { if (drbg->state == EVP_RAND_STATE_UNINITIALISED) {
PROVerr(0, PROV_R_NOT_INSTANTIATED); ERR_raise(ERR_LIB_PROV, PROV_R_NOT_INSTANTIATED);
return 0; return 0;
} }
} }
if (strength > drbg->strength) { if (strength > drbg->strength) {
PROVerr(0, PROV_R_INSUFFICIENT_DRBG_STRENGTH); ERR_raise(ERR_LIB_PROV, PROV_R_INSUFFICIENT_DRBG_STRENGTH);
return 0; return 0;
} }
if (outlen > drbg->max_request) { if (outlen > drbg->max_request) {
PROVerr(0, PROV_R_REQUEST_TOO_LARGE_FOR_DRBG); ERR_raise(ERR_LIB_PROV, PROV_R_REQUEST_TOO_LARGE_FOR_DRBG);
return 0; return 0;
} }
if (adinlen > drbg->max_adinlen) { if (adinlen > drbg->max_adinlen) {
PROVerr(0, PROV_R_ADDITIONAL_INPUT_TOO_LONG); ERR_raise(ERR_LIB_PROV, PROV_R_ADDITIONAL_INPUT_TOO_LONG);
return 0; return 0;
} }
@ -708,7 +708,7 @@ int ossl_prov_drbg_generate(PROV_DRBG *drbg, unsigned char *out, size_t outlen,
if (reseed_required || prediction_resistance) { if (reseed_required || prediction_resistance) {
if (!ossl_prov_drbg_reseed(drbg, prediction_resistance, NULL, 0, if (!ossl_prov_drbg_reseed(drbg, prediction_resistance, NULL, 0,
adin, adinlen)) { adin, adinlen)) {
PROVerr(0, PROV_R_RESEED_ERROR); ERR_raise(ERR_LIB_PROV, PROV_R_RESEED_ERROR);
return 0; return 0;
} }
adin = NULL; adin = NULL;
@ -717,7 +717,7 @@ int ossl_prov_drbg_generate(PROV_DRBG *drbg, unsigned char *out, size_t outlen,
if (!drbg->generate(drbg, out, outlen, adin, adinlen)) { if (!drbg->generate(drbg, out, outlen, adin, adinlen)) {
drbg->state = EVP_RAND_STATE_ERROR; drbg->state = EVP_RAND_STATE_ERROR;
PROVerr(0, PROV_R_GENERATE_ERROR); ERR_raise(ERR_LIB_PROV, PROV_R_GENERATE_ERROR);
return 0; return 0;
} }
@ -749,7 +749,7 @@ static int rand_drbg_restart(PROV_DRBG *drbg)
drbg->state = EVP_RAND_STATE_ERROR; drbg->state = EVP_RAND_STATE_ERROR;
rand_pool_free(drbg->seed_pool); rand_pool_free(drbg->seed_pool);
drbg->seed_pool = NULL; drbg->seed_pool = NULL;
RANDerr(0, ERR_R_INTERNAL_ERROR); ERR_raise(ERR_LIB_RAND, ERR_R_INTERNAL_ERROR);
return 0; return 0;
} }

View File

@ -494,7 +494,7 @@ static int drbg_ctr_init_lengths(PROV_DRBG *drbg)
#ifdef FIPS_MODULE #ifdef FIPS_MODULE
if (!ctr->use_df) { if (!ctr->use_df) {
PROVerr(0, RAND_R_DERIVATION_FUNCTION_MANDATORY_FOR_FIPS); ERR_raise(ERR_LIB_PROV, RAND_R_DERIVATION_FUNCTION_MANDATORY_FOR_FIPS);
ctr->use_df = 1; ctr->use_df = 1;
res = 0; res = 0;
} }

View File

@ -26,7 +26,7 @@ RAND_POOL *rand_pool_new(int entropy_requested, int secure,
size_t min_alloc_size = RAND_POOL_MIN_ALLOCATION(secure); size_t min_alloc_size = RAND_POOL_MIN_ALLOCATION(secure);
if (pool == NULL) { if (pool == NULL) {
RANDerr(RAND_F_RAND_POOL_NEW, ERR_R_MALLOC_FAILURE); ERR_raise(ERR_LIB_RAND, ERR_R_MALLOC_FAILURE);
return NULL; return NULL;
} }
@ -43,7 +43,7 @@ RAND_POOL *rand_pool_new(int entropy_requested, int secure,
pool->buffer = OPENSSL_zalloc(pool->alloc_len); pool->buffer = OPENSSL_zalloc(pool->alloc_len);
if (pool->buffer == NULL) { if (pool->buffer == NULL) {
RANDerr(RAND_F_RAND_POOL_NEW, ERR_R_MALLOC_FAILURE); ERR_raise(ERR_LIB_RAND, ERR_R_MALLOC_FAILURE);
goto err; goto err;
} }
@ -68,7 +68,7 @@ RAND_POOL *rand_pool_attach(const unsigned char *buffer, size_t len,
RAND_POOL *pool = OPENSSL_zalloc(sizeof(*pool)); RAND_POOL *pool = OPENSSL_zalloc(sizeof(*pool));
if (pool == NULL) { if (pool == NULL) {
RANDerr(RAND_F_RAND_POOL_ATTACH, ERR_R_MALLOC_FAILURE); ERR_raise(ERR_LIB_RAND, ERR_R_MALLOC_FAILURE);
return NULL; return NULL;
} }
@ -210,7 +210,7 @@ static int rand_pool_grow(RAND_POOL *pool, size_t len)
size_t newlen = pool->alloc_len; size_t newlen = pool->alloc_len;
if (pool->attached || len > pool->max_len - pool->len) { if (pool->attached || len > pool->max_len - pool->len) {
RANDerr(RAND_F_RAND_POOL_GROW, ERR_R_INTERNAL_ERROR); ERR_raise(ERR_LIB_RAND, ERR_R_INTERNAL_ERROR);
return 0; return 0;
} }
@ -223,7 +223,7 @@ static int rand_pool_grow(RAND_POOL *pool, size_t len)
else else
p = OPENSSL_zalloc(newlen); p = OPENSSL_zalloc(newlen);
if (p == NULL) { if (p == NULL) {
RANDerr(RAND_F_RAND_POOL_GROW, ERR_R_MALLOC_FAILURE); ERR_raise(ERR_LIB_RAND, ERR_R_MALLOC_FAILURE);
return 0; return 0;
} }
memcpy(p, pool->buffer, pool->len); memcpy(p, pool->buffer, pool->len);
@ -249,7 +249,7 @@ size_t rand_pool_bytes_needed(RAND_POOL *pool, unsigned int entropy_factor)
size_t entropy_needed = rand_pool_entropy_needed(pool); size_t entropy_needed = rand_pool_entropy_needed(pool);
if (entropy_factor < 1) { if (entropy_factor < 1) {
RANDerr(RAND_F_RAND_POOL_BYTES_NEEDED, RAND_R_ARGUMENT_OUT_OF_RANGE); ERR_raise(ERR_LIB_RAND, RAND_R_ARGUMENT_OUT_OF_RANGE);
return 0; return 0;
} }
@ -257,7 +257,7 @@ size_t rand_pool_bytes_needed(RAND_POOL *pool, unsigned int entropy_factor)
if (bytes_needed > pool->max_len - pool->len) { if (bytes_needed > pool->max_len - pool->len) {
/* not enough space left */ /* not enough space left */
RANDerr(RAND_F_RAND_POOL_BYTES_NEEDED, RAND_R_RANDOM_POOL_OVERFLOW); ERR_raise(ERR_LIB_RAND, RAND_R_RANDOM_POOL_OVERFLOW);
return 0; return 0;
} }
@ -306,12 +306,12 @@ int rand_pool_add(RAND_POOL *pool,
const unsigned char *buffer, size_t len, size_t entropy) const unsigned char *buffer, size_t len, size_t entropy)
{ {
if (len > pool->max_len - pool->len) { if (len > pool->max_len - pool->len) {
RANDerr(RAND_F_RAND_POOL_ADD, RAND_R_ENTROPY_INPUT_TOO_LONG); ERR_raise(ERR_LIB_RAND, RAND_R_ENTROPY_INPUT_TOO_LONG);
return 0; return 0;
} }
if (pool->buffer == NULL) { if (pool->buffer == NULL) {
RANDerr(RAND_F_RAND_POOL_ADD, ERR_R_INTERNAL_ERROR); ERR_raise(ERR_LIB_RAND, ERR_R_INTERNAL_ERROR);
return 0; return 0;
} }
@ -325,7 +325,7 @@ int rand_pool_add(RAND_POOL *pool,
* indeterminate result. * indeterminate result.
*/ */
if (pool->alloc_len > pool->len && pool->buffer + pool->len == buffer) { if (pool->alloc_len > pool->len && pool->buffer + pool->len == buffer) {
RANDerr(RAND_F_RAND_POOL_ADD, ERR_R_INTERNAL_ERROR); ERR_raise(ERR_LIB_RAND, ERR_R_INTERNAL_ERROR);
return 0; return 0;
} }
/* /*
@ -363,12 +363,12 @@ unsigned char *rand_pool_add_begin(RAND_POOL *pool, size_t len)
return NULL; return NULL;
if (len > pool->max_len - pool->len) { if (len > pool->max_len - pool->len) {
RANDerr(RAND_F_RAND_POOL_ADD_BEGIN, RAND_R_RANDOM_POOL_OVERFLOW); ERR_raise(ERR_LIB_RAND, RAND_R_RANDOM_POOL_OVERFLOW);
return NULL; return NULL;
} }
if (pool->buffer == NULL) { if (pool->buffer == NULL) {
RANDerr(RAND_F_RAND_POOL_ADD_BEGIN, ERR_R_INTERNAL_ERROR); ERR_raise(ERR_LIB_RAND, ERR_R_INTERNAL_ERROR);
return NULL; return NULL;
} }
@ -399,7 +399,7 @@ unsigned char *rand_pool_add_begin(RAND_POOL *pool, size_t len)
int rand_pool_add_end(RAND_POOL *pool, size_t len, size_t entropy) int rand_pool_add_end(RAND_POOL *pool, size_t len, size_t entropy)
{ {
if (len > pool->alloc_len - pool->len) { if (len > pool->alloc_len - pool->len) {
RANDerr(RAND_F_RAND_POOL_ADD_END, RAND_R_RANDOM_POOL_OVERFLOW); ERR_raise(ERR_LIB_RAND, RAND_R_RANDOM_POOL_OVERFLOW);
return 0; return 0;
} }

View File

@ -53,7 +53,7 @@ static void *eddsa_newctx(void *provctx, const char *propq_unused)
peddsactx = OPENSSL_zalloc(sizeof(PROV_EDDSA_CTX)); peddsactx = OPENSSL_zalloc(sizeof(PROV_EDDSA_CTX));
if (peddsactx == NULL) { if (peddsactx == NULL) {
PROVerr(0, ERR_R_MALLOC_FAILURE); ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
return NULL; return NULL;
} }
@ -74,12 +74,12 @@ static int eddsa_digest_signverify_init(void *vpeddsactx, const char *mdname,
return 0; return 0;
if (mdname != NULL && mdname[0] != '\0') { if (mdname != NULL && mdname[0] != '\0') {
PROVerr(0, PROV_R_INVALID_DIGEST); ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_DIGEST);
return 0; return 0;
} }
if (!ecx_key_up_ref(edkey)) { if (!ecx_key_up_ref(edkey)) {
PROVerr(0, ERR_R_INTERNAL_ERROR); ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
return 0; return 0;
} }
@ -101,7 +101,7 @@ static int eddsa_digest_signverify_init(void *vpeddsactx, const char *mdname,
break; break;
default: default:
/* Should never happen */ /* Should never happen */
PROVerr(0, ERR_R_INTERNAL_ERROR); ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
return 0; return 0;
} }
if (ret && WPACKET_finish(&pkt)) { if (ret && WPACKET_finish(&pkt)) {
@ -130,13 +130,13 @@ int ed25519_digest_sign(void *vpeddsactx, unsigned char *sigret,
return 1; return 1;
} }
if (sigsize < ED25519_SIGSIZE) { if (sigsize < ED25519_SIGSIZE) {
PROVerr(0, PROV_R_OUTPUT_BUFFER_TOO_SMALL); ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
return 0; return 0;
} }
if (ED25519_sign(sigret, tbs, tbslen, edkey->pubkey, edkey->privkey, if (ED25519_sign(sigret, tbs, tbslen, edkey->pubkey, edkey->privkey,
peddsactx->libctx, NULL) == 0) { peddsactx->libctx, NULL) == 0) {
PROVerr(0, PROV_R_FAILED_TO_SIGN); ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SIGN);
return 0; return 0;
} }
*siglen = ED25519_SIGSIZE; *siglen = ED25519_SIGSIZE;
@ -158,13 +158,13 @@ int ed448_digest_sign(void *vpeddsactx, unsigned char *sigret,
return 1; return 1;
} }
if (sigsize < ED448_SIGSIZE) { if (sigsize < ED448_SIGSIZE) {
PROVerr(0, PROV_R_OUTPUT_BUFFER_TOO_SMALL); ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
return 0; return 0;
} }
if (ED448_sign(peddsactx->libctx, sigret, tbs, tbslen, edkey->pubkey, if (ED448_sign(peddsactx->libctx, sigret, tbs, tbslen, edkey->pubkey,
edkey->privkey, NULL, 0, edkey->propq) == 0) { edkey->privkey, NULL, 0, edkey->propq) == 0) {
PROVerr(0, PROV_R_FAILED_TO_SIGN); ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SIGN);
return 0; return 0;
} }
*siglen = ED448_SIGSIZE; *siglen = ED448_SIGSIZE;
@ -224,7 +224,7 @@ static void *eddsa_dupctx(void *vpeddsactx)
dstctx->key = NULL; dstctx->key = NULL;
if (srcctx->key != NULL && !ecx_key_up_ref(srcctx->key)) { if (srcctx->key != NULL && !ecx_key_up_ref(srcctx->key)) {
PROVerr(0, ERR_R_INTERNAL_ERROR); ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
goto err; goto err;
} }
dstctx->key = srcctx->key; dstctx->key = srcctx->key;