provider-keymgmt.7ossl 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .nr rF 0
  58. .if \n(.g .if rF .nr rF 1
  59. .if (\n(rF:(\n(.g==0)) \{\
  60. . if \nF \{\
  61. . de IX
  62. . tm Index:\\$1\t\\n%\t"\\$2"
  63. ..
  64. . if !\nF==2 \{\
  65. . nr % 0
  66. . nr F 2
  67. . \}
  68. . \}
  69. .\}
  70. .rr rF
  71. .\"
  72. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  73. .\" Fear. Run. Save yourself. No user-serviceable parts.
  74. . \" fudge factors for nroff and troff
  75. .if n \{\
  76. . ds #H 0
  77. . ds #V .8m
  78. . ds #F .3m
  79. . ds #[ \f1
  80. . ds #] \fP
  81. .\}
  82. .if t \{\
  83. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  84. . ds #V .6m
  85. . ds #F 0
  86. . ds #[ \&
  87. . ds #] \&
  88. .\}
  89. . \" simple accents for nroff and troff
  90. .if n \{\
  91. . ds ' \&
  92. . ds ` \&
  93. . ds ^ \&
  94. . ds , \&
  95. . ds ~ ~
  96. . ds /
  97. .\}
  98. .if t \{\
  99. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  100. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  101. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  102. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  103. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  104. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  105. .\}
  106. . \" troff and (daisy-wheel) nroff accents
  107. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  108. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  109. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  110. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  111. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  112. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  113. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  114. .ds ae a\h'-(\w'a'u*4/10)'e
  115. .ds Ae A\h'-(\w'A'u*4/10)'E
  116. . \" corrections for vroff
  117. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  118. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  119. . \" for low resolution devices (crt and lpr)
  120. .if \n(.H>23 .if \n(.V>19 \
  121. \{\
  122. . ds : e
  123. . ds 8 ss
  124. . ds o a
  125. . ds d- d\h'-1'\(ga
  126. . ds D- D\h'-1'\(hy
  127. . ds th \o'bp'
  128. . ds Th \o'LP'
  129. . ds ae ae
  130. . ds Ae AE
  131. .\}
  132. .rm #[ #] #H #V #F C
  133. .\" ========================================================================
  134. .\"
  135. .IX Title "PROVIDER-KEYMGMT 7ossl"
  136. .TH PROVIDER-KEYMGMT 7ossl "2024-09-03" "3.3.2" "OpenSSL"
  137. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  138. .\" way too many mistakes in technical documents.
  139. .if n .ad l
  140. .nh
  141. .SH "NAME"
  142. provider\-keymgmt \- The KEYMGMT library <\-> provider functions
  143. .SH "SYNOPSIS"
  144. .IX Header "SYNOPSIS"
  145. .Vb 1
  146. \& #include <openssl/core_dispatch.h>
  147. \&
  148. \& /*
  149. \& * None of these are actual functions, but are displayed like this for
  150. \& * the function signatures for functions that are offered as function
  151. \& * pointers in OSSL_DISPATCH arrays.
  152. \& */
  153. \&
  154. \& /* Key object (keydata) creation and destruction */
  155. \& void *OSSL_FUNC_keymgmt_new(void *provctx);
  156. \& void OSSL_FUNC_keymgmt_free(void *keydata);
  157. \&
  158. \& /* Generation, a more complex constructor */
  159. \& void *OSSL_FUNC_keymgmt_gen_init(void *provctx, int selection,
  160. \& const OSSL_PARAM params[]);
  161. \& int OSSL_FUNC_keymgmt_gen_set_template(void *genctx, void *template);
  162. \& int OSSL_FUNC_keymgmt_gen_set_params(void *genctx, const OSSL_PARAM params[]);
  163. \& const OSSL_PARAM *OSSL_FUNC_keymgmt_gen_settable_params(void *genctx,
  164. \& void *provctx);
  165. \& void *OSSL_FUNC_keymgmt_gen(void *genctx, OSSL_CALLBACK *cb, void *cbarg);
  166. \& void OSSL_FUNC_keymgmt_gen_cleanup(void *genctx);
  167. \&
  168. \& /* Key loading by object reference, also a constructor */
  169. \& void *OSSL_FUNC_keymgmt_load(const void *reference, size_t *reference_sz);
  170. \&
  171. \& /* Key object information */
  172. \& int OSSL_FUNC_keymgmt_get_params(void *keydata, OSSL_PARAM params[]);
  173. \& const OSSL_PARAM *OSSL_FUNC_keymgmt_gettable_params(void *provctx);
  174. \& int OSSL_FUNC_keymgmt_set_params(void *keydata, const OSSL_PARAM params[]);
  175. \& const OSSL_PARAM *OSSL_FUNC_keymgmt_settable_params(void *provctx);
  176. \&
  177. \& /* Key object content checks */
  178. \& int OSSL_FUNC_keymgmt_has(const void *keydata, int selection);
  179. \& int OSSL_FUNC_keymgmt_match(const void *keydata1, const void *keydata2,
  180. \& int selection);
  181. \&
  182. \& /* Discovery of supported operations */
  183. \& const char *OSSL_FUNC_keymgmt_query_operation_name(int operation_id);
  184. \&
  185. \& /* Key object import and export functions */
  186. \& int OSSL_FUNC_keymgmt_import(void *keydata, int selection, const OSSL_PARAM params[]);
  187. \& const OSSL_PARAM *OSSL_FUNC_keymgmt_import_types(int selection);
  188. \& const OSSL_PARAM *OSSL_FUNC_keymgmt_import_types_ex(void *provctx, int selection);
  189. \& int OSSL_FUNC_keymgmt_export(void *keydata, int selection,
  190. \& OSSL_CALLBACK *param_cb, void *cbarg);
  191. \& const OSSL_PARAM *OSSL_FUNC_keymgmt_export_types(int selection);
  192. \& const OSSL_PARAM *OSSL_FUNC_keymgmt_export_types_ex(void *provctx, int selection);
  193. \&
  194. \& /* Key object duplication, a constructor */
  195. \& void *OSSL_FUNC_keymgmt_dup(const void *keydata_from, int selection);
  196. \&
  197. \& /* Key object validation */
  198. \& int OSSL_FUNC_keymgmt_validate(const void *keydata, int selection, int checktype);
  199. .Ve
  200. .SH "DESCRIPTION"
  201. .IX Header "DESCRIPTION"
  202. The \s-1KEYMGMT\s0 operation doesn't have much public visibility in OpenSSL
  203. libraries, it's rather an internal operation that's designed to work
  204. in tandem with operations that use private/public key pairs.
  205. .PP
  206. Because the \s-1KEYMGMT\s0 operation shares knowledge with the operations it
  207. works with in tandem, they must belong to the same provider.
  208. The OpenSSL libraries will ensure that they do.
  209. .PP
  210. The primary responsibility of the \s-1KEYMGMT\s0 operation is to hold the
  211. provider side key data for the OpenSSL library \s-1EVP_PKEY\s0 structure.
  212. .PP
  213. All \*(L"functions\*(R" mentioned here are passed as function pointers between
  214. \&\fIlibcrypto\fR and the provider in \s-1\fBOSSL_DISPATCH\s0\fR\|(3) arrays via
  215. \&\s-1\fBOSSL_ALGORITHM\s0\fR\|(3) arrays that are returned by the provider's
  216. \&\fBprovider_query_operation()\fR function
  217. (see \*(L"Provider Functions\*(R" in \fBprovider\-base\fR\|(7)).
  218. .PP
  219. All these \*(L"functions\*(R" have a corresponding function type definition
  220. named \fBOSSL_FUNC_{name}_fn\fR, and a helper function to retrieve the
  221. function pointer from a \s-1\fBOSSL_DISPATCH\s0\fR\|(3) element named
  222. \&\fBOSSL_FUNC_{name}\fR.
  223. For example, the \*(L"function\*(R" \fBOSSL_FUNC_keymgmt_new()\fR has these:
  224. .PP
  225. .Vb 3
  226. \& typedef void *(OSSL_FUNC_keymgmt_new_fn)(void *provctx);
  227. \& static ossl_inline OSSL_FUNC_keymgmt_new_fn
  228. \& OSSL_FUNC_keymgmt_new(const OSSL_DISPATCH *opf);
  229. .Ve
  230. .PP
  231. \&\s-1\fBOSSL_DISPATCH\s0\fR\|(3) arrays are indexed by numbers that are provided as
  232. macros in \fBopenssl\-core_dispatch.h\fR\|(7), as follows:
  233. .PP
  234. .Vb 2
  235. \& OSSL_FUNC_keymgmt_new OSSL_FUNC_KEYMGMT_NEW
  236. \& OSSL_FUNC_keymgmt_free OSSL_FUNC_KEYMGMT_FREE
  237. \&
  238. \& OSSL_FUNC_keymgmt_gen_init OSSL_FUNC_KEYMGMT_GEN_INIT
  239. \& OSSL_FUNC_keymgmt_gen_set_template OSSL_FUNC_KEYMGMT_GEN_SET_TEMPLATE
  240. \& OSSL_FUNC_keymgmt_gen_set_params OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS
  241. \& OSSL_FUNC_keymgmt_gen_settable_params OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS
  242. \& OSSL_FUNC_keymgmt_gen OSSL_FUNC_KEYMGMT_GEN
  243. \& OSSL_FUNC_keymgmt_gen_cleanup OSSL_FUNC_KEYMGMT_GEN_CLEANUP
  244. \&
  245. \& OSSL_FUNC_keymgmt_load OSSL_FUNC_KEYMGMT_LOAD
  246. \&
  247. \& OSSL_FUNC_keymgmt_get_params OSSL_FUNC_KEYMGMT_GET_PARAMS
  248. \& OSSL_FUNC_keymgmt_gettable_params OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS
  249. \& OSSL_FUNC_keymgmt_set_params OSSL_FUNC_KEYMGMT_SET_PARAMS
  250. \& OSSL_FUNC_keymgmt_settable_params OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS
  251. \&
  252. \& OSSL_FUNC_keymgmt_query_operation_name OSSL_FUNC_KEYMGMT_QUERY_OPERATION_NAME
  253. \&
  254. \& OSSL_FUNC_keymgmt_has OSSL_FUNC_KEYMGMT_HAS
  255. \& OSSL_FUNC_keymgmt_validate OSSL_FUNC_KEYMGMT_VALIDATE
  256. \& OSSL_FUNC_keymgmt_match OSSL_FUNC_KEYMGMT_MATCH
  257. \&
  258. \& OSSL_FUNC_keymgmt_import OSSL_FUNC_KEYMGMT_IMPORT
  259. \& OSSL_FUNC_keymgmt_import_types OSSL_FUNC_KEYMGMT_IMPORT_TYPES
  260. \& OSSL_FUNC_keymgmt_import_types_ex OSSL_FUNC_KEYMGMT_IMPORT_TYPES_EX
  261. \& OSSL_FUNC_keymgmt_export OSSL_FUNC_KEYMGMT_EXPORT
  262. \& OSSL_FUNC_keymgmt_export_types OSSL_FUNC_KEYMGMT_EXPORT_TYPES
  263. \& OSSL_FUNC_keymgmt_export_types_ex OSSL_FUNC_KEYMGMT_EXPORT_TYPES_EX
  264. \&
  265. \& OSSL_FUNC_keymgmt_dup OSSL_FUNC_KEYMGMT_DUP
  266. .Ve
  267. .SS "Key Objects"
  268. .IX Subsection "Key Objects"
  269. A key object is a collection of data for an asymmetric key, and is
  270. represented as \fIkeydata\fR in this manual.
  271. .PP
  272. The exact contents of a key object are defined by the provider, and it
  273. is assumed that different operations in one and the same provider use
  274. the exact same structure to represent this collection of data, so that
  275. for example, a key object that has been created using the \s-1KEYMGMT\s0
  276. interface that we document here can be passed as is to other provider
  277. operations, such as \fBOP_signature_sign_init()\fR (see
  278. \&\fBprovider\-signature\fR\|(7)).
  279. .PP
  280. With some of the \s-1KEYMGMT\s0 functions, it's possible to select a specific
  281. subset of data to handle, governed by the bits in a \fIselection\fR
  282. indicator. The bits are:
  283. .IP "\fB\s-1OSSL_KEYMGMT_SELECT_PRIVATE_KEY\s0\fR" 4
  284. .IX Item "OSSL_KEYMGMT_SELECT_PRIVATE_KEY"
  285. Indicating that the private key data in a key object should be
  286. considered.
  287. .IP "\fB\s-1OSSL_KEYMGMT_SELECT_PUBLIC_KEY\s0\fR" 4
  288. .IX Item "OSSL_KEYMGMT_SELECT_PUBLIC_KEY"
  289. Indicating that the public key data in a key object should be
  290. considered.
  291. .IP "\fB\s-1OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS\s0\fR" 4
  292. .IX Item "OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS"
  293. Indicating that the domain parameters in a key object should be
  294. considered.
  295. .IP "\fB\s-1OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS\s0\fR" 4
  296. .IX Item "OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS"
  297. Indicating that other parameters in a key object should be
  298. considered.
  299. .Sp
  300. Other parameters are key parameters that don't fit any other
  301. classification. In other words, this particular selector bit works as
  302. a last resort bit bucket selector.
  303. .PP
  304. Some selector bits have also been combined for easier use:
  305. .IP "\fB\s-1OSSL_KEYMGMT_SELECT_ALL_PARAMETERS\s0\fR" 4
  306. .IX Item "OSSL_KEYMGMT_SELECT_ALL_PARAMETERS"
  307. Indicating that all key object parameters should be considered,
  308. regardless of their more granular classification.
  309. .Sp
  310. This is a combination of \fB\s-1OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS\s0\fR and
  311. \&\fB\s-1OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS\s0\fR.
  312. .IP "\fB\s-1OSSL_KEYMGMT_SELECT_KEYPAIR\s0\fR" 4
  313. .IX Item "OSSL_KEYMGMT_SELECT_KEYPAIR"
  314. Indicating that both the whole key pair in a key object should be
  315. considered, i.e. the combination of public and private key.
  316. .Sp
  317. This is a combination of \fB\s-1OSSL_KEYMGMT_SELECT_PRIVATE_KEY\s0\fR and
  318. \&\fB\s-1OSSL_KEYMGMT_SELECT_PUBLIC_KEY\s0\fR.
  319. .IP "\fB\s-1OSSL_KEYMGMT_SELECT_ALL\s0\fR" 4
  320. .IX Item "OSSL_KEYMGMT_SELECT_ALL"
  321. Indicating that everything in a key object should be considered.
  322. .PP
  323. The exact interpretation of those bits or how they combine is left to
  324. each function where you can specify a selector.
  325. .PP
  326. It's left to the provider implementation to decide what is reasonable
  327. to do with regards to received selector bits and how to do it.
  328. Among others, an implementation of \fBOSSL_FUNC_keymgmt_match()\fR might opt
  329. to not compare the private half if it has compared the public half,
  330. since a match of one half implies a match of the other half.
  331. .SS "Constructing and Destructing Functions"
  332. .IX Subsection "Constructing and Destructing Functions"
  333. \&\fBOSSL_FUNC_keymgmt_new()\fR should create a provider side key object. The
  334. provider context \fIprovctx\fR is passed and may be incorporated in the
  335. key object, but that is not mandatory.
  336. .PP
  337. \&\fBOSSL_FUNC_keymgmt_free()\fR should free the passed \fIkeydata\fR.
  338. .PP
  339. \&\fBOSSL_FUNC_keymgmt_gen_init()\fR, \fBOSSL_FUNC_keymgmt_gen_set_template()\fR,
  340. \&\fBOSSL_FUNC_keymgmt_gen_set_params()\fR, \fBOSSL_FUNC_keymgmt_gen_settable_params()\fR,
  341. \&\fBOSSL_FUNC_keymgmt_gen()\fR and \fBOSSL_FUNC_keymgmt_gen_cleanup()\fR work together as a
  342. more elaborate context based key object constructor.
  343. .PP
  344. \&\fBOSSL_FUNC_keymgmt_gen_init()\fR should create the key object generation context
  345. and initialize it with \fIselections\fR, which will determine what kind
  346. of contents the key object to be generated should get.
  347. The \fIparams\fR, if not \s-1NULL,\s0 should be set on the context in a manner similar to
  348. using \fBOSSL_FUNC_keymgmt_set_params()\fR.
  349. .PP
  350. \&\fBOSSL_FUNC_keymgmt_gen_set_template()\fR should add \fItemplate\fR to the context
  351. \&\fIgenctx\fR. The \fItemplate\fR is assumed to be a key object constructed
  352. with the same \s-1KEYMGMT,\s0 and from which content that the implementation
  353. chooses can be used as a template for the key object to be generated.
  354. Typically, the generation of a \s-1DSA\s0 or \s-1DH\s0 key would get the domain
  355. parameters from this \fItemplate\fR.
  356. .PP
  357. \&\fBOSSL_FUNC_keymgmt_gen_set_params()\fR should set additional parameters from
  358. \&\fIparams\fR in the key object generation context \fIgenctx\fR.
  359. .PP
  360. \&\fBOSSL_FUNC_keymgmt_gen_settable_params()\fR should return a constant array of
  361. descriptor \s-1\fBOSSL_PARAM\s0\fR\|(3), for parameters that \fBOSSL_FUNC_keymgmt_gen_set_params()\fR
  362. can handle.
  363. .PP
  364. \&\fBOSSL_FUNC_keymgmt_gen()\fR should perform the key object generation itself, and
  365. return the result. The callback \fIcb\fR should be called at regular
  366. intervals with indications on how the key object generation
  367. progresses.
  368. .PP
  369. \&\fBOSSL_FUNC_keymgmt_gen_cleanup()\fR should clean up and free the key object
  370. generation context \fIgenctx\fR
  371. .PP
  372. \&\fBOSSL_FUNC_keymgmt_load()\fR creates a provider side key object based on a
  373. \&\fIreference\fR object with a size of \fIreference_sz\fR bytes, that only the
  374. provider knows how to interpret, but that may come from other operations.
  375. Outside the provider, this reference is simply an array of bytes.
  376. .PP
  377. At least one of \fBOSSL_FUNC_keymgmt_new()\fR, \fBOSSL_FUNC_keymgmt_gen()\fR and
  378. \&\fBOSSL_FUNC_keymgmt_load()\fR are mandatory, as well as \fBOSSL_FUNC_keymgmt_free()\fR and
  379. \&\fBOSSL_FUNC_keymgmt_has()\fR. Additionally, if \fBOSSL_FUNC_keymgmt_gen()\fR is present,
  380. \&\fBOSSL_FUNC_keymgmt_gen_init()\fR and \fBOSSL_FUNC_keymgmt_gen_cleanup()\fR must be
  381. present as well.
  382. .SS "Key Object Information Functions"
  383. .IX Subsection "Key Object Information Functions"
  384. \&\fBOSSL_FUNC_keymgmt_get_params()\fR should extract information data associated
  385. with the given \fIkeydata\fR, see \*(L"Common Information Parameters\*(R".
  386. .PP
  387. \&\fBOSSL_FUNC_keymgmt_gettable_params()\fR should return a constant array of
  388. descriptor \s-1\fBOSSL_PARAM\s0\fR\|(3), for parameters that \fBOSSL_FUNC_keymgmt_get_params()\fR
  389. can handle.
  390. .PP
  391. If \fBOSSL_FUNC_keymgmt_gettable_params()\fR is present, \fBOSSL_FUNC_keymgmt_get_params()\fR
  392. must also be present, and vice versa.
  393. .PP
  394. \&\fBOSSL_FUNC_keymgmt_set_params()\fR should update information data associated
  395. with the given \fIkeydata\fR, see \*(L"Common Information Parameters\*(R".
  396. .PP
  397. \&\fBOSSL_FUNC_keymgmt_settable_params()\fR should return a constant array of
  398. descriptor \s-1\fBOSSL_PARAM\s0\fR\|(3), for parameters that \fBOSSL_FUNC_keymgmt_set_params()\fR
  399. can handle.
  400. .PP
  401. If \fBOSSL_FUNC_keymgmt_settable_params()\fR is present, \fBOSSL_FUNC_keymgmt_set_params()\fR
  402. must also be present, and vice versa.
  403. .SS "Key Object Checking Functions"
  404. .IX Subsection "Key Object Checking Functions"
  405. \&\fBOSSL_FUNC_keymgmt_query_operation_name()\fR should return the name of the
  406. supported algorithm for the operation \fIoperation_id\fR. This is
  407. similar to \fBprovider_query_operation()\fR (see \fBprovider\-base\fR\|(7)),
  408. but only works as an advisory. If this function is not present, or
  409. returns \s-1NULL,\s0 the caller is free to assume that there's an algorithm
  410. from the same provider, of the same name as the one used to fetch the
  411. keymgmt and try to use that.
  412. .PP
  413. \&\fBOSSL_FUNC_keymgmt_has()\fR should check whether the given \fIkeydata\fR contains the subsets
  414. of data indicated by the \fIselector\fR. A combination of several
  415. selector bits must consider all those subsets, not just one. An
  416. implementation is, however, free to consider an empty subset of data
  417. to still be a valid subset. For algorithms where some selection is
  418. not meaningful such as \fB\s-1OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS\s0\fR for
  419. \&\s-1RSA\s0 keys the function should just return 1 as the selected subset
  420. is not really missing in the key.
  421. .PP
  422. \&\fBOSSL_FUNC_keymgmt_validate()\fR should check if the \fIkeydata\fR contains valid
  423. data subsets indicated by \fIselection\fR. Some combined selections of
  424. data subsets may cause validation of the combined data.
  425. For example, the combination of \fB\s-1OSSL_KEYMGMT_SELECT_PRIVATE_KEY\s0\fR and
  426. \&\fB\s-1OSSL_KEYMGMT_SELECT_PUBLIC_KEY\s0\fR (or \fB\s-1OSSL_KEYMGMT_SELECT_KEYPAIR\s0\fR
  427. for short) is expected to check that the pairwise consistency of
  428. \&\fIkeydata\fR is valid. The \fIchecktype\fR parameter controls what type of check is
  429. performed on the subset of data. Two types of check are defined:
  430. \&\fB\s-1OSSL_KEYMGMT_VALIDATE_FULL_CHECK\s0\fR and \fB\s-1OSSL_KEYMGMT_VALIDATE_QUICK_CHECK\s0\fR.
  431. The interpretation of how much checking is performed in a full check versus a
  432. quick check is key type specific. Some providers may have no distinction
  433. between a full check and a quick check. For algorithms where some selection is
  434. not meaningful such as \fB\s-1OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS\s0\fR for
  435. \&\s-1RSA\s0 keys the function should just return 1 as there is nothing to validate for
  436. that selection.
  437. .PP
  438. \&\fBOSSL_FUNC_keymgmt_match()\fR should check if the data subset indicated by
  439. \&\fIselection\fR in \fIkeydata1\fR and \fIkeydata2\fR match. It is assumed that
  440. the caller has ensured that \fIkeydata1\fR and \fIkeydata2\fR are both owned
  441. by the implementation of this function.
  442. .SS "Key Object Import, Export and Duplication Functions"
  443. .IX Subsection "Key Object Import, Export and Duplication Functions"
  444. \&\fBOSSL_FUNC_keymgmt_import()\fR should import data indicated by \fIselection\fR into
  445. \&\fIkeydata\fR with values taken from the \s-1\fBOSSL_PARAM\s0\fR\|(3) array \fIparams\fR.
  446. .PP
  447. \&\fBOSSL_FUNC_keymgmt_export()\fR should extract values indicated by \fIselection\fR
  448. from \fIkeydata\fR, create an \s-1\fBOSSL_PARAM\s0\fR\|(3) array with them and call
  449. \&\fIparam_cb\fR with that array as well as the given \fIcbarg\fR.
  450. .PP
  451. \&\fBOSSL_FUNC_keymgmt_import_types()\fR and \fBOSSL_FUNC_keymgmt_import_types_ex()\fR
  452. should return a constant array of descriptor
  453. \&\s-1\fBOSSL_PARAM\s0\fR\|(3) for data indicated by \fIselection\fR, for parameters that
  454. \&\fBOSSL_FUNC_keymgmt_import()\fR can handle.
  455. Either \fBOSSL_FUNC_keymgmt_import_types()\fR or \fBOSSL_FUNC_keymgmt_import_types_ex()\fR,
  456. must be implemented, if \fBOSSL_FUNC_keymgmt_import_types_ex()\fR is implemented, then
  457. it is preferred over \fBOSSL_FUNC_keymgmt_import_types()\fR.
  458. Providers that are supposed to be backward compatible with OpenSSL 3.0 or 3.1
  459. must continue to implement \fBOSSL_FUNC_keymgmt_import_types()\fR.
  460. .PP
  461. \&\fBOSSL_FUNC_keymgmt_export_types()\fR and \fBOSSL_FUNC_keymgmt_export_types_ex()\fR
  462. should return a constant array of descriptor
  463. \&\s-1\fBOSSL_PARAM\s0\fR\|(3) for data indicated by \fIselection\fR, that the
  464. \&\fBOSSL_FUNC_keymgmt_export()\fR callback can expect to receive.
  465. Either \fBOSSL_FUNC_keymgmt_export_types()\fR or \fBOSSL_FUNC_keymgmt_export_types_ex()\fR,
  466. must be implemented, if \fBOSSL_FUNC_keymgmt_export_types_ex()\fR is implemented, then
  467. it is preferred over \fBOSSL_FUNC_keymgmt_export_types()\fR.
  468. Providers that are supposed to be backward compatible with OpenSSL 3.0 or 3.1
  469. must continue to implement \fBOSSL_FUNC_keymgmt_export_types()\fR.
  470. .PP
  471. \&\fBOSSL_FUNC_keymgmt_dup()\fR should duplicate data subsets indicated by
  472. \&\fIselection\fR or the whole key data \fIkeydata_from\fR and create a new
  473. provider side key object with the data.
  474. .SS "Common Information Parameters"
  475. .IX Subsection "Common Information Parameters"
  476. See \s-1\fBOSSL_PARAM\s0\fR\|(3) for further details on the parameters structure.
  477. .PP
  478. Common information parameters currently recognised by all built-in
  479. keymgmt algorithms are as follows:
  480. .ie n .IP """bits"" (\fB\s-1OSSL_PKEY_PARAM_BITS\s0\fR) <integer>" 4
  481. .el .IP "``bits'' (\fB\s-1OSSL_PKEY_PARAM_BITS\s0\fR) <integer>" 4
  482. .IX Item "bits (OSSL_PKEY_PARAM_BITS) <integer>"
  483. The value should be the cryptographic length of the cryptosystem to
  484. which the key belongs, in bits. The definition of cryptographic
  485. length is specific to the key cryptosystem.
  486. .ie n .IP """max-size"" (\fB\s-1OSSL_PKEY_PARAM_MAX_SIZE\s0\fR) <integer>" 4
  487. .el .IP "``max-size'' (\fB\s-1OSSL_PKEY_PARAM_MAX_SIZE\s0\fR) <integer>" 4
  488. .IX Item "max-size (OSSL_PKEY_PARAM_MAX_SIZE) <integer>"
  489. The value should be the maximum size that a caller should allocate to
  490. safely store a signature (called \fIsig\fR in \fBprovider\-signature\fR\|(7)),
  491. the result of asymmetric encryption / decryption (\fIout\fR in
  492. \&\fBprovider\-asym_cipher\fR\|(7), a derived secret (\fIsecret\fR in
  493. \&\fBprovider\-keyexch\fR\|(7), and similar data).
  494. .Sp
  495. Providers need to implement this parameter
  496. in order to properly support various use cases such as \s-1CMS\s0 signing.
  497. .Sp
  498. Because an \s-1EVP_KEYMGMT\s0 method is always tightly bound to another method
  499. (signature, asymmetric cipher, key exchange, ...) and must be of the
  500. same provider, this number only needs to be synchronised with the
  501. dimensions handled in the rest of the same provider.
  502. .ie n .IP """security-bits"" (\fB\s-1OSSL_PKEY_PARAM_SECURITY_BITS\s0\fR) <integer>" 4
  503. .el .IP "``security-bits'' (\fB\s-1OSSL_PKEY_PARAM_SECURITY_BITS\s0\fR) <integer>" 4
  504. .IX Item "security-bits (OSSL_PKEY_PARAM_SECURITY_BITS) <integer>"
  505. The value should be the number of security bits of the given key.
  506. Bits of security is defined in \s-1SP800\-57.\s0
  507. .ie n .IP """mandatory-digest"" (\fB\s-1OSSL_PKEY_PARAM_MANDATORY_DIGEST\s0\fR) <\s-1UTF8\s0 string>" 4
  508. .el .IP "``mandatory-digest'' (\fB\s-1OSSL_PKEY_PARAM_MANDATORY_DIGEST\s0\fR) <\s-1UTF8\s0 string>" 4
  509. .IX Item "mandatory-digest (OSSL_PKEY_PARAM_MANDATORY_DIGEST) <UTF8 string>"
  510. If there is a mandatory digest for performing a signature operation with
  511. keys from this keymgmt, this parameter should get its name as value.
  512. .Sp
  513. When \fBEVP_PKEY_get_default_digest_name()\fR queries this parameter and it's
  514. filled in by the implementation, its return value will be 2.
  515. .Sp
  516. If the keymgmt implementation fills in the value \f(CW""\fR or \f(CW"UNDEF"\fR,
  517. \&\fBEVP_PKEY_get_default_digest_name\fR\|(3) will place the string \f(CW"UNDEF"\fR into
  518. its argument \fImdname\fR. This signifies that no digest should be specified
  519. with the corresponding signature operation.
  520. .ie n .IP """default-digest"" (\fB\s-1OSSL_PKEY_PARAM_DEFAULT_DIGEST\s0\fR) <\s-1UTF8\s0 string>" 4
  521. .el .IP "``default-digest'' (\fB\s-1OSSL_PKEY_PARAM_DEFAULT_DIGEST\s0\fR) <\s-1UTF8\s0 string>" 4
  522. .IX Item "default-digest (OSSL_PKEY_PARAM_DEFAULT_DIGEST) <UTF8 string>"
  523. If there is a default digest for performing a signature operation with
  524. keys from this keymgmt, this parameter should get its name as value.
  525. .Sp
  526. When \fBEVP_PKEY_get_default_digest_name\fR\|(3) queries this parameter and it's
  527. filled in by the implementation, its return value will be 1. Note that if
  528. \&\fB\s-1OSSL_PKEY_PARAM_MANDATORY_DIGEST\s0\fR is responded to as well,
  529. \&\fBEVP_PKEY_get_default_digest_name\fR\|(3) ignores the response to this
  530. parameter.
  531. .Sp
  532. If the keymgmt implementation fills in the value \f(CW""\fR or \f(CW"UNDEF"\fR,
  533. \&\fBEVP_PKEY_get_default_digest_name\fR\|(3) will place the string \f(CW"UNDEF"\fR into
  534. its argument \fImdname\fR. This signifies that no digest has to be specified
  535. with the corresponding signature operation, but may be specified as an
  536. option.
  537. .SH "RETURN VALUES"
  538. .IX Header "RETURN VALUES"
  539. \&\fBOSSL_FUNC_keymgmt_new()\fR and \fBOSSL_FUNC_keymgmt_dup()\fR should return a valid
  540. reference to the newly created provider side key object, or \s-1NULL\s0 on failure.
  541. .PP
  542. \&\fBOSSL_FUNC_keymgmt_import()\fR, \fBOSSL_FUNC_keymgmt_export()\fR, \fBOSSL_FUNC_keymgmt_get_params()\fR and
  543. \&\fBOSSL_FUNC_keymgmt_set_params()\fR should return 1 for success or 0 on error.
  544. .PP
  545. \&\fBOSSL_FUNC_keymgmt_validate()\fR should return 1 on successful validation, or 0 on
  546. failure.
  547. .PP
  548. \&\fBOSSL_FUNC_keymgmt_has()\fR should return 1 if all the selected data subsets are contained
  549. in the given \fIkeydata\fR or 0 otherwise.
  550. .PP
  551. \&\fBOSSL_FUNC_keymgmt_query_operation_name()\fR should return a pointer to a string matching
  552. the requested operation, or \s-1NULL\s0 if the same name used to fetch the keymgmt
  553. applies.
  554. .PP
  555. \&\fBOSSL_FUNC_keymgmt_gettable_params()\fR and \fBOSSL_FUNC_keymgmt_settable_params()\fR
  556. \&\fBOSSL_FUNC_keymgmt_import_types()\fR, \fBOSSL_FUNC_keymgmt_import_types_ex()\fR,
  557. \&\fBOSSL_FUNC_keymgmt_export_types()\fR, \fBOSSL_FUNC_keymgmt_export_types_ex()\fR
  558. should
  559. always return a constant \s-1\fBOSSL_PARAM\s0\fR\|(3) array.
  560. .SH "SEE ALSO"
  561. .IX Header "SEE ALSO"
  562. \&\fBEVP_PKEY_get_size\fR\|(3),
  563. \&\fBEVP_PKEY_get_bits\fR\|(3),
  564. \&\fBEVP_PKEY_get_security_bits\fR\|(3),
  565. \&\fBprovider\fR\|(7),
  566. \&\s-1\fBEVP_PKEY\-X25519\s0\fR\|(7), \s-1\fBEVP_PKEY\-X448\s0\fR\|(7), \s-1\fBEVP_PKEY\-ED25519\s0\fR\|(7),
  567. \&\s-1\fBEVP_PKEY\-ED448\s0\fR\|(7), \s-1\fBEVP_PKEY\-EC\s0\fR\|(7), \s-1\fBEVP_PKEY\-RSA\s0\fR\|(7),
  568. \&\s-1\fBEVP_PKEY\-DSA\s0\fR\|(7), \s-1\fBEVP_PKEY\-DH\s0\fR\|(7)
  569. .SH "HISTORY"
  570. .IX Header "HISTORY"
  571. The \s-1KEYMGMT\s0 interface was introduced in OpenSSL 3.0.
  572. .PP
  573. Functions \fBOSSL_FUNC_keymgmt_import_types_ex()\fR, and \fBOSSL_FUNC_keymgmt_export_types_ex()\fR
  574. were added with OpenSSL 3.2.
  575. .SH "COPYRIGHT"
  576. .IX Header "COPYRIGHT"
  577. Copyright 2019\-2024 The OpenSSL Project Authors. All Rights Reserved.
  578. .PP
  579. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  580. this file except in compliance with the License. You can obtain a copy
  581. in the file \s-1LICENSE\s0 in the source distribution or at
  582. <https://www.openssl.org/source/license.html>.