EVP_PKEY_ASN1_METHOD.3ossl 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "EVP_PKEY_ASN1_METHOD 3ossl"
  58. .TH EVP_PKEY_ASN1_METHOD 3ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. EVP_PKEY_ASN1_METHOD,
  65. EVP_PKEY_asn1_new,
  66. EVP_PKEY_asn1_copy,
  67. EVP_PKEY_asn1_free,
  68. EVP_PKEY_asn1_add0,
  69. EVP_PKEY_asn1_add_alias,
  70. EVP_PKEY_asn1_set_public,
  71. EVP_PKEY_asn1_set_private,
  72. EVP_PKEY_asn1_set_param,
  73. EVP_PKEY_asn1_set_free,
  74. EVP_PKEY_asn1_set_ctrl,
  75. EVP_PKEY_asn1_set_item,
  76. EVP_PKEY_asn1_set_siginf,
  77. EVP_PKEY_asn1_set_check,
  78. EVP_PKEY_asn1_set_public_check,
  79. EVP_PKEY_asn1_set_param_check,
  80. EVP_PKEY_asn1_set_security_bits,
  81. EVP_PKEY_asn1_set_set_priv_key,
  82. EVP_PKEY_asn1_set_set_pub_key,
  83. EVP_PKEY_asn1_set_get_priv_key,
  84. EVP_PKEY_asn1_set_get_pub_key,
  85. EVP_PKEY_get0_asn1
  86. \&\- manipulating and registering EVP_PKEY_ASN1_METHOD structure
  87. .SH SYNOPSIS
  88. .IX Header "SYNOPSIS"
  89. .Vb 1
  90. \& #include <openssl/evp.h>
  91. \&
  92. \& typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;
  93. \&
  94. \& EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,
  95. \& const char *pem_str,
  96. \& const char *info);
  97. \& void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,
  98. \& const EVP_PKEY_ASN1_METHOD *src);
  99. \& void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth);
  100. \& int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth);
  101. \& int EVP_PKEY_asn1_add_alias(int to, int from);
  102. \&
  103. \& void EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth,
  104. \& int (*pub_decode) (EVP_PKEY *pk,
  105. \& const X509_PUBKEY *pub),
  106. \& int (*pub_encode) (X509_PUBKEY *pub,
  107. \& const EVP_PKEY *pk),
  108. \& int (*pub_cmp) (const EVP_PKEY *a,
  109. \& const EVP_PKEY *b),
  110. \& int (*pub_print) (BIO *out,
  111. \& const EVP_PKEY *pkey,
  112. \& int indent, ASN1_PCTX *pctx),
  113. \& int (*pkey_size) (const EVP_PKEY *pk),
  114. \& int (*pkey_bits) (const EVP_PKEY *pk));
  115. \& void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth,
  116. \& int (*priv_decode) (EVP_PKEY *pk,
  117. \& const PKCS8_PRIV_KEY_INFO
  118. \& *p8inf),
  119. \& int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8,
  120. \& const EVP_PKEY *pk),
  121. \& int (*priv_print) (BIO *out,
  122. \& const EVP_PKEY *pkey,
  123. \& int indent,
  124. \& ASN1_PCTX *pctx));
  125. \& void EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth,
  126. \& int (*param_decode) (EVP_PKEY *pkey,
  127. \& const unsigned char **pder,
  128. \& int derlen),
  129. \& int (*param_encode) (const EVP_PKEY *pkey,
  130. \& unsigned char **pder),
  131. \& int (*param_missing) (const EVP_PKEY *pk),
  132. \& int (*param_copy) (EVP_PKEY *to,
  133. \& const EVP_PKEY *from),
  134. \& int (*param_cmp) (const EVP_PKEY *a,
  135. \& const EVP_PKEY *b),
  136. \& int (*param_print) (BIO *out,
  137. \& const EVP_PKEY *pkey,
  138. \& int indent,
  139. \& ASN1_PCTX *pctx));
  140. \&
  141. \& void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,
  142. \& void (*pkey_free) (EVP_PKEY *pkey));
  143. \& void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
  144. \& int (*pkey_ctrl) (EVP_PKEY *pkey, int op,
  145. \& long arg1, void *arg2));
  146. \& void EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth,
  147. \& int (*item_verify) (EVP_MD_CTX *ctx,
  148. \& const ASN1_ITEM *it,
  149. \& void *asn,
  150. \& X509_ALGOR *a,
  151. \& ASN1_BIT_STRING *sig,
  152. \& EVP_PKEY *pkey),
  153. \& int (*item_sign) (EVP_MD_CTX *ctx,
  154. \& const ASN1_ITEM *it,
  155. \& void *asn,
  156. \& X509_ALGOR *alg1,
  157. \& X509_ALGOR *alg2,
  158. \& ASN1_BIT_STRING *sig));
  159. \&
  160. \& void EVP_PKEY_asn1_set_siginf(EVP_PKEY_ASN1_METHOD *ameth,
  161. \& int (*siginf_set) (X509_SIG_INFO *siginf,
  162. \& const X509_ALGOR *alg,
  163. \& const ASN1_STRING *sig));
  164. \&
  165. \& void EVP_PKEY_asn1_set_check(EVP_PKEY_ASN1_METHOD *ameth,
  166. \& int (*pkey_check) (const EVP_PKEY *pk));
  167. \&
  168. \& void EVP_PKEY_asn1_set_public_check(EVP_PKEY_ASN1_METHOD *ameth,
  169. \& int (*pkey_pub_check) (const EVP_PKEY *pk));
  170. \&
  171. \& void EVP_PKEY_asn1_set_param_check(EVP_PKEY_ASN1_METHOD *ameth,
  172. \& int (*pkey_param_check) (const EVP_PKEY *pk));
  173. \&
  174. \& void EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth,
  175. \& int (*pkey_security_bits) (const EVP_PKEY
  176. \& *pk));
  177. \&
  178. \& void EVP_PKEY_asn1_set_set_priv_key(EVP_PKEY_ASN1_METHOD *ameth,
  179. \& int (*set_priv_key) (EVP_PKEY *pk,
  180. \& const unsigned char
  181. \& *priv,
  182. \& size_t len));
  183. \&
  184. \& void EVP_PKEY_asn1_set_set_pub_key(EVP_PKEY_ASN1_METHOD *ameth,
  185. \& int (*set_pub_key) (EVP_PKEY *pk,
  186. \& const unsigned char *pub,
  187. \& size_t len));
  188. \&
  189. \& void EVP_PKEY_asn1_set_get_priv_key(EVP_PKEY_ASN1_METHOD *ameth,
  190. \& int (*get_priv_key) (const EVP_PKEY *pk,
  191. \& unsigned char *priv,
  192. \& size_t *len));
  193. \&
  194. \& void EVP_PKEY_asn1_set_get_pub_key(EVP_PKEY_ASN1_METHOD *ameth,
  195. \& int (*get_pub_key) (const EVP_PKEY *pk,
  196. \& unsigned char *pub,
  197. \& size_t *len));
  198. \&
  199. \& const EVP_PKEY_ASN1_METHOD *EVP_PKEY_get0_asn1(const EVP_PKEY *pkey);
  200. .Ve
  201. .SH DESCRIPTION
  202. .IX Header "DESCRIPTION"
  203. \&\fBEVP_PKEY_ASN1_METHOD\fR is a structure which holds a set of ASN.1
  204. conversion, printing and information methods for a specific public key
  205. algorithm.
  206. .PP
  207. There are two places where the \fBEVP_PKEY_ASN1_METHOD\fR objects are
  208. stored: one is a built-in array representing the standard methods for
  209. different algorithms, and the other one is a stack of user-defined
  210. application-specific methods, which can be manipulated by using
  211. \&\fBEVP_PKEY_asn1_add0\fR\|(3).
  212. .SS Methods
  213. .IX Subsection "Methods"
  214. The methods are the underlying implementations of a particular public
  215. key algorithm present by the \fBEVP_PKEY\fR object.
  216. .PP
  217. .Vb 5
  218. \& int (*pub_decode) (EVP_PKEY *pk, const X509_PUBKEY *pub);
  219. \& int (*pub_encode) (X509_PUBKEY *pub, const EVP_PKEY *pk);
  220. \& int (*pub_cmp) (const EVP_PKEY *a, const EVP_PKEY *b);
  221. \& int (*pub_print) (BIO *out, const EVP_PKEY *pkey, int indent,
  222. \& ASN1_PCTX *pctx);
  223. .Ve
  224. .PP
  225. The \fBpub_decode()\fR and \fBpub_encode()\fR methods are called to decode /
  226. encode \fBX509_PUBKEY\fR ASN.1 parameters to / from \fBpk\fR.
  227. They MUST return 0 on error, 1 on success.
  228. They're called by \fBX509_PUBKEY_get0\fR\|(3) and \fBX509_PUBKEY_set\fR\|(3).
  229. .PP
  230. The \fBpub_cmp()\fR method is called when two public keys are to be
  231. compared.
  232. It MUST return 1 when the keys are equal, 0 otherwise.
  233. It's called by \fBEVP_PKEY_eq\fR\|(3).
  234. .PP
  235. The \fBpub_print()\fR method is called to print a public key in humanly
  236. readable text to \fBout\fR, indented \fBindent\fR spaces.
  237. It MUST return 0 on error, 1 on success.
  238. It's called by \fBEVP_PKEY_print_public\fR\|(3).
  239. .PP
  240. .Vb 4
  241. \& int (*priv_decode) (EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf);
  242. \& int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk);
  243. \& int (*priv_print) (BIO *out, const EVP_PKEY *pkey, int indent,
  244. \& ASN1_PCTX *pctx);
  245. .Ve
  246. .PP
  247. The \fBpriv_decode()\fR and \fBpriv_encode()\fR methods are called to decode /
  248. encode \fBPKCS8_PRIV_KEY_INFO\fR form private key to / from \fBpk\fR.
  249. They MUST return 0 on error, 1 on success.
  250. They're called by \fBEVP_PKCS82PKEY\fR\|(3) and \fBEVP_PKEY2PKCS8\fR\|(3).
  251. .PP
  252. The \fBpriv_print()\fR method is called to print a private key in humanly
  253. readable text to \fBout\fR, indented \fBindent\fR spaces.
  254. It MUST return 0 on error, 1 on success.
  255. It's called by \fBEVP_PKEY_print_private\fR\|(3).
  256. .PP
  257. .Vb 3
  258. \& int (*pkey_size) (const EVP_PKEY *pk);
  259. \& int (*pkey_bits) (const EVP_PKEY *pk);
  260. \& int (*pkey_security_bits) (const EVP_PKEY *pk);
  261. .Ve
  262. .PP
  263. The \fBpkey_size()\fR method returns the key size in bytes.
  264. It's called by \fBEVP_PKEY_get_size\fR\|(3).
  265. .PP
  266. The \fBpkey_bits()\fR method returns the key size in bits.
  267. It's called by \fBEVP_PKEY_get_bits\fR\|(3).
  268. .PP
  269. .Vb 8
  270. \& int (*param_decode) (EVP_PKEY *pkey,
  271. \& const unsigned char **pder, int derlen);
  272. \& int (*param_encode) (const EVP_PKEY *pkey, unsigned char **pder);
  273. \& int (*param_missing) (const EVP_PKEY *pk);
  274. \& int (*param_copy) (EVP_PKEY *to, const EVP_PKEY *from);
  275. \& int (*param_cmp) (const EVP_PKEY *a, const EVP_PKEY *b);
  276. \& int (*param_print) (BIO *out, const EVP_PKEY *pkey, int indent,
  277. \& ASN1_PCTX *pctx);
  278. .Ve
  279. .PP
  280. The \fBparam_decode()\fR and \fBparam_encode()\fR methods are called to decode /
  281. encode DER formatted parameters to / from \fBpk\fR.
  282. They MUST return 0 on error, 1 on success.
  283. They're called by \fBPEM_read_bio_Parameters\fR\|(3) and the \fBfile:\fR
  284. \&\fBOSSL_STORE_LOADER\fR\|(3).
  285. .PP
  286. The \fBparam_missing()\fR method returns 0 if a key parameter is missing,
  287. otherwise 1.
  288. It's called by \fBEVP_PKEY_missing_parameters\fR\|(3).
  289. .PP
  290. The \fBparam_copy()\fR method copies key parameters from \fBfrom\fR to \fBto\fR.
  291. It MUST return 0 on error, 1 on success.
  292. It's called by \fBEVP_PKEY_copy_parameters\fR\|(3).
  293. .PP
  294. The \fBparam_cmp()\fR method compares the parameters of keys \fBa\fR and \fBb\fR.
  295. It MUST return 1 when the keys are equal, 0 when not equal, or a
  296. negative number on error.
  297. It's called by \fBEVP_PKEY_parameters_eq\fR\|(3).
  298. .PP
  299. The \fBparam_print()\fR method prints the private key parameters in humanly
  300. readable text to \fBout\fR, indented \fBindent\fR spaces.
  301. It MUST return 0 on error, 1 on success.
  302. It's called by \fBEVP_PKEY_print_params\fR\|(3).
  303. .PP
  304. .Vb 3
  305. \& int (*sig_print) (BIO *out,
  306. \& const X509_ALGOR *sigalg, const ASN1_STRING *sig,
  307. \& int indent, ASN1_PCTX *pctx);
  308. .Ve
  309. .PP
  310. The \fBsig_print()\fR method prints a signature in humanly readable text to
  311. \&\fBout\fR, indented \fBindent\fR spaces.
  312. \&\fBsigalg\fR contains the exact signature algorithm.
  313. If the signature in \fBsig\fR doesn't correspond to what this method
  314. expects, \fBX509_signature_dump()\fR must be used as a last resort.
  315. It MUST return 0 on error, 1 on success.
  316. It's called by \fBX509_signature_print\fR\|(3).
  317. .PP
  318. .Vb 1
  319. \& void (*pkey_free) (EVP_PKEY *pkey);
  320. .Ve
  321. .PP
  322. The \fBpkey_free()\fR method helps freeing the internals of \fBpkey\fR.
  323. It's called by \fBEVP_PKEY_free\fR\|(3), \fBEVP_PKEY_set_type\fR\|(3),
  324. \&\fBEVP_PKEY_set_type_str\fR\|(3), and \fBEVP_PKEY_assign\fR\|(3).
  325. .PP
  326. .Vb 1
  327. \& int (*pkey_ctrl) (EVP_PKEY *pkey, int op, long arg1, void *arg2);
  328. .Ve
  329. .PP
  330. The \fBpkey_ctrl()\fR method adds extra algorithm specific control.
  331. It's called by \fBEVP_PKEY_get_default_digest_nid\fR\|(3),
  332. \&\fBEVP_PKEY_set1_encoded_public_key\fR\|(3),
  333. \&\fBEVP_PKEY_get1_encoded_public_key\fR\|(3), \fBPKCS7_SIGNER_INFO_set\fR\|(3),
  334. \&\fBPKCS7_RECIP_INFO_set\fR\|(3), ...
  335. .PP
  336. .Vb 3
  337. \& int (*old_priv_decode) (EVP_PKEY *pkey,
  338. \& const unsigned char **pder, int derlen);
  339. \& int (*old_priv_encode) (const EVP_PKEY *pkey, unsigned char **pder);
  340. .Ve
  341. .PP
  342. The \fBold_priv_decode()\fR and \fBold_priv_encode()\fR methods decode / encode
  343. they private key \fBpkey\fR from / to a DER formatted array.
  344. These are exclusively used to help decoding / encoding older (pre
  345. PKCS#8) PEM formatted encrypted private keys.
  346. \&\fBold_priv_decode()\fR MUST return 0 on error, 1 on success.
  347. \&\fBold_priv_encode()\fR MUST the return same kind of values as
  348. \&\fBi2d_PrivateKey()\fR.
  349. They're called by \fBd2i_PrivateKey\fR\|(3) and \fBi2d_PrivateKey\fR\|(3).
  350. .PP
  351. .Vb 5
  352. \& int (*item_verify) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
  353. \& X509_ALGOR *a, ASN1_BIT_STRING *sig, EVP_PKEY *pkey);
  354. \& int (*item_sign) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
  355. \& X509_ALGOR *alg1, X509_ALGOR *alg2,
  356. \& ASN1_BIT_STRING *sig);
  357. .Ve
  358. .PP
  359. The \fBitem_sign()\fR and \fBitem_verify()\fR methods make it possible to have
  360. algorithm specific signatures and verification of them.
  361. .PP
  362. \&\fBitem_sign()\fR MUST return one of:
  363. .IP <=0 4
  364. .IX Item "<=0"
  365. error
  366. .IP 1 4
  367. .IX Item "1"
  368. \&\fBitem_sign()\fR did everything, OpenSSL internals just needs to pass the
  369. signature length back.
  370. .IP 2 4
  371. .IX Item "2"
  372. \&\fBitem_sign()\fR did nothing, OpenSSL internal standard routines are
  373. expected to continue with the default signature production.
  374. .IP 3 4
  375. .IX Item "3"
  376. \&\fBitem_sign()\fR set the algorithm identifier \fBalgor1\fR and \fBalgor2\fR,
  377. OpenSSL internals should just sign using those algorithms.
  378. .PP
  379. \&\fBitem_verify()\fR MUST return one of:
  380. .IP <=0 4
  381. .IX Item "<=0"
  382. error
  383. .IP 1 4
  384. .IX Item "1"
  385. \&\fBitem_sign()\fR did everything, OpenSSL internals just needs to pass the
  386. signature length back.
  387. .IP 2 4
  388. .IX Item "2"
  389. \&\fBitem_sign()\fR did nothing, OpenSSL internal standard routines are
  390. expected to continue with the default signature production.
  391. .PP
  392. \&\fBitem_verify()\fR and \fBitem_sign()\fR are called by \fBASN1_item_verify\fR\|(3) and
  393. \&\fBASN1_item_sign\fR\|(3), and by extension, \fBX509_verify\fR\|(3),
  394. \&\fBX509_REQ_verify\fR\|(3), \fBX509_sign\fR\|(3), \fBX509_REQ_sign\fR\|(3), ...
  395. .PP
  396. .Vb 2
  397. \& int (*siginf_set) (X509_SIG_INFO *siginf, const X509_ALGOR *alg,
  398. \& const ASN1_STRING *sig);
  399. .Ve
  400. .PP
  401. The \fBsiginf_set()\fR method is used to set custom \fBX509_SIG_INFO\fR
  402. parameters.
  403. It MUST return 0 on error, or 1 on success.
  404. It's called as part of \fBX509_check_purpose\fR\|(3), \fBX509_check_ca\fR\|(3)
  405. and \fBX509_check_issued\fR\|(3).
  406. .PP
  407. .Vb 3
  408. \& int (*pkey_check) (const EVP_PKEY *pk);
  409. \& int (*pkey_public_check) (const EVP_PKEY *pk);
  410. \& int (*pkey_param_check) (const EVP_PKEY *pk);
  411. .Ve
  412. .PP
  413. The \fBpkey_check()\fR, \fBpkey_public_check()\fR and \fBpkey_param_check()\fR methods are used
  414. to check the validity of \fBpk\fR for key-pair, public component and parameters,
  415. respectively.
  416. They MUST return 0 for an invalid key, or 1 for a valid key.
  417. They are called by \fBEVP_PKEY_check\fR\|(3), \fBEVP_PKEY_public_check\fR\|(3) and
  418. \&\fBEVP_PKEY_param_check\fR\|(3) respectively.
  419. .PP
  420. .Vb 2
  421. \& int (*set_priv_key) (EVP_PKEY *pk, const unsigned char *priv, size_t len);
  422. \& int (*set_pub_key) (EVP_PKEY *pk, const unsigned char *pub, size_t len);
  423. .Ve
  424. .PP
  425. The \fBset_priv_key()\fR and \fBset_pub_key()\fR methods are used to set the raw private and
  426. public key data for an EVP_PKEY. They MUST return 0 on error, or 1 on success.
  427. They are called by \fBEVP_PKEY_new_raw_private_key\fR\|(3), and
  428. \&\fBEVP_PKEY_new_raw_public_key\fR\|(3) respectively.
  429. .PP
  430. .Vb 2
  431. \& size_t (*dirty) (const EVP_PKEY *pk);
  432. \& void *(*export_to) (const EVP_PKEY *pk, EVP_KEYMGMT *keymgmt);
  433. .Ve
  434. .PP
  435. \&\fBdirty_cnt()\fR returns the internal key's dirty count.
  436. This can be used to synchronise different copies of the same keys.
  437. .PP
  438. The \fBexport_to()\fR method exports the key material from the given key to
  439. a provider, through the \fBEVP_KEYMGMT\fR\|(3) interface, if that provider
  440. supports importing key material.
  441. .SS Functions
  442. .IX Subsection "Functions"
  443. \&\fBEVP_PKEY_asn1_new()\fR creates and returns a new \fBEVP_PKEY_ASN1_METHOD\fR
  444. object, and associates the given \fBid\fR, \fBflags\fR, \fBpem_str\fR and
  445. \&\fBinfo\fR.
  446. \&\fBid\fR is a NID, \fBpem_str\fR is the PEM type string, \fBinfo\fR is a
  447. descriptive string.
  448. The following \fBflags\fR are supported:
  449. .PP
  450. .Vb 1
  451. \& ASN1_PKEY_SIGPARAM_NULL
  452. .Ve
  453. .PP
  454. If \fBASN1_PKEY_SIGPARAM_NULL\fR is set, then the signature algorithm
  455. parameters are given the type \fBV_ASN1_NULL\fR by default, otherwise
  456. they will be given the type \fBV_ASN1_UNDEF\fR (i.e. the parameter is
  457. omitted).
  458. See \fBX509_ALGOR_set0\fR\|(3) for more information.
  459. .PP
  460. \&\fBEVP_PKEY_asn1_copy()\fR copies an \fBEVP_PKEY_ASN1_METHOD\fR object from
  461. \&\fBsrc\fR to \fBdst\fR.
  462. This function is not thread safe, it's recommended to only use this
  463. when initializing the application.
  464. .PP
  465. \&\fBEVP_PKEY_asn1_free()\fR frees an existing \fBEVP_PKEY_ASN1_METHOD\fR pointed
  466. by \fBameth\fR. If the argument is NULL, nothing is done.
  467. .PP
  468. \&\fBEVP_PKEY_asn1_add0()\fR adds \fBameth\fR to the user defined stack of
  469. methods unless another \fBEVP_PKEY_ASN1_METHOD\fR with the same NID is
  470. already there.
  471. This function is not thread safe, it's recommended to only use this
  472. when initializing the application.
  473. .PP
  474. \&\fBEVP_PKEY_asn1_add_alias()\fR creates an alias with the NID \fBto\fR for the
  475. \&\fBEVP_PKEY_ASN1_METHOD\fR with NID \fBfrom\fR unless another
  476. \&\fBEVP_PKEY_ASN1_METHOD\fR with the same NID is already added.
  477. This function is not thread safe, it's recommended to only use this
  478. when initializing the application.
  479. .PP
  480. \&\fBEVP_PKEY_asn1_set_public()\fR, \fBEVP_PKEY_asn1_set_private()\fR,
  481. \&\fBEVP_PKEY_asn1_set_param()\fR, \fBEVP_PKEY_asn1_set_free()\fR,
  482. \&\fBEVP_PKEY_asn1_set_ctrl()\fR, \fBEVP_PKEY_asn1_set_item()\fR,
  483. \&\fBEVP_PKEY_asn1_set_siginf()\fR, \fBEVP_PKEY_asn1_set_check()\fR,
  484. \&\fBEVP_PKEY_asn1_set_public_check()\fR, \fBEVP_PKEY_asn1_set_param_check()\fR,
  485. \&\fBEVP_PKEY_asn1_set_security_bits()\fR, \fBEVP_PKEY_asn1_set_set_priv_key()\fR,
  486. \&\fBEVP_PKEY_asn1_set_set_pub_key()\fR, \fBEVP_PKEY_asn1_set_get_priv_key()\fR and
  487. \&\fBEVP_PKEY_asn1_set_get_pub_key()\fR set the diverse methods of the given
  488. \&\fBEVP_PKEY_ASN1_METHOD\fR object.
  489. .PP
  490. \&\fBEVP_PKEY_get0_asn1()\fR finds the \fBEVP_PKEY_ASN1_METHOD\fR associated
  491. with the key \fBpkey\fR.
  492. .SH "RETURN VALUES"
  493. .IX Header "RETURN VALUES"
  494. \&\fBEVP_PKEY_asn1_new()\fR returns NULL on error, or a pointer to an
  495. \&\fBEVP_PKEY_ASN1_METHOD\fR object otherwise.
  496. .PP
  497. \&\fBEVP_PKEY_asn1_add0()\fR and \fBEVP_PKEY_asn1_add_alias()\fR return 0 on error,
  498. or 1 on success.
  499. .PP
  500. \&\fBEVP_PKEY_get0_asn1()\fR returns NULL on error, or a pointer to a constant
  501. \&\fBEVP_PKEY_ASN1_METHOD\fR object otherwise.
  502. .SH HISTORY
  503. .IX Header "HISTORY"
  504. The signature of the \fIpub_decode\fR functional argument of
  505. \&\fBEVP_PKEY_asn1_set_public()\fR has changed in OpenSSL 3.0 so its \fIpub\fR
  506. parameter is now constified.
  507. .SH COPYRIGHT
  508. .IX Header "COPYRIGHT"
  509. Copyright 2017\-2024 The OpenSSL Project Authors. All Rights Reserved.
  510. .PP
  511. Licensed under the Apache License 2.0 (the "License"). You may not use
  512. this file except in compliance with the License. You can obtain a copy
  513. in the file LICENSE in the source distribution or at
  514. <https://www.openssl.org/source/license.html>.