int ret = 0;
void *provkey = NULL;
EVP_ASYM_CIPHER *cipher = NULL;
+ const char *desc;
EVP_KEYMGMT *tmp_keymgmt = NULL;
const OSSL_PROVIDER *tmp_prov = NULL;
const char *supported_ciph = NULL;
goto err;
}
+ desc = cipher->description != NULL ? cipher->description : "";
switch (operation) {
case EVP_PKEY_OP_ENCRYPT:
if (cipher->encrypt_init == NULL) {
- ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_ASYM_CIPHER_NOT_SUPPORTED,
+ "%s encrypt_init:%s", cipher->type_name, desc);
ret = -2;
goto err;
}
break;
case EVP_PKEY_OP_DECRYPT:
if (cipher->decrypt_init == NULL) {
- ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_ASYM_CIPHER_NOT_SUPPORTED,
+ "%s decrypt_init:%s", cipher->type_name, desc);
ret = -2;
goto err;
}
unsigned char *out, size_t *outlen,
const unsigned char *in, size_t inlen)
{
+ EVP_ASYM_CIPHER *cipher;
+ const char *desc;
int ret;
if (ctx == NULL) {
if (ctx->op.ciph.algctx == NULL)
goto legacy;
- ret = ctx->op.ciph.cipher->encrypt(ctx->op.ciph.algctx, out, outlen,
- (out == NULL ? 0 : *outlen), in, inlen);
+ cipher = ctx->op.ciph.cipher;
+ desc = cipher->description != NULL ? cipher->description : "";
+ ret = cipher->encrypt(ctx->op.ciph.algctx, out, outlen, (out == NULL ? 0 : *outlen), in, inlen);
+ if (ret <= 0)
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_ASYM_CIPHER_FAILURE,
+ "%s encrypt:%s", cipher->type_name, desc);
return ret;
legacy:
unsigned char *out, size_t *outlen,
const unsigned char *in, size_t inlen)
{
+ EVP_ASYM_CIPHER *cipher;
+ const char *desc;
int ret;
if (ctx == NULL) {
if (ctx->op.ciph.algctx == NULL)
goto legacy;
- ret = ctx->op.ciph.cipher->decrypt(ctx->op.ciph.algctx, out, outlen,
- (out == NULL ? 0 : *outlen), in, inlen);
+ cipher = ctx->op.ciph.cipher;
+ desc = cipher->description != NULL ? cipher->description : "";
+ ret = cipher->decrypt(ctx->op.ciph.algctx, out, outlen, (out == NULL ? 0 : *outlen), in, inlen);
+ if (ret <= 0)
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_ASYM_CIPHER_FAILURE,
+ "%s decrypt:%s", cipher->type_name, desc);
+
return ret;
legacy:
/*
* Generated by util/mkerr.pl DO NOT EDIT
- * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2025 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
"private key decode error"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_PRIVATE_KEY_ENCODE_ERROR),
"private key encode error"},
+ {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_PROVIDER_ASYM_CIPHER_FAILURE),
+ "provider asym cipher failure"},
+ {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_PROVIDER_ASYM_CIPHER_NOT_SUPPORTED),
+ "provider asym cipher not supported"},
+ {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_PROVIDER_KEYMGMT_FAILURE),
+ "provider keymgmt failure"},
+ {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_PROVIDER_KEYMGMT_NOT_SUPPORTED),
+ "provider keymgmt not supported"},
+ {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_PROVIDER_SIGNATURE_FAILURE),
+ "provider signature failure"},
+ {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_PROVIDER_SIGNATURE_NOT_SUPPORTED),
+ "provider signature not supported"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_PUBLIC_KEY_NOT_RSA), "public key not rsa"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_SETTING_XOF_FAILED), "setting xof failed"},
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_SET_DEFAULT_PROPERTY_FAILURE),
{
EVP_PKEY_CTX *locpctx = NULL;
EVP_SIGNATURE *signature = NULL;
+ const char *desc;
EVP_KEYMGMT *tmp_keymgmt = NULL;
const OSSL_PROVIDER *tmp_prov = NULL;
const char *supported_sig = NULL;
}
}
+ desc = signature->description != NULL ? signature->description : "";
if (ver) {
if (signature->digest_verify_init == NULL) {
- ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_NOT_SUPPORTED,
+ "%s digest_verify_init:%s", signature->type_name, desc);
goto err;
}
ret = signature->digest_verify_init(locpctx->op.sig.algctx,
mdname, provkey, params);
} else {
if (signature->digest_sign_init == NULL) {
- ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_NOT_SUPPORTED,
+ "%s digest_sign_init:%s", signature->type_name, desc);
goto err;
}
ret = signature->digest_sign_init(locpctx->op.sig.algctx,
goto end;
if (type == NULL) /* This check is redundant but clarifies matters */
ERR_raise(ERR_LIB_EVP, EVP_R_NO_DEFAULT_DIGEST);
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_FAILURE,
+ ver ? "%s digest_verify_init:%s" : "%s digest_sign_init:%s",
+ signature->type_name, desc);
err:
evp_pkey_ctx_free_old_ops(locpctx);
int EVP_DigestSignUpdate(EVP_MD_CTX *ctx, const void *data, size_t dsize)
{
+ EVP_SIGNATURE *signature;
+ const char *desc;
EVP_PKEY_CTX *pctx = ctx->pctx;
+ int ret;
if ((ctx->flags & EVP_MD_CTX_FLAG_FINALISED) != 0) {
ERR_raise(ERR_LIB_EVP, EVP_R_UPDATE_ERROR);
|| pctx->op.sig.signature == NULL)
goto legacy;
- if (pctx->op.sig.signature->digest_sign_update == NULL) {
- ERR_raise(ERR_LIB_EVP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
+ signature = pctx->op.sig.signature;
+ desc = signature->description != NULL ? signature->description : "";
+ if (signature->digest_sign_update == NULL) {
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_NOT_SUPPORTED,
+ "%s digest_sign_update:%s", signature->type_name, desc);
return 0;
}
- return pctx->op.sig.signature->digest_sign_update(pctx->op.sig.algctx,
- data, dsize);
+ ret = signature->digest_sign_update(pctx->op.sig.algctx, data, dsize);
+ if (ret <= 0)
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_FAILURE,
+ "%s digest_sign_update:%s", signature->type_name, desc);
+ return ret;
legacy:
if (pctx != NULL) {
int EVP_DigestVerifyUpdate(EVP_MD_CTX *ctx, const void *data, size_t dsize)
{
+ EVP_SIGNATURE *signature;
+ const char *desc;
EVP_PKEY_CTX *pctx = ctx->pctx;
+ int ret;
if ((ctx->flags & EVP_MD_CTX_FLAG_FINALISED) != 0) {
ERR_raise(ERR_LIB_EVP, EVP_R_UPDATE_ERROR);
|| pctx->op.sig.signature == NULL)
goto legacy;
- if (pctx->op.sig.signature->digest_verify_update == NULL) {
- ERR_raise(ERR_LIB_EVP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
+ signature = pctx->op.sig.signature;
+ desc = signature->description != NULL ? signature->description : "";
+ if (signature->digest_verify_update == NULL) {
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_NOT_SUPPORTED,
+ "%s digest_verify_update:%s", signature->type_name, desc);
return 0;
}
- return pctx->op.sig.signature->digest_verify_update(pctx->op.sig.algctx,
- data, dsize);
+ ret = signature->digest_verify_update(pctx->op.sig.algctx, data, dsize);
+ if (ret <= 0)
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_FAILURE,
+ "%s digest_verify_update:%s", signature->type_name, desc);
+ return ret;
legacy:
if (pctx != NULL) {
int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
size_t *siglen)
{
+ EVP_SIGNATURE *signature;
+ const char *desc;
int sctx = 0;
int r = 0;
EVP_PKEY_CTX *dctx = NULL, *pctx = ctx->pctx;
if (dctx != NULL)
pctx = dctx;
}
- r = pctx->op.sig.signature->digest_sign_final(pctx->op.sig.algctx,
- sigret, siglen,
- sigret == NULL ? 0 : *siglen);
+ signature = pctx->op.sig.signature;
+ desc = signature->description != NULL ? signature->description : "";
+ if (signature->digest_sign_final == NULL) {
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_NOT_SUPPORTED,
+ "%s digest_sign_final:%s", signature->type_name, desc);
+ return 0;
+ }
+ r = signature->digest_sign_final(pctx->op.sig.algctx, sigret, siglen,
+ sigret == NULL ? 0 : *siglen);
+ if (!r)
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_FAILURE,
+ "%s digest_sign_final:%s", signature->type_name, desc);
if (dctx == NULL && sigret != NULL)
ctx->flags |= EVP_MD_CTX_FLAG_FINALISED;
else
const unsigned char *tbs, size_t tbslen)
{
EVP_PKEY_CTX *pctx = ctx->pctx;
+ int ret;
if (pctx == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
if (pctx->operation == EVP_PKEY_OP_SIGNCTX
&& pctx->op.sig.algctx != NULL
&& pctx->op.sig.signature != NULL) {
- if (pctx->op.sig.signature->digest_sign != NULL) {
+ EVP_SIGNATURE *signature = pctx->op.sig.signature;
+
+ if (signature->digest_sign != NULL) {
+ const char *desc = signature->description != NULL ? signature->description : "";
+
if (sigret != NULL)
ctx->flags |= EVP_MD_CTX_FLAG_FINALISED;
- return pctx->op.sig.signature->digest_sign(pctx->op.sig.algctx,
- sigret, siglen,
- sigret == NULL ? 0 : *siglen,
- tbs, tbslen);
+ ret = signature->digest_sign(pctx->op.sig.algctx, sigret, siglen,
+ sigret == NULL ? 0 : *siglen, tbs, tbslen);
+ if (ret <= 0)
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_FAILURE,
+ "%s digest_sign:%s", signature->type_name, desc);
+ return ret;
}
} else {
/* legacy */
int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig,
size_t siglen)
{
+ EVP_SIGNATURE *signature;
+ const char *desc;
int vctx = 0;
unsigned int mdlen = 0;
unsigned char md[EVP_MAX_MD_SIZE];
if (dctx != NULL)
pctx = dctx;
}
- r = pctx->op.sig.signature->digest_verify_final(pctx->op.sig.algctx,
- sig, siglen);
+
+ signature = pctx->op.sig.signature;
+ desc = signature->description != NULL ? signature->description : "";
+ if (signature->digest_verify_final == NULL) {
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_NOT_SUPPORTED,
+ "%s digest_verify_final:%s", signature->type_name, desc);
+ return 0;
+ }
+ r = signature->digest_verify_final(pctx->op.sig.algctx, sig, siglen);
+ if (!r)
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_FAILURE,
+ "%s digest_verify_final:%s", signature->type_name, desc);
if (dctx == NULL)
ctx->flags |= EVP_MD_CTX_FLAG_FINALISED;
else
&& pctx->op.sig.algctx != NULL
&& pctx->op.sig.signature != NULL) {
if (pctx->op.sig.signature->digest_verify != NULL) {
+ EVP_SIGNATURE *signature = pctx->op.sig.signature;
+ const char *desc = signature->description != NULL ? signature->description : "";
+ int ret;
+
ctx->flags |= EVP_MD_CTX_FLAG_FINALISED;
- return pctx->op.sig.signature->digest_verify(pctx->op.sig.algctx,
- sigret, siglen,
- tbs, tbslen);
+ ret = signature->digest_verify(pctx->op.sig.algctx, sigret, siglen, tbs, tbslen);
+ if (ret <= 0)
+ ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_SIGNATURE_FAILURE,
+ "%s digest_verify:%s", signature->type_name, desc);
+ return ret;
}
} else {
/* legacy */