provider-base.7ossl 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982
  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 "PROVIDER-BASE 7ossl"
  58. .TH PROVIDER-BASE 7ossl 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. provider\-base
  65. \&\- The basic OpenSSL library <\-> provider functions
  66. .SH SYNOPSIS
  67. .IX Header "SYNOPSIS"
  68. .Vb 1
  69. \& #include <openssl/core_dispatch.h>
  70. \&
  71. \& /*
  72. \& * None of these are actual functions, but are displayed like this for
  73. \& * the function signatures for functions that are offered as function
  74. \& * pointers in OSSL_DISPATCH arrays.
  75. \& */
  76. \&
  77. \& /* Functions offered by libcrypto to the providers */
  78. \& const OSSL_ITEM *core_gettable_params(const OSSL_CORE_HANDLE *handle);
  79. \& int core_get_params(const OSSL_CORE_HANDLE *handle, OSSL_PARAM params[]);
  80. \&
  81. \& typedef void (*OSSL_thread_stop_handler_fn)(void *arg);
  82. \& int core_thread_start(const OSSL_CORE_HANDLE *handle,
  83. \& OSSL_thread_stop_handler_fn handfn,
  84. \& void *arg);
  85. \&
  86. \& OPENSSL_CORE_CTX *core_get_libctx(const OSSL_CORE_HANDLE *handle);
  87. \& void core_new_error(const OSSL_CORE_HANDLE *handle);
  88. \& void core_set_error_debug(const OSSL_CORE_HANDLE *handle,
  89. \& const char *file, int line, const char *func);
  90. \& void core_vset_error(const OSSL_CORE_HANDLE *handle,
  91. \& uint32_t reason, const char *fmt, va_list args);
  92. \&
  93. \& int core_obj_add_sigid(const OSSL_CORE_HANDLE *prov, const char *sign_name,
  94. \& const char *digest_name, const char *pkey_name);
  95. \& int core_obj_create(const OSSL_CORE_HANDLE *handle, const char *oid,
  96. \& const char *sn, const char *ln);
  97. \&
  98. \& /*
  99. \& * Some OpenSSL functionality is directly offered to providers via
  100. \& * dispatch
  101. \& */
  102. \& void *CRYPTO_malloc(size_t num, const char *file, int line);
  103. \& void *CRYPTO_zalloc(size_t num, const char *file, int line);
  104. \& void CRYPTO_free(void *ptr, const char *file, int line);
  105. \& void CRYPTO_clear_free(void *ptr, size_t num,
  106. \& const char *file, int line);
  107. \& void *CRYPTO_realloc(void *addr, size_t num,
  108. \& const char *file, int line);
  109. \& void *CRYPTO_clear_realloc(void *addr, size_t old_num, size_t num,
  110. \& const char *file, int line);
  111. \& void *CRYPTO_secure_malloc(size_t num, const char *file, int line);
  112. \& void *CRYPTO_secure_zalloc(size_t num, const char *file, int line);
  113. \& void CRYPTO_secure_free(void *ptr, const char *file, int line);
  114. \& void CRYPTO_secure_clear_free(void *ptr, size_t num,
  115. \& const char *file, int line);
  116. \& int CRYPTO_secure_allocated(const void *ptr);
  117. \& void OPENSSL_cleanse(void *ptr, size_t len);
  118. \&
  119. \& unsigned char *OPENSSL_hexstr2buf(const char *str, long *buflen);
  120. \&
  121. \& OSSL_CORE_BIO *BIO_new_file(const char *filename, const char *mode);
  122. \& OSSL_CORE_BIO *BIO_new_membuf(const void *buf, int len);
  123. \& int BIO_read_ex(OSSL_CORE_BIO *bio, void *data, size_t data_len,
  124. \& size_t *bytes_read);
  125. \& int BIO_write_ex(OSSL_CORE_BIO *bio, const void *data, size_t data_len,
  126. \& size_t *written);
  127. \& int BIO_up_ref(OSSL_CORE_BIO *bio);
  128. \& int BIO_free(OSSL_CORE_BIO *bio);
  129. \& int BIO_vprintf(OSSL_CORE_BIO *bio, const char *format, va_list args);
  130. \& int BIO_vsnprintf(char *buf, size_t n, const char *fmt, va_list args);
  131. \&
  132. \& void OSSL_SELF_TEST_set_callback(OSSL_LIB_CTX *libctx, OSSL_CALLBACK *cb,
  133. \& void *cbarg);
  134. \&
  135. \& size_t get_entropy(const OSSL_CORE_HANDLE *handle,
  136. \& unsigned char **pout, int entropy,
  137. \& size_t min_len, size_t max_len);
  138. \& size_t get_user_entropy(const OSSL_CORE_HANDLE *handle,
  139. \& unsigned char **pout, int entropy,
  140. \& size_t min_len, size_t max_len);
  141. \& void cleanup_entropy(const OSSL_CORE_HANDLE *handle,
  142. \& unsigned char *buf, size_t len);
  143. \& void cleanup_user_entropy(const OSSL_CORE_HANDLE *handle,
  144. \& unsigned char *buf, size_t len);
  145. \& size_t get_nonce(const OSSL_CORE_HANDLE *handle,
  146. \& unsigned char **pout, size_t min_len, size_t max_len,
  147. \& const void *salt, size_t salt_len);
  148. \& size_t get_user_nonce(const OSSL_CORE_HANDLE *handle,
  149. \& unsigned char **pout, size_t min_len, size_t max_len,
  150. \& const void *salt, size_t salt_len);
  151. \& void cleanup_nonce(const OSSL_CORE_HANDLE *handle,
  152. \& unsigned char *buf, size_t len);
  153. \& void cleanup_user_nonce(const OSSL_CORE_HANDLE *handle,
  154. \& unsigned char *buf, size_t len);
  155. \&
  156. \& /* Functions for querying the providers in the application library context */
  157. \& int provider_register_child_cb(const OSSL_CORE_HANDLE *handle,
  158. \& int (*create_cb)(const OSSL_CORE_HANDLE *provider,
  159. \& void *cbdata),
  160. \& int (*remove_cb)(const OSSL_CORE_HANDLE *provider,
  161. \& void *cbdata),
  162. \& int (*global_props_cb)(const char *props, void *cbdata),
  163. \& void *cbdata);
  164. \& void provider_deregister_child_cb(const OSSL_CORE_HANDLE *handle);
  165. \& const char *provider_name(const OSSL_CORE_HANDLE *prov);
  166. \& void *provider_get0_provider_ctx(const OSSL_CORE_HANDLE *prov);
  167. \& const OSSL_DISPATCH *provider_get0_dispatch(const OSSL_CORE_HANDLE *prov);
  168. \& int provider_up_ref(const OSSL_CORE_HANDLE *prov, int activate);
  169. \& int provider_free(const OSSL_CORE_HANDLE *prov, int deactivate);
  170. \&
  171. \& /* Functions offered by the provider to libcrypto */
  172. \& void provider_teardown(void *provctx);
  173. \& const OSSL_ITEM *provider_gettable_params(void *provctx);
  174. \& int provider_get_params(void *provctx, OSSL_PARAM params[]);
  175. \& const OSSL_ALGORITHM *provider_query_operation(void *provctx,
  176. \& int operation_id,
  177. \& const int *no_store);
  178. \& void provider_unquery_operation(void *provctx, int operation_id,
  179. \& const OSSL_ALGORITHM *algs);
  180. \& const OSSL_ITEM *provider_get_reason_strings(void *provctx);
  181. \& int provider_get_capabilities(void *provctx, const char *capability,
  182. \& OSSL_CALLBACK *cb, void *arg);
  183. \& int provider_self_test(void *provctx);
  184. .Ve
  185. .SH DESCRIPTION
  186. .IX Header "DESCRIPTION"
  187. All "functions" mentioned here are passed as function pointers between
  188. \&\fIlibcrypto\fR and the provider in \fBOSSL_DISPATCH\fR\|(3) arrays, in the call
  189. of the provider initialization function. See "Provider" in \fBprovider\fR\|(7)
  190. for a description of the initialization function. They are known as "upcalls".
  191. .PP
  192. All these "functions" have a corresponding function type definition
  193. named \fBOSSL_FUNC_{name}_fn\fR, and a helper function to retrieve the
  194. function pointer from a \fBOSSL_DISPATCH\fR\|(3) element named
  195. \&\fBOSSL_FUNC_{name}\fR.
  196. For example, the "function" \fBcore_gettable_params()\fR has these:
  197. .PP
  198. .Vb 4
  199. \& typedef OSSL_PARAM *
  200. \& (OSSL_FUNC_core_gettable_params_fn)(const OSSL_CORE_HANDLE *handle);
  201. \& static ossl_inline OSSL_NAME_core_gettable_params_fn
  202. \& OSSL_FUNC_core_gettable_params(const OSSL_DISPATCH *opf);
  203. .Ve
  204. .PP
  205. \&\fBOSSL_DISPATCH\fR\|(3) arrays are indexed by numbers that are provided as
  206. macros in \fBopenssl\-core_dispatch.h\fR\|(7), as follows:
  207. .PP
  208. For \fIin\fR (the \fBOSSL_DISPATCH\fR\|(3) array passed from \fIlibcrypto\fR to the
  209. provider):
  210. .PP
  211. .Vb 10
  212. \& core_gettable_params OSSL_FUNC_CORE_GETTABLE_PARAMS
  213. \& core_get_params OSSL_FUNC_CORE_GET_PARAMS
  214. \& core_thread_start OSSL_FUNC_CORE_THREAD_START
  215. \& core_get_libctx OSSL_FUNC_CORE_GET_LIBCTX
  216. \& core_new_error OSSL_FUNC_CORE_NEW_ERROR
  217. \& core_set_error_debug OSSL_FUNC_CORE_SET_ERROR_DEBUG
  218. \& core_vset_error OSSL_FUNC_CORE_VSET_ERROR
  219. \& core_obj_add_sigid OSSL_FUNC_CORE_OBJ_ADD_SIGID
  220. \& core_obj_create OSSL_FUNC_CORE_OBJ_CREATE
  221. \& CRYPTO_malloc OSSL_FUNC_CRYPTO_MALLOC
  222. \& CRYPTO_zalloc OSSL_FUNC_CRYPTO_ZALLOC
  223. \& CRYPTO_free OSSL_FUNC_CRYPTO_FREE
  224. \& CRYPTO_clear_free OSSL_FUNC_CRYPTO_CLEAR_FREE
  225. \& CRYPTO_realloc OSSL_FUNC_CRYPTO_REALLOC
  226. \& CRYPTO_clear_realloc OSSL_FUNC_CRYPTO_CLEAR_REALLOC
  227. \& CRYPTO_secure_malloc OSSL_FUNC_CRYPTO_SECURE_MALLOC
  228. \& CRYPTO_secure_zalloc OSSL_FUNC_CRYPTO_SECURE_ZALLOC
  229. \& CRYPTO_secure_free OSSL_FUNC_CRYPTO_SECURE_FREE
  230. \& CRYPTO_secure_clear_free OSSL_FUNC_CRYPTO_SECURE_CLEAR_FREE
  231. \& CRYPTO_secure_allocated OSSL_FUNC_CRYPTO_SECURE_ALLOCATED
  232. \& BIO_new_file OSSL_FUNC_BIO_NEW_FILE
  233. \& BIO_new_mem_buf OSSL_FUNC_BIO_NEW_MEMBUF
  234. \& BIO_read_ex OSSL_FUNC_BIO_READ_EX
  235. \& BIO_write_ex OSSL_FUNC_BIO_WRITE_EX
  236. \& BIO_up_ref OSSL_FUNC_BIO_UP_REF
  237. \& BIO_free OSSL_FUNC_BIO_FREE
  238. \& BIO_vprintf OSSL_FUNC_BIO_VPRINTF
  239. \& BIO_vsnprintf OSSL_FUNC_BIO_VSNPRINTF
  240. \& BIO_puts OSSL_FUNC_BIO_PUTS
  241. \& BIO_gets OSSL_FUNC_BIO_GETS
  242. \& BIO_ctrl OSSL_FUNC_BIO_CTRL
  243. \& OPENSSL_cleanse OSSL_FUNC_OPENSSL_CLEANSE
  244. \& OSSL_SELF_TEST_set_callback OSSL_FUNC_SELF_TEST_CB
  245. \& ossl_rand_get_entropy OSSL_FUNC_GET_ENTROPY
  246. \& ossl_rand_get_user_entropy OSSL_FUNC_GET_USER_ENTROPY
  247. \& ossl_rand_cleanup_entropy OSSL_FUNC_CLEANUP_ENTROPY
  248. \& ossl_rand_cleanup_user_entropy OSSL_FUNC_CLEANUP_USER_ENTROPY
  249. \& ossl_rand_get_nonce OSSL_FUNC_GET_NONCE
  250. \& ossl_rand_get_user_nonce OSSL_FUNC_GET_USER_NONCE
  251. \& ossl_rand_cleanup_nonce OSSL_FUNC_CLEANUP_NONCE
  252. \& ossl_rand_cleanup_user_nonce OSSL_FUNC_CLEANUP_USER_NONCE
  253. \& provider_register_child_cb OSSL_FUNC_PROVIDER_REGISTER_CHILD_CB
  254. \& provider_deregister_child_cb OSSL_FUNC_PROVIDER_DEREGISTER_CHILD_CB
  255. \& provider_name OSSL_FUNC_PROVIDER_NAME
  256. \& provider_get0_provider_ctx OSSL_FUNC_PROVIDER_GET0_PROVIDER_CTX
  257. \& provider_get0_dispatch OSSL_FUNC_PROVIDER_GET0_DISPATCH
  258. \& provider_up_ref OSSL_FUNC_PROVIDER_UP_REF
  259. \& provider_free OSSL_FUNC_PROVIDER_FREE
  260. .Ve
  261. .PP
  262. For \fI*out\fR (the \fBOSSL_DISPATCH\fR\|(3) array passed from the provider to
  263. \&\fIlibcrypto\fR):
  264. .PP
  265. .Vb 8
  266. \& provider_teardown OSSL_FUNC_PROVIDER_TEARDOWN
  267. \& provider_gettable_params OSSL_FUNC_PROVIDER_GETTABLE_PARAMS
  268. \& provider_get_params OSSL_FUNC_PROVIDER_GET_PARAMS
  269. \& provider_query_operation OSSL_FUNC_PROVIDER_QUERY_OPERATION
  270. \& provider_unquery_operation OSSL_FUNC_PROVIDER_UNQUERY_OPERATION
  271. \& provider_get_reason_strings OSSL_FUNC_PROVIDER_GET_REASON_STRINGS
  272. \& provider_get_capabilities OSSL_FUNC_PROVIDER_GET_CAPABILITIES
  273. \& provider_self_test OSSL_FUNC_PROVIDER_SELF_TEST
  274. .Ve
  275. .SS "Core functions"
  276. .IX Subsection "Core functions"
  277. \&\fBcore_gettable_params()\fR returns a constant array of descriptor
  278. \&\fBOSSL_PARAM\fR\|(3), for parameters that \fBcore_get_params()\fR can handle.
  279. .PP
  280. \&\fBcore_get_params()\fR retrieves parameters from the core for the given \fIhandle\fR.
  281. See "Core parameters" below for a description of currently known
  282. parameters.
  283. .PP
  284. The \fBcore_thread_start()\fR function informs the core that the provider has stated
  285. an interest in the current thread. The core will inform the provider when the
  286. thread eventually stops. It must be passed the \fIhandle\fR for this provider, as
  287. well as a callback \fIhandfn\fR which will be called when the thread stops. The
  288. callback will subsequently be called, with the supplied argument \fIarg\fR, from
  289. the thread that is stopping and gets passed the provider context as an
  290. argument. This may be useful to perform thread specific clean up such as
  291. freeing thread local variables.
  292. .PP
  293. \&\fBcore_get_libctx()\fR retrieves the core context in which the library
  294. object for the current provider is stored, accessible through the \fIhandle\fR.
  295. This function is useful only for built-in providers such as the default
  296. provider. Never cast this to OSSL_LIB_CTX in a provider that is not
  297. built-in as the OSSL_LIB_CTX of the library loading the provider might be
  298. a completely different structure than the OSSL_LIB_CTX of the library the
  299. provider is linked to. Use \fBOSSL_LIB_CTX_new_child\fR\|(3) instead to obtain
  300. a proper library context that is linked to the application library context.
  301. .PP
  302. \&\fBcore_new_error()\fR, \fBcore_set_error_debug()\fR and \fBcore_vset_error()\fR are
  303. building blocks for reporting an error back to the core, with
  304. reference to the \fIhandle\fR.
  305. .IP \fBcore_new_error()\fR 4
  306. .IX Item "core_new_error()"
  307. allocates a new thread specific error record.
  308. .Sp
  309. This corresponds to the OpenSSL function \fBERR_new\fR\|(3).
  310. .IP \fBcore_set_error_debug()\fR 4
  311. .IX Item "core_set_error_debug()"
  312. sets debugging information in the current thread specific error
  313. record.
  314. The debugging information includes the name of the file \fIfile\fR, the
  315. line \fIline\fR and the function name \fIfunc\fR where the error occurred.
  316. .Sp
  317. This corresponds to the OpenSSL function \fBERR_set_debug\fR\|(3).
  318. .IP \fBcore_vset_error()\fR 4
  319. .IX Item "core_vset_error()"
  320. sets the \fIreason\fR for the error, along with any addition data.
  321. The \fIreason\fR is a number defined by the provider and used to index
  322. the reason strings table that's returned by
  323. \&\fBprovider_get_reason_strings()\fR.
  324. The additional data is given as a format string \fIfmt\fR and a set of
  325. arguments \fIargs\fR, which are treated in the same manner as with
  326. \&\fBBIO_vsnprintf()\fR.
  327. \&\fIfile\fR and \fIline\fR may also be passed to indicate exactly where the
  328. error occurred or was reported.
  329. .Sp
  330. This corresponds to the OpenSSL function \fBERR_vset_error\fR\|(3).
  331. .PP
  332. The \fBcore_obj_create()\fR function registers a new OID and associated short name
  333. \&\fIsn\fR and long name \fIln\fR for the given \fIhandle\fR. It is similar to the OpenSSL
  334. function \fBOBJ_create\fR\|(3) except that it returns 1 on success or 0 on failure.
  335. It will treat as success the case where the OID already exists (even if the
  336. short name \fIsn\fR or long name \fIln\fR provided as arguments differ from those
  337. associated with the existing OID, in which case the new names are not
  338. associated).
  339. .PP
  340. The \fBcore_obj_add_sigid()\fR function registers a new composite signature algorithm
  341. (\fIsign_name\fR) consisting of an underlying signature algorithm (\fIpkey_name\fR)
  342. and digest algorithm (\fIdigest_name\fR) for the given \fIhandle\fR. It assumes that
  343. the OIDs for the composite signature algorithm as well as for the underlying
  344. signature and digest algorithms are either already known to OpenSSL or have been
  345. registered via a call to \fBcore_obj_create()\fR. It corresponds to the OpenSSL
  346. function \fBOBJ_add_sigid\fR\|(3), except that the objects are identified by name
  347. rather than a numeric NID. Any name (OID, short name or long name) can be used
  348. to identify the object. It will treat as success the case where the composite
  349. signature algorithm already exists (even if registered against a different
  350. underlying signature or digest algorithm). For \fIdigest_name\fR, NULL or an
  351. empty string is permissible for signature algorithms that do not need a digest
  352. to operate correctly. The function returns 1 on success or 0 on failure.
  353. .PP
  354. \&\fBCRYPTO_malloc()\fR, \fBCRYPTO_zalloc()\fR, \fBCRYPTO_free()\fR, \fBCRYPTO_clear_free()\fR,
  355. \&\fBCRYPTO_realloc()\fR, \fBCRYPTO_clear_realloc()\fR, \fBCRYPTO_secure_malloc()\fR,
  356. \&\fBCRYPTO_secure_zalloc()\fR, \fBCRYPTO_secure_free()\fR,
  357. \&\fBCRYPTO_secure_clear_free()\fR, \fBCRYPTO_secure_allocated()\fR,
  358. \&\fBBIO_new_file()\fR, \fBBIO_new_mem_buf()\fR, \fBBIO_read_ex()\fR, \fBBIO_write_ex()\fR, \fBBIO_up_ref()\fR,
  359. \&\fBBIO_free()\fR, \fBBIO_vprintf()\fR, \fBBIO_vsnprintf()\fR, \fBBIO_gets()\fR, \fBBIO_puts()\fR,
  360. \&\fBBIO_ctrl()\fR, \fBOPENSSL_cleanse()\fR and
  361. \&\fBOPENSSL_hexstr2buf()\fR correspond exactly to the public functions with
  362. the same name. As a matter of fact, the pointers in the \fBOSSL_DISPATCH\fR\|(3)
  363. array are typically direct pointers to those public functions. Note that the BIO
  364. functions take an \fBOSSL_CORE_BIO\fR type rather than the standard \fBBIO\fR
  365. type. This is to ensure that a provider does not mix BIOs from the core
  366. with BIOs used on the provider side (the two are not compatible).
  367. \&\fBOSSL_SELF_TEST_set_callback()\fR is used to set an optional callback that can be
  368. passed into a provider. This may be ignored by a provider.
  369. .PP
  370. \&\fBget_entropy()\fR retrieves seeding material from the operating system.
  371. The seeding material will have at least \fIentropy\fR bytes of randomness and the
  372. output will have at least \fImin_len\fR and at most \fImax_len\fR bytes.
  373. The buffer address is stored in \fI*pout\fR and the buffer length is
  374. returned to the caller. On error, zero is returned.
  375. .PP
  376. \&\fBget_user_entropy()\fR is the same as \fBget_entropy()\fR except that it will
  377. attempt to gather seed material via the seed source specified by a call to
  378. \&\fBRAND_set_seed_source_type\fR\|(3) or via "Random Configuration" in \fBconfig\fR\|(5).
  379. .PP
  380. \&\fBcleanup_entropy()\fR is used to clean up and free the buffer returned by
  381. \&\fBget_entropy()\fR. The entropy pointer returned by \fBget_entropy()\fR
  382. is passed in \fBbuf\fR and its length in \fBlen\fR.
  383. .PP
  384. \&\fBcleanup_user_entropy()\fR is used to clean up and free the buffer returned by
  385. \&\fBget_user_entropy()\fR. The entropy pointer returned by \fBget_user_entropy()\fR
  386. is passed in \fBbuf\fR and its length in \fBlen\fR.
  387. .PP
  388. \&\fBget_nonce()\fR retrieves a nonce using the passed \fIsalt\fR parameter
  389. of length \fIsalt_len\fR and operating system specific information.
  390. The \fIsalt\fR should contain uniquely identifying information and this is
  391. included, in an unspecified manner, as part of the output.
  392. The output is stored in a buffer which contains at least \fImin_len\fR and at
  393. most \fImax_len\fR bytes. The buffer address is stored in \fI*pout\fR and the
  394. buffer length returned to the caller. On error, zero is returned.
  395. .PP
  396. \&\fBget_user_nonce()\fR is the same as \fBget_nonce()\fR except that it will attempt
  397. to gather seed material via the seed source specified by a call to
  398. \&\fBRAND_set_seed_source_type\fR\|(3) or via "Random Configuration" in \fBconfig\fR\|(5).
  399. .PP
  400. \&\fBcleanup_nonce()\fR is used to clean up and free the buffer returned by
  401. \&\fBget_nonce()\fR. The nonce pointer returned by \fBget_nonce()\fR
  402. is passed in \fBbuf\fR and its length in \fBlen\fR.
  403. .PP
  404. \&\fBcleanup_user_nonce()\fR is used to clean up and free the buffer returned by
  405. \&\fBget_user_nonce()\fR. The nonce pointer returned by \fBget_user_nonce()\fR
  406. is passed in \fBbuf\fR and its length in \fBlen\fR.
  407. .PP
  408. \&\fBprovider_register_child_cb()\fR registers callbacks for being informed about the
  409. loading and unloading of providers in the application's library context.
  410. \&\fIhandle\fR is this provider's handle and \fIcbdata\fR is this provider's data
  411. that will be passed back to the callbacks. It returns 1 on success or 0
  412. otherwise. These callbacks may be called while holding locks in libcrypto. In
  413. order to avoid deadlocks the callback implementation must not be long running
  414. and must not call other OpenSSL API functions or upcalls.
  415. .PP
  416. \&\fIcreate_cb\fR is a callback that will be called when a new provider is loaded
  417. into the application's library context. It is also called for any providers that
  418. are already loaded at the point that this callback is registered. The callback
  419. is passed the handle being used for the new provider being loadded and this
  420. provider's data in \fIcbdata\fR. It should return 1 on success or 0 on failure.
  421. .PP
  422. \&\fIremove_cb\fR is a callback that will be called when a new provider is unloaded
  423. from the application's library context. It is passed the handle being used for
  424. the provider being unloaded and this provider's data in \fIcbdata\fR. It should
  425. return 1 on success or 0 on failure.
  426. .PP
  427. \&\fIglobal_props_cb\fR is a callback that will be called when the global properties
  428. from the parent library context are changed. It should return 1 on success
  429. or 0 on failure.
  430. .PP
  431. \&\fBprovider_deregister_child_cb()\fR unregisters callbacks previously registered via
  432. \&\fBprovider_register_child_cb()\fR. If \fBprovider_register_child_cb()\fR has been called
  433. then \fBprovider_deregister_child_cb()\fR should be called at or before the point that
  434. this provider's teardown function is called.
  435. .PP
  436. \&\fBprovider_name()\fR returns a string giving the name of the provider identified by
  437. \&\fIhandle\fR.
  438. .PP
  439. \&\fBprovider_get0_provider_ctx()\fR returns the provider context that is associated
  440. with the provider identified by \fIprov\fR.
  441. .PP
  442. \&\fBprovider_get0_dispatch()\fR gets the dispatch table registered by the provider
  443. identified by \fIprov\fR when it initialised.
  444. .PP
  445. \&\fBprovider_up_ref()\fR increments the reference count on the provider \fIprov\fR. If
  446. \&\fIactivate\fR is nonzero then the provider is also loaded if it is not already
  447. loaded. It returns 1 on success or 0 on failure.
  448. .PP
  449. \&\fBprovider_free()\fR decrements the reference count on the provider \fIprov\fR. If
  450. \&\fIdeactivate\fR is nonzero then the provider is also unloaded if it is not
  451. already loaded. It returns 1 on success or 0 on failure.
  452. .SS "Provider functions"
  453. .IX Subsection "Provider functions"
  454. \&\fBprovider_teardown()\fR is called when a provider is shut down and removed
  455. from the core's provider store.
  456. It must free the passed \fIprovctx\fR.
  457. .PP
  458. \&\fBprovider_gettable_params()\fR should return a constant array of
  459. descriptor \fBOSSL_PARAM\fR\|(3), for parameters that \fBprovider_get_params()\fR
  460. can handle.
  461. .PP
  462. \&\fBprovider_get_params()\fR should process the \fBOSSL_PARAM\fR\|(3) array
  463. \&\fIparams\fR, setting the values of the parameters it understands.
  464. .PP
  465. \&\fBprovider_query_operation()\fR should return a constant \fBOSSL_ALGORITHM\fR\|(3)
  466. that corresponds to the given \fIoperation_id\fR.
  467. It should indicate if the core may store a reference to this array by
  468. setting \fI*no_store\fR to 0 (core may store a reference) or 1 (core may
  469. not store a reference).
  470. .PP
  471. \&\fBprovider_unquery_operation()\fR informs the provider that the result of a
  472. \&\fBprovider_query_operation()\fR is no longer directly required and that the function
  473. pointers have been copied. The \fIoperation_id\fR should match that passed to
  474. \&\fBprovider_query_operation()\fR and \fIalgs\fR should be its return value.
  475. .PP
  476. \&\fBprovider_get_reason_strings()\fR should return a constant \fBOSSL_ITEM\fR\|(3)
  477. array that provides reason strings for reason codes the provider may
  478. use when reporting errors using \fBcore_put_error()\fR.
  479. .PP
  480. The \fBprovider_get_capabilities()\fR function should call the callback \fIcb\fR passing
  481. it a set of \fBOSSL_PARAM\fR\|(3)s and the caller supplied argument \fIarg\fR. The
  482. \&\fBOSSL_PARAM\fR\|(3)s should provide details about the capability with the name given
  483. in the \fIcapability\fR argument relevant for the provider context \fIprovctx\fR. If a
  484. provider supports multiple capabilities with the given name then it may call the
  485. callback multiple times (one for each capability). Capabilities can be useful for
  486. describing the services that a provider can offer. For further details see the
  487. "CAPABILITIES" section below. It should return 1 on success or 0 on error.
  488. .PP
  489. The \fBprovider_self_test()\fR function should perform known answer tests on a subset
  490. of the algorithms that it uses, and may also verify the integrity of the
  491. provider module. It should return 1 on success or 0 on error. It will return 1
  492. if this function is not used.
  493. .PP
  494. None of these functions are mandatory, but a provider is fairly
  495. useless without at least \fBprovider_query_operation()\fR, and
  496. \&\fBprovider_gettable_params()\fR is fairly useless if not accompanied by
  497. \&\fBprovider_get_params()\fR.
  498. .SS "Provider parameters"
  499. .IX Subsection "Provider parameters"
  500. \&\fBprovider_get_params()\fR can return the following provider parameters to the core:
  501. .IP """name"" (\fBOSSL_PROV_PARAM_NAME\fR) <UTF8 ptr>" 4
  502. .IX Item """name"" (OSSL_PROV_PARAM_NAME) <UTF8 ptr>"
  503. This points to a string that should give a unique name for the provider.
  504. .IP """version"" (\fBOSSL_PROV_PARAM_VERSION\fR) <UTF8 ptr>" 4
  505. .IX Item """version"" (OSSL_PROV_PARAM_VERSION) <UTF8 ptr>"
  506. This points to a string that is a version number associated with this provider.
  507. OpenSSL in-built providers use OPENSSL_VERSION_STR, but this may be different
  508. for any third party provider. This string is for informational purposes only.
  509. .IP """buildinfo"" (\fBOSSL_PROV_PARAM_BUILDINFO\fR) <UTF8 ptr>" 4
  510. .IX Item """buildinfo"" (OSSL_PROV_PARAM_BUILDINFO) <UTF8 ptr>"
  511. This points to a string that is a build information associated with this provider.
  512. OpenSSL in-built providers use OPENSSL_FULL_VERSION_STR, but this may be
  513. different for any third party provider.
  514. .IP """status"" (\fBOSSL_PROV_PARAM_STATUS\fR) <unsigned integer>" 4
  515. .IX Item """status"" (OSSL_PROV_PARAM_STATUS) <unsigned integer>"
  516. This returns 0 if the provider has entered an error state, otherwise it returns
  517. 1.
  518. .PP
  519. \&\fBprovider_gettable_params()\fR should return the above parameters.
  520. .SS "Core parameters"
  521. .IX Subsection "Core parameters"
  522. \&\fBcore_get_params()\fR can retrieve the following core parameters for each provider:
  523. .IP """openssl-version"" (\fBOSSL_PROV_PARAM_CORE_VERSION\fR) <UTF8 string ptr>" 4
  524. .IX Item """openssl-version"" (OSSL_PROV_PARAM_CORE_VERSION) <UTF8 string ptr>"
  525. This points to the OpenSSL libraries' full version string, i.e. the string
  526. expanded from the macro \fBOPENSSL_VERSION_STR\fR.
  527. .IP """provider-name"" (\fBOSSL_PROV_PARAM_CORE_PROV_NAME\fR) <UTF8 string ptr>" 4
  528. .IX Item """provider-name"" (OSSL_PROV_PARAM_CORE_PROV_NAME) <UTF8 string ptr>"
  529. This points to the OpenSSL libraries' idea of what the calling provider is named.
  530. .IP """module-filename"" (\fBOSSL_PROV_PARAM_CORE_MODULE_FILENAME\fR) <UTF8 string ptr>" 4
  531. .IX Item """module-filename"" (OSSL_PROV_PARAM_CORE_MODULE_FILENAME) <UTF8 string ptr>"
  532. This points to a string containing the full filename of the providers
  533. module file.
  534. .PP
  535. Additionally, provider specific configuration parameters from the
  536. config file are available, in dotted name form.
  537. The dotted name form is a concatenation of section names and final
  538. config command name separated by periods.
  539. .PP
  540. For example, let's say we have the following config example:
  541. .PP
  542. .Vb 2
  543. \& config_diagnostics = 1
  544. \& openssl_conf = openssl_init
  545. \&
  546. \& [openssl_init]
  547. \& providers = providers_sect
  548. \&
  549. \& [providers_sect]
  550. \& foo = foo_sect
  551. \&
  552. \& [foo_sect]
  553. \& activate = 1
  554. \& data1 = 2
  555. \& data2 = str
  556. \& more = foo_more
  557. \&
  558. \& [foo_more]
  559. \& data3 = foo,bar
  560. .Ve
  561. .PP
  562. The provider will have these additional parameters available:
  563. .IP """activate""" 4
  564. .IX Item """activate"""
  565. pointing at the string "1"
  566. .IP """data1""" 4
  567. .IX Item """data1"""
  568. pointing at the string "2"
  569. .IP """data2""" 4
  570. .IX Item """data2"""
  571. pointing at the string "str"
  572. .IP """more.data3""" 4
  573. .IX Item """more.data3"""
  574. pointing at the string "foo,bar"
  575. .PP
  576. For more information on handling parameters, see \fBOSSL_PARAM\fR\|(3) as
  577. \&\fBOSSL_PARAM_int\fR\|(3).
  578. .SH CAPABILITIES
  579. .IX Header "CAPABILITIES"
  580. Capabilities describe some of the services that a provider can offer.
  581. Applications can query the capabilities to discover those services.
  582. .PP
  583. \fI"TLS-GROUP" Capability\fR
  584. .IX Subsection """TLS-GROUP"" Capability"
  585. .PP
  586. The "TLS-GROUP" capability can be queried by libssl to discover the list of
  587. TLS groups that a provider can support. Each group supported can be used for
  588. \&\fIkey exchange\fR (KEX) or \fIkey encapsulation method\fR (KEM) during a TLS
  589. handshake.
  590. TLS clients can advertise the list of TLS groups they support in the
  591. supported_groups extension, and TLS servers can select a group from the offered
  592. list that they also support. In this way a provider can add to the list of
  593. groups that libssl already supports with additional ones.
  594. .PP
  595. Each TLS group that a provider supports should be described via the callback
  596. passed in through the provider_get_capabilities function. Each group should have
  597. the following details supplied (all are mandatory, except
  598. \&\fBOSSL_CAPABILITY_TLS_GROUP_IS_KEM\fR):
  599. .IP """tls-group-name"" (\fBOSSL_CAPABILITY_TLS_GROUP_NAME\fR) <UTF8 string>" 4
  600. .IX Item """tls-group-name"" (OSSL_CAPABILITY_TLS_GROUP_NAME) <UTF8 string>"
  601. The name of the group as given in the IANA TLS Supported Groups registry
  602. <https://www.iana.org/assignments/tls\-parameters/tls\-parameters.xhtml#tls\-parameters\-8>.
  603. .IP """tls-group-name-internal"" (\fBOSSL_CAPABILITY_TLS_GROUP_NAME_INTERNAL\fR) <UTF8 string>" 4
  604. .IX Item """tls-group-name-internal"" (OSSL_CAPABILITY_TLS_GROUP_NAME_INTERNAL) <UTF8 string>"
  605. The name of the group as known by the provider. This could be the same as the
  606. "tls-group-name", but does not have to be.
  607. .IP """tls-group-id"" (\fBOSSL_CAPABILITY_TLS_GROUP_ID\fR) <unsigned integer>" 4
  608. .IX Item """tls-group-id"" (OSSL_CAPABILITY_TLS_GROUP_ID) <unsigned integer>"
  609. The TLS group id value as given in the IANA TLS Supported Groups registry.
  610. .IP """tls-group-alg"" (\fBOSSL_CAPABILITY_TLS_GROUP_ALG\fR) <UTF8 string>" 4
  611. .IX Item """tls-group-alg"" (OSSL_CAPABILITY_TLS_GROUP_ALG) <UTF8 string>"
  612. The name of a Key Management algorithm that the provider offers and that should
  613. be used with this group. Keys created should be able to support \fIkey exchange\fR
  614. or \fIkey encapsulation method\fR (KEM), as implied by the optional
  615. \&\fBOSSL_CAPABILITY_TLS_GROUP_IS_KEM\fR flag.
  616. The algorithm must support key and parameter generation as well as the
  617. key/parameter generation parameter, \fBOSSL_PKEY_PARAM_GROUP_NAME\fR. The group
  618. name given via "tls-group-name-internal" above will be passed via
  619. \&\fBOSSL_PKEY_PARAM_GROUP_NAME\fR when libssl wishes to generate keys/parameters.
  620. .IP """tls-group-sec-bits"" (\fBOSSL_CAPABILITY_TLS_GROUP_SECURITY_BITS\fR) <unsigned integer>" 4
  621. .IX Item """tls-group-sec-bits"" (OSSL_CAPABILITY_TLS_GROUP_SECURITY_BITS) <unsigned integer>"
  622. The number of bits of security offered by keys in this group. The number of bits
  623. should be comparable with the ones given in table 2 and 3 of the NIST SP800\-57
  624. document.
  625. .IP """tls-group-is-kem"" (\fBOSSL_CAPABILITY_TLS_GROUP_IS_KEM\fR) <unsigned integer>" 4
  626. .IX Item """tls-group-is-kem"" (OSSL_CAPABILITY_TLS_GROUP_IS_KEM) <unsigned integer>"
  627. Boolean flag to describe if the group should be used in \fIkey exchange\fR (KEX)
  628. mode (0, default) or in \fIkey encapsulation method\fR (KEM) mode (1).
  629. .Sp
  630. This parameter is optional: if not specified, KEX mode is assumed as the default
  631. mode for the group.
  632. .Sp
  633. In KEX mode, in a typical Diffie-Hellman fashion, both sides execute \fIkeygen\fR
  634. then \fIderive\fR against the peer public key. To operate in KEX mode, the group
  635. implementation must support the provider functions as described in
  636. \&\fBprovider\-keyexch\fR\|(7).
  637. .Sp
  638. In KEM mode, the client executes \fIkeygen\fR and sends its public key, the server
  639. executes \fIencapsulate\fR using the client's public key and sends back the
  640. resulting \fIciphertext\fR, finally the client executes \fIdecapsulate\fR to retrieve
  641. the same \fIshared secret\fR generated by the server's \fIencapsulate\fR. To operate
  642. in KEM mode, the group implementation must support the provider functions as
  643. described in \fBprovider\-kem\fR\|(7).
  644. .Sp
  645. Both in KEX and KEM mode, the resulting \fIshared secret\fR is then used according
  646. to the protocol specification.
  647. .IP """tls-min-tls"" (\fBOSSL_CAPABILITY_TLS_GROUP_MIN_TLS\fR) <integer>" 4
  648. .IX Item """tls-min-tls"" (OSSL_CAPABILITY_TLS_GROUP_MIN_TLS) <integer>"
  649. .PD 0
  650. .IP """tls-max-tls"" (\fBOSSL_CAPABILITY_TLS_GROUP_MAX_TLS\fR) <integer>" 4
  651. .IX Item """tls-max-tls"" (OSSL_CAPABILITY_TLS_GROUP_MAX_TLS) <integer>"
  652. .IP """tls-min-dtls"" (\fBOSSL_CAPABILITY_TLS_GROUP_MIN_DTLS\fR) <integer>" 4
  653. .IX Item """tls-min-dtls"" (OSSL_CAPABILITY_TLS_GROUP_MIN_DTLS) <integer>"
  654. .IP """tls-max-dtls"" (\fBOSSL_CAPABILITY_TLS_GROUP_MAX_DTLS\fR) <integer>" 4
  655. .IX Item """tls-max-dtls"" (OSSL_CAPABILITY_TLS_GROUP_MAX_DTLS) <integer>"
  656. .PD
  657. These parameters can be used to describe the minimum and maximum TLS and DTLS
  658. versions supported by the group. The values equate to the on-the-wire encoding
  659. of the various TLS versions. For example TLSv1.3 is 0x0304 (772 decimal), and
  660. TLSv1.2 is 0x0303 (771 decimal). A 0 indicates that there is no defined minimum
  661. or maximum. A \-1 indicates that the group should not be used in that protocol.
  662. .PP
  663. \fI"TLS-SIGALG" Capability\fR
  664. .IX Subsection """TLS-SIGALG"" Capability"
  665. .PP
  666. The "TLS-SIGALG" capability can be queried by libssl to discover the list of
  667. TLS signature algorithms that a provider can support. Each signature supported
  668. can be used for client\- or server-authentication in addition to the built-in
  669. signature algorithms.
  670. TLS1.3 clients can advertise the list of TLS signature algorithms they support
  671. in the signature_algorithms extension, and TLS servers can select an algorithm
  672. from the offered list that they also support. In this way a provider can add
  673. to the list of signature algorithms that libssl already supports with
  674. additional ones.
  675. .PP
  676. Each TLS signature algorithm that a provider supports should be described via
  677. the callback passed in through the provider_get_capabilities function. Each
  678. algorithm can have the following details supplied:
  679. .IP """iana-name"" (\fBOSSL_CAPABILITY_TLS_SIGALG_IANA_NAME\fR) <UTF8 string>" 4
  680. .IX Item """iana-name"" (OSSL_CAPABILITY_TLS_SIGALG_IANA_NAME) <UTF8 string>"
  681. The name of the signature algorithm as given in the IANA TLS Signature Scheme
  682. registry as "Description":
  683. <https://www.iana.org/assignments/tls\-parameters/tls\-parameters.xhtml#tls\-signaturescheme>.
  684. This value must be supplied.
  685. .IP """iana-code-point"" (\fBOSSL_CAPABILITY_TLS_SIGALG_CODE_POINT\fR) <unsigned integer>" 4
  686. .IX Item """iana-code-point"" (OSSL_CAPABILITY_TLS_SIGALG_CODE_POINT) <unsigned integer>"
  687. The TLS algorithm ID value as given in the IANA TLS SignatureScheme registry.
  688. This value must be supplied.
  689. .IP """sigalg-name"" (\fBOSSL_CAPABILITY_TLS_SIGALG_NAME\fR) <UTF8 string>" 4
  690. .IX Item """sigalg-name"" (OSSL_CAPABILITY_TLS_SIGALG_NAME) <UTF8 string>"
  691. A name for the full (possibly composite hash-and-signature) signature
  692. algorithm.
  693. The provider may, but is not obligated to, provide a signature implementation
  694. with this name; if it doesn't, this is assumed to be a composite of a pure
  695. signature algorithm and a hash algorithm, which must be given with the
  696. parameters "sig-name" and "hash-name".
  697. This value must be supplied.
  698. .IP """sigalg-oid"" (\fBOSSL_CAPABILITY_TLS_SIGALG_OID\fR) <UTF8 string>" 4
  699. .IX Item """sigalg-oid"" (OSSL_CAPABILITY_TLS_SIGALG_OID) <UTF8 string>"
  700. The OID of the "sigalg-name" algorithm in canonical numeric text form. If
  701. this parameter is given, \fBOBJ_create()\fR will be used to create an OBJ and
  702. a NID for this OID, using the "sigalg-name" parameter for its (short) name.
  703. Otherwise, it's assumed to already exist in the object database, possibly
  704. done by the provider with the \fBcore_obj_create()\fR upcall.
  705. This value is optional.
  706. .IP """sig-name"" (\fBOSSL_CAPABILITY_TLS_SIGALG_SIG_NAME\fR) <UTF8 string>" 4
  707. .IX Item """sig-name"" (OSSL_CAPABILITY_TLS_SIGALG_SIG_NAME) <UTF8 string>"
  708. The name of the pure signature algorithm that is part of a composite
  709. "sigalg-name". If "sigalg-name" is implemented by the provider, this
  710. parameter is redundant and must not be given.
  711. This value is optional.
  712. .IP """sig-oid"" (\fBOSSL_CAPABILITY_TLS_SIGALG_SIG_OID\fR) <UTF8 string>" 4
  713. .IX Item """sig-oid"" (OSSL_CAPABILITY_TLS_SIGALG_SIG_OID) <UTF8 string>"
  714. The OID of the "sig-name" algorithm in canonical numeric text form. If
  715. this parameter is given, \fBOBJ_create()\fR will be used to create an OBJ and
  716. a NID for this OID, using the "sig-name" parameter for its (short) name.
  717. Otherwise, it is assumed to already exist in the object database. This
  718. can be done by the provider using the \fBcore_obj_create()\fR upcall.
  719. This value is optional.
  720. .IP """hash-name"" (\fBOSSL_CAPABILITY_TLS_SIGALG_HASH_NAME\fR) <UTF8 string>" 4
  721. .IX Item """hash-name"" (OSSL_CAPABILITY_TLS_SIGALG_HASH_NAME) <UTF8 string>"
  722. The name of the hash algorithm that is part of a composite "sigalg-name".
  723. If "sigalg-name" is implemented by the provider, this parameter is redundant
  724. and must not be given.
  725. This value is optional.
  726. .IP """hash-oid"" (\fBOSSL_CAPABILITY_TLS_SIGALG_HASH_OID\fR) <UTF8 string>" 4
  727. .IX Item """hash-oid"" (OSSL_CAPABILITY_TLS_SIGALG_HASH_OID) <UTF8 string>"
  728. The OID of the "hash-name" algorithm in canonical numeric text form. If
  729. this parameter is given, \fBOBJ_create()\fR will be used to create an OBJ and
  730. a NID for this OID, using the "hash-name" parameter for its (short) name.
  731. Otherwise, it's assumed to already exist in the object database, possibly
  732. done by the provider with the \fBcore_obj_create()\fR upcall.
  733. This value is optional.
  734. .IP """key-type"" (\fBOSSL_CAPABILITY_TLS_SIGALG_KEYTYPE\fR) <UTF8 string>" 4
  735. .IX Item """key-type"" (OSSL_CAPABILITY_TLS_SIGALG_KEYTYPE) <UTF8 string>"
  736. The key type of the public key of applicable certificates. If this parameter
  737. isn't present, it's assumed to be the same as "sig-name" if that's present,
  738. otherwise "sigalg-name".
  739. This value is optional.
  740. .IP """key-type-oid"" (\fBOSSL_CAPABILITY_TLS_SIGALG_KEYTYPE_OID\fR) <UTF8 string>" 4
  741. .IX Item """key-type-oid"" (OSSL_CAPABILITY_TLS_SIGALG_KEYTYPE_OID) <UTF8 string>"
  742. The OID of the "key-type" in canonical numeric text form. If
  743. this parameter is given, \fBOBJ_create()\fR will be used to create an OBJ and
  744. a NID for this OID, using the "key-type" parameter for its (short) name.
  745. Otherwise, it's assumed to already exist in the object database, possibly
  746. done by the provider with the \fBcore_obj_create()\fR upcall.
  747. This value is optional.
  748. .IP """sec-bits"" (\fBOSSL_CAPABILITY_TLS_SIGALG_SECURITY_BITS\fR) <unsigned integer>" 4
  749. .IX Item """sec-bits"" (OSSL_CAPABILITY_TLS_SIGALG_SECURITY_BITS) <unsigned integer>"
  750. The number of bits of security offered by keys of this algorithm. The number
  751. of bits should be comparable with the ones given in table 2 and 3 of the NIST
  752. SP800\-57 document. This number is used to determine the security strength of
  753. the algorithm if no digest algorithm has been registered that otherwise
  754. defines the security strength. If the signature algorithm implements its own
  755. digest internally, this value needs to be set to properly reflect the overall
  756. security strength.
  757. This value must be supplied.
  758. .IP """tls-min-tls"" (\fBOSSL_CAPABILITY_TLS_SIGALG_MIN_TLS\fR) <integer>" 4
  759. .IX Item """tls-min-tls"" (OSSL_CAPABILITY_TLS_SIGALG_MIN_TLS) <integer>"
  760. .PD 0
  761. .IP """tls-max-tls"" (\fBOSSL_CAPABILITY_TLS_SIGALG_MAX_TLS\fR) <integer>" 4
  762. .IX Item """tls-max-tls"" (OSSL_CAPABILITY_TLS_SIGALG_MAX_TLS) <integer>"
  763. .PD
  764. These parameters can be used to describe the minimum and maximum TLS
  765. versions supported by the signature algorithm. The values equate to the
  766. on-the-wire encoding of the various TLS versions. For example TLSv1.3 is
  767. 0x0304 (772 decimal), and TLSv1.2 is 0x0303 (771 decimal). A 0 indicates that
  768. there is no defined minimum or maximum. A \-1 indicates that the signature
  769. algorithm should not be used in that protocol.
  770. Presently values representing anything other than TLS1.3 mean that the
  771. complete algorithm is ignored.
  772. .SH NOTES
  773. .IX Header "NOTES"
  774. The \fBcore_obj_create()\fR and \fBcore_obj_add_sigid()\fR functions were not thread safe
  775. in OpenSSL 3.0.
  776. .SH EXAMPLES
  777. .IX Header "EXAMPLES"
  778. This is an example of a simple provider made available as a
  779. dynamically loadable module.
  780. It implements the fictitious algorithm \f(CW\*(C`FOO\*(C'\fR for the fictitious
  781. operation \f(CW\*(C`BAR\*(C'\fR.
  782. .PP
  783. .Vb 3
  784. \& #include <malloc.h>
  785. \& #include <openssl/core.h>
  786. \& #include <openssl/core_dispatch.h>
  787. \&
  788. \& /* Errors used in this provider */
  789. \& #define E_MALLOC 1
  790. \&
  791. \& static const OSSL_ITEM reasons[] = {
  792. \& { E_MALLOC, "memory allocation failure" }.
  793. \& OSSL_DISPATCH_END
  794. \& };
  795. \&
  796. \& /*
  797. \& * To ensure we get the function signature right, forward declare
  798. \& * them using function types provided by openssl/core_dispatch.h
  799. \& */
  800. \& OSSL_FUNC_bar_newctx_fn foo_newctx;
  801. \& OSSL_FUNC_bar_freectx_fn foo_freectx;
  802. \& OSSL_FUNC_bar_init_fn foo_init;
  803. \& OSSL_FUNC_bar_update_fn foo_update;
  804. \& OSSL_FUNC_bar_final_fn foo_final;
  805. \&
  806. \& OSSL_FUNC_provider_query_operation_fn p_query;
  807. \& OSSL_FUNC_provider_get_reason_strings_fn p_reasons;
  808. \& OSSL_FUNC_provider_teardown_fn p_teardown;
  809. \&
  810. \& OSSL_provider_init_fn OSSL_provider_init;
  811. \&
  812. \& OSSL_FUNC_core_put_error *c_put_error = NULL;
  813. \&
  814. \& /* Provider context */
  815. \& struct prov_ctx_st {
  816. \& OSSL_CORE_HANDLE *handle;
  817. \& }
  818. \&
  819. \& /* operation context for the algorithm FOO */
  820. \& struct foo_ctx_st {
  821. \& struct prov_ctx_st *provctx;
  822. \& int b;
  823. \& };
  824. \&
  825. \& static void *foo_newctx(void *provctx)
  826. \& {
  827. \& struct foo_ctx_st *fooctx = malloc(sizeof(*fooctx));
  828. \&
  829. \& if (fooctx != NULL)
  830. \& fooctx\->provctx = provctx;
  831. \& else
  832. \& c_put_error(provctx\->handle, E_MALLOC, _\|_FILE_\|_, _\|_LINE_\|_);
  833. \& return fooctx;
  834. \& }
  835. \&
  836. \& static void foo_freectx(void *fooctx)
  837. \& {
  838. \& free(fooctx);
  839. \& }
  840. \&
  841. \& static int foo_init(void *vfooctx)
  842. \& {
  843. \& struct foo_ctx_st *fooctx = vfooctx;
  844. \&
  845. \& fooctx\->b = 0x33;
  846. \& }
  847. \&
  848. \& static int foo_update(void *vfooctx, unsigned char *in, size_t inl)
  849. \& {
  850. \& struct foo_ctx_st *fooctx = vfooctx;
  851. \&
  852. \& /* did you expect something serious? */
  853. \& if (inl == 0)
  854. \& return 1;
  855. \& for (; inl\-\- > 0; in++)
  856. \& *in ^= fooctx\->b;
  857. \& return 1;
  858. \& }
  859. \&
  860. \& static int foo_final(void *vfooctx)
  861. \& {
  862. \& struct foo_ctx_st *fooctx = vfooctx;
  863. \&
  864. \& fooctx\->b = 0x66;
  865. \& }
  866. \&
  867. \& static const OSSL_DISPATCH foo_fns[] = {
  868. \& { OSSL_FUNC_BAR_NEWCTX, (void (*)(void))foo_newctx },
  869. \& { OSSL_FUNC_BAR_FREECTX, (void (*)(void))foo_freectx },
  870. \& { OSSL_FUNC_BAR_INIT, (void (*)(void))foo_init },
  871. \& { OSSL_FUNC_BAR_UPDATE, (void (*)(void))foo_update },
  872. \& { OSSL_FUNC_BAR_FINAL, (void (*)(void))foo_final },
  873. \& OSSL_DISPATCH_END
  874. \& };
  875. \&
  876. \& static const OSSL_ALGORITHM bars[] = {
  877. \& { "FOO", "provider=chumbawamba", foo_fns },
  878. \& { NULL, NULL, NULL }
  879. \& };
  880. \&
  881. \& static const OSSL_ALGORITHM *p_query(void *provctx, int operation_id,
  882. \& int *no_store)
  883. \& {
  884. \& switch (operation_id) {
  885. \& case OSSL_OP_BAR:
  886. \& return bars;
  887. \& }
  888. \& return NULL;
  889. \& }
  890. \&
  891. \& static const OSSL_ITEM *p_reasons(void *provctx)
  892. \& {
  893. \& return reasons;
  894. \& }
  895. \&
  896. \& static void p_teardown(void *provctx)
  897. \& {
  898. \& free(provctx);
  899. \& }
  900. \&
  901. \& static const OSSL_DISPATCH prov_fns[] = {
  902. \& { OSSL_FUNC_PROVIDER_TEARDOWN, (void (*)(void))p_teardown },
  903. \& { OSSL_FUNC_PROVIDER_QUERY_OPERATION, (void (*)(void))p_query },
  904. \& { OSSL_FUNC_PROVIDER_GET_REASON_STRINGS, (void (*)(void))p_reasons },
  905. \& OSSL_DISPATCH_END
  906. \& };
  907. \&
  908. \& int OSSL_provider_init(const OSSL_CORE_HANDLE *handle,
  909. \& const OSSL_DISPATCH *in,
  910. \& const OSSL_DISPATCH **out,
  911. \& void **provctx)
  912. \& {
  913. \& struct prov_ctx_st *pctx = NULL;
  914. \&
  915. \& for (; in\->function_id != 0; in++)
  916. \& switch (in\->function_id) {
  917. \& case OSSL_FUNC_CORE_PUT_ERROR:
  918. \& c_put_error = OSSL_FUNC_core_put_error(in);
  919. \& break;
  920. \& }
  921. \&
  922. \& *out = prov_fns;
  923. \&
  924. \& if ((pctx = malloc(sizeof(*pctx))) == NULL) {
  925. \& /*
  926. \& * ALEA IACTA EST, if the core retrieves the reason table
  927. \& * regardless, that string will be displayed, otherwise not.
  928. \& */
  929. \& c_put_error(handle, E_MALLOC, _\|_FILE_\|_, _\|_LINE_\|_);
  930. \& return 0;
  931. \& }
  932. \& pctx\->handle = handle;
  933. \& return 1;
  934. \& }
  935. .Ve
  936. .PP
  937. This relies on a few things existing in \fIopenssl/core_dispatch.h\fR:
  938. .PP
  939. .Vb 1
  940. \& #define OSSL_OP_BAR 4711
  941. \&
  942. \& #define OSSL_FUNC_BAR_NEWCTX 1
  943. \& typedef void *(OSSL_FUNC_bar_newctx_fn)(void *provctx);
  944. \& static ossl_inline OSSL_FUNC_bar_newctx(const OSSL_DISPATCH *opf)
  945. \& { return (OSSL_FUNC_bar_newctx_fn *)opf\->function; }
  946. \&
  947. \& #define OSSL_FUNC_BAR_FREECTX 2
  948. \& typedef void (OSSL_FUNC_bar_freectx_fn)(void *ctx);
  949. \& static ossl_inline OSSL_FUNC_bar_freectx(const OSSL_DISPATCH *opf)
  950. \& { return (OSSL_FUNC_bar_freectx_fn *)opf\->function; }
  951. \&
  952. \& #define OSSL_FUNC_BAR_INIT 3
  953. \& typedef void *(OSSL_FUNC_bar_init_fn)(void *ctx);
  954. \& static ossl_inline OSSL_FUNC_bar_init(const OSSL_DISPATCH *opf)
  955. \& { return (OSSL_FUNC_bar_init_fn *)opf\->function; }
  956. \&
  957. \& #define OSSL_FUNC_BAR_UPDATE 4
  958. \& typedef void *(OSSL_FUNC_bar_update_fn)(void *ctx,
  959. \& unsigned char *in, size_t inl);
  960. \& static ossl_inline OSSL_FUNC_bar_update(const OSSL_DISPATCH *opf)
  961. \& { return (OSSL_FUNC_bar_update_fn *)opf\->function; }
  962. \&
  963. \& #define OSSL_FUNC_BAR_FINAL 5
  964. \& typedef void *(OSSL_FUNC_bar_final_fn)(void *ctx);
  965. \& static ossl_inline OSSL_FUNC_bar_final(const OSSL_DISPATCH *opf)
  966. \& { return (OSSL_FUNC_bar_final_fn *)opf\->function; }
  967. .Ve
  968. .SH "SEE ALSO"
  969. .IX Header "SEE ALSO"
  970. \&\fBprovider\fR\|(7)
  971. .SH HISTORY
  972. .IX Header "HISTORY"
  973. The concept of providers and everything surrounding them was
  974. introduced in OpenSSL 3.0.
  975. .SH COPYRIGHT
  976. .IX Header "COPYRIGHT"
  977. Copyright 2019\-2023 The OpenSSL Project Authors. All Rights Reserved.
  978. .PP
  979. Licensed under the Apache License 2.0 (the "License"). You may not use
  980. this file except in compliance with the License. You can obtain a copy
  981. in the file LICENSE in the source distribution or at
  982. <https://www.openssl.org/source/license.html>.