diff options
author | schwarze <> | 2023-09-19 08:18:13 +0000 |
---|---|---|
committer | schwarze <> | 2023-09-19 08:18:13 +0000 |
commit | e24c846ad62a356d547c1bc5ace0f676d3124bb6 (patch) | |
tree | 9ee21210978d09da9dc30b382fa34ff965c2766d /src/lib | |
parent | 6b95b6b6902a1621638a431b4e1944a9b154e3de (diff) | |
download | openbsd-e24c846ad62a356d547c1bc5ace0f676d3124bb6.tar.gz openbsd-e24c846ad62a356d547c1bc5ace0f676d3124bb6.tar.bz2 openbsd-e24c846ad62a356d547c1bc5ace0f676d3124bb6.zip |
Remove the duplicate documentation of pem_password_cb(3).
While here, also:
* Avoid the misleading term "default password callback" because none of
the functions in SSL_CTX_use_certificate(3) support overriding it.
* Do not talk about "storing", "writing", and "encryption" since the cb
passed to SSL_CTX_set_default_passwd_cb(3) is never used for any of that.
* List the functions using cb.
* Document what happens by default.
* Remove the misleading words "which must be provided by the application"
because all this is actually optional.
* Make several wordings more precise.
* Below EXAMPLES, fix argument naming to agree with pem_password_cb(3),
clarify the description of what the example does, and, as suggested by tb@,
use strlcpy(3).
OK tb@
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libssl/man/SSL_CTX_set_default_passwd_cb.3 | 150 |
1 files changed, 94 insertions, 56 deletions
diff --git a/src/lib/libssl/man/SSL_CTX_set_default_passwd_cb.3 b/src/lib/libssl/man/SSL_CTX_set_default_passwd_cb.3 index 7ab9633f5c..4e119132b2 100644 --- a/src/lib/libssl/man/SSL_CTX_set_default_passwd_cb.3 +++ b/src/lib/libssl/man/SSL_CTX_set_default_passwd_cb.3 | |||
@@ -1,8 +1,25 @@ | |||
1 | .\" $OpenBSD: SSL_CTX_set_default_passwd_cb.3,v 1.7 2018/04/02 02:06:14 schwarze Exp $ | 1 | .\" $OpenBSD: SSL_CTX_set_default_passwd_cb.3,v 1.8 2023/09/19 08:18:13 schwarze Exp $ |
2 | .\" full merge up to: OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 | 2 | .\" full merge up to: OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 |
3 | .\" selective merge up to: OpenSSL 2947af32 Nov 19 00:10:05 2016 +0100 | 3 | .\" selective merge up to: OpenSSL 18bad535 Apr 9 15:13:55 2019 +0100 |
4 | .\" | 4 | .\" |
5 | .\" This file was written by Lutz Jaenicke <jaenicke@openssl.org> | 5 | .\" This file is a derived work. |
6 | .\" The changes are covered by the following Copyright and license: | ||
7 | .\" | ||
8 | .\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org> | ||
9 | .\" | ||
10 | .\" Permission to use, copy, modify, and distribute this software for any | ||
11 | .\" purpose with or without fee is hereby granted, provided that the above | ||
12 | .\" copyright notice and this permission notice appear in all copies. | ||
13 | .\" | ||
14 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
15 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
16 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
17 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
18 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
19 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
20 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
21 | .\" | ||
22 | .\" The original file was written by Lutz Jaenicke <jaenicke@openssl.org> | ||
6 | .\" and Christian Heimes <cheimes@redhat.com>. | 23 | .\" and Christian Heimes <cheimes@redhat.com>. |
7 | .\" Copyright (c) 2000, 2001, 2016 The OpenSSL Project. All rights reserved. | 24 | .\" Copyright (c) 2000, 2001, 2016 The OpenSSL Project. All rights reserved. |
8 | .\" | 25 | .\" |
@@ -50,75 +67,95 @@ | |||
50 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 67 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
51 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | 68 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. |
52 | .\" | 69 | .\" |
53 | .Dd $Mdocdate: April 2 2018 $ | 70 | .Dd $Mdocdate: September 19 2023 $ |
54 | .Dt SSL_CTX_SET_DEFAULT_PASSWD_CB 3 | 71 | .Dt SSL_CTX_SET_DEFAULT_PASSWD_CB 3 |
55 | .Os | 72 | .Os |
56 | .Sh NAME | 73 | .Sh NAME |
57 | .Nm SSL_CTX_set_default_passwd_cb , | 74 | .Nm SSL_CTX_set_default_passwd_cb , |
58 | .Nm SSL_CTX_set_default_passwd_cb_userdata , | 75 | .Nm SSL_CTX_set_default_passwd_cb_userdata , |
59 | .Nm SSL_CTX_get_default_passwd_cb , | 76 | .Nm SSL_CTX_get_default_passwd_cb , |
60 | .Nm SSL_CTX_get_default_passwd_cb_userdata , | 77 | .Nm SSL_CTX_get_default_passwd_cb_userdata |
61 | .Nm pem_password_cb | ||
62 | .Nd set or get passwd callback for encrypted PEM file handling | 78 | .Nd set or get passwd callback for encrypted PEM file handling |
63 | .Sh SYNOPSIS | 79 | .Sh SYNOPSIS |
64 | .In openssl/ssl.h | 80 | .In openssl/ssl.h |
65 | .Ft void | 81 | .Ft void |
66 | .Fn SSL_CTX_set_default_passwd_cb "SSL_CTX *ctx" "pem_password_cb *cb" | 82 | .Fn SSL_CTX_set_default_passwd_cb "SSL_CTX *ctx" "pem_password_cb *cb" |
67 | .Ft void | 83 | .Ft void |
68 | .Fn SSL_CTX_set_default_passwd_cb_userdata "SSL_CTX *ctx" "void *u" | 84 | .Fn SSL_CTX_set_default_passwd_cb_userdata "SSL_CTX *ctx" "void *userdata" |
69 | .Ft pem_password_cb * | 85 | .Ft pem_password_cb * |
70 | .Fn SSL_CTX_get_default_passwd_cb "SSL_CTX *ctx" | 86 | .Fn SSL_CTX_get_default_passwd_cb "SSL_CTX *ctx" |
71 | .Ft void * | 87 | .Ft void * |
72 | .Fn SSL_CTX_get_default_passwd_cb_userdata "SSL_CTX *ctx" | 88 | .Fn SSL_CTX_get_default_passwd_cb_userdata "SSL_CTX *ctx" |
73 | .In openssl/pem.h | ||
74 | .Ft typedef int | ||
75 | .Fn pem_password_cb "char *buf" "int size" "int rwflag" "void *userdata" | ||
76 | .Sh DESCRIPTION | 89 | .Sh DESCRIPTION |
77 | .Fn SSL_CTX_set_default_passwd_cb | 90 | .Fn SSL_CTX_set_default_passwd_cb |
78 | sets the default password callback called when loading/storing a PEM | 91 | sets the password callback for loading a certificate or private key |
79 | certificate with encryption. | 92 | from encrypted PEM format. |
93 | In particular, the callback is used by | ||
94 | .Xr SSL_CTX_use_certificate_file 3 , | ||
95 | .Xr SSL_use_certificate_file 3 , | ||
96 | .Xr SSL_CTX_use_certificate_chain_file 3 , | ||
97 | .Xr SSL_use_certificate_chain_file 3 , | ||
98 | .Xr SSL_CTX_use_certificate_chain_mem 3 , | ||
99 | .Xr SSL_CTX_use_PrivateKey_file 3 , | ||
100 | .Xr SSL_use_PrivateKey_file 3 , | ||
101 | .Xr SSL_CTX_use_RSAPrivateKey_file 3 , | ||
102 | and | ||
103 | .Xr SSL_use_RSAPrivateKey_file 3 . | ||
104 | .Pp | ||
105 | The function pointer type of the | ||
106 | .Fa cb | ||
107 | argument is documented in the | ||
108 | .Xr pem_password_cb 3 | ||
109 | manual page. | ||
110 | If | ||
111 | .Fn SSL_CTX_set_default_passwd_cb | ||
112 | is not called on | ||
113 | .Fa ctx | ||
114 | or if it is called with a | ||
115 | .Fa cb | ||
116 | argument of | ||
117 | .Dv NULL , | ||
118 | .Xr PEM_def_callback 3 | ||
119 | is used instead. | ||
80 | .Pp | 120 | .Pp |
81 | .Fn SSL_CTX_set_default_passwd_cb_userdata | 121 | .Fn SSL_CTX_set_default_passwd_cb_userdata |
82 | sets a pointer to userdata | 122 | sets a pointer to the |
83 | .Fa u | 123 | .Fa userdata |
84 | which will be provided to the password callback on invocation. | 124 | which will be provided to the password callback on invocation. |
85 | .Pp | 125 | .Pp |
86 | The | 126 | Since the |
87 | password callback | 127 | .Fa cb |
88 | .Fa cb , | 128 | passed to |
89 | which must be provided by the application, | 129 | .Fn SSL_CTX_set_default_passwd_cb |
90 | hands back the password to be used during decryption. | 130 | will only be used for reading and decryption and not for writing and |
91 | On invocation a pointer to | 131 | encryption, the library will only call it with a |
92 | .Fa userdata | 132 | .Fa verify |
93 | is provided. | 133 | argument of 0. |
94 | The password callback must write the password into the provided buffer | ||
95 | .Fa buf | ||
96 | which is of size | ||
97 | .Fa size . | ||
98 | The actual length of the password must be returned to the calling function. | ||
99 | .Fa rwflag | ||
100 | indicates whether the callback is used for reading/decryption | ||
101 | .Pq Fa rwflag No = 0 | ||
102 | or writing/encryption | ||
103 | .Pq Fa rwflag No = 1 . | ||
104 | .Pp | 134 | .Pp |
105 | When loading or storing private keys, a password might be supplied to protect | 135 | If an application program only needs to read and decrypt |
106 | the private key. | 136 | one single private key, it can be practical to have the |
107 | The way this password can be supplied may depend on the application. | ||
108 | If only one private key is handled, it can be practical to have the | ||
109 | callback handle the password dialog interactively. | 137 | callback handle the password dialog interactively. |
110 | If several keys have to be handled, it can be practical to ask for the password | 138 | This happens by default if neither |
111 | once, then keep it in memory and use it several times. | 139 | .Fn SSL_CTX_set_default_passwd_cb |
112 | In the last case, the password could be stored into the | 140 | nor |
141 | .Fn SSL_CTX_set_default_passwd_cb_userdata | ||
142 | is called. | ||
143 | In that case, the library uses | ||
144 | .Xr PEM_def_callback 3 | ||
145 | with a | ||
113 | .Fa userdata | 146 | .Fa userdata |
114 | storage and the callback only returns the password already stored. | 147 | argument of |
148 | .Dv NULL . | ||
115 | .Pp | 149 | .Pp |
116 | When asking for the password interactively, the callback can use | 150 | If several keys have to be handled, it can be practical |
117 | .Fa rwflag | 151 | to ask for the password once, for example using |
118 | to check whether an item shall be encrypted | 152 | .Xr UI_UTIL_read_pw_string 3 , |
119 | .Pq Fa rwflag No = 1 . | 153 | then keep it in memory and use it several times by passing a pointer to it to |
120 | In this case the password dialog may ask for the same password twice for | 154 | .Fn SSL_CTX_set_default_passwd_cb_userdata . |
121 | comparison in order to catch typos which would make decryption impossible. | 155 | .Xr PEM_def_callback 3 |
156 | is able to handle this case, too, so calling | ||
157 | .Fn SSL_CTX_set_default_passwd_cb | ||
158 | is not needed in this case either. | ||
122 | .Pp | 159 | .Pp |
123 | Other items in PEM formatting (certificates) can also be encrypted; it is | 160 | Other items in PEM formatting (certificates) can also be encrypted; it is |
124 | however atypical, as certificate information is considered public. | 161 | however atypical, as certificate information is considered public. |
@@ -137,22 +174,23 @@ or | |||
137 | .Dv NULL | 174 | .Dv NULL |
138 | if none is set. | 175 | if none is set. |
139 | .Sh EXAMPLES | 176 | .Sh EXAMPLES |
140 | The following example returns the password provided as | 177 | The following example provides a subset of the functionality of |
178 | .Xr PEM_def_callback 3 . | ||
179 | It interprets | ||
141 | .Fa userdata | 180 | .Fa userdata |
142 | to the calling function. | 181 | as a NUL-terminated string and copies it to the |
143 | The password is considered to be a | 182 | .Fa password |
144 | .Sq \e0 | 183 | buffer, truncating the copy if it does not fit. |
145 | terminated string. | ||
146 | If the password does not fit into the buffer, the password is truncated. | ||
147 | .Bd -literal | 184 | .Bd -literal |
148 | int pem_passwd_cb(char *buf, int size, int rwflag, void *password) | 185 | int |
186 | trivial_passwd_cb(char *password, int size, int verify, void *userdata) | ||
149 | { | 187 | { |
150 | strncpy(buf, (char *)password, size); | 188 | strlcpy(password, userdata, size); |
151 | buf[size - 1] = '\e0'; | 189 | return strlen(password); |
152 | return strlen(buf); | ||
153 | } | 190 | } |
154 | .Ed | 191 | .Ed |
155 | .Sh SEE ALSO | 192 | .Sh SEE ALSO |
193 | .Xr pem_password_cb 3 , | ||
156 | .Xr ssl 3 , | 194 | .Xr ssl 3 , |
157 | .Xr SSL_CTX_use_certificate 3 | 195 | .Xr SSL_CTX_use_certificate 3 |
158 | .Sh HISTORY | 196 | .Sh HISTORY |