OSSL_PARAM_int.3ossl 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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 "OSSL_PARAM_INT 3ossl"
  58. .TH OSSL_PARAM_INT 3ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. OSSL_PARAM_double, OSSL_PARAM_int, OSSL_PARAM_int32, OSSL_PARAM_int64,
  65. OSSL_PARAM_long, OSSL_PARAM_size_t, OSSL_PARAM_time_t, OSSL_PARAM_uint,
  66. OSSL_PARAM_uint32, OSSL_PARAM_uint64, OSSL_PARAM_ulong, OSSL_PARAM_BN,
  67. OSSL_PARAM_utf8_string, OSSL_PARAM_octet_string, OSSL_PARAM_utf8_ptr,
  68. OSSL_PARAM_octet_ptr,
  69. OSSL_PARAM_END, OSSL_PARAM_DEFN,
  70. OSSL_PARAM_construct_double, OSSL_PARAM_construct_int,
  71. OSSL_PARAM_construct_int32, OSSL_PARAM_construct_int64,
  72. OSSL_PARAM_construct_long, OSSL_PARAM_construct_size_t,
  73. OSSL_PARAM_construct_time_t, OSSL_PARAM_construct_uint,
  74. OSSL_PARAM_construct_uint32, OSSL_PARAM_construct_uint64,
  75. OSSL_PARAM_construct_ulong, OSSL_PARAM_construct_BN,
  76. OSSL_PARAM_construct_utf8_string, OSSL_PARAM_construct_utf8_ptr,
  77. OSSL_PARAM_construct_octet_string, OSSL_PARAM_construct_octet_ptr,
  78. OSSL_PARAM_construct_end,
  79. OSSL_PARAM_locate, OSSL_PARAM_locate_const,
  80. OSSL_PARAM_get_double, OSSL_PARAM_get_int, OSSL_PARAM_get_int32,
  81. OSSL_PARAM_get_int64, OSSL_PARAM_get_long, OSSL_PARAM_get_size_t,
  82. OSSL_PARAM_get_time_t, OSSL_PARAM_get_uint, OSSL_PARAM_get_uint32,
  83. OSSL_PARAM_get_uint64, OSSL_PARAM_get_ulong, OSSL_PARAM_get_BN,
  84. OSSL_PARAM_get_utf8_string, OSSL_PARAM_get_octet_string,
  85. OSSL_PARAM_get_utf8_ptr, OSSL_PARAM_get_octet_ptr,
  86. OSSL_PARAM_get_utf8_string_ptr, OSSL_PARAM_get_octet_string_ptr,
  87. OSSL_PARAM_set_double, OSSL_PARAM_set_int, OSSL_PARAM_set_int32,
  88. OSSL_PARAM_set_int64, OSSL_PARAM_set_long, OSSL_PARAM_set_size_t,
  89. OSSL_PARAM_set_time_t, OSSL_PARAM_set_uint, OSSL_PARAM_set_uint32,
  90. OSSL_PARAM_set_uint64, OSSL_PARAM_set_ulong, OSSL_PARAM_set_BN,
  91. OSSL_PARAM_set_utf8_string, OSSL_PARAM_set_octet_string,
  92. OSSL_PARAM_set_utf8_ptr, OSSL_PARAM_set_octet_ptr,
  93. OSSL_PARAM_UNMODIFIED, OSSL_PARAM_modified, OSSL_PARAM_set_all_unmodified
  94. \&\- OSSL_PARAM helpers
  95. .SH SYNOPSIS
  96. .IX Header "SYNOPSIS"
  97. .Vb 1
  98. \& #include <openssl/params.h>
  99. \&
  100. \& /*
  101. \& * TYPE in function names is one of:
  102. \& * double, int, int32, int64, long, size_t, time_t, uint, uint32, uint64, ulong
  103. \& * Corresponding TYPE in function arguments is one of:
  104. \& * double, int, int32_t, int64_t, long, size_t, time_t, unsigned int, uint32_t,
  105. \& * uint64_t, unsigned long
  106. \& */
  107. \&
  108. \& #define OSSL_PARAM_TYPE(key, address)
  109. \& #define OSSL_PARAM_BN(key, address, size)
  110. \& #define OSSL_PARAM_utf8_string(key, address, size)
  111. \& #define OSSL_PARAM_octet_string(key, address, size)
  112. \& #define OSSL_PARAM_utf8_ptr(key, address, size)
  113. \& #define OSSL_PARAM_octet_ptr(key, address, size)
  114. \& #define OSSL_PARAM_END
  115. \&
  116. \& #define OSSL_PARAM_UNMODIFIED
  117. \&
  118. \& #define OSSL_PARAM_DEFN(key, type, addr, sz) \e
  119. \& { (key), (type), (addr), (sz), OSSL_PARAM_UNMODIFIED }
  120. \&
  121. \& OSSL_PARAM OSSL_PARAM_construct_TYPE(const char *key, TYPE *buf);
  122. \& OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf,
  123. \& size_t bsize);
  124. \& OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf,
  125. \& size_t bsize);
  126. \& OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf,
  127. \& size_t bsize);
  128. \& OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf,
  129. \& size_t bsize);
  130. \& OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf,
  131. \& size_t bsize);
  132. \& OSSL_PARAM OSSL_PARAM_construct_end(void);
  133. \&
  134. \& OSSL_PARAM *OSSL_PARAM_locate(OSSL_PARAM *array, const char *key);
  135. \& const OSSL_PARAM *OSSL_PARAM_locate_const(const OSSL_PARAM *array,
  136. \& const char *key);
  137. \&
  138. \& int OSSL_PARAM_get_TYPE(const OSSL_PARAM *p, TYPE *val);
  139. \& int OSSL_PARAM_set_TYPE(OSSL_PARAM *p, TYPE val);
  140. \&
  141. \& int OSSL_PARAM_get_BN(const OSSL_PARAM *p, BIGNUM **val);
  142. \& int OSSL_PARAM_set_BN(OSSL_PARAM *p, const BIGNUM *val);
  143. \&
  144. \& int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val,
  145. \& size_t max_len);
  146. \& int OSSL_PARAM_set_utf8_string(OSSL_PARAM *p, const char *val);
  147. \&
  148. \& int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val,
  149. \& size_t max_len, size_t *used_len);
  150. \& int OSSL_PARAM_set_octet_string(OSSL_PARAM *p, const void *val, size_t len);
  151. \&
  152. \& int OSSL_PARAM_get_utf8_ptr(const OSSL_PARAM *p, const char **val);
  153. \& int OSSL_PARAM_set_utf8_ptr(OSSL_PARAM *p, const char *val);
  154. \&
  155. \& int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, const void **val,
  156. \& size_t *used_len);
  157. \& int OSSL_PARAM_set_octet_ptr(OSSL_PARAM *p, const void *val,
  158. \& size_t used_len);
  159. \&
  160. \& int OSSL_PARAM_get_utf8_string_ptr(const OSSL_PARAM *p, const char **val);
  161. \& int OSSL_PARAM_get_octet_string_ptr(const OSSL_PARAM *p, const void **val,
  162. \& size_t *used_len);
  163. \&
  164. \& int OSSL_PARAM_modified(const OSSL_PARAM *param);
  165. \& void OSSL_PARAM_set_all_unmodified(OSSL_PARAM *params);
  166. .Ve
  167. .SH DESCRIPTION
  168. .IX Header "DESCRIPTION"
  169. A collection of utility functions that simplify and add type safety to the
  170. \&\fBOSSL_PARAM\fR\|(3) arrays. The following \fR\f(BITYPE\fR\fB\fR names are supported:
  171. .IP \(bu 2
  172. double
  173. .IP \(bu 2
  174. int
  175. .IP \(bu 2
  176. int32 (int32_t)
  177. .IP \(bu 2
  178. int64 (int64_t)
  179. .IP \(bu 2
  180. long int (long)
  181. .IP \(bu 2
  182. time_t
  183. .IP \(bu 2
  184. size_t
  185. .IP \(bu 2
  186. uint32 (uint32_t)
  187. .IP \(bu 2
  188. uint64 (uint64_t)
  189. .IP \(bu 2
  190. unsigned int (uint)
  191. .IP \(bu 2
  192. unsigned long int (ulong)
  193. .PP
  194. \&\fBOSSL_PARAM_TYPE()\fR are a series of macros designed to assist initialising an
  195. array of \fBOSSL_PARAM\fR\|(3) structures.
  196. Each of these macros defines a parameter of the specified \fR\f(BITYPE\fR\fB\fR with the
  197. provided \fIkey\fR and parameter variable \fIaddress\fR.
  198. .PP
  199. \&\fBOSSL_PARAM_utf8_string()\fR, \fBOSSL_PARAM_octet_string()\fR, \fBOSSL_PARAM_utf8_ptr()\fR,
  200. \&\fBOSSL_PARAM_octet_ptr()\fR, \fBOSSL_PARAM_BN()\fR are macros that provide support
  201. for defining UTF8 strings, OCTET strings and big numbers.
  202. A parameter with name \fIkey\fR is defined.
  203. The storage for this parameter is at \fIaddress\fR and is of \fIsize\fR bytes.
  204. .PP
  205. OSSL_PARAM_END provides an end of parameter list marker.
  206. This should terminate all \fBOSSL_PARAM\fR\|(3) arrays.
  207. .PP
  208. The \fBOSSL_PARAM_DEFN()\fR macro provides the ability to construct a single
  209. \&\fBOSSL_PARAM\fR\|(3) (typically used in the construction of \fBOSSL_PARAM\fR arrays). The
  210. \&\fIkey\fR, \fItype\fR, \fIaddr\fR and \fIsz\fR arguments correspond to the \fIkey\fR,
  211. \&\fIdata_type\fR, \fIdata\fR and \fIdata_size\fR fields of the \fBOSSL_PARAM\fR\|(3) structure as
  212. described on the \fBOSSL_PARAM\fR\|(3) page.
  213. .PP
  214. \&\fBOSSL_PARAM_construct_TYPE()\fR are a series of functions that create \fBOSSL_PARAM\fR\|(3)
  215. records dynamically.
  216. A parameter with name \fIkey\fR is created.
  217. The parameter will use storage pointed to by \fIbuf\fR and return size of \fIret\fR.
  218. .PP
  219. \&\fBOSSL_PARAM_construct_BN()\fR is a function that constructs a large integer
  220. \&\fBOSSL_PARAM\fR\|(3) structure.
  221. A parameter with name \fIkey\fR, storage \fIbuf\fR, size \fIbsize\fR and return
  222. size \fIrsize\fR is created.
  223. .PP
  224. \&\fBOSSL_PARAM_construct_utf8_string()\fR is a function that constructs a UTF8
  225. string \fBOSSL_PARAM\fR\|(3) structure.
  226. A parameter with name \fIkey\fR, storage \fIbuf\fR and size \fIbsize\fR is created.
  227. If \fIbsize\fR is zero, the string length is determined using \fBstrlen\fR\|(3).
  228. Generally pass zero for \fIbsize\fR instead of calling \fBstrlen\fR\|(3) yourself.
  229. .PP
  230. \&\fBOSSL_PARAM_construct_octet_string()\fR is a function that constructs an OCTET
  231. string \fBOSSL_PARAM\fR\|(3) structure.
  232. A parameter with name \fIkey\fR, storage \fIbuf\fR and size \fIbsize\fR is created.
  233. .PP
  234. \&\fBOSSL_PARAM_construct_utf8_ptr()\fR is a function that constructs a UTF8 string
  235. pointer \fBOSSL_PARAM\fR\|(3) structure.
  236. A parameter with name \fIkey\fR, storage pointer \fI*buf\fR and size \fIbsize\fR
  237. is created.
  238. .PP
  239. \&\fBOSSL_PARAM_construct_octet_ptr()\fR is a function that constructs an OCTET string
  240. pointer \fBOSSL_PARAM\fR\|(3) structure.
  241. A parameter with name \fIkey\fR, storage pointer \fI*buf\fR and size \fIbsize\fR
  242. is created.
  243. .PP
  244. \&\fBOSSL_PARAM_construct_end()\fR is a function that constructs the terminating
  245. \&\fBOSSL_PARAM\fR\|(3) structure.
  246. .PP
  247. \&\fBOSSL_PARAM_locate()\fR is a function that searches an \fIarray\fR of parameters for
  248. the one matching the \fIkey\fR name.
  249. .PP
  250. \&\fBOSSL_PARAM_locate_const()\fR behaves exactly like \fBOSSL_PARAM_locate()\fR except for
  251. the presence of \fIconst\fR for the \fIarray\fR argument and its return value.
  252. .PP
  253. \&\fBOSSL_PARAM_get_TYPE()\fR retrieves a value of type \fR\f(BITYPE\fR\fB\fR from the parameter
  254. \&\fIp\fR.
  255. The value is copied to the address \fIval\fR.
  256. Type coercion takes place as discussed in the NOTES section.
  257. .PP
  258. \&\fBOSSL_PARAM_set_TYPE()\fR stores a value \fIval\fR of type \fR\f(BITYPE\fR\fB\fR into the
  259. parameter \fIp\fR.
  260. If the parameter's \fIdata\fR field is NULL, then only its \fIreturn_size\fR field
  261. will be assigned the size the parameter's \fIdata\fR buffer should have.
  262. Type coercion takes place as discussed in the NOTES section.
  263. .PP
  264. \&\fBOSSL_PARAM_get_BN()\fR retrieves a BIGNUM from the parameter pointed to by \fIp\fR.
  265. The BIGNUM referenced by \fIval\fR is updated and is allocated if \fI*val\fR is
  266. NULL.
  267. .PP
  268. \&\fBOSSL_PARAM_set_BN()\fR stores the BIGNUM \fIval\fR into the parameter \fIp\fR.
  269. If the parameter's \fIdata\fR field is NULL, then only its \fIreturn_size\fR field
  270. will be assigned the size the parameter's \fIdata\fR buffer should have.
  271. .PP
  272. \&\fBOSSL_PARAM_get_utf8_string()\fR retrieves a UTF8 string from the parameter
  273. pointed to by \fIp\fR.
  274. The string is stored into \fI*val\fR with a size limit of \fImax_len\fR,
  275. which must be large enough to accommodate a terminating NUL byte,
  276. otherwise this function will fail.
  277. If \fI*val\fR is NULL, memory is allocated for the string (including the
  278. terminating NUL byte) and \fImax_len\fR is ignored.
  279. If memory is allocated by this function, it must be freed by the caller.
  280. .PP
  281. \&\fBOSSL_PARAM_set_utf8_string()\fR sets a UTF8 string from the parameter pointed to
  282. by \fIp\fR to the value referenced by \fIval\fR.
  283. If the parameter's \fIdata\fR field isn't NULL, its \fIdata_size\fR must indicate
  284. that the buffer is large enough to accommodate the string that \fIval\fR points at,
  285. not including the terminating NUL byte, or this function will fail.
  286. A terminating NUL byte is added only if the parameter's \fIdata_size\fR indicates
  287. the buffer is longer than the string length, otherwise the string will not be
  288. NUL terminated.
  289. If the parameter's \fIdata\fR field is NULL, then only its \fIreturn_size\fR field
  290. will be assigned the minimum size the parameter's \fIdata\fR buffer should have
  291. to accommodate the string, not including a terminating NUL byte.
  292. .PP
  293. \&\fBOSSL_PARAM_get_octet_string()\fR retrieves an OCTET string from the parameter
  294. pointed to by \fIp\fR.
  295. The OCTETs are either stored into \fI*val\fR with a length limit of \fImax_len\fR or,
  296. in the case when \fI*val\fR is NULL, memory is allocated and
  297. \&\fImax_len\fR is ignored. \fI*used_len\fR is populated with the number of OCTETs
  298. stored. If \fIval\fR is NULL then the OCTETS are not stored, but \fI*used_len\fR is
  299. still populated.
  300. If memory is allocated by this function, it must be freed by the caller.
  301. .PP
  302. \&\fBOSSL_PARAM_set_octet_string()\fR sets an OCTET string from the parameter
  303. pointed to by \fIp\fR to the value referenced by \fIval\fR.
  304. If the parameter's \fIdata\fR field is NULL, then only its \fIreturn_size\fR field
  305. will be assigned the size the parameter's \fIdata\fR buffer should have.
  306. .PP
  307. \&\fBOSSL_PARAM_get_utf8_ptr()\fR retrieves the UTF8 string pointer from the parameter
  308. referenced by \fIp\fR and stores it in \fI*val\fR.
  309. .PP
  310. \&\fBOSSL_PARAM_set_utf8_ptr()\fR sets the UTF8 string pointer in the parameter
  311. referenced by \fIp\fR to the values \fIval\fR.
  312. .PP
  313. \&\fBOSSL_PARAM_get_octet_ptr()\fR retrieves the OCTET string pointer from the parameter
  314. referenced by \fIp\fR and stores it in \fI*val\fR.
  315. The length of the OCTET string is stored in \fI*used_len\fR.
  316. .PP
  317. \&\fBOSSL_PARAM_set_octet_ptr()\fR sets the OCTET string pointer in the parameter
  318. referenced by \fIp\fR to the values \fIval\fR.
  319. The length of the OCTET string is provided by \fIused_len\fR.
  320. .PP
  321. \&\fBOSSL_PARAM_get_utf8_string_ptr()\fR retrieves the pointer to a UTF8 string from
  322. the parameter pointed to by \fIp\fR, and stores that pointer in \fI*val\fR.
  323. This is different from \fBOSSL_PARAM_get_utf8_string()\fR, which copies the
  324. string.
  325. .PP
  326. \&\fBOSSL_PARAM_get_octet_string_ptr()\fR retrieves the pointer to a octet string
  327. from the parameter pointed to by \fIp\fR, and stores that pointer in \fI*val\fR,
  328. along with the string's length in \fI*used_len\fR.
  329. This is different from \fBOSSL_PARAM_get_octet_string()\fR, which copies the
  330. string.
  331. .PP
  332. The OSSL_PARAM_UNMODIFIED macro is used to detect if a parameter was set. On
  333. creation, via either the macros or construct calls, the \fIreturn_size\fR field
  334. is set to this. If the parameter is set using the calls defined herein, the
  335. \&\fIreturn_size\fR field is changed.
  336. .PP
  337. \&\fBOSSL_PARAM_modified()\fR queries if the parameter \fIparam\fR has been set or not
  338. using the calls defined herein.
  339. .PP
  340. \&\fBOSSL_PARAM_set_all_unmodified()\fR resets the unused indicator for all parameters
  341. in the array \fIparams\fR.
  342. .SH "RETURN VALUES"
  343. .IX Header "RETURN VALUES"
  344. \&\fBOSSL_PARAM_construct_TYPE()\fR, \fBOSSL_PARAM_construct_BN()\fR,
  345. \&\fBOSSL_PARAM_construct_utf8_string()\fR, \fBOSSL_PARAM_construct_octet_string()\fR,
  346. \&\fBOSSL_PARAM_construct_utf8_ptr()\fR and \fBOSSL_PARAM_construct_octet_ptr()\fR
  347. return a populated \fBOSSL_PARAM\fR\|(3) structure.
  348. .PP
  349. \&\fBOSSL_PARAM_locate()\fR and \fBOSSL_PARAM_locate_const()\fR return a pointer to
  350. the matching \fBOSSL_PARAM\fR\|(3) object. They return NULL on error or when
  351. no object matching \fIkey\fR exists in the \fIarray\fR.
  352. .PP
  353. \&\fBOSSL_PARAM_modified()\fR returns 1 if the parameter was set and 0 otherwise.
  354. .PP
  355. All other functions return 1 on success and 0 on failure.
  356. .SH NOTES
  357. .IX Header "NOTES"
  358. Native types will be converted as required only if the value is exactly
  359. representable by the target type or parameter.
  360. Apart from that, the functions must be used appropriately for the
  361. expected type of the parameter.
  362. .PP
  363. \&\fBOSSL_PARAM_get_BN()\fR and \fBOSSL_PARAM_set_BN()\fR only support nonnegative
  364. \&\fBBIGNUM\fRs when the desired data type is \fBOSSL_PARAM_UNSIGNED_INTEGER\fR.
  365. \&\fBOSSL_PARAM_construct_BN()\fR currently constructs an \fBOSSL_PARAM\fR\|(3) structure
  366. with the data type \fBOSSL_PARAM_UNSIGNED_INTEGER\fR.
  367. .PP
  368. For \fBOSSL_PARAM_construct_utf8_ptr()\fR and \fBOSSL_PARAM_consstruct_octet_ptr()\fR,
  369. \&\fIbsize\fR is not relevant if the purpose is to send the \fBOSSL_PARAM\fR\|(3) array
  370. to a \fIresponder\fR, i.e. to get parameter data back.
  371. In that case, \fIbsize\fR can safely be given zero.
  372. See "DESCRIPTION" in \fBOSSL_PARAM\fR\|(3) for further information on the
  373. possible purposes.
  374. .SH EXAMPLES
  375. .IX Header "EXAMPLES"
  376. Reusing the examples from \fBOSSL_PARAM\fR\|(3) to just show how
  377. \&\fBOSSL_PARAM\fR\|(3) arrays can be handled using the macros and functions
  378. defined herein.
  379. .SS "Example 1"
  380. .IX Subsection "Example 1"
  381. This example is for setting parameters on some object:
  382. .PP
  383. .Vb 1
  384. \& #include <openssl/core.h>
  385. \&
  386. \& const char *foo = "some string";
  387. \& size_t foo_l = strlen(foo);
  388. \& const char bar[] = "some other string";
  389. \& const OSSL_PARAM set[] = {
  390. \& OSSL_PARAM_utf8_ptr("foo", &foo, foo_l),
  391. \& OSSL_PARAM_utf8_string("bar", bar, sizeof(bar) \- 1),
  392. \& OSSL_PARAM_END
  393. \& };
  394. .Ve
  395. .SS "Example 2"
  396. .IX Subsection "Example 2"
  397. This example is for requesting parameters on some object, and also
  398. demonstrates that the requester isn't obligated to request all
  399. available parameters:
  400. .PP
  401. .Vb 7
  402. \& const char *foo = NULL;
  403. \& char bar[1024];
  404. \& OSSL_PARAM request[] = {
  405. \& OSSL_PARAM_utf8_ptr("foo", &foo, 0),
  406. \& OSSL_PARAM_utf8_string("bar", bar, sizeof(bar)),
  407. \& OSSL_PARAM_END
  408. \& };
  409. .Ve
  410. .PP
  411. A \fIresponder\fR that receives this array (as \f(CW\*(C`params\*(C'\fR in this example)
  412. could fill in the parameters like this:
  413. .PP
  414. .Vb 1
  415. \& /* OSSL_PARAM *params */
  416. \&
  417. \& OSSL_PARAM *p;
  418. \&
  419. \& if ((p = OSSL_PARAM_locate(params, "foo")) != NULL)
  420. \& OSSL_PARAM_set_utf8_ptr(p, "foo value");
  421. \& if ((p = OSSL_PARAM_locate(params, "bar")) != NULL)
  422. \& OSSL_PARAM_set_utf8_string(p, "bar value");
  423. \& if ((p = OSSL_PARAM_locate(params, "cookie")) != NULL)
  424. \& OSSL_PARAM_set_utf8_ptr(p, "cookie value");
  425. .Ve
  426. .SH "SEE ALSO"
  427. .IX Header "SEE ALSO"
  428. \&\fBopenssl\-core.h\fR\|(7), \fBOSSL_PARAM\fR\|(3)
  429. .SH HISTORY
  430. .IX Header "HISTORY"
  431. These APIs were introduced in OpenSSL 3.0.
  432. .SH COPYRIGHT
  433. .IX Header "COPYRIGHT"
  434. Copyright 2019\-2023 The OpenSSL Project Authors. All Rights Reserved.
  435. .PP
  436. Licensed under the Apache License 2.0 (the "License"). You may not use
  437. this file except in compliance with the License. You can obtain a copy
  438. in the file LICENSE in the source distribution or at
  439. <https://www.openssl.org/source/license.html>.