int EVP_PKEY_CTX_set_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD *md)
{
- OSSL_PARAM sig_md_params[3], *p = sig_md_params;
- size_t mdsize;
+ OSSL_PARAM sig_md_params[2], *p = sig_md_params;
const char *name;
if (ctx == NULL || !EVP_PKEY_CTX_IS_SIGNATURE_OP(ctx)) {
if (md == NULL) {
name = "";
- mdsize = 0;
} else {
- mdsize = EVP_MD_size(md);
name = EVP_MD_name(md);
}
*/
(char *)name,
strlen(name) + 1);
- *p++ = OSSL_PARAM_construct_size_t(OSSL_SIGNATURE_PARAM_DIGEST_SIZE,
- &mdsize);
*p++ = OSSL_PARAM_construct_end();
return EVP_PKEY_CTX_set_params(ctx, sig_md_params);
#define OSSL_PKEY_PARAM_MAX_SIZE "max-size" /* integer */
#define OSSL_PKEY_PARAM_SECURITY_BITS "security-bits" /* integer */
#define OSSL_PKEY_PARAM_DIGEST OSSL_ALG_PARAM_DIGEST
-#define OSSL_PKEY_PARAM_DIGEST_SIZE "digest-size"
#define OSSL_PKEY_PARAM_DEFAULT_DIGEST "default-digest" /* utf8 string */
#define OSSL_PKEY_PARAM_MANDATORY_DIGEST "mandatory-digest" /* utf8 string */
/* Signature parameters */
#define OSSL_SIGNATURE_PARAM_ALGORITHM_ID "algorithm-id"
#define OSSL_SIGNATURE_PARAM_DIGEST OSSL_PKEY_PARAM_DIGEST
-#define OSSL_SIGNATURE_PARAM_DIGEST_SIZE OSSL_PKEY_PARAM_DIGEST_SIZE
/* Asym cipher parameters */
#define OSSL_ASYM_CIPHER_PARAM_PAD_MODE "pad-mode"
/* set signature parameters */
ossl_param_bld_init(&bld);
if (!ossl_param_bld_push_utf8_string(&bld, OSSL_SIGNATURE_PARAM_DIGEST,
- SN_sha256,strlen(SN_sha256) + 1)
- || !ossl_param_bld_push_size_t(&bld, OSSL_SIGNATURE_PARAM_DIGEST_SIZE,
- SHA256_DIGEST_LENGTH))
+ SN_sha256,strlen(SN_sha256) + 1))
goto err;
params_sig = ossl_param_bld_to_param(&bld);
if (EVP_PKEY_CTX_set_params(sctx, params_sig) <= 0)
EVP_MD_CTX_free(pdsactx->mdctx);
EVP_MD_free(pdsactx->md);
pdsactx->mdctx = NULL;
- pdsactx->mdsize = 0;
pdsactx->md = NULL;
return 0;
}
&& !OSSL_PARAM_set_octet_string(p, pdsactx->aid, pdsactx->aid_len))
return 0;
- p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_DIGEST_SIZE);
- if (p != NULL && !OSSL_PARAM_set_size_t(p, pdsactx->mdsize))
- return 0;
-
p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_DIGEST);
if (p != NULL && !OSSL_PARAM_set_utf8_string(p, pdsactx->md == NULL
? pdsactx->mdname
static const OSSL_PARAM known_gettable_ctx_params[] = {
OSSL_PARAM_octet_string(OSSL_SIGNATURE_PARAM_ALGORITHM_ID, NULL, 0),
- OSSL_PARAM_size_t(OSSL_SIGNATURE_PARAM_DIGEST_SIZE, NULL),
OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0),
OSSL_PARAM_END
};
return 1;
}
- p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_DIGEST_SIZE);
- if (p != NULL && !OSSL_PARAM_get_size_t(p, &pdsactx->mdsize))
- return 0;
-
/*
* We never actually use the mdname, but we do support getting it later.
* This can be useful for applications that want to know the MD that they
}
static const OSSL_PARAM known_settable_ctx_params[] = {
- OSSL_PARAM_size_t(OSSL_SIGNATURE_PARAM_DIGEST_SIZE, NULL),
OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0),
OSSL_PARAM_END
};
#include <openssl/dh.h>
#include "testutil.h"
#include "internal/nelem.h"
+#include "internal/sizes.h"
#include "crypto/evp.h"
/*
EVP_PKEY_CTX *ctx = NULL;
EVP_SIGNATURE *dsaimpl = NULL;
const OSSL_PARAM *params;
- OSSL_PARAM ourparams[2], *param = ourparams;
+ OSSL_PARAM ourparams[2], *param = ourparams, *param_md;
DSA *dsa = NULL;
BIGNUM *p = NULL, *q = NULL, *g = NULL, *pub = NULL, *priv = NULL;
EVP_PKEY *pkey = NULL;
int ret = 0;
const EVP_MD *md;
- size_t mdsize = SHA512_DIGEST_LENGTH;
+ char mdname[OSSL_MAX_NAME_SIZE];
char ssl3ms[48];
/*
*/
params = EVP_PKEY_CTX_settable_params(ctx);
if (!TEST_ptr(params)
- || !TEST_ptr(OSSL_PARAM_locate_const(params,
- OSSL_SIGNATURE_PARAM_DIGEST_SIZE))
|| !TEST_ptr(OSSL_PARAM_locate_const(params,
OSSL_SIGNATURE_PARAM_DIGEST)))
goto err;
if (!TEST_ptr(params)
|| !TEST_ptr(OSSL_PARAM_locate_const(params,
OSSL_SIGNATURE_PARAM_ALGORITHM_ID))
- || !TEST_ptr(OSSL_PARAM_locate_const(params,
- OSSL_SIGNATURE_PARAM_DIGEST_SIZE))
|| !TEST_ptr(OSSL_PARAM_locate_const(params,
OSSL_SIGNATURE_PARAM_DIGEST)))
goto err;
* Test getting and setting params via EVP_PKEY_CTX_set_params() and
* EVP_PKEY_CTX_get_params()
*/
- *param++ = OSSL_PARAM_construct_size_t(OSSL_SIGNATURE_PARAM_DIGEST_SIZE,
- &mdsize);
+ strcpy(mdname, "SHA512");
+ param_md = param;
+ *param++ = OSSL_PARAM_construct_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST,
+ mdname, 0);
*param++ = OSSL_PARAM_construct_end();
if (!TEST_true(EVP_PKEY_CTX_set_params(ctx, ourparams)))
goto err;
- mdsize = 0;
+ mdname[0] = '\0';
+ *param_md = OSSL_PARAM_construct_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST,
+ mdname, sizeof(mdname));
if (!TEST_true(EVP_PKEY_CTX_get_params(ctx, ourparams))
- || !TEST_size_t_eq(mdsize, SHA512_DIGEST_LENGTH))
+ || !TEST_str_eq(mdname, "SHA512"))
goto err;
/*