summaryrefslogtreecommitdiff
path: root/src/lib/libssl/doc/SSL_CTX_set_default_passwd_cb.3
diff options
context:
space:
mode:
authorbentley <>2014-10-12 09:33:04 +0000
committerbentley <>2014-10-12 09:33:04 +0000
commit78332233d01faa45e0bb0b1583d47cb5ad1ddc19 (patch)
treea5087bf8d016a6041c2b6822fbecfd8f6c5e70b1 /src/lib/libssl/doc/SSL_CTX_set_default_passwd_cb.3
parent4e737c824fafe5f105e5f4849a9db2569b5d53d8 (diff)
downloadopenbsd-78332233d01faa45e0bb0b1583d47cb5ad1ddc19.tar.gz
openbsd-78332233d01faa45e0bb0b1583d47cb5ad1ddc19.tar.bz2
openbsd-78332233d01faa45e0bb0b1583d47cb5ad1ddc19.zip
Convert libssl manpages from pod to mdoc(7).
libcrypto has not been started yet. ok schwarze@ miod@
Diffstat (limited to 'src/lib/libssl/doc/SSL_CTX_set_default_passwd_cb.3')
-rw-r--r--src/lib/libssl/doc/SSL_CTX_set_default_passwd_cb.392
1 files changed, 92 insertions, 0 deletions
diff --git a/src/lib/libssl/doc/SSL_CTX_set_default_passwd_cb.3 b/src/lib/libssl/doc/SSL_CTX_set_default_passwd_cb.3
new file mode 100644
index 0000000000..2c35ed501c
--- /dev/null
+++ b/src/lib/libssl/doc/SSL_CTX_set_default_passwd_cb.3
@@ -0,0 +1,92 @@
1.Dd $Mdocdate: October 12 2014 $
2.Dt SSL_CTX_SET_DEFAULT_PASSWD_CB 3
3.Os
4.Sh NAME
5.Nm SSL_CTX_set_default_passwd_cb ,
6.Nm SSL_CTX_set_default_passwd_cb_userdata
7.Nd set passwd callback for encrypted PEM file handling
8.Sh SYNOPSIS
9.In openssl/ssl.h
10.Ft void
11.Fn SSL_CTX_set_default_passwd_cb "SSL_CTX *ctx" "pem_password_cb *cb"
12.Ft void
13.Fn SSL_CTX_set_default_passwd_cb_userdata "SSL_CTX *ctx" "void *u"
14.Ft int
15.Fn pem_passwd_cb "char *buf" "int size" "int rwflag" "void *userdata"
16.Sh DESCRIPTION
17.Fn SSL_CTX_set_default_passwd_cb
18sets the default password callback called when loading/storing a PEM
19certificate with encryption.
20.Pp
21.Fn SSL_CTX_set_default_passwd_cb_userdata
22sets a pointer to userdata
23.Fa u
24which will be provided to the password callback on invocation.
25.Pp
26The
27.Fn pem_passwd_cb ,
28which must be provided by the application,
29hands back the password to be used during decryption.
30On invocation a pointer to
31.Fa userdata
32is provided.
33The pem_passwd_cb must write the password into the provided buffer
34.Fa buf
35which is of size
36.Fa size .
37The actual length of the password must be returned to the calling function.
38.Fa rwflag
39indicates whether the callback is used for reading/decryption
40.Pq Fa rwflag No = 0
41or writing/encryption
42.Pq Fa rwflag No = 1 .
43.Sh NOTES
44When loading or storing private keys, a password might be supplied to protect
45the private key.
46The way this password can be supplied may depend on the application.
47If only one private key is handled, it can be practical to have
48.Fn pem_passwd_cb
49handle the password dialog interactively.
50If several keys have to be handled, it can be practical to ask for the password
51once, then keep it in memory and use it several times.
52In the last case, the password could be stored into the
53.Fa userdata
54storage and the
55.Fn pem_passwd_cb
56only returns the password already stored.
57.Pp
58When asking for the password interactively,
59.Fn pem_passwd_cb
60can use
61.Fa rwflag
62to check whether an item shall be encrypted
63.Pq Fa rwflag No = 1 .
64In this case the password dialog may ask for the same password twice for
65comparison in order to catch typos which would make decryption impossible.
66.Pp
67Other items in PEM formatting (certificates) can also be encrypted; it is
68however atypical, as certificate information is considered public.
69.Sh RETURN VALUES
70.Fn SSL_CTX_set_default_passwd_cb
71and
72.Fn SSL_CTX_set_default_passwd_cb_userdata
73do not provide diagnostic information.
74.Sh EXAMPLES
75The following example returns the password provided as
76.Fa userdata
77to the calling function.
78The password is considered to be a
79.Sq \e0
80terminated string.
81If the password does not fit into the buffer, the password is truncated.
82.Bd -literal
83int pem_passwd_cb(char *buf, int size, int rwflag, void *password)
84{
85 strncpy(buf, (char *)password, size);
86 buf[size - 1] = '\e0';
87 return strlen(buf);
88}
89.Ed
90.Sh SEE ALSO
91.Xr ssl 3 ,
92.Xr SSL_CTX_use_certificate 3