Lines Matching refs:psm2ctx
93 static int sm2sig_set_mdname(PROV_SM2_CTX *psm2ctx, const char *mdname) in sm2sig_set_mdname() argument
95 if (psm2ctx->md == NULL) /* We need an SM3 md to compare with */ in sm2sig_set_mdname()
96 psm2ctx->md = EVP_MD_fetch(psm2ctx->libctx, psm2ctx->mdname, in sm2sig_set_mdname()
97 psm2ctx->propq); in sm2sig_set_mdname()
98 if (psm2ctx->md == NULL) in sm2sig_set_mdname()
104 if (strlen(mdname) >= sizeof(psm2ctx->mdname) in sm2sig_set_mdname()
105 || !EVP_MD_is_a(psm2ctx->md, mdname)) { in sm2sig_set_mdname()
111 OPENSSL_strlcpy(psm2ctx->mdname, mdname, sizeof(psm2ctx->mdname)); in sm2sig_set_mdname()
136 PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx; in sm2sig_signature_init() local
139 || psm2ctx == NULL) in sm2sig_signature_init()
142 if (ec == NULL && psm2ctx->ec == NULL) { in sm2sig_signature_init()
150 EC_KEY_free(psm2ctx->ec); in sm2sig_signature_init()
151 psm2ctx->ec = ec; in sm2sig_signature_init()
154 return sm2sig_set_ctx_params(psm2ctx, params); in sm2sig_signature_init()
275 PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx; in sm2sig_digest_signverify_update() local
277 if (psm2ctx == NULL || psm2ctx->mdctx == NULL) in sm2sig_digest_signverify_update()
280 return sm2sig_compute_z_digest(psm2ctx) in sm2sig_digest_signverify_update()
281 && EVP_DigestUpdate(psm2ctx->mdctx, data, datalen); in sm2sig_digest_signverify_update()
287 PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx; in sm2sig_digest_sign_final() local
291 if (psm2ctx == NULL || psm2ctx->mdctx == NULL) in sm2sig_digest_sign_final()
299 if (!(sm2sig_compute_z_digest(psm2ctx) in sm2sig_digest_sign_final()
300 && EVP_DigestFinal_ex(psm2ctx->mdctx, digest, &dlen))) in sm2sig_digest_sign_final()
311 PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx; in sm2sig_digest_verify_final() local
315 if (psm2ctx == NULL in sm2sig_digest_verify_final()
316 || psm2ctx->mdctx == NULL in sm2sig_digest_verify_final()
317 || EVP_MD_get_size(psm2ctx->md) > (int)sizeof(digest)) in sm2sig_digest_verify_final()
320 if (!(sm2sig_compute_z_digest(psm2ctx) in sm2sig_digest_verify_final()
321 && EVP_DigestFinal_ex(psm2ctx->mdctx, digest, &dlen))) in sm2sig_digest_verify_final()
382 PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx; in sm2sig_get_ctx_params() local
385 if (psm2ctx == NULL) in sm2sig_get_ctx_params()
390 && !OSSL_PARAM_set_octet_string(p, psm2ctx->aid, psm2ctx->aid_len)) in sm2sig_get_ctx_params()
394 if (p != NULL && !OSSL_PARAM_set_size_t(p, psm2ctx->mdsize)) in sm2sig_get_ctx_params()
398 if (p != NULL && !OSSL_PARAM_set_utf8_string(p, psm2ctx->md == NULL in sm2sig_get_ctx_params()
399 ? psm2ctx->mdname in sm2sig_get_ctx_params()
400 : EVP_MD_get0_name(psm2ctx->md))) in sm2sig_get_ctx_params()
421 PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx; in sm2sig_set_ctx_params() local
425 if (psm2ctx == NULL) in sm2sig_set_ctx_params()
438 if (!psm2ctx->flag_compute_z_digest) in sm2sig_set_ctx_params()
444 OPENSSL_free(psm2ctx->id); in sm2sig_set_ctx_params()
445 psm2ctx->id = tmp_id; in sm2sig_set_ctx_params()
446 psm2ctx->id_len = tmp_idlen; in sm2sig_set_ctx_params()
457 || mdsize != psm2ctx->mdsize)) in sm2sig_set_ctx_params()
466 if (!sm2sig_set_mdname(psm2ctx, mdname)) { in sm2sig_set_ctx_params()
491 PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx; in sm2sig_get_ctx_md_params() local
493 if (psm2ctx->mdctx == NULL) in sm2sig_get_ctx_md_params()
496 return EVP_MD_CTX_get_params(psm2ctx->mdctx, params); in sm2sig_get_ctx_md_params()
501 PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx; in sm2sig_gettable_ctx_md_params() local
503 if (psm2ctx->md == NULL) in sm2sig_gettable_ctx_md_params()
506 return EVP_MD_gettable_ctx_params(psm2ctx->md); in sm2sig_gettable_ctx_md_params()
511 PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx; in sm2sig_set_ctx_md_params() local
513 if (psm2ctx->mdctx == NULL) in sm2sig_set_ctx_md_params()
516 return EVP_MD_CTX_set_params(psm2ctx->mdctx, params); in sm2sig_set_ctx_md_params()
521 PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx; in sm2sig_settable_ctx_md_params() local
523 if (psm2ctx->md == NULL) in sm2sig_settable_ctx_md_params()
526 return EVP_MD_settable_ctx_params(psm2ctx->md); in sm2sig_settable_ctx_md_params()