Except for Ed448 and RSA PSS where they are mandatory and allow respectively.
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/25020)
pdhctx->kdf_md = EVP_MD_fetch(pdhctx->libctx, name, mdprops);
if (pdhctx->kdf_md == NULL)
return 0;
+ /* XOF digests are not allowed */
+ if ((EVP_MD_get_flags(pdhctx->kdf_md) & EVP_MD_FLAG_XOF) != 0) {
+ ERR_raise(ERR_LIB_PROV, PROV_R_XOF_DIGESTS_NOT_ALLOWED);
+ return 0;
+ }
#ifdef FIPS_MODULE
if (!digest_check(pdhctx, pdhctx->kdf_md)) {
EVP_MD_free(pdhctx->kdf_md);
pectx->kdf_md = EVP_MD_fetch(pectx->libctx, name, mdprops);
if (pectx->kdf_md == NULL)
return 0;
+ /* XOF digests are not allowed */
+ if ((EVP_MD_get_flags(pectx->kdf_md) & EVP_MD_FLAG_XOF) != 0) {
+ ERR_raise(ERR_LIB_PROV, PROV_R_XOF_DIGESTS_NOT_ALLOWED);
+ return 0;
+ }
#ifdef FIPS_MODULE
if (!ossl_fips_ind_digest_check(OSSL_FIPS_IND_GET(pectx),
OSSL_FIPS_IND_SETTABLE1, pectx->libctx,
"%s exceeds name buffer length", mdname);
goto err;
}
+ /* XOF digests don't work */
+ if ((EVP_MD_get_flags(md) & EVP_MD_FLAG_XOF) != 0) {
+ ERR_raise(ERR_LIB_PROV, PROV_R_XOF_DIGESTS_NOT_ALLOWED);
+ return 0;
+ }
#ifdef FIPS_MODULE
{
int sha1_allowed = (ctx->operation != EVP_PKEY_OP_SIGN);
"digest=%s", mdname);
goto err;
}
+ /* XOF digests don't work */
+ if ((EVP_MD_get_flags(md) & EVP_MD_FLAG_XOF) != 0) {
+ ERR_raise(ERR_LIB_PROV, PROV_R_XOF_DIGESTS_NOT_ALLOWED);
+ return 0;
+ }
#ifdef FIPS_MODULE
{
"digest=%s", mdname);
goto err;
}
+ /* XOF digests are not allowed except for RSA PSS */
+ if (ctx->pad_mode != RSA_PKCS1_PSS_PADDING
+ && (EVP_MD_get_flags(md) & EVP_MD_FLAG_XOF) != 0) {
+ ERR_raise(ERR_LIB_PROV, PROV_R_XOF_DIGESTS_NOT_ALLOWED);
+ return 0;
+ }
#ifdef FIPS_MODULE
{
int sha1_allowed = (ctx->operation != EVP_PKEY_OP_SIGN);
if (psm2ctx->md == NULL)
return 0;
+ /* XOF digests don't work */
+ if ((EVP_MD_get_flags(psm2ctx->md) & EVP_MD_FLAG_XOF) != 0) {
+ ERR_raise(ERR_LIB_PROV, PROV_R_XOF_DIGESTS_NOT_ALLOWED);
+ return 0;
+ }
+
if (mdname == NULL)
return 1;