OSSL_PARAM_int.3ossl 21 KB

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