sm2sig.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. /*
  2. * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. /*
  10. * ECDSA low level APIs are deprecated for public use, but still ok for
  11. * internal use - SM2 implemetation uses ECDSA_size() function.
  12. */
  13. #include "internal/deprecated.h"
  14. #include <string.h> /* memcpy */
  15. #include <openssl/crypto.h>
  16. #include <openssl/core_dispatch.h>
  17. #include <openssl/core_names.h>
  18. #include <openssl/dsa.h>
  19. #include <openssl/params.h>
  20. #include <openssl/evp.h>
  21. #include <openssl/err.h>
  22. #include <openssl/proverr.h>
  23. #include "internal/nelem.h"
  24. #include "internal/sizes.h"
  25. #include "internal/cryptlib.h"
  26. #include "prov/implementations.h"
  27. #include "prov/provider_ctx.h"
  28. #include "crypto/ec.h"
  29. #include "crypto/sm2.h"
  30. #include "prov/der_sm2.h"
  31. static OSSL_FUNC_signature_newctx_fn sm2sig_newctx;
  32. static OSSL_FUNC_signature_sign_init_fn sm2sig_signature_init;
  33. static OSSL_FUNC_signature_verify_init_fn sm2sig_signature_init;
  34. static OSSL_FUNC_signature_sign_fn sm2sig_sign;
  35. static OSSL_FUNC_signature_verify_fn sm2sig_verify;
  36. static OSSL_FUNC_signature_digest_sign_init_fn sm2sig_digest_signverify_init;
  37. static OSSL_FUNC_signature_digest_sign_update_fn sm2sig_digest_signverify_update;
  38. static OSSL_FUNC_signature_digest_sign_final_fn sm2sig_digest_sign_final;
  39. static OSSL_FUNC_signature_digest_verify_init_fn sm2sig_digest_signverify_init;
  40. static OSSL_FUNC_signature_digest_verify_update_fn sm2sig_digest_signverify_update;
  41. static OSSL_FUNC_signature_digest_verify_final_fn sm2sig_digest_verify_final;
  42. static OSSL_FUNC_signature_freectx_fn sm2sig_freectx;
  43. static OSSL_FUNC_signature_dupctx_fn sm2sig_dupctx;
  44. static OSSL_FUNC_signature_get_ctx_params_fn sm2sig_get_ctx_params;
  45. static OSSL_FUNC_signature_gettable_ctx_params_fn sm2sig_gettable_ctx_params;
  46. static OSSL_FUNC_signature_set_ctx_params_fn sm2sig_set_ctx_params;
  47. static OSSL_FUNC_signature_settable_ctx_params_fn sm2sig_settable_ctx_params;
  48. static OSSL_FUNC_signature_get_ctx_md_params_fn sm2sig_get_ctx_md_params;
  49. static OSSL_FUNC_signature_gettable_ctx_md_params_fn sm2sig_gettable_ctx_md_params;
  50. static OSSL_FUNC_signature_set_ctx_md_params_fn sm2sig_set_ctx_md_params;
  51. static OSSL_FUNC_signature_settable_ctx_md_params_fn sm2sig_settable_ctx_md_params;
  52. /*
  53. * What's passed as an actual key is defined by the KEYMGMT interface.
  54. * We happen to know that our KEYMGMT simply passes EC structures, so
  55. * we use that here too.
  56. */
  57. typedef struct {
  58. OSSL_LIB_CTX *libctx;
  59. char *propq;
  60. EC_KEY *ec;
  61. /*
  62. * Flag to determine if the hash function can be changed (1) or not (0)
  63. * Because it's dangerous to change during a DigestSign or DigestVerify
  64. * operation, this flag is cleared by their Init function, and set again
  65. * by their Final function.
  66. */
  67. unsigned int flag_allow_md : 1;
  68. /*
  69. * Flag to termine if the 'z' digest needs to be computed and fed to the
  70. * hash function.
  71. * This flag should be set on initialization and the compuation should
  72. * be performed only once, on first update.
  73. */
  74. unsigned int flag_compute_z_digest : 1;
  75. char mdname[OSSL_MAX_NAME_SIZE];
  76. /* The Algorithm Identifier of the combined signature algorithm */
  77. unsigned char aid_buf[OSSL_MAX_ALGORITHM_ID_SIZE];
  78. unsigned char *aid;
  79. size_t aid_len;
  80. /* main digest */
  81. EVP_MD *md;
  82. EVP_MD_CTX *mdctx;
  83. size_t mdsize;
  84. /* SM2 ID used for calculating the Z value */
  85. unsigned char *id;
  86. size_t id_len;
  87. } PROV_SM2_CTX;
  88. static void *sm2sig_newctx(void *provctx, const char *propq)
  89. {
  90. PROV_SM2_CTX *ctx = OPENSSL_zalloc(sizeof(PROV_SM2_CTX));
  91. if (ctx == NULL)
  92. return NULL;
  93. ctx->libctx = PROV_LIBCTX_OF(provctx);
  94. if (propq != NULL && (ctx->propq = OPENSSL_strdup(propq)) == NULL) {
  95. OPENSSL_free(ctx);
  96. ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
  97. return NULL;
  98. }
  99. /* don't allow to change MD, and in fact there is no such need */
  100. ctx->flag_allow_md = 0;
  101. return ctx;
  102. }
  103. static int sm2sig_signature_init(void *vpsm2ctx, void *ec,
  104. const OSSL_PARAM params[])
  105. {
  106. PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx;
  107. if (psm2ctx == NULL || ec == NULL || !EC_KEY_up_ref(ec))
  108. return 0;
  109. EC_KEY_free(psm2ctx->ec);
  110. psm2ctx->ec = ec;
  111. return sm2sig_set_ctx_params(psm2ctx, params);
  112. }
  113. static int sm2sig_sign(void *vpsm2ctx, unsigned char *sig, size_t *siglen,
  114. size_t sigsize, const unsigned char *tbs, size_t tbslen)
  115. {
  116. PROV_SM2_CTX *ctx = (PROV_SM2_CTX *)vpsm2ctx;
  117. int ret;
  118. unsigned int sltmp;
  119. /* SM2 uses ECDSA_size as well */
  120. size_t ecsize = ECDSA_size(ctx->ec);
  121. if (sig == NULL) {
  122. *siglen = ecsize;
  123. return 1;
  124. }
  125. if (sigsize < (size_t)ecsize)
  126. return 0;
  127. if (ctx->mdsize != 0 && tbslen != ctx->mdsize)
  128. return 0;
  129. ret = ossl_sm2_internal_sign(tbs, tbslen, sig, &sltmp, ctx->ec);
  130. if (ret <= 0)
  131. return 0;
  132. *siglen = sltmp;
  133. return 1;
  134. }
  135. static int sm2sig_verify(void *vpsm2ctx, const unsigned char *sig, size_t siglen,
  136. const unsigned char *tbs, size_t tbslen)
  137. {
  138. PROV_SM2_CTX *ctx = (PROV_SM2_CTX *)vpsm2ctx;
  139. if (ctx->mdsize != 0 && tbslen != ctx->mdsize)
  140. return 0;
  141. return ossl_sm2_internal_verify(tbs, tbslen, sig, siglen, ctx->ec);
  142. }
  143. static void free_md(PROV_SM2_CTX *ctx)
  144. {
  145. EVP_MD_CTX_free(ctx->mdctx);
  146. EVP_MD_free(ctx->md);
  147. ctx->mdctx = NULL;
  148. ctx->md = NULL;
  149. ctx->mdsize = 0;
  150. }
  151. static int sm2sig_digest_signverify_init(void *vpsm2ctx, const char *mdname,
  152. void *ec, const OSSL_PARAM params[])
  153. {
  154. PROV_SM2_CTX *ctx = (PROV_SM2_CTX *)vpsm2ctx;
  155. int md_nid = NID_sm3;
  156. WPACKET pkt;
  157. int ret = 0;
  158. free_md(ctx);
  159. if (!sm2sig_signature_init(vpsm2ctx, ec, params))
  160. return ret;
  161. ctx->md = EVP_MD_fetch(ctx->libctx, mdname, ctx->propq);
  162. ctx->mdsize = EVP_MD_size(ctx->md);
  163. ctx->mdctx = EVP_MD_CTX_new();
  164. if (ctx->mdctx == NULL)
  165. goto error;
  166. /*
  167. * We do not care about DER writing errors.
  168. * All it really means is that for some reason, there's no
  169. * AlgorithmIdentifier to be had, but the operation itself is
  170. * still valid, just as long as it's not used to construct
  171. * anything that needs an AlgorithmIdentifier.
  172. */
  173. ctx->aid_len = 0;
  174. if (WPACKET_init_der(&pkt, ctx->aid_buf, sizeof(ctx->aid_buf))
  175. && ossl_DER_w_algorithmIdentifier_SM2_with_MD(&pkt, -1, ctx->ec, md_nid)
  176. && WPACKET_finish(&pkt)) {
  177. WPACKET_get_total_written(&pkt, &ctx->aid_len);
  178. ctx->aid = WPACKET_get_curr(&pkt);
  179. }
  180. WPACKET_cleanup(&pkt);
  181. if (!EVP_DigestInit_ex2(ctx->mdctx, ctx->md, params))
  182. goto error;
  183. ctx->flag_compute_z_digest = 1;
  184. ret = 1;
  185. error:
  186. if (!ret)
  187. free_md(ctx);
  188. return ret;
  189. }
  190. static int sm2sig_compute_z_digest(PROV_SM2_CTX *ctx)
  191. {
  192. uint8_t *z = NULL;
  193. int ret = 1;
  194. if (ctx->flag_compute_z_digest) {
  195. /* Only do this once */
  196. ctx->flag_compute_z_digest = 0;
  197. if ((z = OPENSSL_zalloc(ctx->mdsize)) == NULL
  198. /* get hashed prefix 'z' of tbs message */
  199. || !ossl_sm2_compute_z_digest(z, ctx->md, ctx->id, ctx->id_len,
  200. ctx->ec)
  201. || !EVP_DigestUpdate(ctx->mdctx, z, ctx->mdsize))
  202. ret = 0;
  203. OPENSSL_free(z);
  204. }
  205. return ret;
  206. }
  207. int sm2sig_digest_signverify_update(void *vpsm2ctx, const unsigned char *data,
  208. size_t datalen)
  209. {
  210. PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx;
  211. if (psm2ctx == NULL || psm2ctx->mdctx == NULL)
  212. return 0;
  213. return sm2sig_compute_z_digest(psm2ctx)
  214. && EVP_DigestUpdate(psm2ctx->mdctx, data, datalen);
  215. }
  216. int sm2sig_digest_sign_final(void *vpsm2ctx, unsigned char *sig, size_t *siglen,
  217. size_t sigsize)
  218. {
  219. PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx;
  220. unsigned char digest[EVP_MAX_MD_SIZE];
  221. unsigned int dlen = 0;
  222. if (psm2ctx == NULL || psm2ctx->mdctx == NULL)
  223. return 0;
  224. /*
  225. * If sig is NULL then we're just finding out the sig size. Other fields
  226. * are ignored. Defer to sm2sig_sign.
  227. */
  228. if (sig != NULL) {
  229. if (!(sm2sig_compute_z_digest(psm2ctx)
  230. && EVP_DigestFinal_ex(psm2ctx->mdctx, digest, &dlen)))
  231. return 0;
  232. }
  233. return sm2sig_sign(vpsm2ctx, sig, siglen, sigsize, digest, (size_t)dlen);
  234. }
  235. int sm2sig_digest_verify_final(void *vpsm2ctx, const unsigned char *sig,
  236. size_t siglen)
  237. {
  238. PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx;
  239. unsigned char digest[EVP_MAX_MD_SIZE];
  240. unsigned int dlen = 0;
  241. if (psm2ctx == NULL || psm2ctx->mdctx == NULL)
  242. return 0;
  243. /* SM2 always use SM3 so it's not possible to exceed the limit */
  244. if (!(sm2sig_compute_z_digest(psm2ctx)
  245. && EVP_DigestFinal_ex(psm2ctx->mdctx, digest, &dlen)))
  246. return 0;
  247. return sm2sig_verify(vpsm2ctx, sig, siglen, digest, (size_t)dlen);
  248. }
  249. static void sm2sig_freectx(void *vpsm2ctx)
  250. {
  251. PROV_SM2_CTX *ctx = (PROV_SM2_CTX *)vpsm2ctx;
  252. free_md(ctx);
  253. EC_KEY_free(ctx->ec);
  254. OPENSSL_free(ctx->id);
  255. OPENSSL_free(ctx);
  256. }
  257. static void *sm2sig_dupctx(void *vpsm2ctx)
  258. {
  259. PROV_SM2_CTX *srcctx = (PROV_SM2_CTX *)vpsm2ctx;
  260. PROV_SM2_CTX *dstctx;
  261. dstctx = OPENSSL_zalloc(sizeof(*srcctx));
  262. if (dstctx == NULL)
  263. return NULL;
  264. *dstctx = *srcctx;
  265. dstctx->ec = NULL;
  266. dstctx->md = NULL;
  267. dstctx->mdctx = NULL;
  268. if (srcctx->ec != NULL && !EC_KEY_up_ref(srcctx->ec))
  269. goto err;
  270. dstctx->ec = srcctx->ec;
  271. if (srcctx->md != NULL && !EVP_MD_up_ref(srcctx->md))
  272. goto err;
  273. dstctx->md = srcctx->md;
  274. if (srcctx->mdctx != NULL) {
  275. dstctx->mdctx = EVP_MD_CTX_new();
  276. if (dstctx->mdctx == NULL
  277. || !EVP_MD_CTX_copy_ex(dstctx->mdctx, srcctx->mdctx))
  278. goto err;
  279. }
  280. if (srcctx->id != NULL) {
  281. dstctx->id = OPENSSL_malloc(srcctx->id_len);
  282. if (dstctx->id == NULL)
  283. goto err;
  284. dstctx->id_len = srcctx->id_len;
  285. memcpy(dstctx->id, srcctx->id, srcctx->id_len);
  286. }
  287. return dstctx;
  288. err:
  289. sm2sig_freectx(dstctx);
  290. return NULL;
  291. }
  292. static int sm2sig_get_ctx_params(void *vpsm2ctx, OSSL_PARAM *params)
  293. {
  294. PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx;
  295. OSSL_PARAM *p;
  296. if (psm2ctx == NULL)
  297. return 0;
  298. p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_ALGORITHM_ID);
  299. if (p != NULL
  300. && !OSSL_PARAM_set_octet_string(p, psm2ctx->aid, psm2ctx->aid_len))
  301. return 0;
  302. p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_DIGEST_SIZE);
  303. if (p != NULL && !OSSL_PARAM_set_size_t(p, psm2ctx->mdsize))
  304. return 0;
  305. p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_DIGEST);
  306. if (p != NULL && !OSSL_PARAM_set_utf8_string(p, psm2ctx->md == NULL
  307. ? psm2ctx->mdname
  308. : EVP_MD_name(psm2ctx->md)))
  309. return 0;
  310. return 1;
  311. }
  312. static const OSSL_PARAM known_gettable_ctx_params[] = {
  313. OSSL_PARAM_octet_string(OSSL_SIGNATURE_PARAM_ALGORITHM_ID, NULL, 0),
  314. OSSL_PARAM_size_t(OSSL_SIGNATURE_PARAM_DIGEST_SIZE, NULL),
  315. OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0),
  316. OSSL_PARAM_END
  317. };
  318. static const OSSL_PARAM *sm2sig_gettable_ctx_params(ossl_unused void *vpsm2ctx,
  319. ossl_unused void *provctx)
  320. {
  321. return known_gettable_ctx_params;
  322. }
  323. static int sm2sig_set_ctx_params(void *vpsm2ctx, const OSSL_PARAM params[])
  324. {
  325. PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx;
  326. const OSSL_PARAM *p;
  327. char *mdname;
  328. if (psm2ctx == NULL)
  329. return 0;
  330. if (params == NULL)
  331. return 1;
  332. p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_DIST_ID);
  333. if (p != NULL) {
  334. void *tmp_id = NULL;
  335. size_t tmp_idlen;
  336. /*
  337. * If the 'z' digest has already been computed, the ID is set too late
  338. */
  339. if (!psm2ctx->flag_compute_z_digest)
  340. return 0;
  341. if (!OSSL_PARAM_get_octet_string(p, &tmp_id, 0, &tmp_idlen))
  342. return 0;
  343. OPENSSL_free(psm2ctx->id);
  344. psm2ctx->id = tmp_id;
  345. psm2ctx->id_len = tmp_idlen;
  346. }
  347. if (psm2ctx->md != NULL) {
  348. /*
  349. * You cannot set the digest name/size when doing a DigestSign or
  350. * DigestVerify.
  351. */
  352. return 1;
  353. }
  354. p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_DIGEST_SIZE);
  355. if (p != NULL && !OSSL_PARAM_get_size_t(p, &psm2ctx->mdsize))
  356. return 0;
  357. /*
  358. * We never actually use the mdname, but we do support getting it later.
  359. * This can be useful for applications that want to know the MD that they
  360. * previously set.
  361. */
  362. p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_DIGEST);
  363. mdname = psm2ctx->mdname;
  364. if (p != NULL
  365. && !OSSL_PARAM_get_utf8_string(p, &mdname, sizeof(psm2ctx->mdname)))
  366. return 0;
  367. return 1;
  368. }
  369. static const OSSL_PARAM known_settable_ctx_params[] = {
  370. OSSL_PARAM_size_t(OSSL_SIGNATURE_PARAM_DIGEST_SIZE, NULL),
  371. OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0),
  372. OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_DIST_ID, NULL, 0),
  373. OSSL_PARAM_END
  374. };
  375. static const OSSL_PARAM *sm2sig_settable_ctx_params(ossl_unused void *vpsm2ctx,
  376. ossl_unused void *provctx)
  377. {
  378. /*
  379. * TODO(3.0): Should this function return a different set of settable ctx
  380. * params if the ctx is being used for a DigestSign/DigestVerify? In that
  381. * case it is not allowed to set the digest size/digest name because the
  382. * digest is explicitly set as part of the init.
  383. */
  384. return known_settable_ctx_params;
  385. }
  386. static int sm2sig_get_ctx_md_params(void *vpsm2ctx, OSSL_PARAM *params)
  387. {
  388. PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx;
  389. if (psm2ctx->mdctx == NULL)
  390. return 0;
  391. return EVP_MD_CTX_get_params(psm2ctx->mdctx, params);
  392. }
  393. static const OSSL_PARAM *sm2sig_gettable_ctx_md_params(void *vpsm2ctx)
  394. {
  395. PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx;
  396. if (psm2ctx->md == NULL)
  397. return 0;
  398. return EVP_MD_gettable_ctx_params(psm2ctx->md);
  399. }
  400. static int sm2sig_set_ctx_md_params(void *vpsm2ctx, const OSSL_PARAM params[])
  401. {
  402. PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx;
  403. if (psm2ctx->mdctx == NULL)
  404. return 0;
  405. return EVP_MD_CTX_set_params(psm2ctx->mdctx, params);
  406. }
  407. static const OSSL_PARAM *sm2sig_settable_ctx_md_params(void *vpsm2ctx)
  408. {
  409. PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx;
  410. if (psm2ctx->md == NULL)
  411. return 0;
  412. return EVP_MD_settable_ctx_params(psm2ctx->md);
  413. }
  414. const OSSL_DISPATCH ossl_sm2_signature_functions[] = {
  415. { OSSL_FUNC_SIGNATURE_NEWCTX, (void (*)(void))sm2sig_newctx },
  416. { OSSL_FUNC_SIGNATURE_SIGN_INIT, (void (*)(void))sm2sig_signature_init },
  417. { OSSL_FUNC_SIGNATURE_SIGN, (void (*)(void))sm2sig_sign },
  418. { OSSL_FUNC_SIGNATURE_VERIFY_INIT, (void (*)(void))sm2sig_signature_init },
  419. { OSSL_FUNC_SIGNATURE_VERIFY, (void (*)(void))sm2sig_verify },
  420. { OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT,
  421. (void (*)(void))sm2sig_digest_signverify_init },
  422. { OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE,
  423. (void (*)(void))sm2sig_digest_signverify_update },
  424. { OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL,
  425. (void (*)(void))sm2sig_digest_sign_final },
  426. { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT,
  427. (void (*)(void))sm2sig_digest_signverify_init },
  428. { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE,
  429. (void (*)(void))sm2sig_digest_signverify_update },
  430. { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL,
  431. (void (*)(void))sm2sig_digest_verify_final },
  432. { OSSL_FUNC_SIGNATURE_FREECTX, (void (*)(void))sm2sig_freectx },
  433. { OSSL_FUNC_SIGNATURE_DUPCTX, (void (*)(void))sm2sig_dupctx },
  434. { OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS, (void (*)(void))sm2sig_get_ctx_params },
  435. { OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS,
  436. (void (*)(void))sm2sig_gettable_ctx_params },
  437. { OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS, (void (*)(void))sm2sig_set_ctx_params },
  438. { OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS,
  439. (void (*)(void))sm2sig_settable_ctx_params },
  440. { OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS,
  441. (void (*)(void))sm2sig_get_ctx_md_params },
  442. { OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS,
  443. (void (*)(void))sm2sig_gettable_ctx_md_params },
  444. { OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS,
  445. (void (*)(void))sm2sig_set_ctx_md_params },
  446. { OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS,
  447. (void (*)(void))sm2sig_settable_ctx_md_params },
  448. { 0, NULL }
  449. };