diff options
author | schwarze <> | 2020-06-15 14:13:14 +0000 |
---|---|---|
committer | schwarze <> | 2020-06-15 14:13:14 +0000 |
commit | be1a496d70a47f3c5c3dda88e02d5297c3913e2a (patch) | |
tree | bc161df063488045bbf6766c8a9387db141fb561 /src | |
parent | bb665705811d77d0aff1a5399bc12e8d86ae09e4 (diff) | |
download | openbsd-be1a496d70a47f3c5c3dda88e02d5297c3913e2a.tar.gz openbsd-be1a496d70a47f3c5c3dda88e02d5297c3913e2a.tar.bz2 openbsd-be1a496d70a47f3c5c3dda88e02d5297c3913e2a.zip |
Document PEM_def_callback(3).
Move pem_password_cb(3) to the file PEM_read(3) and rewrite
its description from scratch for precision and conciseness.
Plus some minor improvements in the vicinity.
Tweaks and OK tb@.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/man/PEM_bytes_read_bio.3 | 36 | ||||
-rw-r--r-- | src/lib/libcrypto/man/PEM_read.3 | 146 | ||||
-rw-r--r-- | src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3 | 82 |
3 files changed, 158 insertions, 106 deletions
diff --git a/src/lib/libcrypto/man/PEM_bytes_read_bio.3 b/src/lib/libcrypto/man/PEM_bytes_read_bio.3 index d3a664ba74..d1148edfe0 100644 --- a/src/lib/libcrypto/man/PEM_bytes_read_bio.3 +++ b/src/lib/libcrypto/man/PEM_bytes_read_bio.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: PEM_bytes_read_bio.3,v 1.4 2020/06/12 18:16:13 schwarze Exp $ | 1 | .\" $OpenBSD: PEM_bytes_read_bio.3,v 1.5 2020/06/15 14:13:14 schwarze Exp $ |
2 | .\" selective merge up to: | 2 | .\" selective merge up to: |
3 | .\" OpenSSL PEM_bytes_read_bio.pod 7671342e Feb 29 15:47:12 2016 -0600 | 3 | .\" OpenSSL PEM_bytes_read_bio.pod 7671342e Feb 29 15:47:12 2016 -0600 |
4 | .\" | 4 | .\" |
@@ -65,7 +65,7 @@ | |||
65 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 65 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
66 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | 66 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. |
67 | .\" | 67 | .\" |
68 | .Dd $Mdocdate: June 12 2020 $ | 68 | .Dd $Mdocdate: June 15 2020 $ |
69 | .Dt PEM_BYTES_READ_BIO 3 | 69 | .Dt PEM_BYTES_READ_BIO 3 |
70 | .Os | 70 | .Os |
71 | .Sh NAME | 71 | .Sh NAME |
@@ -79,31 +79,31 @@ | |||
79 | .Fa "long *plen" | 79 | .Fa "long *plen" |
80 | .Fa "char **pnm" | 80 | .Fa "char **pnm" |
81 | .Fa "const char *name" | 81 | .Fa "const char *name" |
82 | .Fa "BIO *bp" | 82 | .Fa "BIO *in_bp" |
83 | .Fa "pem_password_cb *cb" | 83 | .Fa "pem_password_cb *cb" |
84 | .Fa "void *u" | 84 | .Fa "void *u" |
85 | .Fc | 85 | .Fc |
86 | .Sh DESCRIPTION | 86 | .Sh DESCRIPTION |
87 | .Fn PEM_bytes_read_bio | 87 | .Fn PEM_bytes_read_bio |
88 | reads PEM-formatted (RFC 1421) data from the BIO | 88 | reads and PEM decodes the first object of type |
89 | .Fa bp | ||
90 | for the data type given in | ||
91 | .Fa name | 89 | .Fa name |
92 | (RSA PRIVATE KEY, CERTIFICATE, etc.). | 90 | .Pq e.g. RSA PRIVATE KEY, CERTIFICATE, etc.\& |
91 | from | ||
92 | .Fa in_bp . | ||
93 | If multiple PEM-encoded data structures are present in the same stream, | 93 | If multiple PEM-encoded data structures are present in the same stream, |
94 | .Fn PEM_bytes_read_bio | 94 | it skips non-matching data types and continues reading. |
95 | will skip non-matching data types and continue reading. | 95 | Before reading each PEM object, lines not starting with |
96 | Non-PEM data present in the stream may cause an error. | 96 | .Qq "-----BEGIN " |
97 | are also skipped; see | ||
98 | .Xr PEM_read_bio 3 | ||
99 | for details of PEM parsing. | ||
97 | .Pp | 100 | .Pp |
98 | The PEM header may indicate that the following data is encrypted; if so, | 101 | The PEM header may indicate that the following data is encrypted; if so, |
99 | the data will be decrypted, waiting on user input to supply a passphrase | 102 | the data is decrypted, optionally using |
100 | if needed. | ||
101 | The password callback | ||
102 | .Fa cb | 103 | .Fa cb |
103 | and rock | 104 | and |
104 | .Fa u | 105 | .Fa u , |
105 | are used to obtain the decryption passphrase, if applicable. | 106 | as described in |
106 | For more details, see | ||
107 | .Xr pem_password_cb 3 . | 107 | .Xr pem_password_cb 3 . |
108 | .Pp | 108 | .Pp |
109 | Some data types have compatibility aliases, such as a file containing | 109 | Some data types have compatibility aliases, such as a file containing |
@@ -175,6 +175,8 @@ Additional types of errors can result from | |||
175 | .Xr PEM_ASN1_read 3 , | 175 | .Xr PEM_ASN1_read 3 , |
176 | .Xr PEM_read 3 , | 176 | .Xr PEM_read 3 , |
177 | .Xr PEM_read_bio_PrivateKey 3 | 177 | .Xr PEM_read_bio_PrivateKey 3 |
178 | .Sh STANDARDS | ||
179 | RFC 1421: Privacy Enhancement for Internet Electronic Mail (PEM), Part I | ||
178 | .Sh HISTORY | 180 | .Sh HISTORY |
179 | .Fn PEM_bytes_read_bio | 181 | .Fn PEM_bytes_read_bio |
180 | first appeared in OpenSSL 0.9.7 and has been available since | 182 | first appeared in OpenSSL 0.9.7 and has been available since |
diff --git a/src/lib/libcrypto/man/PEM_read.3 b/src/lib/libcrypto/man/PEM_read.3 index 1469ccd558..49cdd0f3c5 100644 --- a/src/lib/libcrypto/man/PEM_read.3 +++ b/src/lib/libcrypto/man/PEM_read.3 | |||
@@ -1,7 +1,24 @@ | |||
1 | .\" $OpenBSD: PEM_read.3,v 1.10 2020/06/12 11:37:42 schwarze Exp $ | 1 | .\" $OpenBSD: PEM_read.3,v 1.11 2020/06/15 14:13:14 schwarze Exp $ |
2 | .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 | 2 | .\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100 |
3 | .\" | 3 | .\" |
4 | .\" This file was written by Viktor Dukhovni | 4 | .\" This file is a derived work. |
5 | .\" The changes are covered by the following Copyright and license: | ||
6 | .\" | ||
7 | .\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> | ||
8 | .\" | ||
9 | .\" Permission to use, copy, modify, and distribute this software for any | ||
10 | .\" purpose with or without fee is hereby granted, provided that the above | ||
11 | .\" copyright notice and this permission notice appear in all copies. | ||
12 | .\" | ||
13 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
14 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
15 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
16 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
17 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
18 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
19 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
20 | .\" | ||
21 | .\" The original file was written by Viktor Dukhovni | ||
5 | .\" and by Rich Salz <rsalz@openssl.org>. | 22 | .\" and by Rich Salz <rsalz@openssl.org>. |
6 | .\" Copyright (c) 2016 The OpenSSL Project. All rights reserved. | 23 | .\" Copyright (c) 2016 The OpenSSL Project. All rights reserved. |
7 | .\" | 24 | .\" |
@@ -49,7 +66,7 @@ | |||
49 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 66 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
50 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | 67 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. |
51 | .\" | 68 | .\" |
52 | .Dd $Mdocdate: June 12 2020 $ | 69 | .Dd $Mdocdate: June 15 2020 $ |
53 | .Dt PEM_READ 3 | 70 | .Dt PEM_READ 3 |
54 | .Os | 71 | .Os |
55 | .Sh NAME | 72 | .Sh NAME |
@@ -57,8 +74,10 @@ | |||
57 | .Nm PEM_write_bio , | 74 | .Nm PEM_write_bio , |
58 | .Nm PEM_read , | 75 | .Nm PEM_read , |
59 | .Nm PEM_read_bio , | 76 | .Nm PEM_read_bio , |
77 | .Nm PEM_get_EVP_CIPHER_INFO , | ||
60 | .Nm PEM_do_header , | 78 | .Nm PEM_do_header , |
61 | .Nm PEM_get_EVP_CIPHER_INFO | 79 | .Nm PEM_def_callback , |
80 | .Nm pem_password_cb | ||
62 | .Nd PEM encoding routines | 81 | .Nd PEM encoding routines |
63 | .Sh SYNOPSIS | 82 | .Sh SYNOPSIS |
64 | .In openssl/pem.h | 83 | .In openssl/pem.h |
@@ -107,6 +126,20 @@ | |||
107 | .Fa "pem_password_cb *cb" | 126 | .Fa "pem_password_cb *cb" |
108 | .Fa "void *u" | 127 | .Fa "void *u" |
109 | .Fc | 128 | .Fc |
129 | .Ft int | ||
130 | .Fo PEM_def_callback | ||
131 | .Fa "char *password" | ||
132 | .Fa "int size" | ||
133 | .Fa "int verify" | ||
134 | .Fa "void *u" | ||
135 | .Fc | ||
136 | .Ft typedef int | ||
137 | .Fo pem_password_cb | ||
138 | .Fa "char *password" | ||
139 | .Fa "int size" | ||
140 | .Fa "int verify" | ||
141 | .Fa "void *u" | ||
142 | .Fc | ||
110 | .Sh DESCRIPTION | 143 | .Sh DESCRIPTION |
111 | These functions read and write PEM-encoded objects, using the PEM type | 144 | These functions read and write PEM-encoded objects, using the PEM type |
112 | .Fa name , | 145 | .Fa name , |
@@ -224,34 +257,83 @@ unknown or some internal error happens, 0 is returned. | |||
224 | can then be used to decrypt the data if the header indicates encryption. | 257 | can then be used to decrypt the data if the header indicates encryption. |
225 | The | 258 | The |
226 | .Fa cinfo | 259 | .Fa cinfo |
227 | argument is a pointer to the structure initialized by the previous call | 260 | argument is a pointer to the structure initialized by a preceding call |
228 | to | 261 | to |
229 | .Fn PEM_get_EVP_CIPHER_INFO . | 262 | .Fn PEM_get_EVP_CIPHER_INFO . |
263 | If that structure indicates the absence of encryption, | ||
264 | .Fn PEM_do_header | ||
265 | returns sucessfully without taking any action. | ||
230 | The | 266 | The |
231 | .Fa data | 267 | .Fa data |
232 | and | 268 | and |
233 | .Fa len | 269 | .Fa len |
234 | arguments are those returned by the previous call to | 270 | arguments are used both to pass in the encrypted data that was |
271 | returned in the same arguments from the preceding call to | ||
235 | .Fn PEM_read | 272 | .Fn PEM_read |
236 | or | 273 | or |
237 | .Fn PEM_read_bio . | 274 | .Fn PEM_read_bio |
275 | and to pass out the decrypted data. | ||
276 | .Pp | ||
277 | The callback function | ||
278 | .Fa cb | ||
279 | is used to obtain the encryption | ||
280 | .Fa password ; | ||
281 | if | ||
282 | .Fa cb | ||
283 | is | ||
284 | .Dv NULL , | ||
285 | .Fn PEM_def_callback | ||
286 | is used instead. | ||
238 | The | 287 | The |
288 | .Fa password | ||
289 | buffer needs to be at least | ||
290 | .Fa size | ||
291 | bytes long. | ||
292 | .Fn PEM_def_callback | ||
293 | silently truncates the NUL-terminated byte string | ||
294 | .Fa u | ||
295 | to at most | ||
296 | .Fa num | ||
297 | bytes and copies it into | ||
298 | .Fa password | ||
299 | without a terminating NUL byte. | ||
300 | If | ||
301 | .Fa u | ||
302 | is | ||
303 | .Dv NULL , | ||
304 | .Fn PEM_def_callback | ||
305 | instead prompts the user for the password with echoing turned off | ||
306 | by calling | ||
307 | .Xr EVP_read_pw_string_min 3 | ||
308 | internally. | ||
309 | In this case, the | ||
310 | .Fa size | ||
311 | is silently reduced to at most | ||
312 | .Dv BUFSIZ | ||
313 | and at most | ||
314 | .Fa size No \- 1 | ||
315 | bytes are accepted from the user and copied into the byte string buffer | ||
316 | .Fa password . | ||
317 | A callback function | ||
239 | .Fa cb | 318 | .Fa cb |
240 | and | 319 | supplied by the application may use |
241 | .Fa u | 320 | .Fa u |
242 | arguments make it possible to override the default password prompt | 321 | for a different purpose than |
243 | function as described in | 322 | .Fn PEM_def_callback |
244 | .Xr PEM_read_PrivateKey 3 . | 323 | does, e.g., as auxiliary data to use while acquiring the password. |
245 | On successful completion, the | 324 | For example, a GUI application might pass a window handle. |
246 | .Fa data | 325 | If the |
247 | is decrypted in place, and | 326 | .Fa verify |
248 | .Fa len | 327 | flag is non-zero, the user is prompted twice for the password to |
249 | is updated to indicate the plaintext length. | 328 | make typos less likely and it is checked that both inputs agree. |
329 | This flag is not set by | ||
330 | .Fn PEM_do_header | ||
331 | nor by other read functions. | ||
250 | .Pp | 332 | .Pp |
251 | If the data is a priori known to not be encrypted, then neither | 333 | If the data is a priori known to not be encrypted, then neither |
252 | .Fn PEM_do_header | ||
253 | nor | ||
254 | .Fn PEM_get_EVP_CIPHER_INFO | 334 | .Fn PEM_get_EVP_CIPHER_INFO |
335 | nor | ||
336 | .Fn PEM_do_header | ||
255 | need to be called. | 337 | need to be called. |
256 | .Sh RETURN VALUES | 338 | .Sh RETURN VALUES |
257 | .Fn PEM_read | 339 | .Fn PEM_read |
@@ -276,6 +358,28 @@ return 1 on success or 0 on failure. | |||
276 | The | 358 | The |
277 | .Fa data | 359 | .Fa data |
278 | is likely meaningless if these functions fail. | 360 | is likely meaningless if these functions fail. |
361 | .Pp | ||
362 | .Fn PEM_def_callback | ||
363 | returns the number of bytes stored into | ||
364 | .Fa buf | ||
365 | or a negative value on failure, and | ||
366 | .Fa cb | ||
367 | is expected to behave in the same way. | ||
368 | If | ||
369 | .Fa u | ||
370 | is | ||
371 | .Dv NULL , | ||
372 | .Fn PEM_def_callback | ||
373 | fails if | ||
374 | .Fa num | ||
375 | is less than 5 | ||
376 | or if an error occurs trying to prompt the user for the password. | ||
377 | Otherwise, it fails when | ||
378 | .Fa num | ||
379 | is negative. | ||
380 | The details of the circumstances that cause | ||
381 | .Fa cb | ||
382 | to fail may differ. | ||
279 | .Sh SEE ALSO | 383 | .Sh SEE ALSO |
280 | .Xr crypto 3 , | 384 | .Xr crypto 3 , |
281 | .Xr d2i_PKCS8PrivateKey_bio 3 , | 385 | .Xr d2i_PKCS8PrivateKey_bio 3 , |
@@ -299,3 +403,7 @@ and | |||
299 | first appeared in SSLeay 0.6.0. | 403 | first appeared in SSLeay 0.6.0. |
300 | These functions have been available since | 404 | These functions have been available since |
301 | .Ox 2.4 . | 405 | .Ox 2.4 . |
406 | .Pp | ||
407 | .Fn PEM_def_callback | ||
408 | first appeared in OpenSSL 0.9.7 and has been available since | ||
409 | .Ox 3.2 . | ||
diff --git a/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3 b/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3 index 3799baa040..cc58640b1c 100644 --- a/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3 +++ b/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: PEM_read_bio_PrivateKey.3,v 1.17 2020/06/12 11:37:42 schwarze Exp $ | 1 | .\" $OpenBSD: PEM_read_bio_PrivateKey.3,v 1.18 2020/06/15 14:13:14 schwarze Exp $ |
2 | .\" full merge up to: | 2 | .\" full merge up to: |
3 | .\" OpenSSL man3/PEM_read_bio_PrivateKey.pod 18bad535 Apr 9 15:13:55 2019 +0100 | 3 | .\" OpenSSL man3/PEM_read_bio_PrivateKey.pod 18bad535 Apr 9 15:13:55 2019 +0100 |
4 | .\" OpenSSL man3/PEM_read_CMS.pod 83cf7abf May 29 13:07:08 2018 +0100 | 4 | .\" OpenSSL man3/PEM_read_CMS.pod 83cf7abf May 29 13:07:08 2018 +0100 |
@@ -51,11 +51,10 @@ | |||
51 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 51 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
52 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | 52 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. |
53 | .\" | 53 | .\" |
54 | .Dd $Mdocdate: June 12 2020 $ | 54 | .Dd $Mdocdate: June 15 2020 $ |
55 | .Dt PEM_READ_BIO_PRIVATEKEY 3 | 55 | .Dt PEM_READ_BIO_PRIVATEKEY 3 |
56 | .Os | 56 | .Os |
57 | .Sh NAME | 57 | .Sh NAME |
58 | .Nm pem_password_cb , | ||
59 | .Nm PEM_read_bio_PrivateKey , | 58 | .Nm PEM_read_bio_PrivateKey , |
60 | .Nm PEM_read_PrivateKey , | 59 | .Nm PEM_read_PrivateKey , |
61 | .Nm PEM_write_bio_PrivateKey , | 60 | .Nm PEM_write_bio_PrivateKey , |
@@ -149,13 +148,6 @@ | |||
149 | .Nd PEM routines | 148 | .Nd PEM routines |
150 | .Sh SYNOPSIS | 149 | .Sh SYNOPSIS |
151 | .In openssl/pem.h | 150 | .In openssl/pem.h |
152 | .Ft typedef int | ||
153 | .Fo pem_password_cb | ||
154 | .Fa "char *buf" | ||
155 | .Fa "int size" | ||
156 | .Fa "int rwflag" | ||
157 | .Fa "void *u" | ||
158 | .Fc | ||
159 | .Ft EVP_PKEY * | 151 | .Ft EVP_PKEY * |
160 | .Fo PEM_read_bio_PrivateKey | 152 | .Fo PEM_read_bio_PrivateKey |
161 | .Fa "BIO *bp" | 153 | .Fa "BIO *bp" |
@@ -754,7 +746,9 @@ | |||
754 | .Sh DESCRIPTION | 746 | .Sh DESCRIPTION |
755 | The PEM functions read or write structures in PEM format. | 747 | The PEM functions read or write structures in PEM format. |
756 | In this sense PEM format is simply base64-encoded data surrounded by | 748 | In this sense PEM format is simply base64-encoded data surrounded by |
757 | header lines. | 749 | header lines; see |
750 | .Xr PEM_read 3 | ||
751 | for more details. | ||
758 | .Pp | 752 | .Pp |
759 | For more details about the meaning of arguments see the | 753 | For more details about the meaning of arguments see the |
760 | .Sx PEM function arguments | 754 | .Sx PEM function arguments |
@@ -1050,10 +1044,14 @@ If this parameter is set to | |||
1050 | .Dv NULL , | 1044 | .Dv NULL , |
1051 | then the private key is written in unencrypted form. | 1045 | then the private key is written in unencrypted form. |
1052 | .Pp | 1046 | .Pp |
1053 | The | 1047 | The optional arguments |
1048 | .Fa u | ||
1049 | and | ||
1054 | .Fa cb | 1050 | .Fa cb |
1055 | argument is the callback to use when querying for the passphrase used | 1051 | are a passphrase used for encrypting a PEM structure |
1056 | for encrypted PEM structures (normally only private keys). | 1052 | or a callback to obtain the passphrase; see |
1053 | .Xr pem_password_cb 3 | ||
1054 | for details. | ||
1057 | .Pp | 1055 | .Pp |
1058 | For the PEM write routines, if the | 1056 | For the PEM write routines, if the |
1059 | .Fa kstr | 1057 | .Fa kstr |
@@ -1066,62 +1064,6 @@ bytes at | |||
1066 | are used as the passphrase and | 1064 | are used as the passphrase and |
1067 | .Fa cb | 1065 | .Fa cb |
1068 | is ignored. | 1066 | is ignored. |
1069 | .Pp | ||
1070 | If the | ||
1071 | .Fa cb | ||
1072 | parameter is set to | ||
1073 | .Dv NULL | ||
1074 | and the | ||
1075 | .Fa u | ||
1076 | parameter is not | ||
1077 | .Dv NULL , | ||
1078 | then the | ||
1079 | .Fa u | ||
1080 | parameter is interpreted as a null terminated string to use as the | ||
1081 | passphrase. | ||
1082 | If both | ||
1083 | .Fa cb | ||
1084 | and | ||
1085 | .Fa u | ||
1086 | are | ||
1087 | .Dv NULL , | ||
1088 | then the default callback routine is used, which will typically | ||
1089 | prompt for the passphrase on the current terminal with echoing | ||
1090 | turned off. | ||
1091 | .Pp | ||
1092 | The default passphrase callback is sometimes inappropriate (for example | ||
1093 | in a GUI application) so an alternative can be supplied. | ||
1094 | The callback routine has the following form: | ||
1095 | .Bd -filled -offset inset | ||
1096 | .Ft int | ||
1097 | .Fo cb | ||
1098 | .Fa "char *buf" | ||
1099 | .Fa "int size" | ||
1100 | .Fa "int rwflag" | ||
1101 | .Fa "void *u" | ||
1102 | .Fc | ||
1103 | .Ed | ||
1104 | .Pp | ||
1105 | .Fa buf | ||
1106 | is the buffer to write the passphrase to. | ||
1107 | .Fa size | ||
1108 | is the maximum length of the passphrase, i.e. the size of | ||
1109 | .Fa buf . | ||
1110 | .Fa rwflag | ||
1111 | is a flag which is set to 0 when reading and 1 when writing. | ||
1112 | A typical routine will ask the user to verify the passphrase (for | ||
1113 | example by prompting for it twice) if | ||
1114 | .Fa rwflag | ||
1115 | is 1. | ||
1116 | The | ||
1117 | .Fa u | ||
1118 | parameter has the same value as the | ||
1119 | .Fa u | ||
1120 | parameter passed to the PEM routine. | ||
1121 | It allows arbitrary data to be passed to the callback by the application | ||
1122 | (for example a window handle in a GUI application). | ||
1123 | The callback must return the number of characters in the passphrase | ||
1124 | or -1 if an error occurred. | ||
1125 | .Ss PEM encryption format | 1067 | .Ss PEM encryption format |
1126 | This old | 1068 | This old |
1127 | .Sy PrivateKey | 1069 | .Sy PrivateKey |