Skip to content

Commit

Permalink
EVP: add missing *_get/settable_params() error queue entries and erro…
Browse files Browse the repository at this point in the history
…r result documentation
  • Loading branch information
DDvO committed Dec 2, 2023
1 parent 5a06c06 commit ab56952
Show file tree
Hide file tree
Showing 25 changed files with 136 additions and 36 deletions.
6 changes: 5 additions & 1 deletion crypto/encode_decode/decoder_err.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Generated by util/mkerr.pl DO NOT EDIT
* Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
Expand All @@ -19,8 +19,12 @@ static const ERR_STRING_DATA OSSL_DECODER_str_reasons[] = {
"could not decode object"},
{ERR_PACK(ERR_LIB_OSSL_DECODER, 0, OSSL_DECODER_R_DECODER_NOT_FOUND),
"decoder not found"},
{ERR_PACK(ERR_LIB_OSSL_DECODER, 0, OSSL_DECODER_R_MISSING_GETTABLE_PARAMS),
"missing gettable params"},
{ERR_PACK(ERR_LIB_OSSL_DECODER, 0, OSSL_DECODER_R_MISSING_GET_PARAMS),
"missing get params"},
{ERR_PACK(ERR_LIB_OSSL_DECODER, 0, OSSL_DECODER_R_MISSING_SETTABLE_CTX_PARAMS),
"missing settable ctx params"},
{0, NULL}
};

Expand Down
4 changes: 3 additions & 1 deletion crypto/encode_decode/decoder_meth.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,8 @@ OSSL_DECODER_gettable_params(OSSL_DECODER *decoder)

return decoder->gettable_params(provctx);
}
return NULL;
ERR_raise(ERR_LIB_OSSL_DECODER, OSSL_DECODER_R_MISSING_GETTABLE_PARAMS);
return NULL;
}

int OSSL_DECODER_get_params(OSSL_DECODER *decoder, OSSL_PARAM params[])
Expand All @@ -606,6 +607,7 @@ OSSL_DECODER_settable_ctx_params(OSSL_DECODER *decoder)

return decoder->settable_ctx_params(provctx);
}
ERR_raise(ERR_LIB_OSSL_DECODER, OSSL_DECODER_R_MISSING_SETTABLE_CTX_PARAMS);
return NULL;
}

Expand Down
6 changes: 5 additions & 1 deletion crypto/encode_decode/encoder_err.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Generated by util/mkerr.pl DO NOT EDIT
* Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
Expand All @@ -19,8 +19,12 @@ static const ERR_STRING_DATA OSSL_ENCODER_str_reasons[] = {
"encoder not found"},
{ERR_PACK(ERR_LIB_OSSL_ENCODER, 0, OSSL_ENCODER_R_INCORRECT_PROPERTY_QUERY),
"incorrect property query"},
{ERR_PACK(ERR_LIB_OSSL_ENCODER, 0, OSSL_ENCODER_R_MISSING_GETTABLE_PARAMS),
"missing gettable params"},
{ERR_PACK(ERR_LIB_OSSL_ENCODER, 0, OSSL_ENCODER_R_MISSING_GET_PARAMS),
"missing get params"},
{ERR_PACK(ERR_LIB_OSSL_ENCODER, 0, OSSL_ENCODER_R_MISSING_SETTABLE_CTX_PARAMS),
"missing settable ctx params"},
{0, NULL}
};

Expand Down
2 changes: 2 additions & 0 deletions crypto/encode_decode/encoder_meth.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ OSSL_ENCODER_gettable_params(OSSL_ENCODER *encoder)

return encoder->gettable_params(provctx);
}
ERR_raise(ERR_LIB_OSSL_ENCODER, OSSL_ENCODER_R_MISSING_GETTABLE_PARAMS);
return NULL;
}

Expand All @@ -596,6 +597,7 @@ const OSSL_PARAM *OSSL_ENCODER_settable_ctx_params(OSSL_ENCODER *encoder)

return encoder->settable_ctx_params(provctx);
}
ERR_raise(ERR_LIB_OSSL_ENCODER, OSSL_ENCODER_R_MISSING_SETTABLE_CTX_PARAMS);
return NULL;
}

Expand Down
9 changes: 9 additions & 0 deletions crypto/err/openssl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,12 @@ EVP_R_LOCKING_NOT_SUPPORTED:213:locking not supported
EVP_R_MEMORY_LIMIT_EXCEEDED:172:memory limit exceeded
EVP_R_MESSAGE_DIGEST_IS_NULL:159:message digest is null
EVP_R_METHOD_NOT_SUPPORTED:144:method not supported
EVP_R_MISSING_GETTABLE_CTX_PARAMS:226:missing gettable ctx params
EVP_R_MISSING_GETTABLE_PARAMS:229:missing gettable params
EVP_R_MISSING_GET_CTX_PARAMS:230:missing get ctx params
EVP_R_MISSING_PARAMETERS:103:missing parameters
EVP_R_MISSING_SETTABLE_CTX_PARAMS:228:missing settable ctx params
EVP_R_MISSING_SET_CTX_PARAMS:231:missing set ctx params
EVP_R_NOT_ABLE_TO_COPY_CTX:190:not able to copy ctx
EVP_R_NOT_XOF_OR_INVALID_LENGTH:178:not XOF or invalid length
EVP_R_NO_CIPHER_SET:131:no cipher set
Expand Down Expand Up @@ -868,10 +873,14 @@ OCSP_R_UNKNOWN_NID:120:unknown nid
OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE:129:unsupported requestorname type
OSSL_DECODER_R_COULD_NOT_DECODE_OBJECT:101:could not decode object
OSSL_DECODER_R_DECODER_NOT_FOUND:102:decoder not found
OSSL_DECODER_R_MISSING_GETTABLE_PARAMS:103:missing gettable params
OSSL_DECODER_R_MISSING_GET_PARAMS:100:missing get params
OSSL_DECODER_R_MISSING_SETTABLE_CTX_PARAMS:104:missing settable ctx params
OSSL_ENCODER_R_ENCODER_NOT_FOUND:101:encoder not found
OSSL_ENCODER_R_INCORRECT_PROPERTY_QUERY:100:incorrect property query
OSSL_ENCODER_R_MISSING_GETTABLE_PARAMS:103:missing gettable params
OSSL_ENCODER_R_MISSING_GET_PARAMS:102:missing get params
OSSL_ENCODER_R_MISSING_SETTABLE_CTX_PARAMS:104:missing settable ctx params
OSSL_STORE_R_AMBIGUOUS_CONTENT_TYPE:107:ambiguous content type
OSSL_STORE_R_BAD_PASSWORD_READ:115:bad password read
OSSL_STORE_R_ERROR_VERIFYING_PKCS12_MAC:113:error verifying pkcs12 mac
Expand Down
8 changes: 6 additions & 2 deletions crypto/evp/asymcipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,10 @@ const OSSL_PARAM *EVP_ASYM_CIPHER_gettable_ctx_params(const EVP_ASYM_CIPHER *cip
{
void *provctx;

if (cip == NULL || cip->gettable_ctx_params == NULL)
if (cip == NULL || cip->gettable_ctx_params == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_GETTABLE_CTX_PARAMS);
return NULL;
}

provctx = ossl_provider_ctx(EVP_ASYM_CIPHER_get0_provider(cip));
return cip->gettable_ctx_params(NULL, provctx);
Expand All @@ -557,8 +559,10 @@ const OSSL_PARAM *EVP_ASYM_CIPHER_settable_ctx_params(const EVP_ASYM_CIPHER *cip
{
void *provctx;

if (cip == NULL || cip->settable_ctx_params == NULL)
if (cip == NULL || cip->settable_ctx_params == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_SETTABLE_CTX_PARAMS);
return NULL;
}

provctx = ossl_provider_ctx(EVP_ASYM_CIPHER_get0_provider(cip));
return cip->settable_ctx_params(NULL, provctx);
Expand Down
5 changes: 5 additions & 0 deletions crypto/evp/digest.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ const OSSL_PARAM *EVP_MD_gettable_params(const EVP_MD *digest)
if (digest != NULL && digest->gettable_params != NULL)
return digest->gettable_params(
ossl_provider_ctx(EVP_MD_get0_provider(digest)));
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_GETTABLE_PARAMS);
return NULL;
}

Expand Down Expand Up @@ -795,6 +796,7 @@ const OSSL_PARAM *EVP_MD_settable_ctx_params(const EVP_MD *md)
provctx = ossl_provider_ctx(EVP_MD_get0_provider(md));
return md->settable_ctx_params(NULL, provctx);
}
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_SETTABLE_CTX_PARAMS);
return NULL;
}

Expand All @@ -821,6 +823,7 @@ const OSSL_PARAM *EVP_MD_CTX_settable_params(EVP_MD_CTX *ctx)
return ctx->digest->settable_ctx_params(ctx->algctx, alg);
}

ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_SETTABLE_CTX_PARAMS);
return NULL;
}

Expand Down Expand Up @@ -851,6 +854,7 @@ const OSSL_PARAM *EVP_MD_gettable_ctx_params(const EVP_MD *md)
provctx = ossl_provider_ctx(EVP_MD_get0_provider(md));
return md->gettable_ctx_params(NULL, provctx);
}
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_GETTABLE_CTX_PARAMS);
return NULL;
}

Expand All @@ -876,6 +880,7 @@ const OSSL_PARAM *EVP_MD_CTX_gettable_params(EVP_MD_CTX *ctx)
provctx = ossl_provider_ctx(EVP_MD_get0_provider(ctx->digest));
return ctx->digest->gettable_ctx_params(ctx->algctx, provctx);
}
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_GETTABLE_CTX_PARAMS);
return NULL;
}

Expand Down
14 changes: 11 additions & 3 deletions crypto/evp/evp_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,8 @@ int EVP_CIPHER_CTX_set_params(EVP_CIPHER_CTX *ctx, const OSSL_PARAM params[])

int EVP_CIPHER_CTX_get_params(EVP_CIPHER_CTX *ctx, OSSL_PARAM params[])
{
if (ctx->cipher != NULL && ctx->cipher->get_ctx_params != NULL)
if (ctx != NULL && ctx->cipher != NULL
&& ctx->cipher->get_ctx_params != NULL)
return ctx->cipher->get_ctx_params(ctx->algctx, params);
return 0;
}
Expand All @@ -1363,6 +1364,7 @@ const OSSL_PARAM *EVP_CIPHER_gettable_params(const EVP_CIPHER *cipher)
if (cipher != NULL && cipher->gettable_params != NULL)
return cipher->gettable_params(
ossl_provider_ctx(EVP_CIPHER_get0_provider(cipher)));
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_GETTABLE_PARAMS);
return NULL;
}

Expand All @@ -1374,6 +1376,7 @@ const OSSL_PARAM *EVP_CIPHER_settable_ctx_params(const EVP_CIPHER *cipher)
provctx = ossl_provider_ctx(EVP_CIPHER_get0_provider(cipher));
return cipher->settable_ctx_params(NULL, provctx);
}
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_SETTABLE_CTX_PARAMS);
return NULL;
}

Expand All @@ -1385,28 +1388,33 @@ const OSSL_PARAM *EVP_CIPHER_gettable_ctx_params(const EVP_CIPHER *cipher)
provctx = ossl_provider_ctx(EVP_CIPHER_get0_provider(cipher));
return cipher->gettable_ctx_params(NULL, provctx);
}
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_GETTABLE_CTX_PARAMS);
return NULL;
}

const OSSL_PARAM *EVP_CIPHER_CTX_settable_params(EVP_CIPHER_CTX *cctx)
{
void *alg;

if (cctx != NULL && cctx->cipher->settable_ctx_params != NULL) {
if (cctx != NULL && cctx->cipher != NULL
&& cctx->cipher->settable_ctx_params != NULL) {
alg = ossl_provider_ctx(EVP_CIPHER_get0_provider(cctx->cipher));
return cctx->cipher->settable_ctx_params(cctx->algctx, alg);
}
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_SETTABLE_CTX_PARAMS);
return NULL;
}

const OSSL_PARAM *EVP_CIPHER_CTX_gettable_params(EVP_CIPHER_CTX *cctx)
{
void *provctx;

if (cctx != NULL && cctx->cipher->gettable_ctx_params != NULL) {
if (cctx != NULL && cctx->cipher != NULL
&& cctx->cipher->gettable_ctx_params != NULL) {
provctx = ossl_provider_ctx(EVP_CIPHER_get0_provider(cctx->cipher));
return cctx->cipher->gettable_ctx_params(cctx->algctx, provctx);
}
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_GETTABLE_CTX_PARAMS);
return NULL;
}

Expand Down
10 changes: 10 additions & 0 deletions crypto/evp/evp_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,17 @@ static const ERR_STRING_DATA EVP_str_reasons[] = {
"message digest is null"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_METHOD_NOT_SUPPORTED),
"method not supported"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_MISSING_GETTABLE_CTX_PARAMS),
"missing gettable ctx params"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_MISSING_GETTABLE_PARAMS),
"missing gettable params"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_MISSING_GET_CTX_PARAMS),
"missing get ctx params"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_MISSING_PARAMETERS), "missing parameters"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_MISSING_SETTABLE_CTX_PARAMS),
"missing settable ctx params"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_MISSING_SET_CTX_PARAMS),
"missing set ctx params"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_NOT_ABLE_TO_COPY_CTX),
"not able to copy ctx"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_NOT_XOF_OR_INVALID_LENGTH),
Expand Down
20 changes: 15 additions & 5 deletions crypto/evp/evp_rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,17 +445,21 @@ int EVP_RAND_CTX_set_params(EVP_RAND_CTX *ctx, const OSSL_PARAM params[])

const OSSL_PARAM *EVP_RAND_gettable_params(const EVP_RAND *rand)
{
if (rand->gettable_params == NULL)
if (rand->gettable_params == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_GETTABLE_PARAMS);
return NULL;
}
return rand->gettable_params(ossl_provider_ctx(EVP_RAND_get0_provider(rand)));
}

const OSSL_PARAM *EVP_RAND_gettable_ctx_params(const EVP_RAND *rand)
{
void *provctx;

if (rand->gettable_ctx_params == NULL)
if (rand->gettable_ctx_params == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_GETTABLE_CTX_PARAMS);
return NULL;
}
provctx = ossl_provider_ctx(EVP_RAND_get0_provider(rand));
return rand->gettable_ctx_params(NULL, provctx);
}
Expand All @@ -464,8 +468,10 @@ const OSSL_PARAM *EVP_RAND_settable_ctx_params(const EVP_RAND *rand)
{
void *provctx;

if (rand->settable_ctx_params == NULL)
if (rand->settable_ctx_params == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_SETTABLE_CTX_PARAMS);
return NULL;
}
provctx = ossl_provider_ctx(EVP_RAND_get0_provider(rand));
return rand->settable_ctx_params(NULL, provctx);
}
Expand All @@ -474,8 +480,10 @@ const OSSL_PARAM *EVP_RAND_CTX_gettable_params(EVP_RAND_CTX *ctx)
{
void *provctx;

if (ctx->meth->gettable_ctx_params == NULL)
if (ctx->meth->gettable_ctx_params == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_GETTABLE_CTX_PARAMS);
return NULL;
}
provctx = ossl_provider_ctx(EVP_RAND_get0_provider(ctx->meth));
return ctx->meth->gettable_ctx_params(ctx->algctx, provctx);
}
Expand All @@ -484,8 +492,10 @@ const OSSL_PARAM *EVP_RAND_CTX_settable_params(EVP_RAND_CTX *ctx)
{
void *provctx;

if (ctx->meth->settable_ctx_params == NULL)
if (ctx->meth->settable_ctx_params == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_SETTABLE_CTX_PARAMS);
return NULL;
}
provctx = ossl_provider_ctx(EVP_RAND_get0_provider(ctx->meth));
return ctx->meth->settable_ctx_params(ctx->algctx, provctx);
}
Expand Down
8 changes: 6 additions & 2 deletions crypto/evp/exchange.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,10 @@ const OSSL_PARAM *EVP_KEYEXCH_gettable_ctx_params(const EVP_KEYEXCH *keyexch)
{
void *provctx;

if (keyexch == NULL || keyexch->gettable_ctx_params == NULL)
if (keyexch == NULL || keyexch->gettable_ctx_params == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_GETTABLE_CTX_PARAMS);
return NULL;
}

provctx = ossl_provider_ctx(EVP_KEYEXCH_get0_provider(keyexch));
return keyexch->gettable_ctx_params(NULL, provctx);
Expand All @@ -591,8 +593,10 @@ const OSSL_PARAM *EVP_KEYEXCH_settable_ctx_params(const EVP_KEYEXCH *keyexch)
{
void *provctx;

if (keyexch == NULL || keyexch->settable_ctx_params == NULL)
if (keyexch == NULL || keyexch->settable_ctx_params == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_SETTABLE_CTX_PARAMS);
return NULL;
}
provctx = ossl_provider_ctx(EVP_KEYEXCH_get0_provider(keyexch));
return keyexch->settable_ctx_params(NULL, provctx);
}
8 changes: 6 additions & 2 deletions crypto/evp/kem.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,10 @@ const OSSL_PARAM *EVP_KEM_gettable_ctx_params(const EVP_KEM *kem)
{
void *provctx;

if (kem == NULL || kem->gettable_ctx_params == NULL)
if (kem == NULL || kem->gettable_ctx_params == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_GETTABLE_CTX_PARAMS);
return NULL;
}

provctx = ossl_provider_ctx(EVP_KEM_get0_provider(kem));
return kem->gettable_ctx_params(NULL, provctx);
Expand All @@ -520,8 +522,10 @@ const OSSL_PARAM *EVP_KEM_settable_ctx_params(const EVP_KEM *kem)
{
void *provctx;

if (kem == NULL || kem->settable_ctx_params == NULL)
if (kem == NULL || kem->settable_ctx_params == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_SETTABLE_CTX_PARAMS);
return NULL;
}

provctx = ossl_provider_ctx(EVP_KEM_get0_provider(kem));
return kem->settable_ctx_params(NULL, provctx);
Expand Down
Loading

0 comments on commit ab56952

Please sign in to comment.