provider-signature.7ossl 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  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-SIGNATURE 7ossl"
  136. .TH PROVIDER-SIGNATURE 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\-signature \- The signature library <\-> provider functions
  143. .SH "SYNOPSIS"
  144. .IX Header "SYNOPSIS"
  145. .Vb 2
  146. \& #include <openssl/core_dispatch.h>
  147. \& #include <openssl/core_names.h>
  148. \&
  149. \& /*
  150. \& * None of these are actual functions, but are displayed like this for
  151. \& * the function signatures for functions that are offered as function
  152. \& * pointers in OSSL_DISPATCH arrays.
  153. \& */
  154. \&
  155. \& /* Context management */
  156. \& void *OSSL_FUNC_signature_newctx(void *provctx, const char *propq);
  157. \& void OSSL_FUNC_signature_freectx(void *ctx);
  158. \& void *OSSL_FUNC_signature_dupctx(void *ctx);
  159. \&
  160. \& /* Signing */
  161. \& int OSSL_FUNC_signature_sign_init(void *ctx, void *provkey,
  162. \& const OSSL_PARAM params[]);
  163. \& int OSSL_FUNC_signature_sign(void *ctx, unsigned char *sig, size_t *siglen,
  164. \& size_t sigsize, const unsigned char *tbs, size_t tbslen);
  165. \&
  166. \& /* Verifying */
  167. \& int OSSL_FUNC_signature_verify_init(void *ctx, void *provkey,
  168. \& const OSSL_PARAM params[]);
  169. \& int OSSL_FUNC_signature_verify(void *ctx, const unsigned char *sig, size_t siglen,
  170. \& const unsigned char *tbs, size_t tbslen);
  171. \&
  172. \& /* Verify Recover */
  173. \& int OSSL_FUNC_signature_verify_recover_init(void *ctx, void *provkey,
  174. \& const OSSL_PARAM params[]);
  175. \& int OSSL_FUNC_signature_verify_recover(void *ctx, unsigned char *rout,
  176. \& size_t *routlen, size_t routsize,
  177. \& const unsigned char *sig, size_t siglen);
  178. \&
  179. \& /* Digest Sign */
  180. \& int OSSL_FUNC_signature_digest_sign_init(void *ctx, const char *mdname,
  181. \& void *provkey,
  182. \& const OSSL_PARAM params[]);
  183. \& int OSSL_FUNC_signature_digest_sign_update(void *ctx, const unsigned char *data,
  184. \& size_t datalen);
  185. \& int OSSL_FUNC_signature_digest_sign_final(void *ctx, unsigned char *sig,
  186. \& size_t *siglen, size_t sigsize);
  187. \& int OSSL_FUNC_signature_digest_sign(void *ctx,
  188. \& unsigned char *sig, size_t *siglen,
  189. \& size_t sigsize, const unsigned char *tbs,
  190. \& size_t tbslen);
  191. \&
  192. \& /* Digest Verify */
  193. \& int OSSL_FUNC_signature_digest_verify_init(void *ctx, const char *mdname,
  194. \& void *provkey,
  195. \& const OSSL_PARAM params[]);
  196. \& int OSSL_FUNC_signature_digest_verify_update(void *ctx,
  197. \& const unsigned char *data,
  198. \& size_t datalen);
  199. \& int OSSL_FUNC_signature_digest_verify_final(void *ctx, const unsigned char *sig,
  200. \& size_t siglen);
  201. \& int OSSL_FUNC_signature_digest_verify(void *ctx, const unsigned char *sig,
  202. \& size_t siglen, const unsigned char *tbs,
  203. \& size_t tbslen);
  204. \&
  205. \& /* Signature parameters */
  206. \& int OSSL_FUNC_signature_get_ctx_params(void *ctx, OSSL_PARAM params[]);
  207. \& const OSSL_PARAM *OSSL_FUNC_signature_gettable_ctx_params(void *ctx,
  208. \& void *provctx);
  209. \& int OSSL_FUNC_signature_set_ctx_params(void *ctx, const OSSL_PARAM params[]);
  210. \& const OSSL_PARAM *OSSL_FUNC_signature_settable_ctx_params(void *ctx,
  211. \& void *provctx);
  212. \& /* MD parameters */
  213. \& int OSSL_FUNC_signature_get_ctx_md_params(void *ctx, OSSL_PARAM params[]);
  214. \& const OSSL_PARAM * OSSL_FUNC_signature_gettable_ctx_md_params(void *ctx);
  215. \& int OSSL_FUNC_signature_set_ctx_md_params(void *ctx, const OSSL_PARAM params[]);
  216. \& const OSSL_PARAM * OSSL_FUNC_signature_settable_ctx_md_params(void *ctx);
  217. .Ve
  218. .SH "DESCRIPTION"
  219. .IX Header "DESCRIPTION"
  220. This documentation is primarily aimed at provider authors. See \fBprovider\fR\|(7)
  221. for further information.
  222. .PP
  223. The signature (\s-1OSSL_OP_SIGNATURE\s0) operation enables providers to implement
  224. signature algorithms and make them available to applications via the \s-1API\s0
  225. functions \fBEVP_PKEY_sign\fR\|(3),
  226. \&\fBEVP_PKEY_verify\fR\|(3),
  227. and \fBEVP_PKEY_verify_recover\fR\|(3) (as well
  228. as other related functions).
  229. .PP
  230. All \*(L"functions\*(R" mentioned here are passed as function pointers between
  231. \&\fIlibcrypto\fR and the provider in \s-1\fBOSSL_DISPATCH\s0\fR\|(3) arrays via
  232. \&\s-1\fBOSSL_ALGORITHM\s0\fR\|(3) arrays that are returned by the provider's
  233. \&\fBprovider_query_operation()\fR function
  234. (see \*(L"Provider Functions\*(R" in \fBprovider\-base\fR\|(7)).
  235. .PP
  236. All these \*(L"functions\*(R" have a corresponding function type definition
  237. named \fBOSSL_FUNC_{name}_fn\fR, and a helper function to retrieve the
  238. function pointer from an \s-1\fBOSSL_DISPATCH\s0\fR\|(3) element named
  239. \&\fBOSSL_FUNC_{name}\fR.
  240. For example, the \*(L"function\*(R" \fBOSSL_FUNC_signature_newctx()\fR has these:
  241. .PP
  242. .Vb 3
  243. \& typedef void *(OSSL_FUNC_signature_newctx_fn)(void *provctx, const char *propq);
  244. \& static ossl_inline OSSL_FUNC_signature_newctx_fn
  245. \& OSSL_FUNC_signature_newctx(const OSSL_DISPATCH *opf);
  246. .Ve
  247. .PP
  248. \&\s-1\fBOSSL_DISPATCH\s0\fR\|(3) arrays are indexed by numbers that are provided as
  249. macros in \fBopenssl\-core_dispatch.h\fR\|(7), as follows:
  250. .PP
  251. .Vb 3
  252. \& OSSL_FUNC_signature_newctx OSSL_FUNC_SIGNATURE_NEWCTX
  253. \& OSSL_FUNC_signature_freectx OSSL_FUNC_SIGNATURE_FREECTX
  254. \& OSSL_FUNC_signature_dupctx OSSL_FUNC_SIGNATURE_DUPCTX
  255. \&
  256. \& OSSL_FUNC_signature_sign_init OSSL_FUNC_SIGNATURE_SIGN_INIT
  257. \& OSSL_FUNC_signature_sign OSSL_FUNC_SIGNATURE_SIGN
  258. \&
  259. \& OSSL_FUNC_signature_verify_init OSSL_FUNC_SIGNATURE_VERIFY_INIT
  260. \& OSSL_FUNC_signature_verify OSSL_FUNC_SIGNATURE_VERIFY
  261. \&
  262. \& OSSL_FUNC_signature_verify_recover_init OSSL_FUNC_SIGNATURE_VERIFY_RECOVER_INIT
  263. \& OSSL_FUNC_signature_verify_recover OSSL_FUNC_SIGNATURE_VERIFY_RECOVER
  264. \&
  265. \& OSSL_FUNC_signature_digest_sign_init OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT
  266. \& OSSL_FUNC_signature_digest_sign_update OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE
  267. \& OSSL_FUNC_signature_digest_sign_final OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL
  268. \& OSSL_FUNC_signature_digest_sign OSSL_FUNC_SIGNATURE_DIGEST_SIGN
  269. \&
  270. \& OSSL_FUNC_signature_digest_verify_init OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT
  271. \& OSSL_FUNC_signature_digest_verify_update OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE
  272. \& OSSL_FUNC_signature_digest_verify_final OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL
  273. \& OSSL_FUNC_signature_digest_verify OSSL_FUNC_SIGNATURE_DIGEST_VERIFY
  274. \&
  275. \& OSSL_FUNC_signature_get_ctx_params OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS
  276. \& OSSL_FUNC_signature_gettable_ctx_params OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS
  277. \& OSSL_FUNC_signature_set_ctx_params OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS
  278. \& OSSL_FUNC_signature_settable_ctx_params OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS
  279. \&
  280. \& OSSL_FUNC_signature_get_ctx_md_params OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS
  281. \& OSSL_FUNC_signature_gettable_ctx_md_params OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS
  282. \& OSSL_FUNC_signature_set_ctx_md_params OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS
  283. \& OSSL_FUNC_signature_settable_ctx_md_params OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS
  284. .Ve
  285. .PP
  286. A signature algorithm implementation may not implement all of these functions.
  287. In order to be a consistent set of functions we must have at least a set of
  288. context functions (OSSL_FUNC_signature_newctx and OSSL_FUNC_signature_freectx) as well as a
  289. set of \*(L"signature\*(R" functions, i.e. at least one of:
  290. .IP "OSSL_FUNC_signature_sign_init and OSSL_FUNC_signature_sign" 4
  291. .IX Item "OSSL_FUNC_signature_sign_init and OSSL_FUNC_signature_sign"
  292. .PD 0
  293. .IP "OSSL_FUNC_signature_verify_init and OSSL_FUNC_signature_verify" 4
  294. .IX Item "OSSL_FUNC_signature_verify_init and OSSL_FUNC_signature_verify"
  295. .IP "OSSL_FUNC_signature_verify_recover_init and OSSL_FUNC_signature_verify_recover" 4
  296. .IX Item "OSSL_FUNC_signature_verify_recover_init and OSSL_FUNC_signature_verify_recover"
  297. .IP "OSSL_FUNC_signature_digest_sign_init, OSSL_FUNC_signature_digest_sign_update and OSSL_FUNC_signature_digest_sign_final" 4
  298. .IX Item "OSSL_FUNC_signature_digest_sign_init, OSSL_FUNC_signature_digest_sign_update and OSSL_FUNC_signature_digest_sign_final"
  299. .IP "OSSL_FUNC_signature_digest_verify_init, OSSL_FUNC_signature_digest_verify_update and OSSL_FUNC_signature_digest_verify_final" 4
  300. .IX Item "OSSL_FUNC_signature_digest_verify_init, OSSL_FUNC_signature_digest_verify_update and OSSL_FUNC_signature_digest_verify_final"
  301. .IP "OSSL_FUNC_signature_digest_sign_init and OSSL_FUNC_signature_digest_sign" 4
  302. .IX Item "OSSL_FUNC_signature_digest_sign_init and OSSL_FUNC_signature_digest_sign"
  303. .IP "OSSL_FUNC_signature_digest_verify_init and OSSL_FUNC_signature_digest_verify" 4
  304. .IX Item "OSSL_FUNC_signature_digest_verify_init and OSSL_FUNC_signature_digest_verify"
  305. .PD
  306. .PP
  307. OSSL_FUNC_signature_set_ctx_params and OSSL_FUNC_signature_settable_ctx_params are optional,
  308. but if one of them is present then the other one must also be present. The same
  309. applies to OSSL_FUNC_signature_get_ctx_params and OSSL_FUNC_signature_gettable_ctx_params, as
  310. well as the \*(L"md_params\*(R" functions. The OSSL_FUNC_signature_dupctx function is optional.
  311. .PP
  312. A signature algorithm must also implement some mechanism for generating,
  313. loading or importing keys via the key management (\s-1OSSL_OP_KEYMGMT\s0) operation.
  314. See \fBprovider\-keymgmt\fR\|(7) for further details.
  315. .SS "Context Management Functions"
  316. .IX Subsection "Context Management Functions"
  317. \&\fBOSSL_FUNC_signature_newctx()\fR should create and return a pointer to a provider side
  318. structure for holding context information during a signature operation.
  319. A pointer to this context will be passed back in a number of the other signature
  320. operation function calls.
  321. The parameter \fIprovctx\fR is the provider context generated during provider
  322. initialisation (see \fBprovider\fR\|(7)). The \fIpropq\fR parameter is a property query
  323. string that may be (optionally) used by the provider during any \*(L"fetches\*(R" that
  324. it may perform (if it performs any).
  325. .PP
  326. \&\fBOSSL_FUNC_signature_freectx()\fR is passed a pointer to the provider side signature
  327. context in the \fIctx\fR parameter.
  328. This function should free any resources associated with that context.
  329. .PP
  330. \&\fBOSSL_FUNC_signature_dupctx()\fR should duplicate the provider side signature context in
  331. the \fIctx\fR parameter and return the duplicate copy.
  332. .SS "Signing Functions"
  333. .IX Subsection "Signing Functions"
  334. \&\fBOSSL_FUNC_signature_sign_init()\fR initialises a context for signing given a provider side
  335. signature context in the \fIctx\fR parameter, and a pointer to a provider key object
  336. in the \fIprovkey\fR parameter.
  337. The \fIparams\fR, if not \s-1NULL,\s0 should be set on the context in a manner similar to
  338. using \fBOSSL_FUNC_signature_set_ctx_params()\fR.
  339. The key object should have been previously generated, loaded or imported into
  340. the provider using the key management (\s-1OSSL_OP_KEYMGMT\s0) operation (see
  341. \&\fBprovider\-keymgmt\fR\|(7)>.
  342. .PP
  343. \&\fBOSSL_FUNC_signature_sign()\fR performs the actual signing itself.
  344. A previously initialised signature context is passed in the \fIctx\fR
  345. parameter.
  346. The data to be signed is pointed to be the \fItbs\fR parameter which is \fItbslen\fR
  347. bytes long.
  348. Unless \fIsig\fR is \s-1NULL,\s0 the signature should be written to the location pointed
  349. to by the \fIsig\fR parameter and it should not exceed \fIsigsize\fR bytes in length.
  350. The length of the signature should be written to \fI*siglen\fR.
  351. If \fIsig\fR is \s-1NULL\s0 then the maximum length of the signature should be written to
  352. \&\fI*siglen\fR.
  353. .SS "Verify Functions"
  354. .IX Subsection "Verify Functions"
  355. \&\fBOSSL_FUNC_signature_verify_init()\fR initialises a context for verifying a signature given
  356. a provider side signature context in the \fIctx\fR parameter, and a pointer to a
  357. provider key object in the \fIprovkey\fR parameter.
  358. The \fIparams\fR, if not \s-1NULL,\s0 should be set on the context in a manner similar to
  359. using \fBOSSL_FUNC_signature_set_ctx_params()\fR.
  360. The key object should have been previously generated, loaded or imported into
  361. the provider using the key management (\s-1OSSL_OP_KEYMGMT\s0) operation (see
  362. \&\fBprovider\-keymgmt\fR\|(7)>.
  363. .PP
  364. \&\fBOSSL_FUNC_signature_verify()\fR performs the actual verification itself.
  365. A previously initialised signature context is passed in the \fIctx\fR parameter.
  366. The data that the signature covers is pointed to be the \fItbs\fR parameter which
  367. is \fItbslen\fR bytes long.
  368. The signature is pointed to by the \fIsig\fR parameter which is \fIsiglen\fR bytes
  369. long.
  370. .SS "Verify Recover Functions"
  371. .IX Subsection "Verify Recover Functions"
  372. \&\fBOSSL_FUNC_signature_verify_recover_init()\fR initialises a context for recovering the
  373. signed data given a provider side signature context in the \fIctx\fR parameter, and
  374. a pointer to a provider key object in the \fIprovkey\fR parameter.
  375. The \fIparams\fR, if not \s-1NULL,\s0 should be set on the context in a manner similar to
  376. using \fBOSSL_FUNC_signature_set_ctx_params()\fR.
  377. The key object should have been previously generated, loaded or imported into
  378. the provider using the key management (\s-1OSSL_OP_KEYMGMT\s0) operation (see
  379. \&\fBprovider\-keymgmt\fR\|(7)>.
  380. .PP
  381. \&\fBOSSL_FUNC_signature_verify_recover()\fR performs the actual verify recover itself.
  382. A previously initialised signature context is passed in the \fIctx\fR parameter.
  383. The signature is pointed to by the \fIsig\fR parameter which is \fIsiglen\fR bytes
  384. long.
  385. Unless \fIrout\fR is \s-1NULL,\s0 the recovered data should be written to the location
  386. pointed to by \fIrout\fR which should not exceed \fIroutsize\fR bytes in length.
  387. The length of the recovered data should be written to \fI*routlen\fR.
  388. If \fIrout\fR is \s-1NULL\s0 then the maximum size of the output buffer is written to
  389. the \fIroutlen\fR parameter.
  390. .SS "Digest Sign Functions"
  391. .IX Subsection "Digest Sign Functions"
  392. \&\fBOSSL_FUNC_signature_digeset_sign_init()\fR initialises a context for signing given a
  393. provider side signature context in the \fIctx\fR parameter, and a pointer to a
  394. provider key object in the \fIprovkey\fR parameter.
  395. The \fIparams\fR, if not \s-1NULL,\s0 should be set on the context in a manner similar to
  396. using \fBOSSL_FUNC_signature_set_ctx_params()\fR and
  397. \&\fBOSSL_FUNC_signature_set_ctx_md_params()\fR.
  398. The key object should have been
  399. previously generated, loaded or imported into the provider using the
  400. key management (\s-1OSSL_OP_KEYMGMT\s0) operation (see \fBprovider\-keymgmt\fR\|(7)>.
  401. The name of the digest to be used will be in the \fImdname\fR parameter.
  402. .PP
  403. \&\fBOSSL_FUNC_signature_digest_sign_update()\fR provides data to be signed in the \fIdata\fR
  404. parameter which should be of length \fIdatalen\fR. A previously initialised
  405. signature context is passed in the \fIctx\fR parameter. This function may be called
  406. multiple times to cumulatively add data to be signed.
  407. .PP
  408. \&\fBOSSL_FUNC_signature_digest_sign_final()\fR finalises a signature operation previously
  409. started through \fBOSSL_FUNC_signature_digest_sign_init()\fR and
  410. \&\fBOSSL_FUNC_signature_digest_sign_update()\fR calls. Once finalised no more data will be
  411. added through \fBOSSL_FUNC_signature_digest_sign_update()\fR. A previously initialised
  412. signature context is passed in the \fIctx\fR parameter. Unless \fIsig\fR is \s-1NULL,\s0 the
  413. signature should be written to the location pointed to by the \fIsig\fR parameter
  414. and it should not exceed \fIsigsize\fR bytes in length. The length of the signature
  415. should be written to \fI*siglen\fR. If \fIsig\fR is \s-1NULL\s0 then the maximum length of
  416. the signature should be written to \fI*siglen\fR.
  417. .PP
  418. \&\fBOSSL_FUNC_signature_digest_sign()\fR implements a \*(L"one shot\*(R" digest sign operation
  419. previously started through \fBOSSL_FUNC_signature_digeset_sign_init()\fR. A previously
  420. initialised signature context is passed in the \fIctx\fR parameter. The data to be
  421. signed is in \fItbs\fR which should be \fItbslen\fR bytes long. Unless \fIsig\fR is \s-1NULL,\s0
  422. the signature should be written to the location pointed to by the \fIsig\fR
  423. parameter and it should not exceed \fIsigsize\fR bytes in length. The length of the
  424. signature should be written to \fI*siglen\fR. If \fIsig\fR is \s-1NULL\s0 then the maximum
  425. length of the signature should be written to \fI*siglen\fR.
  426. .SS "Digest Verify Functions"
  427. .IX Subsection "Digest Verify Functions"
  428. \&\fBOSSL_FUNC_signature_digeset_verify_init()\fR initialises a context for verifying given a
  429. provider side verification context in the \fIctx\fR parameter, and a pointer to a
  430. provider key object in the \fIprovkey\fR parameter.
  431. The \fIparams\fR, if not \s-1NULL,\s0 should be set on the context in a manner similar to
  432. \&\fBOSSL_FUNC_signature_set_ctx_params()\fR and
  433. \&\fBOSSL_FUNC_signature_set_ctx_md_params()\fR.
  434. The key object should have been
  435. previously generated, loaded or imported into the provider using the
  436. key management (\s-1OSSL_OP_KEYMGMT\s0) operation (see \fBprovider\-keymgmt\fR\|(7)>.
  437. The name of the digest to be used will be in the \fImdname\fR parameter.
  438. .PP
  439. \&\fBOSSL_FUNC_signature_digest_verify_update()\fR provides data to be verified in the \fIdata\fR
  440. parameter which should be of length \fIdatalen\fR. A previously initialised
  441. verification context is passed in the \fIctx\fR parameter. This function may be
  442. called multiple times to cumulatively add data to be verified.
  443. .PP
  444. \&\fBOSSL_FUNC_signature_digest_verify_final()\fR finalises a verification operation previously
  445. started through \fBOSSL_FUNC_signature_digest_verify_init()\fR and
  446. \&\fBOSSL_FUNC_signature_digest_verify_update()\fR calls. Once finalised no more data will be
  447. added through \fBOSSL_FUNC_signature_digest_verify_update()\fR. A previously initialised
  448. verification context is passed in the \fIctx\fR parameter. The signature to be
  449. verified is in \fIsig\fR which is \fIsiglen\fR bytes long.
  450. .PP
  451. \&\fBOSSL_FUNC_signature_digest_verify()\fR implements a \*(L"one shot\*(R" digest verify operation
  452. previously started through \fBOSSL_FUNC_signature_digeset_verify_init()\fR. A previously
  453. initialised verification context is passed in the \fIctx\fR parameter. The data to be
  454. verified is in \fItbs\fR which should be \fItbslen\fR bytes long. The signature to be
  455. verified is in \fIsig\fR which is \fIsiglen\fR bytes long.
  456. .SS "Signature parameters"
  457. .IX Subsection "Signature parameters"
  458. See \s-1\fBOSSL_PARAM\s0\fR\|(3) for further details on the parameters structure used by
  459. the \fBOSSL_FUNC_signature_get_ctx_params()\fR and \fBOSSL_FUNC_signature_set_ctx_params()\fR functions.
  460. .PP
  461. \&\fBOSSL_FUNC_signature_get_ctx_params()\fR gets signature parameters associated with the
  462. given provider side signature context \fIctx\fR and stored them in \fIparams\fR.
  463. Passing \s-1NULL\s0 for \fIparams\fR should return true.
  464. .PP
  465. \&\fBOSSL_FUNC_signature_set_ctx_params()\fR sets the signature parameters associated with the
  466. given provider side signature context \fIctx\fR to \fIparams\fR.
  467. Any parameter settings are additional to any that were previously set.
  468. Passing \s-1NULL\s0 for \fIparams\fR should return true.
  469. .PP
  470. Common parameters currently recognised by built-in signature algorithms are as
  471. follows.
  472. .ie n .IP """digest"" (\fB\s-1OSSL_SIGNATURE_PARAM_DIGEST\s0\fR) <\s-1UTF8\s0 string>" 4
  473. .el .IP "``digest'' (\fB\s-1OSSL_SIGNATURE_PARAM_DIGEST\s0\fR) <\s-1UTF8\s0 string>" 4
  474. .IX Item "digest (OSSL_SIGNATURE_PARAM_DIGEST) <UTF8 string>"
  475. Get or sets the name of the digest algorithm used for the input to the
  476. signature functions. It is required in order to calculate the \*(L"algorithm-id\*(R".
  477. .ie n .IP """properties"" (\fB\s-1OSSL_SIGNATURE_PARAM_PROPERTIES\s0\fR) <\s-1UTF8\s0 string>" 4
  478. .el .IP "``properties'' (\fB\s-1OSSL_SIGNATURE_PARAM_PROPERTIES\s0\fR) <\s-1UTF8\s0 string>" 4
  479. .IX Item "properties (OSSL_SIGNATURE_PARAM_PROPERTIES) <UTF8 string>"
  480. Sets the name of the property query associated with the \*(L"digest\*(R" algorithm.
  481. \&\s-1NULL\s0 is used if this optional value is not set.
  482. .ie n .IP """digest-size"" (\fB\s-1OSSL_SIGNATURE_PARAM_DIGEST_SIZE\s0\fR) <unsigned integer>" 4
  483. .el .IP "``digest-size'' (\fB\s-1OSSL_SIGNATURE_PARAM_DIGEST_SIZE\s0\fR) <unsigned integer>" 4
  484. .IX Item "digest-size (OSSL_SIGNATURE_PARAM_DIGEST_SIZE) <unsigned integer>"
  485. Gets or sets the output size of the digest algorithm used for the input to the
  486. signature functions.
  487. The length of the \*(L"digest-size\*(R" parameter should not exceed that of a \fBsize_t\fR.
  488. .ie n .IP """algorithm-id"" (\fB\s-1OSSL_SIGNATURE_PARAM_ALGORITHM_ID\s0\fR) <octet string>" 4
  489. .el .IP "``algorithm-id'' (\fB\s-1OSSL_SIGNATURE_PARAM_ALGORITHM_ID\s0\fR) <octet string>" 4
  490. .IX Item "algorithm-id (OSSL_SIGNATURE_PARAM_ALGORITHM_ID) <octet string>"
  491. Gets the \s-1DER\s0 encoded AlgorithmIdentifier that corresponds to the combination of
  492. signature algorithm and digest algorithm for the signature operation.
  493. .ie n .IP """nonce-type"" (\fB\s-1OSSL_SIGNATURE_PARAM_NONCE_TYPE\s0\fR) <unsigned integer>" 4
  494. .el .IP "``nonce-type'' (\fB\s-1OSSL_SIGNATURE_PARAM_NONCE_TYPE\s0\fR) <unsigned integer>" 4
  495. .IX Item "nonce-type (OSSL_SIGNATURE_PARAM_NONCE_TYPE) <unsigned integer>"
  496. Set this to 1 to use deterministic digital signature generation with
  497. \&\s-1ECDSA\s0 or \s-1DSA,\s0 as defined in \s-1RFC 6979\s0 (see Section 3.2 \*(L"Generation of
  498. k\*(R"). In this case, the \*(L"digest\*(R" parameter must be explicitly set
  499. (otherwise, deterministic nonce generation will fail). Before using
  500. deterministic digital signature generation, please read \s-1RFC 6979\s0
  501. Section 4 \*(L"Security Considerations\*(R". The default value for
  502. \&\*(L"nonce-type\*(R" is 0 and results in a random value being used for the
  503. nonce \fBk\fR as defined in \s-1FIPS 186\-4\s0 Section 6.3 \*(L"Secret Number
  504. Generation\*(R".
  505. .ie n .IP """kat"" (\fB\s-1OSSL_SIGNATURE_PARAM_KAT\s0\fR) <unsigned integer>" 4
  506. .el .IP "``kat'' (\fB\s-1OSSL_SIGNATURE_PARAM_KAT\s0\fR) <unsigned integer>" 4
  507. .IX Item "kat (OSSL_SIGNATURE_PARAM_KAT) <unsigned integer>"
  508. Sets a flag to modify the sign operation to return an error if the initial
  509. calculated signature is invalid.
  510. In the normal mode of operation \- new random values are chosen until the
  511. signature operation succeeds.
  512. By default it retries until a signature is calculated.
  513. Setting the value to 0 causes the sign operation to retry,
  514. otherwise the sign operation is only tried once and returns whether or not it
  515. was successful.
  516. Known answer tests can be performed if the random generator is overridden to
  517. supply known values that either pass or fail.
  518. .PP
  519. \&\fBOSSL_FUNC_signature_gettable_ctx_params()\fR and \fBOSSL_FUNC_signature_settable_ctx_params()\fR get a
  520. constant \s-1\fBOSSL_PARAM\s0\fR\|(3) array that describes the gettable and settable parameters,
  521. i.e. parameters that can be used with \fBOSSL_FUNC_signature_get_ctx_params()\fR and
  522. \&\fBOSSL_FUNC_signature_set_ctx_params()\fR respectively.
  523. .SS "\s-1MD\s0 parameters"
  524. .IX Subsection "MD parameters"
  525. See \s-1\fBOSSL_PARAM\s0\fR\|(3) for further details on the parameters structure used by
  526. the \fBOSSL_FUNC_signature_get_md_ctx_params()\fR and \fBOSSL_FUNC_signature_set_md_ctx_params()\fR
  527. functions.
  528. .PP
  529. \&\fBOSSL_FUNC_signature_get_md_ctx_params()\fR gets digest parameters associated with the
  530. given provider side digest signature context \fIctx\fR and stores them in \fIparams\fR.
  531. Passing \s-1NULL\s0 for \fIparams\fR should return true.
  532. .PP
  533. \&\fBOSSL_FUNC_signature_set_ms_ctx_params()\fR sets the digest parameters associated with the
  534. given provider side digest signature context \fIctx\fR to \fIparams\fR.
  535. Any parameter settings are additional to any that were previously set.
  536. Passing \s-1NULL\s0 for \fIparams\fR should return true.
  537. .PP
  538. Parameters currently recognised by built-in signature algorithms are the same
  539. as those for built-in digest algorithms. See
  540. \&\*(L"Digest Parameters\*(R" in \fBprovider\-digest\fR\|(7) for further information.
  541. .PP
  542. \&\fBOSSL_FUNC_signature_gettable_md_ctx_params()\fR and \fBOSSL_FUNC_signature_settable_md_ctx_params()\fR
  543. get a constant \s-1\fBOSSL_PARAM\s0\fR\|(3) array that describes the gettable and settable
  544. digest parameters, i.e. parameters that can be used with
  545. \&\fBOSSL_FUNC_signature_get_md_ctx_params()\fR and \fBOSSL_FUNC_signature_set_md_ctx_params()\fR
  546. respectively.
  547. .SH "RETURN VALUES"
  548. .IX Header "RETURN VALUES"
  549. \&\fBOSSL_FUNC_signature_newctx()\fR and \fBOSSL_FUNC_signature_dupctx()\fR should return the newly created
  550. provider side signature context, or \s-1NULL\s0 on failure.
  551. .PP
  552. \&\fBOSSL_FUNC_signature_gettable_ctx_params()\fR, \fBOSSL_FUNC_signature_settable_ctx_params()\fR,
  553. \&\fBOSSL_FUNC_signature_gettable_md_ctx_params()\fR and \fBOSSL_FUNC_signature_settable_md_ctx_params()\fR,
  554. return the gettable or settable parameters in a constant \s-1\fBOSSL_PARAM\s0\fR\|(3) array.
  555. .PP
  556. All other functions should return 1 for success or 0 on error.
  557. .SH "SEE ALSO"
  558. .IX Header "SEE ALSO"
  559. \&\fBprovider\fR\|(7)
  560. .SH "HISTORY"
  561. .IX Header "HISTORY"
  562. The provider \s-1SIGNATURE\s0 interface was introduced in OpenSSL 3.0.
  563. .SH "COPYRIGHT"
  564. .IX Header "COPYRIGHT"
  565. Copyright 2019\-2024 The OpenSSL Project Authors. All Rights Reserved.
  566. .PP
  567. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  568. this file except in compliance with the License. You can obtain a copy
  569. in the file \s-1LICENSE\s0 in the source distribution or at
  570. <https://www.openssl.org/source/license.html>.