provider-base.7ossl 53 KB

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