summaryrefslogtreecommitdiff
path: root/src/lib/libssl/src/doc
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/src/doc')
-rw-r--r--src/lib/libssl/src/doc/HOWTO/certificates.txt85
-rw-r--r--src/lib/libssl/src/doc/apps/CA.pl.pod5
-rw-r--r--src/lib/libssl/src/doc/apps/ca.pod133
-rw-r--r--src/lib/libssl/src/doc/apps/enc.pod16
-rw-r--r--src/lib/libssl/src/doc/apps/ocsp.pod348
-rw-r--r--src/lib/libssl/src/doc/apps/openssl.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/passwd.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/pkcs12.pod2
-rw-r--r--src/lib/libssl/src/doc/apps/pkcs7.pod2
-rw-r--r--src/lib/libssl/src/doc/apps/rand.pod2
-rw-r--r--src/lib/libssl/src/doc/apps/req.pod59
-rw-r--r--src/lib/libssl/src/doc/apps/rsa.pod2
-rw-r--r--src/lib/libssl/src/doc/apps/s_client.pod25
-rw-r--r--src/lib/libssl/src/doc/apps/s_server.pod28
-rw-r--r--src/lib/libssl/src/doc/apps/verify.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/version.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/x509.pod122
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_f_md.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_new_bio_pair.pod7
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_s_accept.pod31
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_s_connect.pod34
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_s_socket.pod12
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_add.pod89
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_bn2bin.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod20
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_rand.pod5
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_swap.pod23
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_zero.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/DH_set_method.pod4
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_set_method.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/ERR_get_error.pod29
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_BytesToKey.pod67
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_DigestInit.pod119
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_EncryptInit.pod289
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_SignInit.pod39
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_VerifyInit.pod36
-rw-r--r--src/lib/libssl/src/doc/crypto/OPENSSL_VERSION_NUMBER.pod29
-rw-r--r--src/lib/libssl/src/doc/crypto/RAND_egd.pod18
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_generate_key.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_public_encrypt.pod4
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_set_method.pod26
-rw-r--r--src/lib/libssl/src/doc/crypto/blowfish.pod4
-rw-r--r--src/lib/libssl/src/doc/crypto/bn.pod17
-rw-r--r--src/lib/libssl/src/doc/crypto/bn_internal.pod19
-rw-r--r--src/lib/libssl/src/doc/crypto/crypto.pod3
-rw-r--r--src/lib/libssl/src/doc/crypto/des.pod324
-rw-r--r--src/lib/libssl/src/doc/crypto/hmac.pod31
-rw-r--r--src/lib/libssl/src/doc/crypto/lhash.pod196
-rw-r--r--src/lib/libssl/src/doc/crypto/pem.pod476
-rw-r--r--src/lib/libssl/src/doc/crypto/rsa.pod1
-rw-r--r--src/lib/libssl/src/doc/crypto/threads.pod6
-rw-r--r--src/lib/libssl/src/doc/crypto/ui.pod194
-rw-r--r--src/lib/libssl/src/doc/crypto/ui_compat.pod55
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_COMP_add_compression_method.pod70
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_add_extra_chain_cert.pod1
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_ctrl.pod34
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod2
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod6
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_new.pod4
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod8
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_store.pod57
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_verify_callback.pod75
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_cipher_list.pod24
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_cert_cb.pod90
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_default_passwd_cb.pod6
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_generate_session_id.pod150
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_info_callback.pod153
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_max_cert_list.pod77
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_mode.pod3
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_msg_callback.pod97
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod89
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_quiet_shutdown.pod63
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod1
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_timeout.pod8
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_dh_callback.pod170
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_rsa_callback.pod166
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod14
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod1
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_SESSION_free.pod32
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.pod3
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_accept.pod5
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_alert_type_string.pod228
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_clear.pod22
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_connect.pod5
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_SSL_CTX.pod26
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_client_CA_list.pod3
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_default_timeout.pod41
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_error.pod8
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_peer_certificate.pod2
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_session.pod12
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_new.pod1
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_read.pod25
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_rstate_string.pod59
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_session_reused.pod45
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_connect_state.pod23
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_session.pod13
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_shutdown.pod6
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_shutdown.pod67
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_state_string.pod45
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_want.pod77
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_write.pod16
-rw-r--r--src/lib/libssl/src/doc/ssl/d2i_SSL_SESSION.pod14
-rw-r--r--src/lib/libssl/src/doc/ssl/ssl.pod39
-rw-r--r--src/lib/libssl/src/doc/ssleay.txt16
-rw-r--r--src/lib/libssl/src/doc/standards.txt19
105 files changed, 4672 insertions, 627 deletions
diff --git a/src/lib/libssl/src/doc/HOWTO/certificates.txt b/src/lib/libssl/src/doc/HOWTO/certificates.txt
new file mode 100644
index 0000000000..88048645db
--- /dev/null
+++ b/src/lib/libssl/src/doc/HOWTO/certificates.txt
@@ -0,0 +1,85 @@
1<DRAFT!>
2 HOWTO certificates
3
4How you handle certificates depend a great deal on what your role is.
5Your role can be one or several of:
6
7 - User of some client software
8 - User of some server software
9 - Certificate authority
10
11This file is for users who wish to get a certificate of their own.
12Certificate authorities should read ca.txt.
13
14In all the cases shown below, the standard configuration file, as
15compiled into openssl, will be used. You may find it in /etc/,
16/usr/local/ssr/ or somewhere else. The name is openssl.cnf, and
17is better described in another HOWTO <config.txt?>. If you want to
18use a different configuration file, use the argument '-config {file}'
19with the command shown below.
20
21
22Certificates are related to public key cryptography by containing a
23public key. To be useful, there must be a corresponding private key
24somewhere. With OpenSSL, public keys are easily derived from private
25keys, so before you create a certificate or a certificate request, you
26need to create a private key.
27
28Private keys are generated with 'openssl genrsa' if you want a RSA
29private key, or 'openssl gendsa' if you want a DSA private key. More
30info on how to handle these commands are found in the manual pages for
31those commands or by running them with the argument '-h'. For the
32sake of the description in this file, let's assume that the private
33key ended up in the file privkey.pem (which is the default in some
34cases).
35
36
37Let's start with the most normal way of getting a certificate. Most
38often, you want or need to get a certificate from a certificate
39authority. To handle that, the certificate authority needs a
40certificate request (or, as some certificate authorities like to put
41it, "certificate signing request", since that's exactly what they do,
42they sign it and give you the result back, thus making it authentic
43according to their policies) from you. To generate a request, use the
44command 'openssl req' like this:
45
46 openssl req -new -key privkey.pem -out cert.csr
47
48Now, cert.csr can be sent to the certificate authority, if they can
49handle files in PEM format. If not, use the extra argument '-outform'
50followed by the keyword for the format to use (see another HOWTO
51<formats.txt?>). In some cases, that isn't sufficient and you will
52have to be more creative.
53
54When the certificate authority has then done the checks the need to
55do (and probably gotten payment from you), they will hand over your
56new certificate to you.
57
58
59[fill in on how to create a self-signed certificate]
60
61
62If you created everything yourself, or if the certificate authority
63was kind enough, your certificate is a raw DER thing in PEM format.
64Your key most definitely is if you have followed the examples above.
65However, some (most?) certificate authorities will encode them with
66things like PKCS7 or PKCS12, or something else. Depending on your
67applications, this may be perfectly OK, it all depends on what they
68know how to decode. If not, There are a number of OpenSSL tools to
69convert between some (most?) formats.
70
71So, depending on your application, you may have to convert your
72certificate and your key to various formats, most often also putting
73them together into one file. The ways to do this is described in
74another HOWTO <formats.txt?>, I will just mention the simplest case.
75In the case of a raw DER thing in PEM format, and assuming that's all
76right for yor applications, simply concatenating the certificate and
77the key into a new file and using that one should be enough. With
78some applications, you don't even have to do that.
79
80
81By now, you have your cetificate and your private key and can start
82using the software that depend on it.
83
84--
85Richard Levitte
diff --git a/src/lib/libssl/src/doc/apps/CA.pl.pod b/src/lib/libssl/src/doc/apps/CA.pl.pod
index 63cd1320cc..58e0f52001 100644
--- a/src/lib/libssl/src/doc/apps/CA.pl.pod
+++ b/src/lib/libssl/src/doc/apps/CA.pl.pod
@@ -13,6 +13,7 @@ B<CA.pl>
13[B<-help>] 13[B<-help>]
14[B<-newcert>] 14[B<-newcert>]
15[B<-newreq>] 15[B<-newreq>]
16[B<-newreq-nodes>]
16[B<-newca>] 17[B<-newca>]
17[B<-xsign>] 18[B<-xsign>]
18[B<-sign>] 19[B<-sign>]
@@ -46,6 +47,10 @@ written to the file "newreq.pem".
46creates a new certificate request. The private key and request are 47creates a new certificate request. The private key and request are
47written to the file "newreq.pem". 48written to the file "newreq.pem".
48 49
50=item B<-newreq-nowdes>
51
52is like B<-newreq> except that the private key will not be encrypted.
53
49=item B<-newca> 54=item B<-newca>
50 55
51creates a new CA hierarchy for use with the B<ca> program (or the B<-signcert> 56creates a new CA hierarchy for use with the B<ca> program (or the B<-signcert>
diff --git a/src/lib/libssl/src/doc/apps/ca.pod b/src/lib/libssl/src/doc/apps/ca.pod
index d352925864..c2ca8f2400 100644
--- a/src/lib/libssl/src/doc/apps/ca.pod
+++ b/src/lib/libssl/src/doc/apps/ca.pod
@@ -13,6 +13,7 @@ B<openssl> B<ca>
13[B<-name section>] 13[B<-name section>]
14[B<-gencrl>] 14[B<-gencrl>]
15[B<-revoke file>] 15[B<-revoke file>]
16[B<-subj arg>]
16[B<-crldays days>] 17[B<-crldays days>]
17[B<-crlhours hours>] 18[B<-crlhours hours>]
18[B<-crlexts section>] 19[B<-crlexts section>]
@@ -33,9 +34,11 @@ B<openssl> B<ca>
33[B<-spkac file>] 34[B<-spkac file>]
34[B<-ss_cert file>] 35[B<-ss_cert file>]
35[B<-preserveDN>] 36[B<-preserveDN>]
37[B<-noemailDN>]
36[B<-batch>] 38[B<-batch>]
37[B<-msie_hack>] 39[B<-msie_hack>]
38[B<-extensions section>] 40[B<-extensions section>]
41[B<-extfile section>]
39 42
40=head1 DESCRIPTION 43=head1 DESCRIPTION
41 44
@@ -54,6 +57,11 @@ The options descriptions will be divided into each purpose.
54 57
55specifies the configuration file to use. 58specifies the configuration file to use.
56 59
60=item B<-name section>
61
62specifies the configuration file section to use (overrides
63B<default_ca> in the B<ca> section).
64
57=item B<-in filename> 65=item B<-in filename>
58 66
59an input filename containing a single certificate request to be 67an input filename containing a single certificate request to be
@@ -104,6 +112,7 @@ the 'ps' utility) this option should be used with caution.
104 112
105the key password source. For more information about the format of B<arg> 113the key password source. For more information about the format of B<arg>
106see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>. 114see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
115
107=item B<-verbose> 116=item B<-verbose>
108 117
109this prints extra details about the operations being performed. 118this prints extra details about the operations being performed.
@@ -154,6 +163,15 @@ is the same as the request. This is largely for compatibility with the
154older IE enrollment control which would only accept certificates if their 163older IE enrollment control which would only accept certificates if their
155DNs match the order of the request. This is not needed for Xenroll. 164DNs match the order of the request. This is not needed for Xenroll.
156 165
166=item B<-noemailDN>
167
168The DN of a certificate can contain the EMAIL field if present in the
169request DN, however it is good policy just having the e-mail set into
170the altName extension of the certificate. When this option is set the
171EMAIL field is removed from the certificate' subject and set only in
172the, eventually present, extensions. The B<email_in_dn> keyword can be
173used in the configuration file to enable this behaviour.
174
157=item B<-batch> 175=item B<-batch>
158 176
159this sets the batch mode. In this mode no questions will be asked 177this sets the batch mode. In this mode no questions will be asked
@@ -162,9 +180,16 @@ and all certificates will be certified automatically.
162=item B<-extensions section> 180=item B<-extensions section>
163 181
164the section of the configuration file containing certificate extensions 182the section of the configuration file containing certificate extensions
165to be added when a certificate is issued. If no extension section is 183to be added when a certificate is issued (defaults to B<x509_extensions>
166present then a V1 certificate is created. If the extension section 184unless the B<-extfile> option is used). If no extension section is
167is present (even if it is empty) then a V3 certificate is created. 185present then, a V1 certificate is created. If the extension section
186is present (even if it is empty), then a V3 certificate is created.
187
188=item B<-extfile file>
189
190an additional configuration file to read certificate extensions from
191(using the default section unless the B<-extensions> option is also
192used).
168 193
169=back 194=back
170 195
@@ -189,6 +214,12 @@ the number of hours before the next CRL is due.
189 214
190a filename containing a certificate to revoke. 215a filename containing a certificate to revoke.
191 216
217=item B<-subj arg>
218
219supersedes subject name given in the request.
220The arg must be formatted as I</type0=value0/type1=value1/type2=...>,
221characters may be escaped by \ (backslash), no spaces are skipped.
222
192=item B<-crlexts section> 223=item B<-crlexts section>
193 224
194the section of the configuration file containing CRL extensions to 225the section of the configuration file containing CRL extensions to
@@ -202,8 +233,20 @@ that some software (for example Netscape) can't handle V2 CRLs.
202 233
203=head1 CONFIGURATION FILE OPTIONS 234=head1 CONFIGURATION FILE OPTIONS
204 235
205The options for B<ca> are contained in the B<ca> section of the 236The section of the configuration file containing options for B<ca>
206configuration file. Many of these are identical to command line 237is found as follows: If the B<-name> command line option is used,
238then it names the section to be used. Otherwise the section to
239be used must be named in the B<default_ca> option of the B<ca> section
240of the configuration file (or in the default section of the
241configuration file). Besides B<default_ca>, the following options are
242read directly from the B<ca> section:
243 RANDFILE
244 preserve
245 msie_hack
246With the exception of B<RANDFILE>, this is probably a bug and may
247change in future releases.
248
249Many of the configuration file options are identical to command line
207options. Where the option is present in the configuration file 250options. Where the option is present in the configuration file
208and the command line the command line value is used. Where an 251and the command line the command line value is used. Where an
209option is described as mandatory then it must be present in 252option is described as mandatory then it must be present in
@@ -294,6 +337,12 @@ the same as B<-crlexts>.
294 337
295the same as B<-preserveDN> 338the same as B<-preserveDN>
296 339
340=item B<email_in_dn>
341
342the same as B<-noemailDN>. If you want the EMAIL field to be removed
343from the DN of the certificate simply set this to 'no'. If not present
344the default is to allow for the EMAIL filed in the certificate's DN.
345
297=item B<msie_hack> 346=item B<msie_hack>
298 347
299the same as B<-msie_hack> 348the same as B<-msie_hack>
@@ -303,6 +352,37 @@ the same as B<-msie_hack>
303the same as B<-policy>. Mandatory. See the B<POLICY FORMAT> section 352the same as B<-policy>. Mandatory. See the B<POLICY FORMAT> section
304for more information. 353for more information.
305 354
355=item B<nameopt>, B<certopt>
356
357these options allow the format used to display the certificate details
358when asking the user to confirm signing. All the options supported by
359the B<x509> utilities B<-nameopt> and B<-certopt> switches can be used
360here, except the B<no_signame> and B<no_sigdump> are permanently set
361and cannot be disabled (this is because the certificate signature cannot
362be displayed because the certificate has not been signed at this point).
363
364For convenience the values B<default_ca> are accepted by both to produce
365a reasonable output.
366
367If neither option is present the format used in earlier versions of
368OpenSSL is used. Use of the old format is B<strongly> discouraged because
369it only displays fields mentioned in the B<policy> section, mishandles
370multicharacter string types and does not display extensions.
371
372=item B<copy_extensions>
373
374determines how extensions in certificate requests should be handled.
375If set to B<none> or this option is not present then extensions are
376ignored and not copied to the certificate. If set to B<copy> then any
377extensions present in the request that are not already present are copied
378to the certificate. If set to B<copyall> then all extensions in the
379request are copied to the certificate: if the extension is already present
380in the certificate it is deleted first. See the B<WARNINGS> section before
381using this option.
382
383The main use of this option is to allow a certificate request to supply
384values for certain extensions such as subjectAltName.
385
306=back 386=back
307 387
308=head1 POLICY FORMAT 388=head1 POLICY FORMAT
@@ -392,6 +472,11 @@ A sample configuration file with the relevant sections for B<ca>:
392 default_md = md5 # md to use 472 default_md = md5 # md to use
393 473
394 policy = policy_any # default policy 474 policy = policy_any # default policy
475 email_in_dn = no # Don't add the email into cert DN
476
477 nameopt = default_ca # Subject name display option
478 certopt = default_ca # Certificate display option
479 copy_extensions = none # Don't copy extensions from request
395 480
396 [ policy_any ] 481 [ policy_any ]
397 countryName = supplied 482 countryName = supplied
@@ -406,7 +491,7 @@ A sample configuration file with the relevant sections for B<ca>:
406The B<ca> command is quirky and at times downright unfriendly. 491The B<ca> command is quirky and at times downright unfriendly.
407 492
408The B<ca> utility was originally meant as an example of how to do things 493The B<ca> utility was originally meant as an example of how to do things
409in a CA. It was not supposed be be used as a full blown CA itself: 494in a CA. It was not supposed to be used as a full blown CA itself:
410nevertheless some people are using it for this purpose. 495nevertheless some people are using it for this purpose.
411 496
412The B<ca> command is effectively a single user command: no locking is 497The B<ca> command is effectively a single user command: no locking is
@@ -457,10 +542,6 @@ The use of an in memory text database can cause problems when large
457numbers of certificates are present because, as the name implies 542numbers of certificates are present because, as the name implies
458the database has to be kept in memory. 543the database has to be kept in memory.
459 544
460Certificate request extensions are ignored: some kind of "policy" should
461be included to use certain static extensions and certain extensions
462from the request.
463
464It is not possible to certify two certificates with the same DN: this 545It is not possible to certify two certificates with the same DN: this
465is a side effect of how the text database is indexed and it cannot easily 546is a side effect of how the text database is indexed and it cannot easily
466be fixed without introducing other problems. Some S/MIME clients can use 547be fixed without introducing other problems. Some S/MIME clients can use
@@ -473,13 +554,39 @@ exposed at either a command or interface level so a more friendly utility
473B<CA.pl> help a little but not very much. 554B<CA.pl> help a little but not very much.
474 555
475Any fields in a request that are not present in a policy are silently 556Any fields in a request that are not present in a policy are silently
476deleted. This does not happen if the B<-preserveDN> option is used but 557deleted. This does not happen if the B<-preserveDN> option is used. To
477the extra fields are not displayed when the user is asked to certify 558enforce the absence of the EMAIL field within the DN, as suggested by
478a request. The behaviour should be more friendly and configurable. 559RFCs, regardless the contents of the request' subject the B<-noemailDN>
560option can be used. The behaviour should be more friendly and
561configurable.
479 562
480Cancelling some commands by refusing to certify a certificate can 563Cancelling some commands by refusing to certify a certificate can
481create an empty file. 564create an empty file.
482 565
566=head1 WARNINGS
567
568The B<copy_extensions> option should be used with caution. If care is
569not taken then it can be a security risk. For example if a certificate
570request contains a basicConstraints extension with CA:TRUE and the
571B<copy_extensions> value is set to B<copyall> and the user does not spot
572this when the certificate is displayed then this will hand the requestor
573a valid CA certificate.
574
575This situation can be avoided by setting B<copy_extensions> to B<copy>
576and including basicConstraints with CA:FALSE in the configuration file.
577Then if the request contains a basicConstraints extension it will be
578ignored.
579
580It is advisable to also include values for other extensions such
581as B<keyUsage> to prevent a request supplying its own values.
582
583Additional restrictions can be placed on the CA certificate itself.
584For example if the CA certificate has:
585
586 basicConstraints = CA:TRUE, pathlen:0
587
588then even if a certificate is issued with CA:TRUE it will not be valid.
589
483=head1 SEE ALSO 590=head1 SEE ALSO
484 591
485L<req(1)|req(1)>, L<spkac(1)|spkac(1)>, L<x509(1)|x509(1)>, L<CA.pl(1)|CA.pl(1)>, 592L<req(1)|req(1)>, L<spkac(1)|spkac(1)>, L<x509(1)|x509(1)>, L<CA.pl(1)|CA.pl(1)>,
diff --git a/src/lib/libssl/src/doc/apps/enc.pod b/src/lib/libssl/src/doc/apps/enc.pod
index a68ddca139..ddf081617f 100644
--- a/src/lib/libssl/src/doc/apps/enc.pod
+++ b/src/lib/libssl/src/doc/apps/enc.pod
@@ -21,6 +21,7 @@ B<openssl enc -ciphername>
21[B<-p>] 21[B<-p>]
22[B<-P>] 22[B<-P>]
23[B<-bufsize number>] 23[B<-bufsize number>]
24[B<-nopad>]
24[B<-debug>] 25[B<-debug>]
25 26
26=head1 DESCRIPTION 27=head1 DESCRIPTION
@@ -122,6 +123,10 @@ or decryption.
122 123
123set the buffer size for I/O 124set the buffer size for I/O
124 125
126=item B<-nopad>
127
128disable standard block padding
129
125=item B<-debug> 130=item B<-debug>
126 131
127debug the BIOs used for I/O. 132debug the BIOs used for I/O.
@@ -150,11 +155,14 @@ Some of the ciphers do not have large keys and others have security
150implications if not used correctly. A beginner is advised to just use 155implications if not used correctly. A beginner is advised to just use
151a strong block cipher in CBC mode such as bf or des3. 156a strong block cipher in CBC mode such as bf or des3.
152 157
153All the block ciphers use PKCS#5 padding also known as standard block 158All the block ciphers normally use PKCS#5 padding also known as standard block
154padding: this allows a rudimentary integrity or password check to be 159padding: this allows a rudimentary integrity or password check to be
155performed. However since the chance of random data passing the test is 160performed. However since the chance of random data passing the test is
156better than 1 in 256 it isn't a very good test. 161better than 1 in 256 it isn't a very good test.
157 162
163If padding is disabled then the input data must be a multiple of the cipher
164block length.
165
158All RC2 ciphers have the same key and effective key length. 166All RC2 ciphers have the same key and effective key length.
159 167
160Blowfish and RC5 algorithms use a 128 bit key. 168Blowfish and RC5 algorithms use a 128 bit key.
@@ -256,8 +264,8 @@ The B<-A> option when used with large files doesn't work properly.
256 264
257There should be an option to allow an iteration count to be included. 265There should be an option to allow an iteration count to be included.
258 266
259Like the EVP library the B<enc> program only supports a fixed number of 267The B<enc> program only supports a fixed number of algorithms with
260algorithms with certain parameters. So if, for example, you want to use RC2 268certain parameters. So if, for example, you want to use RC2 with a
261with a 76 bit key or RC4 with an 84 bit key you can't use this program. 26976 bit key or RC4 with an 84 bit key you can't use this program.
262 270
263=cut 271=cut
diff --git a/src/lib/libssl/src/doc/apps/ocsp.pod b/src/lib/libssl/src/doc/apps/ocsp.pod
new file mode 100644
index 0000000000..da201b95e6
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/ocsp.pod
@@ -0,0 +1,348 @@
1=pod
2
3=head1 NAME
4
5ocsp - Online Certificate Status Protocol utility
6
7=head1 SYNOPSIS
8
9B<openssl> B<ocsp>
10[B<-out file>]
11[B<-issuer file>]
12[B<-cert file>]
13[B<-serial n>]
14[B<-req_text>]
15[B<-resp_text>]
16[B<-text>]
17[B<-reqout file>]
18[B<-respout file>]
19[B<-reqin file>]
20[B<-respin file>]
21[B<-nonce>]
22[B<-no_nonce>]
23[B<-url responder_url>]
24[B<-host host:n>]
25[B<-path>]
26[B<-CApath file>]
27[B<-CAfile file>]
28[B<-VAfile file>]
29[B<-verify_certs file>]
30[B<-noverify>]
31[B<-trust_other>]
32[B<-no_intern>]
33[B<-no_sig_verify>]
34[B<-no_cert_verify>]
35[B<-no_chain>]
36[B<-no_cert_checks>]
37[B<-validity_period nsec>]
38[B<-status_age nsec>]
39
40=head1 DESCRIPTION
41
42B<WARNING: this documentation is preliminary and subject to change.>
43
44The Online Certificate Status Protocol (OCSP) enables applications to
45determine the (revocation) state of an identified certificate (RFC 2560).
46
47The B<ocsp> command performs many common OCSP tasks. It can be used
48to print out requests and responses, create requests and send queries
49to an OCSP responder and behave like a mini OCSP server itself.
50
51=head1 OCSP CLIENT OPTIONS
52
53=over 4
54
55=item B<-out filename>
56
57specify output filename, default is standard output.
58
59=item B<-issuer filename>
60
61This specifies the current issuer certificate. This option can be used
62multiple times. The certificate specified in B<filename> must be in
63PEM format.
64
65=item B<-cert filename>
66
67Add the certificate B<filename> to the request. The issuer certificate
68is taken from the previous B<issuer> option, or an error occurs if no
69issuer certificate is specified.
70
71=item B<-serial num>
72
73Same as the B<cert> option except the certificate with serial number
74B<num> is added to the request. The serial number is interpreted as a
75decimal integer unless preceded by B<0x>. Negative integers can also
76be specified by preceding the value by a B<-> sign.
77
78=item B<-signer filename>, B<-signkey filename>
79
80Sign the OCSP request using the certificate specified in the B<signer>
81option and the private key specified by the B<signkey> option. If
82the B<signkey> option is not present then the private key is read
83from the same file as the certificate. If neither option is specified then
84the OCSP request is not signed.
85
86=item B<-nonce>, B<-no_nonce>
87
88Add an OCSP nonce extension to a request or disable OCSP nonce addition.
89Normally if an OCSP request is input using the B<respin> option no
90nonce is added: using the B<nonce> option will force addition of a nonce.
91If an OCSP request is being created (using B<cert> and B<serial> options)
92a nonce is automatically added specifying B<no_nonce> overrides this.
93
94=item B<-req_text>, B<-resp_text>, B<-text>
95
96print out the text form of the OCSP request, response or both respectively.
97
98=item B<-reqout file>, B<-respout file>
99
100write out the DER encoded certificate request or response to B<file>.
101
102=item B<-reqin file>, B<-respin file>
103
104read OCSP request or response file from B<file>. These option are ignored
105if OCSP request or response creation is implied by other options (for example
106with B<serial>, B<cert> and B<host> options).
107
108=item B<-url responder_url>
109
110specify the responder URL. Both HTTP and HTTPS (SSL/TLS) URLs can be specified.
111
112=item B<-host hostname:port>, B<-path pathname>
113
114if the B<host> option is present then the OCSP request is sent to the host
115B<hostname> on port B<port>. B<path> specifies the HTTP path name to use
116or "/" by default.
117
118=item B<-CAfile file>, B<-CApath pathname>
119
120file or pathname containing trusted CA certificates. These are used to verify
121the signature on the OCSP response.
122
123=item B<-verify_certs file>
124
125file containing additional certificates to search when attempting to locate
126the OCSP response signing certificate. Some responders omit the actual signer's
127certificate from the response: this option can be used to supply the necessary
128certificate in such cases.
129
130=item B<-trust_other>
131
132the certificates specified by the B<-verify_certs> option should be explicitly
133trusted and no additional checks will be performed on them. This is useful
134when the complete responder certificate chain is not available or trusting a
135root CA is not appropriate.
136
137=item B<-VAfile file>
138
139file containing explicitly trusted responder certificates. Equivalent to the
140B<-verify_certs> and B<-trust_other> options.
141
142=item B<-noverify>
143
144don't attempt to verify the OCSP response signature or the nonce values. This
145option will normally only be used for debugging since it disables all verification
146of the responders certificate.
147
148=item B<-no_intern>
149
150ignore certificates contained in the OCSP response when searching for the
151signers certificate. With this option the signers certificate must be specified
152with either the B<-verify_certs> or B<-VAfile> options.
153
154=item B<-no_sig_verify>
155
156don't check the signature on the OCSP response. Since this option tolerates invalid
157signatures on OCSP responses it will normally only be used for testing purposes.
158
159=item B<-no_cert_verify>
160
161don't verify the OCSP response signers certificate at all. Since this option allows
162the OCSP response to be signed by any certificate it should only be used for
163testing purposes.
164
165=item B<-no_chain>
166
167do not use certificates in the response as additional untrusted CA
168certificates.
169
170=item B<-no_cert_checks>
171
172don't perform any additional checks on the OCSP response signers certificate.
173That is do not make any checks to see if the signers certificate is authorised
174to provide the necessary status information: as a result this option should
175only be used for testing purposes.
176
177=item B<-validity_period nsec>, B<-status_age age>
178
179these options specify the range of times, in seconds, which will be tolerated
180in an OCSP response. Each certificate status response includes a B<notBefore> time and
181an optional B<notAfter> time. The current time should fall between these two values, but
182the interval between the two times may be only a few seconds. In practice the OCSP
183responder and clients clocks may not be precisely synchronised and so such a check
184may fail. To avoid this the B<-validity_period> option can be used to specify an
185acceptable error range in seconds, the default value is 5 minutes.
186
187If the B<notAfter> time is omitted from a response then this means that new status
188information is immediately available. In this case the age of the B<notBefore> field
189is checked to see it is not older than B<age> seconds old. By default this additional
190check is not performed.
191
192=back
193
194=head1 OCSP SERVER OPTIONS
195
196=over 4
197
198=item B<-index indexfile>
199
200B<indexfile> is a text index file in B<ca> format containing certificate revocation
201information.
202
203If the B<index> option is specified the B<ocsp> utility is in responder mode, otherwise
204it is in client mode. The request(s) the responder processes can be either specified on
205the command line (using B<issuer> and B<serial> options), supplied in a file (using the
206B<respin> option) or via external OCSP clients (if B<port> or B<url> is specified).
207
208If the B<index> option is present then the B<CA> and B<rsigner> options must also be
209present.
210
211=item B<-CA file>
212
213CA certificate corresponding to the revocation information in B<indexfile>.
214
215=item B<-rsigner file>
216
217The certificate to sign OCSP responses with.
218
219=item B<-rother file>
220
221Additional certificates to include in the OCSP response.
222
223=item B<-resp_no_certs>
224
225Don't include any certificates in the OCSP response.
226
227=item B<-resp_key_id>
228
229Identify the signer certificate using the key ID, default is to use the subject name.
230
231=item B<-rkey file>
232
233The private key to sign OCSP responses with: if not present the file specified in the
234B<rsigner> option is used.
235
236=item B<-port portnum>
237
238Port to listen for OCSP requests on. The port may also be specified using the B<url>
239option.
240
241=item B<-nrequest number>
242
243The OCSP server will exit after receiving B<number> requests, default unlimited.
244
245=item B<-nmin minutes>, B<-ndays days>
246
247Number of minutes or days when fresh revocation information is available: used in the
248B<nextUpdate> field. If neither option is present then the B<nextUpdate> field is
249omitted meaning fresh revocation information is immediately available.
250
251=back
252
253=head1 OCSP Response verification.
254
255OCSP Response follows the rules specified in RFC2560.
256
257Initially the OCSP responder certificate is located and the signature on
258the OCSP request checked using the responder certificate's public key.
259
260Then a normal certificate verify is performed on the OCSP responder certificate
261building up a certificate chain in the process. The locations of the trusted
262certificates used to build the chain can be specified by the B<CAfile>
263and B<CApath> options or they will be looked for in the standard OpenSSL
264certificates directory.
265
266If the initial verify fails then the OCSP verify process halts with an
267error.
268
269Otherwise the issuing CA certificate in the request is compared to the OCSP
270responder certificate: if there is a match then the OCSP verify succeeds.
271
272Otherwise the OCSP responder certificate's CA is checked against the issuing
273CA certificate in the request. If there is a match and the OCSPSigning
274extended key usage is present in the OCSP responder certificate then the
275OCSP verify succeeds.
276
277Otherwise the root CA of the OCSP responders CA is checked to see if it
278is trusted for OCSP signing. If it is the OCSP verify succeeds.
279
280If none of these checks is successful then the OCSP verify fails.
281
282What this effectively means if that if the OCSP responder certificate is
283authorised directly by the CA it is issuing revocation information about
284(and it is correctly configured) then verification will succeed.
285
286If the OCSP responder is a "global responder" which can give details about
287multiple CAs and has its own separate certificate chain then its root
288CA can be trusted for OCSP signing. For example:
289
290 openssl x509 -in ocspCA.pem -addtrust OCSPSigning -out trustedCA.pem
291
292Alternatively the responder certificate itself can be explicitly trusted
293with the B<-VAfile> option.
294
295=head1 NOTES
296
297As noted, most of the verify options are for testing or debugging purposes.
298Normally only the B<-CApath>, B<-CAfile> and (if the responder is a 'global
299VA') B<-VAfile> options need to be used.
300
301The OCSP server is only useful for test and demonstration purposes: it is
302not really usable as a full OCSP responder. It contains only a very
303simple HTTP request handling and can only handle the POST form of OCSP
304queries. It also handles requests serially meaning it cannot respond to
305new requests until it has processed the current one. The text index file
306format of revocation is also inefficient for large quantities of revocation
307data.
308
309It is possible to run the B<ocsp> application in responder mode via a CGI
310script using the B<respin> and B<respout> options.
311
312=head1 EXAMPLES
313
314Create an OCSP request and write it to a file:
315
316 openssl ocsp -issuer issuer.pem -cert c1.pem -cert c2.pem -reqout req.der
317
318Send a query to an OCSP responder with URL http://ocsp.myhost.com/ save the
319response to a file and print it out in text form
320
321 openssl ocsp -issuer issuer.pem -cert c1.pem -cert c2.pem \
322 -url http://ocsp.myhost.com/ -resp_text -respout resp.der
323
324Read in an OCSP response and print out text form:
325
326 openssl ocsp -respin resp.der -text
327
328OCSP server on port 8888 using a standard B<ca> configuration, and a separate
329responder certificate. All requests and responses are printed to a file.
330
331 openssl ocsp -index demoCA/index.txt -port 8888 -rsigner rcert.pem -CA demoCA/cacert.pem
332 -text -out log.txt
333
334As above but exit after processing one request:
335
336 openssl ocsp -index demoCA/index.txt -port 8888 -rsigner rcert.pem -CA demoCA/cacert.pem
337 -nrequest 1
338
339Query status information using internally generated request:
340
341 openssl ocsp -index demoCA/index.txt -rsigner rcert.pem -CA demoCA/cacert.pem
342 -issuer demoCA/cacert.pem -serial 1
343
344Query status information using request read from a file, write response to a
345second file.
346
347 openssl ocsp -index demoCA/index.txt -rsigner rcert.pem -CA demoCA/cacert.pem
348 -reqin req.der -respout resp.der
diff --git a/src/lib/libssl/src/doc/apps/openssl.pod b/src/lib/libssl/src/doc/apps/openssl.pod
index 0cbd199d79..07dd80eabe 100644
--- a/src/lib/libssl/src/doc/apps/openssl.pod
+++ b/src/lib/libssl/src/doc/apps/openssl.pod
@@ -121,10 +121,18 @@ Generation of DSA Parameters.
121 121
122Generation of RSA Parameters. 122Generation of RSA Parameters.
123 123
124=item L<B<ocsp>|ocsp(1)>
125
126Online Certificate Status Protocol utility.
127
124=item L<B<passwd>|passwd(1)> 128=item L<B<passwd>|passwd(1)>
125 129
126Generation of hashed passwords. 130Generation of hashed passwords.
127 131
132=item L<B<pkcs12>|pkcs12(1)>
133
134PKCS#12 Data Management.
135
128=item L<B<pkcs7>|pkcs7(1)> 136=item L<B<pkcs7>|pkcs7(1)>
129 137
130PKCS#7 Data Management. 138PKCS#7 Data Management.
diff --git a/src/lib/libssl/src/doc/apps/passwd.pod b/src/lib/libssl/src/doc/apps/passwd.pod
index 6e098940c7..07d849c824 100644
--- a/src/lib/libssl/src/doc/apps/passwd.pod
+++ b/src/lib/libssl/src/doc/apps/passwd.pod
@@ -13,6 +13,7 @@ B<openssl passwd>
13[B<-salt> I<string>] 13[B<-salt> I<string>]
14[B<-in> I<file>] 14[B<-in> I<file>]
15[B<-stdin>] 15[B<-stdin>]
16[B<-noverify>]
16[B<-quiet>] 17[B<-quiet>]
17[B<-table>] 18[B<-table>]
18{I<password>} 19{I<password>}
@@ -22,7 +23,7 @@ B<openssl passwd>
22The B<passwd> command computes the hash of a password typed at 23The B<passwd> command computes the hash of a password typed at
23run-time or the hash of each password in a list. The password list is 24run-time or the hash of each password in a list. The password list is
24taken from the named file for option B<-in file>, from stdin for 25taken from the named file for option B<-in file>, from stdin for
25option B<-stdin>, and from the command line otherwise. 26option B<-stdin>, or from the command line, or from the terminal otherwise.
26The Unix standard algorithm B<crypt> and the MD5-based BSD password 27The Unix standard algorithm B<crypt> and the MD5-based BSD password
27algorithm B<1> and its Apache variant B<apr1> are available. 28algorithm B<1> and its Apache variant B<apr1> are available.
28 29
@@ -45,6 +46,7 @@ Use the B<apr1> algorithm (Apache variant of the BSD algorithm).
45=item B<-salt> I<string> 46=item B<-salt> I<string>
46 47
47Use the specified salt. 48Use the specified salt.
49When reading a password from the terminal, this implies B<-noverify>.
48 50
49=item B<-in> I<file> 51=item B<-in> I<file>
50 52
@@ -54,6 +56,10 @@ Read passwords from I<file>.
54 56
55Read passwords from B<stdin>. 57Read passwords from B<stdin>.
56 58
59=item B<-noverify>
60
61Don't verify when reading a password from the terminal.
62
57=item B<-quiet> 63=item B<-quiet>
58 64
59Don't output warnings when passwords given at the command line are truncated. 65Don't output warnings when passwords given at the command line are truncated.
diff --git a/src/lib/libssl/src/doc/apps/pkcs12.pod b/src/lib/libssl/src/doc/apps/pkcs12.pod
index 7e0307dda0..7d84146293 100644
--- a/src/lib/libssl/src/doc/apps/pkcs12.pod
+++ b/src/lib/libssl/src/doc/apps/pkcs12.pod
@@ -262,7 +262,7 @@ the one corresponding to the private key. Certain software which requires
262a private key and certificate and assumes the first certificate in the 262a private key and certificate and assumes the first certificate in the
263file is the one corresponding to the private key: this may not always 263file is the one corresponding to the private key: this may not always
264be the case. Using the B<-clcerts> option will solve this problem by only 264be the case. Using the B<-clcerts> option will solve this problem by only
265outputing the certificate corresponding to the private key. If the CA 265outputting the certificate corresponding to the private key. If the CA
266certificates are required then they can be output to a separate file using 266certificates are required then they can be output to a separate file using
267the B<-nokeys -cacerts> options to just output CA certificates. 267the B<-nokeys -cacerts> options to just output CA certificates.
268 268
diff --git a/src/lib/libssl/src/doc/apps/pkcs7.pod b/src/lib/libssl/src/doc/apps/pkcs7.pod
index 4e9bd6e46b..9871c0e0cd 100644
--- a/src/lib/libssl/src/doc/apps/pkcs7.pod
+++ b/src/lib/libssl/src/doc/apps/pkcs7.pod
@@ -78,7 +78,7 @@ The PEM PKCS#7 format uses the header and footer lines:
78 -----BEGIN PKCS7----- 78 -----BEGIN PKCS7-----
79 -----END PKCS7----- 79 -----END PKCS7-----
80 80
81For compatability with some CAs it will also accept: 81For compatibility with some CAs it will also accept:
82 82
83 -----BEGIN CERTIFICATE----- 83 -----BEGIN CERTIFICATE-----
84 -----END CERTIFICATE----- 84 -----END CERTIFICATE-----
diff --git a/src/lib/libssl/src/doc/apps/rand.pod b/src/lib/libssl/src/doc/apps/rand.pod
index cbf8768801..75745ca002 100644
--- a/src/lib/libssl/src/doc/apps/rand.pod
+++ b/src/lib/libssl/src/doc/apps/rand.pod
@@ -15,7 +15,7 @@ I<num>
15=head1 DESCRIPTION 15=head1 DESCRIPTION
16 16
17The B<rand> command outputs I<num> pseudo-random bytes after seeding 17The B<rand> command outputs I<num> pseudo-random bytes after seeding
18the random number generater once. As in other B<openssl> command 18the random number generator once. As in other B<openssl> command
19line tools, PRNG seeding uses the file I<$HOME/>B<.rnd> or B<.rnd> 19line tools, PRNG seeding uses the file I<$HOME/>B<.rnd> or B<.rnd>
20in addition to the files given in the B<-rand> option. A new 20in addition to the files given in the B<-rand> option. A new
21I<$HOME>/B<.rnd> or B<.rnd> file will be written back if enough 21I<$HOME>/B<.rnd> or B<.rnd> file will be written back if enough
diff --git a/src/lib/libssl/src/doc/apps/req.pod b/src/lib/libssl/src/doc/apps/req.pod
index a3f54f45a3..10e4e12a5c 100644
--- a/src/lib/libssl/src/doc/apps/req.pod
+++ b/src/lib/libssl/src/doc/apps/req.pod
@@ -3,7 +3,7 @@
3 3
4=head1 NAME 4=head1 NAME
5 5
6req - PKCS#10 certificate and certificate generating utility. 6req - PKCS#10 certificate request and certificate generating utility.
7 7
8=head1 SYNOPSIS 8=head1 SYNOPSIS
9 9
@@ -15,6 +15,7 @@ B<openssl> B<req>
15[B<-out filename>] 15[B<-out filename>]
16[B<-passout arg>] 16[B<-passout arg>]
17[B<-text>] 17[B<-text>]
18[B<-pubkey>]
18[B<-noout>] 19[B<-noout>]
19[B<-verify>] 20[B<-verify>]
20[B<-modulus>] 21[B<-modulus>]
@@ -28,12 +29,18 @@ B<openssl> B<req>
28[B<-keyout filename>] 29[B<-keyout filename>]
29[B<-[md5|sha1|md2|mdc2]>] 30[B<-[md5|sha1|md2|mdc2]>]
30[B<-config filename>] 31[B<-config filename>]
32[B<-subj arg>]
31[B<-x509>] 33[B<-x509>]
32[B<-days n>] 34[B<-days n>]
35[B<-set_serial n>]
33[B<-asn1-kludge>] 36[B<-asn1-kludge>]
34[B<-newhdr>] 37[B<-newhdr>]
35[B<-extensions section>] 38[B<-extensions section>]
36[B<-reqexts section>] 39[B<-reqexts section>]
40[B<-utf8>]
41[B<-nameopt>]
42[B<-batch>]
43[B<-verbose>]
37 44
38=head1 DESCRIPTION 45=head1 DESCRIPTION
39 46
@@ -82,6 +89,10 @@ see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
82 89
83prints out the certificate request in text form. 90prints out the certificate request in text form.
84 91
92=item B<-pubkey>
93
94outputs the public key.
95
85=item B<-noout> 96=item B<-noout>
86 97
87this option prevents output of the encoded version of the request. 98this option prevents output of the encoded version of the request.
@@ -154,18 +165,33 @@ this allows an alternative configuration file to be specified,
154this overrides the compile time filename or any specified in 165this overrides the compile time filename or any specified in
155the B<OPENSSL_CONF> environment variable. 166the B<OPENSSL_CONF> environment variable.
156 167
168=item B<-subj arg>
169
170sets subject name for new request or supersedes the subject name
171when processing a request.
172The arg must be formatted as I</type0=value0/type1=value1/type2=...>,
173characters may be escaped by \ (backslash), no spaces are skipped.
174
157=item B<-x509> 175=item B<-x509>
158 176
159this option outputs a self signed certificate instead of a certificate 177this option outputs a self signed certificate instead of a certificate
160request. This is typically used to generate a test certificate or 178request. This is typically used to generate a test certificate or
161a self signed root CA. The extensions added to the certificate 179a self signed root CA. The extensions added to the certificate
162(if any) are specified in the configuration file. 180(if any) are specified in the configuration file. Unless specified
181using the B<set_serial> option B<0> will be used for the serial
182number.
163 183
164=item B<-days n> 184=item B<-days n>
165 185
166when the B<-x509> option is being used this specifies the number of 186when the B<-x509> option is being used this specifies the number of
167days to certify the certificate for. The default is 30 days. 187days to certify the certificate for. The default is 30 days.
168 188
189=item B<-set_serial n>
190
191serial number to use when outputting a self signed certificate. This
192may be specified as a decimal value or a hex value if preceded by B<0x>.
193It is possible to use negative serial numbers but this is not recommended.
194
169=item B<-extensions section> 195=item B<-extensions section>
170 196
171=item B<-reqexts section> 197=item B<-reqexts section>
@@ -176,6 +202,20 @@ request extensions. This allows several different sections to
176be used in the same configuration file to specify requests for 202be used in the same configuration file to specify requests for
177a variety of purposes. 203a variety of purposes.
178 204
205=item B<-utf8>
206
207this option causes field values to be interpreted as UTF8 strings, by
208default they are interpreted as ASCII. This means that the field
209values, whether prompted from a terminal or obtained from a
210configuration file, must be valid UTF8 strings.
211
212=item B<-nameopt option>
213
214option which determines how the subject or issuer names are displayed. The
215B<option> argument can be a single option or multiple options separated by
216commas. Alternatively the B<-nameopt> switch may be used more than once to
217set multiple options. See the L<x509(1)|x509(1)> manual page for details.
218
179=item B<-asn1-kludge> 219=item B<-asn1-kludge>
180 220
181by default the B<req> command outputs certificate requests containing 221by default the B<req> command outputs certificate requests containing
@@ -196,6 +236,14 @@ It should be noted that very few CAs still require the use of this option.
196Adds the word B<NEW> to the PEM file header and footer lines on the outputed 236Adds the word B<NEW> to the PEM file header and footer lines on the outputed
197request. Some software (Netscape certificate server) and some CAs need this. 237request. Some software (Netscape certificate server) and some CAs need this.
198 238
239=item B<-batch>
240
241non-interactive mode.
242
243=item B<-verbose>
244
245print extra details about the operations being performed.
246
199=back 247=back
200 248
201=head1 CONFIGURATION FILE FORMAT 249=head1 CONFIGURATION FILE FORMAT
@@ -292,6 +340,13 @@ if set to the value B<no> this disables prompting of certificate fields
292and just takes values from the config file directly. It also changes the 340and just takes values from the config file directly. It also changes the
293expected format of the B<distinguished_name> and B<attributes> sections. 341expected format of the B<distinguished_name> and B<attributes> sections.
294 342
343=item B<utf8>
344
345if set to the value B<yes> then field values to be interpreted as UTF8
346strings, by default they are interpreted as ASCII. This means that
347the field values, whether prompted from a terminal or obtained from a
348configuration file, must be valid UTF8 strings.
349
295=item B<attributes> 350=item B<attributes>
296 351
297this specifies the section containing any request attributes: its format 352this specifies the section containing any request attributes: its format
diff --git a/src/lib/libssl/src/doc/apps/rsa.pod b/src/lib/libssl/src/doc/apps/rsa.pod
index f0e613ed05..ef74f1adff 100644
--- a/src/lib/libssl/src/doc/apps/rsa.pod
+++ b/src/lib/libssl/src/doc/apps/rsa.pod
@@ -136,7 +136,7 @@ and Microsoft IIS .key files, this uses unsalted RC4 for its encryption.
136It is not very secure and so should only be used when necessary. 136It is not very secure and so should only be used when necessary.
137 137
138Some newer version of IIS have additional data in the exported .key 138Some newer version of IIS have additional data in the exported .key
139files. To use thse with the utility view the file with a binary editor 139files. To use these with the utility, view the file with a binary editor
140and look for the string "private-key", then trace back to the byte 140and look for the string "private-key", then trace back to the byte
141sequence 0x30, 0x82 (this is an ASN1 SEQUENCE). Copy all the data 141sequence 0x30, 0x82 (this is an ASN1 SEQUENCE). Copy all the data
142from this point onwards to another file and use that as the input 142from this point onwards to another file and use that as the input
diff --git a/src/lib/libssl/src/doc/apps/s_client.pod b/src/lib/libssl/src/doc/apps/s_client.pod
index 078ff086c3..7fca9cbdbd 100644
--- a/src/lib/libssl/src/doc/apps/s_client.pod
+++ b/src/lib/libssl/src/doc/apps/s_client.pod
@@ -18,6 +18,7 @@ B<openssl> B<s_client>
18[B<-pause>] 18[B<-pause>]
19[B<-showcerts>] 19[B<-showcerts>]
20[B<-debug>] 20[B<-debug>]
21[B<-msg>]
21[B<-nbio_test>] 22[B<-nbio_test>]
22[B<-state>] 23[B<-state>]
23[B<-nbio>] 24[B<-nbio>]
@@ -32,8 +33,8 @@ B<openssl> B<s_client>
32[B<-no_tls1>] 33[B<-no_tls1>]
33[B<-bugs>] 34[B<-bugs>]
34[B<-cipher cipherlist>] 35[B<-cipher cipherlist>]
35[B<-rand file(s)>]
36[B<-engine id>] 36[B<-engine id>]
37[B<-rand file(s)>]
37 38
38=head1 DESCRIPTION 39=head1 DESCRIPTION
39 40
@@ -112,6 +113,10 @@ prints out the SSL session states.
112 113
113print extensive debugging information including a hex dump of all traffic. 114print extensive debugging information including a hex dump of all traffic.
114 115
116=item B<-msg>
117
118show all protocol messages with hex dump.
119
115=item B<-nbio_test> 120=item B<-nbio_test>
116 121
117tests non-blocking I/O 122tests non-blocking I/O
@@ -132,7 +137,7 @@ input.
132 137
133=item B<-quiet> 138=item B<-quiet>
134 139
135inhibit printing of session and certificate information. This implicitely 140inhibit printing of session and certificate information. This implicitly
136turns on B<-ign_eof> as well. 141turns on B<-ign_eof> as well.
137 142
138=item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1> 143=item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1>
@@ -158,6 +163,13 @@ the server determines which cipher suite is used it should take the first
158supported cipher in the list sent by the client. See the B<ciphers> 163supported cipher in the list sent by the client. See the B<ciphers>
159command for more information. 164command for more information.
160 165
166=item B<-engine id>
167
168specifying an engine (by it's unique B<id> string) will cause B<s_client>
169to attempt to obtain a functional reference to the specified engine,
170thus initialising it if needed. The engine will then be set as the default
171for all available algorithms.
172
161=item B<-rand file(s)> 173=item B<-rand file(s)>
162 174
163a file or files containing random data used to seed the random number 175a file or files containing random data used to seed the random number
@@ -166,13 +178,6 @@ Multiple files can be specified separated by a OS-dependent character.
166The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for 178The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
167all others. 179all others.
168 180
169=item B<-engine id>
170
171specifying an engine (by it's unique B<id> string) will cause B<s_client>
172to attempt to obtain a functional reference to the specified engine,
173thus initialising it if needed. The engine will then be set as the default
174for all available algorithms.
175
176=back 181=back
177 182
178=head1 CONNECTED COMMANDS 183=head1 CONNECTED COMMANDS
@@ -180,7 +185,7 @@ for all available algorithms.
180If a connection is established with an SSL server then any data received 185If a connection is established with an SSL server then any data received
181from the server is displayed and any key presses will be sent to the 186from the server is displayed and any key presses will be sent to the
182server. When used interactively (which means neither B<-quiet> nor B<-ign_eof> 187server. When used interactively (which means neither B<-quiet> nor B<-ign_eof>
183have been given), the session will be renegociated if the line begins with an 188have been given), the session will be renegotiated if the line begins with an
184B<R>, and if the line begins with a B<Q> or if end of file is reached, the 189B<R>, and if the line begins with a B<Q> or if end of file is reached, the
185connection will be closed down. 190connection will be closed down.
186 191
diff --git a/src/lib/libssl/src/doc/apps/s_server.pod b/src/lib/libssl/src/doc/apps/s_server.pod
index 313116ab66..4b1e4260ef 100644
--- a/src/lib/libssl/src/doc/apps/s_server.pod
+++ b/src/lib/libssl/src/doc/apps/s_server.pod
@@ -21,6 +21,7 @@ B<openssl> B<s_server>
21[B<-nbio_test>] 21[B<-nbio_test>]
22[B<-crlf>] 22[B<-crlf>]
23[B<-debug>] 23[B<-debug>]
24[B<-msg>]
24[B<-state>] 25[B<-state>]
25[B<-CApath directory>] 26[B<-CApath directory>]
26[B<-CAfile filename>] 27[B<-CAfile filename>]
@@ -39,8 +40,9 @@ B<openssl> B<s_server>
39[B<-hack>] 40[B<-hack>]
40[B<-www>] 41[B<-www>]
41[B<-WWW>] 42[B<-WWW>]
42[B<-rand file(s)>] 43[B<-HTTP>]
43[B<-engine id>] 44[B<-engine id>]
45[B<-rand file(s)>]
44 46
45=head1 DESCRIPTION 47=head1 DESCRIPTION
46 48
@@ -135,6 +137,10 @@ prints out the SSL session states.
135 137
136print extensive debugging information including a hex dump of all traffic. 138print extensive debugging information including a hex dump of all traffic.
137 139
140=item B<-msg>
141
142show all protocol messages with hex dump.
143
138=item B<-nbio_test> 144=item B<-nbio_test>
139 145
140tests non blocking I/O 146tests non blocking I/O
@@ -188,13 +194,13 @@ emulates a simple web server. Pages will be resolved relative to the
188current directory, for example if the URL https://myhost/page.html is 194current directory, for example if the URL https://myhost/page.html is
189requested the file ./page.html will be loaded. 195requested the file ./page.html will be loaded.
190 196
191=item B<-rand file(s)> 197=item B<-HTTP>
192 198
193a file or files containing random data used to seed the random number 199emulates a simple web server. Pages will be resolved relative to the
194generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>). 200current directory, for example if the URL https://myhost/page.html is
195Multiple files can be specified separated by a OS-dependent character. 201requested the file ./page.html will be loaded. The files loaded are
196The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for 202assumed to contain a complete and correct HTTP response (lines that
197all others. 203are part of the HTTP response line and headers must end with CRLF).
198 204
199=item B<-engine id> 205=item B<-engine id>
200 206
@@ -203,6 +209,14 @@ to attempt to obtain a functional reference to the specified engine,
203thus initialising it if needed. The engine will then be set as the default 209thus initialising it if needed. The engine will then be set as the default
204for all available algorithms. 210for all available algorithms.
205 211
212=item B<-rand file(s)>
213
214a file or files containing random data used to seed the random number
215generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>).
216Multiple files can be specified separated by a OS-dependent character.
217The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
218all others.
219
206=back 220=back
207 221
208=head1 CONNECTED COMMANDS 222=head1 CONNECTED COMMANDS
diff --git a/src/lib/libssl/src/doc/apps/verify.pod b/src/lib/libssl/src/doc/apps/verify.pod
index 90455525d1..ea5c29c150 100644
--- a/src/lib/libssl/src/doc/apps/verify.pod
+++ b/src/lib/libssl/src/doc/apps/verify.pod
@@ -200,13 +200,13 @@ the signature of the certificate is invalid. Unused.
200 200
201the certificate is not yet valid: the notBefore date is after the current time. 201the certificate is not yet valid: the notBefore date is after the current time.
202 202
203=item B<10 X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid> 203=item B<10 X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired>
204 204
205the CRL is not yet valid. Unused. 205the certificate has expired: that is the notAfter date is before the current time.
206 206
207=item B<11 X509_V_ERR_CERT_HAS_EXPIRED: Certificate has expired> 207=item B<11 X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid>
208 208
209the certificate has expired: that is the notAfter date is before the current time. 209the CRL is not yet valid. Unused.
210 210
211=item B<12 X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired> 211=item B<12 X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired>
212 212
diff --git a/src/lib/libssl/src/doc/apps/version.pod b/src/lib/libssl/src/doc/apps/version.pod
index 5d261a6405..e00324c446 100644
--- a/src/lib/libssl/src/doc/apps/version.pod
+++ b/src/lib/libssl/src/doc/apps/version.pod
@@ -46,6 +46,10 @@ compilation flags.
46 46
47platform setting. 47platform setting.
48 48
49=item B<-d>
50
51OPENSSLDIR setting.
52
49=back 53=back
50 54
51=head1 NOTES 55=head1 NOTES
@@ -53,4 +57,8 @@ platform setting.
53The output of B<openssl version -a> would typically be used when sending 57The output of B<openssl version -a> would typically be used when sending
54in a bug report. 58in a bug report.
55 59
60=head1 HISTORY
61
62The B<-d> option was added in OpenSSL 0.9.7.
63
56=cut 64=cut
diff --git a/src/lib/libssl/src/doc/apps/x509.pod b/src/lib/libssl/src/doc/apps/x509.pod
index 84f76cb421..23367b7659 100644
--- a/src/lib/libssl/src/doc/apps/x509.pod
+++ b/src/lib/libssl/src/doc/apps/x509.pod
@@ -36,6 +36,7 @@ B<openssl> B<x509>
36[B<-addreject arg>] 36[B<-addreject arg>]
37[B<-setalias arg>] 37[B<-setalias arg>]
38[B<-days arg>] 38[B<-days arg>]
39[B<-set_serial n>]
39[B<-signkey filename>] 40[B<-signkey filename>]
40[B<-x509toreq>] 41[B<-x509toreq>]
41[B<-req>] 42[B<-req>]
@@ -112,6 +113,13 @@ prints out the certificate in text form. Full details are output including the
112public key, signature algorithms, issuer and subject names, serial number 113public key, signature algorithms, issuer and subject names, serial number
113any extensions present and any trust settings. 114any extensions present and any trust settings.
114 115
116=item B<-certopt option>
117
118customise the output format used with B<-text>. The B<option> argument can be
119a single option or multiple options separated by commas. The B<-certopt> switch
120may be also be used more than once to set multiple options. See the B<TEXT OPTIONS>
121section for more information.
122
115=item B<-noout> 123=item B<-noout>
116 124
117this option prevents output of the encoded version of the request. 125this option prevents output of the encoded version of the request.
@@ -141,9 +149,10 @@ outputs the issuer name.
141 149
142=item B<-nameopt option> 150=item B<-nameopt option>
143 151
144option which determine how the subject or issuer names are displayed. This 152option which determines how the subject or issuer names are displayed. The
145option may be used more than once to set multiple options. See the B<NAME 153B<option> argument can be a single option or multiple options separated by
146OPTIONS> section for more information. 154commas. Alternatively the B<-nameopt> switch may be used more than once to
155set multiple options. See the B<NAME OPTIONS> section for more information.
147 156
148=item B<-email> 157=item B<-email>
149 158
@@ -163,7 +172,8 @@ prints out the start and expiry dates of a certificate.
163 172
164=item B<-fingerprint> 173=item B<-fingerprint>
165 174
166prints out the digest of the DER encoded version of the whole certificate. 175prints out the digest of the DER encoded version of the whole certificate
176(see digest options).
167 177
168=item B<-C> 178=item B<-C>
169 179
@@ -292,6 +302,16 @@ is used to pass the required private key.
292by default a certificate is expected on input. With this option a 302by default a certificate is expected on input. With this option a
293certificate request is expected instead. 303certificate request is expected instead.
294 304
305=item B<-set_serial n>
306
307specifies the serial number to use. This option can be used with either
308the B<-signkey> or B<-CA> options. If used in conjunction with the B<-CA>
309option the serial number file (as specified by the B<-CAserial> or
310B<-CAcreateserial> options) is not used.
311
312The serial number can be decimal or hex (if preceded by B<0x>). Negative
313serial numbers can also be specified but their use is not recommended.
314
295=item B<-CA filename> 315=item B<-CA filename>
296 316
297specifies the CA certificate to be used for signing. When this option is 317specifies the CA certificate to be used for signing. When this option is
@@ -372,12 +392,12 @@ options.
372=item B<multiline> 392=item B<multiline>
373 393
374a multiline format. It is equivalent B<esc_ctrl>, B<esc_msb>, B<sep_multiline>, 394a multiline format. It is equivalent B<esc_ctrl>, B<esc_msb>, B<sep_multiline>,
375B<spc_eq> and B<lname>. 395B<spc_eq>, B<lname> and B<align>.
376 396
377=item B<esc_2253> 397=item B<esc_2253>
378 398
379escape the "special" characters required by RFC2253 in a field That is 399escape the "special" characters required by RFC2253 in a field That is
380B<,+"E<lt>E<gt>;>. Additionally B<#> is escaped at the beginnging of a string 400B<,+"E<lt>E<gt>;>. Additionally B<#> is escaped at the beginning of a string
381and a space character at the beginning or end of a string. 401and a space character at the beginning or end of a string.
382 402
383=item B<esc_ctrl> 403=item B<esc_ctrl>
@@ -431,7 +451,7 @@ B<#XXXX...> format.
431 451
432dump non character string types (for example OCTET STRING) if this 452dump non character string types (for example OCTET STRING) if this
433option is not set then non character string types will be displayed 453option is not set then non character string types will be displayed
434as though each content octet repesents a single character. 454as though each content octet represents a single character.
435 455
436=item B<dump_all> 456=item B<dump_all>
437 457
@@ -467,6 +487,11 @@ not display the field at all. B<sname> uses the "short name" form
467B<oid> represents the OID in numerical form and is useful for 487B<oid> represents the OID in numerical form and is useful for
468diagnostic purpose. 488diagnostic purpose.
469 489
490=item B<align>
491
492align field values for a more readable output. Only usable with
493B<sep_multiline>.
494
470=item B<spc_eq> 495=item B<spc_eq>
471 496
472places spaces round the B<=> character which follows the field 497places spaces round the B<=> character which follows the field
@@ -474,6 +499,87 @@ name.
474 499
475=back 500=back
476 501
502=head1 TEXT OPTIONS
503
504As well as customising the name output format, it is also possible to
505customise the actual fields printed using the B<certopt> options when
506the B<text> option is present. The default behaviour is to print all fields.
507
508=item B<compatible>
509
510use the old format. This is equivalent to specifying no output options at all.
511
512=item B<no_header>
513
514don't print header information: that is the lines saying "Certificate" and "Data".
515
516=item B<no_version>
517
518don't print out the version number.
519
520=item B<no_serial>
521
522don't print out the serial number.
523
524=item B<no_signame>
525
526don't print out the signature algorithm used.
527
528=item B<no_validity>
529
530don't print the validity, that is the B<notBefore> and B<notAfter> fields.
531
532=item B<no_subject>
533
534don't print out the subject name.
535
536=item B<no_issuer>
537
538don't print out the issuer name.
539
540=item B<no_pubkey>
541
542don't print out the public key.
543
544=item B<no_sigdump>
545
546don't give a hexadecimal dump of the certificate signature.
547
548=item B<no_aux>
549
550don't print out certificate trust information.
551
552=item B<no_extensions>
553
554don't print out any X509V3 extensions.
555
556=item B<ext_default>
557
558retain default extension behaviour: attempt to print out unsupported certificate extensions.
559
560=item B<ext_error>
561
562print an error message for unsupported certificate extensions.
563
564=item B<ext_parse>
565
566ASN1 parse unsupported extensions.
567
568=item B<ext_dump>
569
570hex dump unsupported extensions.
571
572=item B<ca_default>
573
574the value used by the B<ca> utility, equivalent to B<no_issuer>, B<no_pubkey>, B<no_header>,
575B<no_version>, B<no_sigdump> and B<no_signame>.
576
577
578
579=over 4
580
581=back
582
477=head1 EXAMPLES 583=head1 EXAMPLES
478 584
479Note: in these examples the '\' means the example should be all on one 585Note: in these examples the '\' means the example should be all on one
@@ -498,7 +604,7 @@ Display the certificate subject name in RFC2253 form:
498Display the certificate subject name in oneline form on a terminal 604Display the certificate subject name in oneline form on a terminal
499supporting UTF8: 605supporting UTF8:
500 606
501 openssl x509 -in cert.pem -noout -subject -nameopt oneline -nameopt -escmsb 607 openssl x509 -in cert.pem -noout -subject -nameopt oneline,-escmsb
502 608
503Display the certificate MD5 fingerprint: 609Display the certificate MD5 fingerprint:
504 610
diff --git a/src/lib/libssl/src/doc/crypto/BIO_f_md.pod b/src/lib/libssl/src/doc/crypto/BIO_f_md.pod
index c32504dfb1..0d24083e6d 100644
--- a/src/lib/libssl/src/doc/crypto/BIO_f_md.pod
+++ b/src/lib/libssl/src/doc/crypto/BIO_f_md.pod
@@ -28,7 +28,7 @@ BIO_gets(), if its B<size> parameter is large enough finishes the
28digest calculation and returns the digest value. BIO_puts() is 28digest calculation and returns the digest value. BIO_puts() is
29not supported. 29not supported.
30 30
31BIO_reset() reinitializes a digest BIO. 31BIO_reset() reinitialises a digest BIO.
32 32
33BIO_set_md() sets the message digest of BIO B<b> to B<md>: this 33BIO_set_md() sets the message digest of BIO B<b> to B<md>: this
34must be called to initialize a digest BIO before any data is 34must be called to initialize a digest BIO before any data is
diff --git a/src/lib/libssl/src/doc/crypto/BIO_new_bio_pair.pod b/src/lib/libssl/src/doc/crypto/BIO_new_bio_pair.pod
index 2256ba9d34..1a8dbc577b 100644
--- a/src/lib/libssl/src/doc/crypto/BIO_new_bio_pair.pod
+++ b/src/lib/libssl/src/doc/crypto/BIO_new_bio_pair.pod
@@ -12,7 +12,8 @@ BIO_new_bio_pair - create a new BIO pair
12 12
13=head1 DESCRIPTION 13=head1 DESCRIPTION
14 14
15BIO_new_bio_pair() creates a buffering BIO pair. It has two endpoints between 15BIO_new_bio_pair() creates a buffering BIO pair based on the
16L<SSL_set_bio(3)|SSL_set_bio(3)> method. The BIO pair has two endpoints between which
16data can be buffered. Its typical use is to connect one endpoint as underlying 17data can be buffered. Its typical use is to connect one endpoint as underlying
17input/output BIO to an SSL and access the other one controlled by the program 18input/output BIO to an SSL and access the other one controlled by the program
18instead of accessing the network connection directly. 19instead of accessing the network connection directly.
@@ -38,7 +39,7 @@ without having to go through the SSL-interface.
38 BIO *internal_bio, *network_bio; 39 BIO *internal_bio, *network_bio;
39 ... 40 ...
40 BIO_new_bio_pair(internal_bio, 0, network_bio, 0); 41 BIO_new_bio_pair(internal_bio, 0, network_bio, 0);
41 SSL_set_bio(ssl, internal_bio); 42 SSL_set_bio(ssl, internal_bio, internal_bio);
42 SSL_operations(); 43 SSL_operations();
43 ... 44 ...
44 45
@@ -67,7 +68,7 @@ and must be transfered to the network. Use BIO_ctrl_get_read_request() to
67find out, how many bytes must be written into the buffer before the 68find out, how many bytes must be written into the buffer before the
68SSL_operation() can successfully be continued. 69SSL_operation() can successfully be continued.
69 70
70=head1 IMPORTANT 71=head1 WARNING
71 72
72As the data is buffered, SSL_operation() may return with a ERROR_SSL_WANT_READ 73As the data is buffered, SSL_operation() may return with a ERROR_SSL_WANT_READ
73condition, but there is still data in the write buffer. An application must 74condition, but there is still data in the write buffer. An application must
diff --git a/src/lib/libssl/src/doc/crypto/BIO_s_accept.pod b/src/lib/libssl/src/doc/crypto/BIO_s_accept.pod
index c49da7fb02..55e4b730b9 100644
--- a/src/lib/libssl/src/doc/crypto/BIO_s_accept.pod
+++ b/src/lib/libssl/src/doc/crypto/BIO_s_accept.pod
@@ -10,31 +10,31 @@ BIO_get_bind_mode, BIO_do_accept - accept BIO
10 10
11 #include <openssl/bio.h> 11 #include <openssl/bio.h>
12 12
13 BIO_METHOD * BIO_s_accept(void); 13 BIO_METHOD *BIO_s_accept(void);
14 14
15 #define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name) 15 long BIO_set_accept_port(BIO *b, char *name);
16 #define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0) 16 char *BIO_get_accept_port(BIO *b);
17 17
18 BIO *BIO_new_accept(char *host_port); 18 BIO *BIO_new_accept(char *host_port);
19 19
20 #define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?"a":NULL) 20 long BIO_set_nbio_accept(BIO *b, int n);
21 #define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio) 21 long BIO_set_accept_bios(BIO *b, char *bio);
22 22
23 #define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL) 23 long BIO_set_bind_mode(BIO *b, long mode);
24 #define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL) 24 long BIO_get_bind_mode(BIO *b, long dummy);
25 25
26 #define BIO_BIND_NORMAL 0 26 #define BIO_BIND_NORMAL 0
27 #define BIO_BIND_REUSEADDR_IF_UNUSED 1 27 #define BIO_BIND_REUSEADDR_IF_UNUSED 1
28 #define BIO_BIND_REUSEADDR 2 28 #define BIO_BIND_REUSEADDR 2
29 29
30 #define BIO_do_accept(b) BIO_do_handshake(b) 30 int BIO_do_accept(BIO *b);
31 31
32=head1 DESCRIPTION 32=head1 DESCRIPTION
33 33
34BIO_s_accept() returns the accept BIO method. This is a wrapper 34BIO_s_accept() returns the accept BIO method. This is a wrapper
35round the platform's TCP/IP socket accept routines. 35round the platform's TCP/IP socket accept routines.
36 36
37Using accept BIOs TCP/IP connections can be accepted and data 37Using accept BIOs, TCP/IP connections can be accepted and data
38transferred using only BIO routines. In this way any platform 38transferred using only BIO routines. In this way any platform
39specific operations are hidden by the BIO abstraction. 39specific operations are hidden by the BIO abstraction.
40 40
@@ -92,7 +92,7 @@ BIO_do_accept() serves two functions. When it is first
92called, after the accept BIO has been setup, it will attempt 92called, after the accept BIO has been setup, it will attempt
93to create the accept socket and bind an address to it. Second 93to create the accept socket and bind an address to it. Second
94and subsequent calls to BIO_do_accept() will await an incoming 94and subsequent calls to BIO_do_accept() will await an incoming
95connection. 95connection, or request a retry in non blocking mode.
96 96
97=head1 NOTES 97=head1 NOTES
98 98
@@ -130,6 +130,17 @@ however because the accept BIO will still accept additional incoming
130connections. This can be resolved by using BIO_pop() (see above) 130connections. This can be resolved by using BIO_pop() (see above)
131and freeing up the accept BIO after the initial connection. 131and freeing up the accept BIO after the initial connection.
132 132
133If the underlying accept socket is non-blocking and BIO_do_accept() is
134called to await an incoming connection it is possible for
135BIO_should_io_special() with the reason BIO_RR_ACCEPT. If this happens
136then it is an indication that an accept attempt would block: the application
137should take appropriate action to wait until the underlying socket has
138accepted a connection and retry the call.
139
140BIO_set_accept_port(), BIO_get_accept_port(), BIO_set_nbio_accept(),
141BIO_set_accept_bios(), BIO_set_bind_mode(), BIO_get_bind_mode() and
142BIO_do_accept() are macros.
143
133=head1 RETURN VALUES 144=head1 RETURN VALUES
134 145
135TBA 146TBA
diff --git a/src/lib/libssl/src/doc/crypto/BIO_s_connect.pod b/src/lib/libssl/src/doc/crypto/BIO_s_connect.pod
index fe1aa679d4..bcf7d8dcac 100644
--- a/src/lib/libssl/src/doc/crypto/BIO_s_connect.pod
+++ b/src/lib/libssl/src/doc/crypto/BIO_s_connect.pod
@@ -13,25 +13,27 @@ BIO_set_nbio, BIO_do_connect - connect BIO
13 13
14 BIO_METHOD * BIO_s_connect(void); 14 BIO_METHOD * BIO_s_connect(void);
15 15
16 #define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name) 16 BIO *BIO_new_connect(char *name);
17 #define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port)
18 #define BIO_set_conn_ip(b,ip) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip)
19 #define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)
20 #define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
21 #define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
22 #define BIO_get_conn_ip(b,ip) BIO_ptr_ctrl(b,BIO_C_SET_CONNECT,2)
23 #define BIO_get_conn_int_port(b,port) BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,port)
24 17
25 #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) 18 long BIO_set_conn_hostname(BIO *b, char *name);
19 long BIO_set_conn_port(BIO *b, char *port);
20 long BIO_set_conn_ip(BIO *b, char *ip);
21 long BIO_set_conn_int_port(BIO *b, char *port);
22 char *BIO_get_conn_hostname(BIO *b);
23 char *BIO_get_conn_port(BIO *b);
24 char *BIO_get_conn_ip(BIO *b, dummy);
25 long BIO_get_conn_int_port(BIO *b, int port);
26 26
27 #define BIO_do_connect(b) BIO_do_handshake(b) 27 long BIO_set_nbio(BIO *b, long n);
28
29 int BIO_do_connect(BIO *b);
28 30
29=head1 DESCRIPTION 31=head1 DESCRIPTION
30 32
31BIO_s_connect() returns the connect BIO method. This is a wrapper 33BIO_s_connect() returns the connect BIO method. This is a wrapper
32round the platform's TCP/IP socket connection routines. 34round the platform's TCP/IP socket connection routines.
33 35
34Using connect BIOs TCP/IP connections can be made and data 36Using connect BIOs, TCP/IP connections can be made and data
35transferred using only BIO routines. In this way any platform 37transferred using only BIO routines. In this way any platform
36specific operations are hidden by the BIO abstraction. 38specific operations are hidden by the BIO abstraction.
37 39
@@ -54,7 +56,7 @@ BIO_get_fd() places the underlying socket in B<c> if it is not NULL,
54it also returns the socket . If B<c> is not NULL it should be of 56it also returns the socket . If B<c> is not NULL it should be of
55type (int *). 57type (int *).
56 58
57BIO_set_conn_hostname() uses the string B<name> to set the hostname 59BIO_set_conn_hostname() uses the string B<name> to set the hostname.
58The hostname can be an IP address. The hostname can also include the 60The hostname can be an IP address. The hostname can also include the
59port in the form hostname:port . It is also acceptable to use the 61port in the form hostname:port . It is also acceptable to use the
60form "hostname/any/other/path" or "hostname:port/any/other/path". 62form "hostname/any/other/path" or "hostname:port/any/other/path".
@@ -87,6 +89,9 @@ is set. Blocking I/O is the default. The call to BIO_set_nbio()
87should be made before the connection is established because 89should be made before the connection is established because
88non blocking I/O is set during the connect process. 90non blocking I/O is set during the connect process.
89 91
92BIO_new_connect() combines BIO_new() and BIO_set_conn_hostname() into
93a single call: that is it creates a new connect BIO with B<name>.
94
90BIO_do_connect() attempts to connect the supplied BIO. It returns 1 95BIO_do_connect() attempts to connect the supplied BIO. It returns 1
91if the connection was established successfully. A zero or negative 96if the connection was established successfully. A zero or negative
92value is returned if the connection could not be established, the 97value is returned if the connection could not be established, the
@@ -123,6 +128,11 @@ then this is an indication that a connection attempt would block,
123the application should then take appropriate action to wait until 128the application should then take appropriate action to wait until
124the underlying socket has connected and retry the call. 129the underlying socket has connected and retry the call.
125 130
131BIO_set_conn_hostname(), BIO_set_conn_port(), BIO_set_conn_ip(),
132BIO_set_conn_int_port(), BIO_get_conn_hostname(), BIO_get_conn_port(),
133BIO_get_conn_ip(), BIO_get_conn_int_port(), BIO_set_nbio() and
134BIO_do_connect() are macros.
135
126=head1 RETURN VALUES 136=head1 RETURN VALUES
127 137
128BIO_s_connect() returns the connect BIO method. 138BIO_s_connect() returns the connect BIO method.
diff --git a/src/lib/libssl/src/doc/crypto/BIO_s_socket.pod b/src/lib/libssl/src/doc/crypto/BIO_s_socket.pod
index 253185185c..1c8d3a9110 100644
--- a/src/lib/libssl/src/doc/crypto/BIO_s_socket.pod
+++ b/src/lib/libssl/src/doc/crypto/BIO_s_socket.pod
@@ -8,10 +8,10 @@ BIO_s_socket, BIO_new_socket - socket BIO
8 8
9 #include <openssl/bio.h> 9 #include <openssl/bio.h>
10 10
11 BIO_METHOD * BIO_s_socket(void); 11 BIO_METHOD *BIO_s_socket(void);
12 12
13 #define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd) 13 long BIO_set_fd(BIO *b, int fd, long close_flag);
14 #define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c) 14 long BIO_get_fd(BIO *b, int *c);
15 15
16 BIO *BIO_new_socket(int sock, int close_flag); 16 BIO *BIO_new_socket(int sock, int close_flag);
17 17
@@ -27,10 +27,10 @@ If the close flag is set then the socket is shut down and closed
27when the BIO is freed. 27when the BIO is freed.
28 28
29BIO_set_fd() sets the socket of BIO B<b> to B<fd> and the close 29BIO_set_fd() sets the socket of BIO B<b> to B<fd> and the close
30flag to B<c>. 30flag to B<close_flag>.
31 31
32BIO_get_fd() places the socket in B<c> if it is not NULL, it also 32BIO_get_fd() places the socket in B<c> if it is not NULL, it also
33returns the socket . If B<c> is not NULL it should be of type (int *). 33returns the socket. If B<c> is not NULL it should be of type (int *).
34 34
35BIO_new_socket() returns a socket BIO using B<sock> and B<close_flag>. 35BIO_new_socket() returns a socket BIO using B<sock> and B<close_flag>.
36 36
@@ -44,6 +44,8 @@ platforms sockets are not file descriptors and use distinct I/O routines,
44Windows is one such platform. Any code mixing the two will not work on 44Windows is one such platform. Any code mixing the two will not work on
45all platforms. 45all platforms.
46 46
47BIO_set_fd() and BIO_get_fd() are macros.
48
47=head1 RETURN VALUES 49=head1 RETURN VALUES
48 50
49BIO_s_socket() returns the socket BIO method. 51BIO_s_socket() returns the socket BIO method.
diff --git a/src/lib/libssl/src/doc/crypto/BN_add.pod b/src/lib/libssl/src/doc/crypto/BN_add.pod
index 7baed2d492..88c7a799ee 100644
--- a/src/lib/libssl/src/doc/crypto/BN_add.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_add.pod
@@ -2,8 +2,9 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5BN_add, BN_sub, BN_mul, BN_div, BN_sqr, BN_mod, BN_mod_mul, BN_exp, 5BN_add, BN_sub, BN_mul, BN_sqr, BN_div, BN_mod, BN_nnmod, BN_mod_add,
6BN_mod_exp, BN_gcd - arithmetic operations on BIGNUMs 6BN_mod_sub, BN_mod_mul, BN_mod_sqr, BN_exp, BN_mod_exp, BN_gcd -
7arithmetic operations on BIGNUMs
7 8
8=head1 SYNOPSIS 9=head1 SYNOPSIS
9 10
@@ -15,16 +16,26 @@ BN_mod_exp, BN_gcd - arithmetic operations on BIGNUMs
15 16
16 int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); 17 int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
17 18
19 int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx);
20
18 int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d, 21 int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d,
19 BN_CTX *ctx); 22 BN_CTX *ctx);
20 23
21 int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx);
22
23 int BN_mod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); 24 int BN_mod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
24 25
25 int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, 26 int BN_nnmod(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
27
28 int BN_mod_add(BIGNUM *r, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
29 BN_CTX *ctx);
30
31 int BN_mod_sub(BIGNUM *r, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
32 BN_CTX *ctx);
33
34 int BN_mod_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
26 BN_CTX *ctx); 35 BN_CTX *ctx);
27 36
37 int BN_mod_sqr(BIGNUM *r, BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
38
28 int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx); 39 int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx);
29 40
30 int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 41 int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
@@ -34,45 +45,59 @@ BN_mod_exp, BN_gcd - arithmetic operations on BIGNUMs
34 45
35=head1 DESCRIPTION 46=head1 DESCRIPTION
36 47
37BN_add() adds B<a> and B<b> and places the result in B<r> (C<r=a+b>). 48BN_add() adds I<a> and I<b> and places the result in I<r> (C<r=a+b>).
38B<r> may be the same B<BIGNUM> as B<a> or B<b>. 49I<r> may be the same B<BIGNUM> as I<a> or I<b>.
39 50
40BN_sub() subtracts B<b> from B<a> and places the result in B<r> (C<r=a-b>). 51BN_sub() subtracts I<b> from I<a> and places the result in I<r> (C<r=a-b>).
41 52
42BN_mul() multiplies B<a> and B<b> and places the result in B<r> (C<r=a*b>). 53BN_mul() multiplies I<a> and I<b> and places the result in I<r> (C<r=a*b>).
43B<r> may be the same B<BIGNUM> as B<a> or B<b>. 54I<r> may be the same B<BIGNUM> as I<a> or I<b>.
44For multiplication by powers of 2, use L<BN_lshift(3)|BN_lshift(3)>. 55For multiplication by powers of 2, use L<BN_lshift(3)|BN_lshift(3)>.
45 56
46BN_div() divides B<a> by B<d> and places the result in B<dv> and the 57BN_sqr() takes the square of I<a> and places the result in I<r>
47remainder in B<rem> (C<dv=a/d, rem=a%d>). Either of B<dv> and B<rem> may 58(C<r=a^2>). I<r> and I<a> may be the same B<BIGNUM>.
48be NULL, in which case the respective value is not returned. 59This function is faster than BN_mul(r,a,a).
60
61BN_div() divides I<a> by I<d> and places the result in I<dv> and the
62remainder in I<rem> (C<dv=a/d, rem=a%d>). Either of I<dv> and I<rem> may
63be B<NULL>, in which case the respective value is not returned.
64The result is rounded towards zero; thus if I<a> is negative, the
65remainder will be zero or negative.
49For division by powers of 2, use BN_rshift(3). 66For division by powers of 2, use BN_rshift(3).
50 67
51BN_sqr() takes the square of B<a> and places the result in B<r> 68BN_mod() corresponds to BN_div() with I<dv> set to B<NULL>.
52(C<r=a^2>). B<r> and B<a> may be the same B<BIGNUM>. 69
53This function is faster than BN_mul(r,a,a). 70BN_nnmod() reduces I<a> modulo I<m> and places the non-negative
71remainder in I<r>.
72
73BN_mod_add() adds I<a> to I<b> modulo I<m> and places the non-negative
74result in I<r>.
75
76BN_mod_sub() subtracts I<b> from I<a> modulo I<m> and places the
77non-negative result in I<r>.
54 78
55BN_mod() find the remainder of B<a> divided by B<m> and places it in 79BN_mod_mul() multiplies I<a> by I<b> and finds the non-negative
56B<rem> (C<rem=a%m>). 80remainder respective to modulus I<m> (C<r=(a*b) mod m>). I<r> may be
81the same B<BIGNUM> as I<a> or I<b>. For more efficient algorithms for
82repeated computations using the same modulus, see
83L<BN_mod_mul_montgomery(3)|BN_mod_mul_montgomery(3)> and
84L<BN_mod_mul_reciprocal(3)|BN_mod_mul_reciprocal(3)>.
57 85
58BN_mod_mul() multiplies B<a> by B<b> and finds the remainder when 86BN_mod_sqr() takes the square of I<a> modulo B<m> and places the
59divided by B<m> (C<r=(a*b)%m>). B<r> may be the same B<BIGNUM> as B<a> 87result in I<r>.
60or B<b>. For a more efficient algorithm, see
61L<BN_mod_mul_montgomery(3)|BN_mod_mul_montgomery(3)>; for repeated
62computations using the same modulus, see L<BN_mod_mul_reciprocal(3)|BN_mod_mul_reciprocal(3)>.
63 88
64BN_exp() raises B<a> to the B<p>-th power and places the result in B<r> 89BN_exp() raises I<a> to the I<p>-th power and places the result in I<r>
65(C<r=a^p>). This function is faster than repeated applications of 90(C<r=a^p>). This function is faster than repeated applications of
66BN_mul(). 91BN_mul().
67 92
68BN_mod_exp() computes B<a> to the B<p>-th power modulo B<m> (C<r=a^p % 93BN_mod_exp() computes I<a> to the I<p>-th power modulo I<m> (C<r=a^p %
69m>). This function uses less time and space than BN_exp(). 94m>). This function uses less time and space than BN_exp().
70 95
71BN_gcd() computes the greatest common divisor of B<a> and B<b> and 96BN_gcd() computes the greatest common divisor of I<a> and I<b> and
72places the result in B<r>. B<r> may be the same B<BIGNUM> as B<a> or 97places the result in I<r>. I<r> may be the same B<BIGNUM> as I<a> or
73B<b>. 98I<b>.
74 99
75For all functions, B<ctx> is a previously allocated B<BN_CTX> used for 100For all functions, I<ctx> is a previously allocated B<BN_CTX> used for
76temporary variables; see L<BN_CTX_new(3)|BN_CTX_new(3)>. 101temporary variables; see L<BN_CTX_new(3)|BN_CTX_new(3)>.
77 102
78Unless noted otherwise, the result B<BIGNUM> must be different from 103Unless noted otherwise, the result B<BIGNUM> must be different from
@@ -91,9 +116,11 @@ L<BN_add_word(3)|BN_add_word(3)>, L<BN_set_bit(3)|BN_set_bit(3)>
91 116
92=head1 HISTORY 117=head1 HISTORY
93 118
94BN_add(), BN_sub(), BN_div(), BN_sqr(), BN_mod(), BN_mod_mul(), 119BN_add(), BN_sub(), BN_sqr(), BN_div(), BN_mod(), BN_mod_mul(),
95BN_mod_exp() and BN_gcd() are available in all versions of SSLeay and 120BN_mod_exp() and BN_gcd() are available in all versions of SSLeay and
96OpenSSL. The B<ctx> argument to BN_mul() was added in SSLeay 121OpenSSL. The I<ctx> argument to BN_mul() was added in SSLeay
970.9.1b. BN_exp() appeared in SSLeay 0.9.0. 1220.9.1b. BN_exp() appeared in SSLeay 0.9.0.
123BN_nnmod(), BN_mod_add(), BN_mod_sub(), and BN_mod_sqr() were added in
124OpenSSL 0.9.7.
98 125
99=cut 126=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_bn2bin.pod b/src/lib/libssl/src/doc/crypto/BN_bn2bin.pod
index 4f78574ed0..a4b17ca60a 100644
--- a/src/lib/libssl/src/doc/crypto/BN_bn2bin.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_bn2bin.pod
@@ -49,7 +49,7 @@ with a leading '-' for negative numbers, to the B<BIO> or B<FILE>
49B<fp>. 49B<fp>.
50 50
51BN_bn2mpi() and BN_mpi2bn() convert B<BIGNUM>s from and to a format 51BN_bn2mpi() and BN_mpi2bn() convert B<BIGNUM>s from and to a format
52that consists of the number's length in bytes represented as a 3-byte 52that consists of the number's length in bytes represented as a 4-byte
53big-endian number, and the number itself in big-endian format, where 53big-endian number, and the number itself in big-endian format, where
54the most significant bit signals a negative number (the representation 54the most significant bit signals a negative number (the representation
55of numbers with the MSB set is prefixed with null byte). 55of numbers with the MSB set is prefixed with null byte).
diff --git a/src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod b/src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod
index f3cee924b9..6b16351b92 100644
--- a/src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod
@@ -36,22 +36,23 @@ using the same modulus.
36BN_MONT_CTX_new() allocates and initializes a B<BN_MONT_CTX> structure. 36BN_MONT_CTX_new() allocates and initializes a B<BN_MONT_CTX> structure.
37BN_MONT_CTX_init() initializes an existing uninitialized B<BN_MONT_CTX>. 37BN_MONT_CTX_init() initializes an existing uninitialized B<BN_MONT_CTX>.
38 38
39BN_MONT_CTX_set() sets up the B<mont> structure from the modulus B<m> 39BN_MONT_CTX_set() sets up the I<mont> structure from the modulus I<m>
40by precomputing its inverse and a value R. 40by precomputing its inverse and a value R.
41 41
42BN_MONT_CTX_copy() copies the B<BN_MONT_CTX> B<from> to B<to>. 42BN_MONT_CTX_copy() copies the B<BN_MONT_CTX> I<from> to I<to>.
43 43
44BN_MONT_CTX_free() frees the components of the B<BN_MONT_CTX>, and, if 44BN_MONT_CTX_free() frees the components of the B<BN_MONT_CTX>, and, if
45it was created by BN_MONT_CTX_new(), also the structure itself. 45it was created by BN_MONT_CTX_new(), also the structure itself.
46 46
47BN_mod_mul_montgomery() computes Mont(B<a>,B<b>):=B<a>*B<b>*R^-1 and places 47BN_mod_mul_montgomery() computes Mont(I<a>,I<b>):=I<a>*I<b>*R^-1 and places
48the result in B<r>. 48the result in I<r>.
49 49
50BN_from_montgomery() performs the Montgomery reduction B<r> = B<a>*R^-1. 50BN_from_montgomery() performs the Montgomery reduction I<r> = I<a>*R^-1.
51 51
52BN_to_montgomery() computes Mont(B<a>,R^2), i.e. B<a>*R. 52BN_to_montgomery() computes Mont(I<a>,R^2), i.e. I<a>*R.
53Note that I<a> must be non-negative and smaller than the modulus.
53 54
54For all functions, B<ctx> is a previously allocated B<BN_CTX> used for 55For all functions, I<ctx> is a previously allocated B<BN_CTX> used for
55temporary variables. 56temporary variables.
56 57
57The B<BN_MONT_CTX> structure is defined as follows: 58The B<BN_MONT_CTX> structure is defined as follows:
@@ -79,6 +80,11 @@ BN_MONT_CTX_init() and BN_MONT_CTX_free() have no return values.
79For the other functions, 1 is returned for success, 0 on error. 80For the other functions, 1 is returned for success, 0 on error.
80The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>. 81The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
81 82
83=head1 WARNING
84
85The inputs must be reduced modulo B<m>, otherwise the result will be
86outside the expected range.
87
82=head1 SEE ALSO 88=head1 SEE ALSO
83 89
84L<bn(3)|bn(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<BN_add(3)|BN_add(3)>, 90L<bn(3)|bn(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<BN_add(3)|BN_add(3)>,
diff --git a/src/lib/libssl/src/doc/crypto/BN_rand.pod b/src/lib/libssl/src/doc/crypto/BN_rand.pod
index 5406552ba4..18301a396a 100644
--- a/src/lib/libssl/src/doc/crypto/BN_rand.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_rand.pod
@@ -14,6 +14,8 @@ BN_rand, BN_pseudo_rand - generate pseudo-random number
14 14
15 int BN_rand_range(BIGNUM *rnd, BIGNUM *range); 15 int BN_rand_range(BIGNUM *rnd, BIGNUM *range);
16 16
17 int BN_pseudo_rand_range(BIGNUM *rnd, int bits, int top, int bottom);
18
17=head1 DESCRIPTION 19=head1 DESCRIPTION
18 20
19BN_rand() generates a cryptographically strong pseudo-random number of 21BN_rand() generates a cryptographically strong pseudo-random number of
@@ -31,6 +33,8 @@ protocols, but usually not for key generation etc.
31 33
32BN_rand_range() generates a cryptographically strong pseudo-random 34BN_rand_range() generates a cryptographically strong pseudo-random
33number B<rnd> in the range 0 <lt>= B<rnd> E<lt> B<range>. 35number B<rnd> in the range 0 <lt>= B<rnd> E<lt> B<range>.
36BN_pseudo_rand_range() does the same, but is based on BN_pseudo_rand(),
37and hence numbers generated by it are not necessarily unpredictable.
34 38
35The PRNG must be seeded prior to calling BN_rand() or BN_rand_range(). 39The PRNG must be seeded prior to calling BN_rand() or BN_rand_range().
36 40
@@ -49,5 +53,6 @@ L<RAND_add(3)|RAND_add(3)>, L<RAND_bytes(3)|RAND_bytes(3)>
49BN_rand() is available in all versions of SSLeay and OpenSSL. 53BN_rand() is available in all versions of SSLeay and OpenSSL.
50BN_pseudo_rand() was added in OpenSSL 0.9.5. The B<top> == -1 case 54BN_pseudo_rand() was added in OpenSSL 0.9.5. The B<top> == -1 case
51and the function BN_rand_range() were added in OpenSSL 0.9.6a. 55and the function BN_rand_range() were added in OpenSSL 0.9.6a.
56BN_pseudo_rand_range() was added in OpenSSL 0.9.6c.
52 57
53=cut 58=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_swap.pod b/src/lib/libssl/src/doc/crypto/BN_swap.pod
new file mode 100644
index 0000000000..79efaa1446
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_swap.pod
@@ -0,0 +1,23 @@
1=pod
2
3=head1 NAME
4
5BN_swap - exchange BIGNUMs
6
7=head1 SYNOPSIS
8
9 #include <openssl/bn.h>
10
11 void BN_swap(BIGNUM *a, BIGNUM *b);
12
13=head1 DESCRIPTION
14
15BN_swap() exchanges the values of I<a> and I<b>.
16
17L<bn(3)|bn(3)>
18
19=head1 HISTORY
20
21BN_swap was added in OpenSSL 0.9.7.
22
23=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_zero.pod b/src/lib/libssl/src/doc/crypto/BN_zero.pod
index 2f33876498..3c64a65697 100644
--- a/src/lib/libssl/src/doc/crypto/BN_zero.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_zero.pod
@@ -12,7 +12,7 @@ operations
12 int BN_zero(BIGNUM *a); 12 int BN_zero(BIGNUM *a);
13 int BN_one(BIGNUM *a); 13 int BN_one(BIGNUM *a);
14 14
15 BIGNUM *BN_value_one(void); 15 const BIGNUM *BN_value_one(void);
16 16
17 int BN_set_word(BIGNUM *a, unsigned long w); 17 int BN_set_word(BIGNUM *a, unsigned long w);
18 unsigned long BN_get_word(BIGNUM *a); 18 unsigned long BN_get_word(BIGNUM *a);
diff --git a/src/lib/libssl/src/doc/crypto/DH_set_method.pod b/src/lib/libssl/src/doc/crypto/DH_set_method.pod
index 62088eea1b..d990bf8786 100644
--- a/src/lib/libssl/src/doc/crypto/DH_set_method.pod
+++ b/src/lib/libssl/src/doc/crypto/DH_set_method.pod
@@ -82,8 +82,8 @@ the default engine for Diffie-Hellman opertaions is used.
82 82
83=head1 RETURN VALUES 83=head1 RETURN VALUES
84 84
85DH_OpenSSL() and DH_get_default_method() return pointers to the respective 85DH_OpenSSL() and DH_get_default_openssl_method() return pointers to the
86DH_METHODs. 86respective B<DH_METHOD>s.
87 87
88DH_set_default_openssl_method() returns no value. 88DH_set_default_openssl_method() returns no value.
89 89
diff --git a/src/lib/libssl/src/doc/crypto/DSA_set_method.pod b/src/lib/libssl/src/doc/crypto/DSA_set_method.pod
index c56dfd0f47..36a1052d27 100644
--- a/src/lib/libssl/src/doc/crypto/DSA_set_method.pod
+++ b/src/lib/libssl/src/doc/crypto/DSA_set_method.pod
@@ -90,7 +90,7 @@ struct
90=head1 RETURN VALUES 90=head1 RETURN VALUES
91 91
92DSA_OpenSSL() and DSA_get_default_openssl_method() return pointers to the 92DSA_OpenSSL() and DSA_get_default_openssl_method() return pointers to the
93respective DSA_METHODs. 93respective B<DSA_METHOD>s.
94 94
95DSA_set_default_openssl_method() returns no value. 95DSA_set_default_openssl_method() returns no value.
96 96
diff --git a/src/lib/libssl/src/doc/crypto/ERR_get_error.pod b/src/lib/libssl/src/doc/crypto/ERR_get_error.pod
index 3551bacb8d..9fdedbcb91 100644
--- a/src/lib/libssl/src/doc/crypto/ERR_get_error.pod
+++ b/src/lib/libssl/src/doc/crypto/ERR_get_error.pod
@@ -2,8 +2,10 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5ERR_get_error, ERR_peek_error, ERR_get_error_line, ERR_peek_error_line, 5ERR_get_error, ERR_peek_error, ERR_peek_last_error,
6ERR_get_error_line_data, ERR_peek_error_line_data - obtain error code and data 6ERR_get_error_line, ERR_peek_error_line, ERR_peek_last_error_line,
7ERR_get_error_line_data, ERR_peek_error_line_data,
8ERR_peek_error_line_data - obtain error code and data
7 9
8=head1 SYNOPSIS 10=head1 SYNOPSIS
9 11
@@ -11,22 +13,29 @@ ERR_get_error_line_data, ERR_peek_error_line_data - obtain error code and data
11 13
12 unsigned long ERR_get_error(void); 14 unsigned long ERR_get_error(void);
13 unsigned long ERR_peek_error(void); 15 unsigned long ERR_peek_error(void);
16 unsigned long ERR_peek_last_error(void);
14 17
15 unsigned long ERR_get_error_line(const char **file, int *line); 18 unsigned long ERR_get_error_line(const char **file, int *line);
16 unsigned long ERR_peek_error_line(const char **file, int *line); 19 unsigned long ERR_peek_error_line(const char **file, int *line);
20 unsigned long ERR_peek_last_error_line(const char **file, int *line);
17 21
18 unsigned long ERR_get_error_line_data(const char **file, int *line, 22 unsigned long ERR_get_error_line_data(const char **file, int *line,
19 const char **data, int *flags); 23 const char **data, int *flags);
20 unsigned long ERR_peek_error_line_data(const char **file, int *line, 24 unsigned long ERR_peek_error_line_data(const char **file, int *line,
21 const char **data, int *flags); 25 const char **data, int *flags);
26 unsigned long ERR_peek_last_error_line_data(const char **file, int *line,
27 const char **data, int *flags);
22 28
23=head1 DESCRIPTION 29=head1 DESCRIPTION
24 30
25ERR_get_error() returns the last error code from the thread's error 31ERR_get_error() returns the earliest error code from the thread's error
26queue and removes the entry. This function can be called repeatedly 32queue and removes the entry. This function can be called repeatedly
27until there are no more error codes to return. 33until there are no more error codes to return.
28 34
29ERR_peek_error() returns the last error code from the thread's 35ERR_peek_error() returns the earliest error code from the thread's
36error queue without modifying it.
37
38ERR_peek_last_error() returns the latest error code from the thread's
30error queue without modifying it. 39error queue without modifying it.
31 40
32See L<ERR_GET_LIB(3)|ERR_GET_LIB(3)> for obtaining information about 41See L<ERR_GET_LIB(3)|ERR_GET_LIB(3)> for obtaining information about
@@ -34,12 +43,14 @@ location and reason of the error, and
34L<ERR_error_string(3)|ERR_error_string(3)> for human-readable error 43L<ERR_error_string(3)|ERR_error_string(3)> for human-readable error
35messages. 44messages.
36 45
37ERR_get_error_line() and ERR_peek_error_line() are the same as the 46ERR_get_error_line(), ERR_peek_error_line() and
38above, but they additionally store the file name and line number where 47ERR_peek_last_error_line() are the same as the above, but they
48additionally store the file name and line number where
39the error occurred in *B<file> and *B<line>, unless these are B<NULL>. 49the error occurred in *B<file> and *B<line>, unless these are B<NULL>.
40 50
41ERR_get_error_line_data() and ERR_peek_error_line_data() store 51ERR_get_error_line_data(), ERR_peek_error_line_data() and
42additional data and flags associated with the error code in *B<data> 52ERR_get_last_error_line_data() store additional data and flags
53associated with the error code in *B<data>
43and *B<flags>, unless these are B<NULL>. *B<data> contains a string 54and *B<flags>, unless these are B<NULL>. *B<data> contains a string
44if *B<flags>&B<ERR_TXT_STRING>. If it has been allocated by OPENSSL_malloc(), 55if *B<flags>&B<ERR_TXT_STRING>. If it has been allocated by OPENSSL_malloc(),
45*B<flags>&B<ERR_TXT_MALLOCED> is true. 56*B<flags>&B<ERR_TXT_MALLOCED> is true.
@@ -59,5 +70,7 @@ ERR_get_error(), ERR_peek_error(), ERR_get_error_line() and
59ERR_peek_error_line() are available in all versions of SSLeay and 70ERR_peek_error_line() are available in all versions of SSLeay and
60OpenSSL. ERR_get_error_line_data() and ERR_peek_error_line_data() 71OpenSSL. ERR_get_error_line_data() and ERR_peek_error_line_data()
61were added in SSLeay 0.9.0. 72were added in SSLeay 0.9.0.
73ERR_peek_last_error(), ERR_peek_last_error_line() and
74ERR_peek_last_error_line_data() were added in OpenSSL 0.9.7.
62 75
63=cut 76=cut
diff --git a/src/lib/libssl/src/doc/crypto/EVP_BytesToKey.pod b/src/lib/libssl/src/doc/crypto/EVP_BytesToKey.pod
new file mode 100644
index 0000000000..5ce4add082
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/EVP_BytesToKey.pod
@@ -0,0 +1,67 @@
1=pod
2
3=head1 NAME
4
5 EVP_BytesToKey - password based encryption routine
6
7=head1 SYNOPSIS
8
9 #include <openssl/evp.h>
10
11 int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md,
12 const unsigned char *salt,
13 const unsigned char *data, int datal, int count,
14 unsigned char *key,unsigned char *iv);
15
16=head1 DESCRIPTION
17
18EVP_BytesToKey() derives a key and IV from various parameters. B<type> is
19the cipher to derive the key and IV for. B<md> is the message digest to use.
20The B<salt> paramter is used as a salt in the derivation: it should point to
21an 8 byte buffer or NULL if no salt is used. B<data> is a buffer containing
22B<datal> bytes which is used to derive the keying data. B<count> is the
23iteration count to use. The derived key and IV will be written to B<key>
24and B<iv> respectively.
25
26=head1 NOTES
27
28A typical application of this function is to derive keying material for an
29encryption algorithm from a password in the B<data> parameter.
30
31Increasing the B<count> parameter slows down the algorithm which makes it
32harder for an attacker to peform a brute force attack using a large number
33of candidate passwords.
34
35If the total key and IV length is less than the digest length and
36B<MD5> is used then the derivation algorithm is compatible with PKCS#5 v1.5
37otherwise a non standard extension is used to derive the extra data.
38
39Newer applications should use more standard algorithms such as PKCS#5
40v2.0 for key derivation.
41
42=head1 KEY DERIVATION ALGORITHM
43
44The key and IV is derived by concatenating D_1, D_2, etc until
45enough data is available for the key and IV. D_i is defined as:
46
47 D_i = HASH^count(D_(i-1) || data || salt)
48
49where || denotes concatentaion, D_0 is empty, HASH is the digest
50algorithm in use, HASH^1(data) is simply HASH(data), HASH^2(data)
51is HASH(HASH(data)) and so on.
52
53The initial bytes are used for the key and the subsequent bytes for
54the IV.
55
56=head1 RETURN VALUES
57
58EVP_BytesToKey() returns the size of the derived key in bytes.
59
60=head1 SEE ALSO
61
62L<evp(3)|evp(3)>, L<rand(3)|rand(3)>,
63L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>,
64
65=head1 HISTORY
66
67=cut
diff --git a/src/lib/libssl/src/doc/crypto/EVP_DigestInit.pod b/src/lib/libssl/src/doc/crypto/EVP_DigestInit.pod
index fefc858f7e..acd4d0167a 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_DigestInit.pod
+++ b/src/lib/libssl/src/doc/crypto/EVP_DigestInit.pod
@@ -2,9 +2,10 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5EVP_DigestInit, EVP_DigestUpdate, EVP_DigestFinal, EVP_MAX_MD_SIZE, 5EVP_MD_CTX_init, EVP_MD_CTX_create, EVP_DigestInit_ex, EVP_DigestUpdate,
6EVP_MD_CTX_copy, EVP_MD_type, EVP_MD_pkey_type, EVP_MD_size, EVP_MD_block_size, 6EVP_DigestFinal_ex, EVP_MD_CTX_cleanup, EVP_MD_CTX_destroy, EVP_MAX_MD_SIZE,
7EVP_MD_CTX_md, EVP_MD_CTX_size, EVP_MD_CTX_block_size, EVP_MD_CTX_type, 7EVP_MD_CTX_copy_ex EVP_MD_CTX_copy, EVP_MD_type, EVP_MD_pkey_type, EVP_MD_size,
8EVP_MD_block_size, EVP_MD_CTX_md, EVP_MD_CTX_size, EVP_MD_CTX_block_size, EVP_MD_CTX_type,
8EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_dss, EVP_dss1, EVP_mdc2, 9EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_dss, EVP_dss1, EVP_mdc2,
9EVP_ripemd160, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj - 10EVP_ripemd160, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj -
10EVP digest routines 11EVP digest routines
@@ -13,15 +14,28 @@ EVP digest routines
13 14
14 #include <openssl/evp.h> 15 #include <openssl/evp.h>
15 16
16 void EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); 17 void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
17 void EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); 18 EVP_MD_CTX *EVP_MD_CTX_create(void);
18 void EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, 19
20 int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
21 int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
22 int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md,
19 unsigned int *s); 23 unsigned int *s);
20 24
21 #define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */ 25 int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
26 void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
27
28 int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in);
29
30 int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
31 int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md,
32 unsigned int *s);
22 33
23 int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in); 34 int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in);
24 35
36 #define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */
37
38
25 #define EVP_MD_type(e) ((e)->type) 39 #define EVP_MD_type(e) ((e)->type)
26 #define EVP_MD_pkey_type(e) ((e)->pkey_type) 40 #define EVP_MD_pkey_type(e) ((e)->pkey_type)
27 #define EVP_MD_size(e) ((e)->md_size) 41 #define EVP_MD_size(e) ((e)->md_size)
@@ -32,15 +46,15 @@ EVP digest routines
32 #define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest) 46 #define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest)
33 #define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest) 47 #define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest)
34 48
35 EVP_MD *EVP_md_null(void); 49 const EVP_MD *EVP_md_null(void);
36 EVP_MD *EVP_md2(void); 50 const EVP_MD *EVP_md2(void);
37 EVP_MD *EVP_md5(void); 51 const EVP_MD *EVP_md5(void);
38 EVP_MD *EVP_sha(void); 52 const EVP_MD *EVP_sha(void);
39 EVP_MD *EVP_sha1(void); 53 const EVP_MD *EVP_sha1(void);
40 EVP_MD *EVP_dss(void); 54 const EVP_MD *EVP_dss(void);
41 EVP_MD *EVP_dss1(void); 55 const EVP_MD *EVP_dss1(void);
42 EVP_MD *EVP_mdc2(void); 56 const EVP_MD *EVP_mdc2(void);
43 EVP_MD *EVP_ripemd160(void); 57 const EVP_MD *EVP_ripemd160(void);
44 58
45 const EVP_MD *EVP_get_digestbyname(const char *name); 59 const EVP_MD *EVP_get_digestbyname(const char *name);
46 #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) 60 #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
@@ -50,25 +64,48 @@ EVP digest routines
50 64
51The EVP digest routines are a high level interface to message digests. 65The EVP digest routines are a high level interface to message digests.
52 66
53EVP_DigestInit() initializes a digest context B<ctx> to use a digest 67EVP_MD_CTX_init() initializes digest contet B<ctx>.
54B<type>: this will typically be supplied by a function such as 68
55EVP_sha1(). 69EVP_MD_CTX_create() allocates, initializes and returns a digest contet.
70
71EVP_DigestInit_ex() sets up digest context B<ctx> to use a digest
72B<type> from ENGINE B<impl>. B<ctx> must be initialized before calling this
73function. B<type> will typically be supplied by a functionsuch as EVP_sha1().
74If B<impl> is NULL then the default implementation of digest B<type> is used.
56 75
57EVP_DigestUpdate() hashes B<cnt> bytes of data at B<d> into the 76EVP_DigestUpdate() hashes B<cnt> bytes of data at B<d> into the
58digest context B<ctx>. This function can be called several times on the 77digest context B<ctx>. This function can be called several times on the
59same B<ctx> to hash additional data. 78same B<ctx> to hash additional data.
60 79
61EVP_DigestFinal() retrieves the digest value from B<ctx> and places 80EVP_DigestFinal_ex() retrieves the digest value from B<ctx> and places
62it in B<md>. If the B<s> parameter is not NULL then the number of 81it in B<md>. If the B<s> parameter is not NULL then the number of
63bytes of data written (i.e. the length of the digest) will be written 82bytes of data written (i.e. the length of the digest) will be written
64to the integer at B<s>, at most B<EVP_MAX_MD_SIZE> bytes will be written. 83to the integer at B<s>, at most B<EVP_MAX_MD_SIZE> bytes will be written.
65After calling EVP_DigestFinal() no additional calls to EVP_DigestUpdate() 84After calling EVP_DigestFinal_ex() no additional calls to EVP_DigestUpdate()
66can be made, but EVP_DigestInit() can be called to initialize a new 85can be made, but EVP_DigestInit_ex() can be called to initialize a new
67digest operation. 86digest operation.
68 87
69EVP_MD_CTX_copy() can be used to copy the message digest state from 88EVP_MD_CTX_cleanup() cleans up digest context B<ctx>, it should be called
89after a digest context is no longer needed.
90
91EVP_MD_CTX_destroy() cleans up digest context B<ctx> and frees up the
92space allocated to it, it should be called only on a context created
93using EVP_MD_CTX_create().
94
95EVP_MD_CTX_copy_ex() can be used to copy the message digest state from
70B<in> to B<out>. This is useful if large amounts of data are to be 96B<in> to B<out>. This is useful if large amounts of data are to be
71hashed which only differ in the last few bytes. 97hashed which only differ in the last few bytes. B<out> must be initialized
98before calling this function.
99
100EVP_DigestInit() behaves in the same way as EVP_DigestInit_ex() except
101the passed context B<ctx> does not have to be initialized, and it always
102uses the default digest implementation.
103
104EVP_DigestFinal() is similar to EVP_DigestFinal_ex() except the digest
105contet B<ctx> is automatically cleaned up.
106
107EVP_MD_CTX_copy() is similar to EVP_MD_CTX_copy_ex() except the destination
108B<out> does not have to be initialized.
72 109
73EVP_MD_size() and EVP_MD_CTX_size() return the size of the message digest 110EVP_MD_size() and EVP_MD_CTX_size() return the size of the message digest
74when passed an B<EVP_MD> or an B<EVP_MD_CTX> structure, i.e. the size of the 111when passed an B<EVP_MD> or an B<EVP_MD_CTX> structure, i.e. the size of the
@@ -107,9 +144,10 @@ using, for example, OpenSSL_add_all_digests() for these functions to work.
107 144
108=head1 RETURN VALUES 145=head1 RETURN VALUES
109 146
110EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() do not return values. 147EVP_DigestInit_ex(), EVP_DigestUpdate() and EVP_DigestFinal_ex() return 1 for
148success and 0 for failure.
111 149
112EVP_MD_CTX_copy() returns 1 if successful or 0 for failure. 150EVP_MD_CTX_copy_ex() returns 1 if successful or 0 for failure.
113 151
114EVP_MD_type(), EVP_MD_pkey_type() and EVP_MD_type() return the NID of the 152EVP_MD_type(), EVP_MD_pkey_type() and EVP_MD_type() return the NID of the
115corresponding OBJECT IDENTIFIER or NID_undef if none exists. 153corresponding OBJECT IDENTIFIER or NID_undef if none exists.
@@ -134,6 +172,19 @@ transparent to the digest used and much more flexible.
134SHA1 is the digest of choice for new applications. The other digest algorithms 172SHA1 is the digest of choice for new applications. The other digest algorithms
135are still in common use. 173are still in common use.
136 174
175For most applications the B<impl> parameter to EVP_DigestInit_ex() will be
176set to NULL to use the default digest implementation.
177
178The functions EVP_DigestInit(), EVP_DigestFinal() and EVP_MD_CTX_copy() are
179obsolete but are retained to maintain compatibility with existing code. New
180applications should use EVP_DigestInit_ex(), EVP_DigestFinal_ex() and
181EVP_MD_CTX_copy_ex() because they can efficiently reuse a digest context
182instead of initializing and cleaning it up on each call and allow non default
183implementations of digests to be specified.
184
185In OpenSSL 0.9.7 and later if digest contexts are not cleaned up after use
186memory leaks will occur.
187
137=head1 EXAMPLE 188=head1 EXAMPLE
138 189
139This example digests the data "Test Message\n" and "Hello World\n", using the 190This example digests the data "Test Message\n" and "Hello World\n", using the
@@ -165,10 +216,12 @@ digest name passed on the command line.
165 exit(1); 216 exit(1);
166 } 217 }
167 218
168 EVP_DigestInit(&mdctx, md); 219 EVP_MD_CTX_init(&mdctx);
220 EVP_DigestInit_ex(&mdctx, md, NULL);
169 EVP_DigestUpdate(&mdctx, mess1, strlen(mess1)); 221 EVP_DigestUpdate(&mdctx, mess1, strlen(mess1));
170 EVP_DigestUpdate(&mdctx, mess2, strlen(mess2)); 222 EVP_DigestUpdate(&mdctx, mess2, strlen(mess2));
171 EVP_DigestFinal(&mdctx, md_value, &md_len); 223 EVP_DigestFinal_ex(&mdctx, md_value, &md_len);
224 EVP_MD_CTX_cleanup(&mdctx);
172 225
173 printf("Digest is: "); 226 printf("Digest is: ");
174 for(i = 0; i < md_len; i++) printf("%02x", md_value[i]); 227 for(i = 0; i < md_len; i++) printf("%02x", md_value[i]);
@@ -177,17 +230,10 @@ digest name passed on the command line.
177 230
178=head1 BUGS 231=head1 BUGS
179 232
180Several of the functions do not return values: maybe they should. Although the
181internal digest operations will never fail some future hardware based operations
182might.
183
184The link between digests and signing algorithms results in a situation where 233The link between digests and signing algorithms results in a situation where
185EVP_sha1() must be used with RSA and EVP_dss1() must be used with DSS 234EVP_sha1() must be used with RSA and EVP_dss1() must be used with DSS
186even though they are identical digests. 235even though they are identical digests.
187 236
188The size of an B<EVP_MD_CTX> structure is determined at compile time: this results
189in code that must be recompiled if the size of B<EVP_MD_CTX> increases.
190
191=head1 SEE ALSO 237=head1 SEE ALSO
192 238
193L<evp(3)|evp(3)>, L<HMAC(3)|HMAC(3)>, L<MD2(3)|MD2(3)>, 239L<evp(3)|evp(3)>, L<HMAC(3)|HMAC(3)>, L<MD2(3)|MD2(3)>,
@@ -199,4 +245,7 @@ L<SHA1(3)|SHA1(3)>
199EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() are 245EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() are
200available in all versions of SSLeay and OpenSSL. 246available in all versions of SSLeay and OpenSSL.
201 247
248EVP_DigestInit_ex(), EVP_DigestFinal_ex() and EVP_MD_CTX_copy_ex()
249were added in OpenSSL 0.9.7.
250
202=cut 251=cut
diff --git a/src/lib/libssl/src/doc/crypto/EVP_EncryptInit.pod b/src/lib/libssl/src/doc/crypto/EVP_EncryptInit.pod
index 9afe2396e2..371b6a2287 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_EncryptInit.pod
+++ b/src/lib/libssl/src/doc/crypto/EVP_EncryptInit.pod
@@ -2,43 +2,65 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5EVP_EncryptInit, EVP_EncryptUpdate, EVP_EncryptFinal, EVP_DecryptInit, 5EVP_CIPHER_CTX_init, EVP_EncryptInit_ex, EVP_EncryptUpdate,
6EVP_DecryptUpdate, EVP_DecryptFinal, EVP_CipherInit, EVP_CipherUpdate, 6EVP_EncryptFinal_ex, EVP_DecryptInit_ex, EVP_DecryptUpdate,
7EVP_CipherFinal, EVP_CIPHER_CTX_set_key_length, EVP_CIPHER_CTX_ctrl, 7EVP_DecryptFinal_ex, EVP_CipherInit_ex, EVP_CipherUpdate,
8EVP_CIPHER_CTX_cleanup, EVP_get_cipherbyname, EVP_get_cipherbynid, 8EVP_CipherFinal_ex, EVP_CIPHER_CTX_set_key_length,
9EVP_get_cipherbyobj, EVP_CIPHER_nid, EVP_CIPHER_block_size, 9EVP_CIPHER_CTX_ctrl, EVP_CIPHER_CTX_cleanup, EVP_EncryptInit,
10EVP_CIPHER_key_length, EVP_CIPHER_iv_length, EVP_CIPHER_flags, 10EVP_EncryptFinal, EVP_DecryptInit, EVP_DecryptFinal,
11EVP_CIPHER_mode, EVP_CIPHER_type, EVP_CIPHER_CTX_cipher, EVP_CIPHER_CTX_nid, 11EVP_CipherInit, EVP_CipherFinal, EVP_get_cipherbyname,
12EVP_CIPHER_CTX_block_size, EVP_CIPHER_CTX_key_length, EVP_CIPHER_CTX_iv_length, 12EVP_get_cipherbynid, EVP_get_cipherbyobj, EVP_CIPHER_nid,
13EVP_CIPHER_CTX_get_app_data, EVP_CIPHER_CTX_set_app_data, EVP_CIPHER_CTX_type, 13EVP_CIPHER_block_size, EVP_CIPHER_key_length, EVP_CIPHER_iv_length,
14EVP_CIPHER_CTX_flags, EVP_CIPHER_CTX_mode, EVP_CIPHER_param_to_asn1, 14EVP_CIPHER_flags, EVP_CIPHER_mode, EVP_CIPHER_type, EVP_CIPHER_CTX_cipher,
15EVP_CIPHER_asn1_to_param - EVP cipher routines 15EVP_CIPHER_CTX_nid, EVP_CIPHER_CTX_block_size, EVP_CIPHER_CTX_key_length,
16EVP_CIPHER_CTX_iv_length, EVP_CIPHER_CTX_get_app_data,
17EVP_CIPHER_CTX_set_app_data, EVP_CIPHER_CTX_type, EVP_CIPHER_CTX_flags,
18EVP_CIPHER_CTX_mode, EVP_CIPHER_param_to_asn1, EVP_CIPHER_asn1_to_param,
19EVP_CIPHER_CTX_set_padding - EVP cipher routines
16 20
17=head1 SYNOPSIS 21=head1 SYNOPSIS
18 22
19 #include <openssl/evp.h> 23 #include <openssl/evp.h>
20 24
21 int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, 25 int EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
22 unsigned char *key, unsigned char *iv); 26
27 int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
28 ENGINE *impl, unsigned char *key, unsigned char *iv);
23 int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, 29 int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
24 int *outl, unsigned char *in, int inl); 30 int *outl, unsigned char *in, int inl);
31 int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out,
32 int *outl);
33
34 int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
35 ENGINE *impl, unsigned char *key, unsigned char *iv);
36 int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
37 int *outl, unsigned char *in, int inl);
38 int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,
39 int *outl);
40
41 int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
42 ENGINE *impl, unsigned char *key, unsigned char *iv, int enc);
43 int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
44 int *outl, unsigned char *in, int inl);
45 int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,
46 int *outl);
47
48 int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
49 unsigned char *key, unsigned char *iv);
25 int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, 50 int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,
26 int *outl); 51 int *outl);
27 52
28 int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, 53 int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
29 unsigned char *key, unsigned char *iv); 54 unsigned char *key, unsigned char *iv);
30 int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
31 int *outl, unsigned char *in, int inl);
32 int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, 55 int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
33 int *outl); 56 int *outl);
34 57
35 int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, 58 int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
36 unsigned char *key, unsigned char *iv, int enc); 59 unsigned char *key, unsigned char *iv, int enc);
37 int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
38 int *outl, unsigned char *in, int inl);
39 int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, 60 int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
40 int *outl); 61 int *outl);
41 62
63 int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *x, int padding);
42 int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); 64 int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
43 int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); 65 int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
44 int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a); 66 int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
@@ -74,14 +96,19 @@ EVP_CIPHER_asn1_to_param - EVP cipher routines
74The EVP cipher routines are a high level interface to certain 96The EVP cipher routines are a high level interface to certain
75symmetric ciphers. 97symmetric ciphers.
76 98
77EVP_EncryptInit() initializes a cipher context B<ctx> for encryption 99EVP_CIPHER_CTX_init() initializes cipher contex B<ctx>.
78with cipher B<type>. B<type> is normally supplied by a function such 100
79as EVP_des_cbc() . B<key> is the symmetric key to use and B<iv> is the 101EVP_EncryptInit_ex() sets up cipher context B<ctx> for encryption
80IV to use (if necessary), the actual number of bytes used for the 102with cipher B<type> from ENGINE B<impl>. B<ctx> must be initialized
81key and IV depends on the cipher. It is possible to set all parameters 103before calling this function. B<type> is normally supplied
82to NULL except B<type> in an initial call and supply the remaining 104by a function such as EVP_des_cbc(). If B<impl> is NULL then the
83parameters in subsequent calls, all of which have B<type> set to NULL. 105default implementation is used. B<key> is the symmetric key to use
84This is done when the default cipher parameters are not appropriate. 106and B<iv> is the IV to use (if necessary), the actual number of bytes
107used for the key and IV depends on the cipher. It is possible to set
108all parameters to NULL except B<type> in an initial call and supply
109the remaining parameters in subsequent calls, all of which have B<type>
110set to NULL. This is done when the default cipher parameters are not
111appropriate.
85 112
86EVP_EncryptUpdate() encrypts B<inl> bytes from the buffer B<in> and 113EVP_EncryptUpdate() encrypts B<inl> bytes from the buffer B<in> and
87writes the encrypted version to B<out>. This function can be called 114writes the encrypted version to B<out>. This function can be called
@@ -89,32 +116,49 @@ multiple times to encrypt successive blocks of data. The amount
89of data written depends on the block alignment of the encrypted data: 116of data written depends on the block alignment of the encrypted data:
90as a result the amount of data written may be anything from zero bytes 117as a result the amount of data written may be anything from zero bytes
91to (inl + cipher_block_size - 1) so B<outl> should contain sufficient 118to (inl + cipher_block_size - 1) so B<outl> should contain sufficient
92room. The actual number of bytes written is placed in B<outl>. 119room. The actual number of bytes written is placed in B<outl>.
120
121If padding is enabled (the default) then EVP_EncryptFinal_ex() encrypts
122the "final" data, that is any data that remains in a partial block.
123It uses L<standard block padding|/NOTES> (aka PKCS padding). The encrypted
124final data is written to B<out> which should have sufficient space for
125one cipher block. The number of bytes written is placed in B<outl>. After
126this function is called the encryption operation is finished and no further
127calls to EVP_EncryptUpdate() should be made.
93 128
94EVP_EncryptFinal() encrypts the "final" data, that is any data that 129If padding is disabled then EVP_EncryptFinal_ex() will not encrypt any more
95remains in a partial block. It uses L<standard block padding|/NOTES> (aka PKCS 130data and it will return an error if any data remains in a partial block:
96padding). The encrypted final data is written to B<out> which should 131that is if the total data length is not a multiple of the block size.
97have sufficient space for one cipher block. The number of bytes written
98is placed in B<outl>. After this function is called the encryption operation
99is finished and no further calls to EVP_EncryptUpdate() should be made.
100 132
101EVP_DecryptInit(), EVP_DecryptUpdate() and EVP_DecryptFinal() are the 133EVP_DecryptInit_ex(), EVP_DecryptUpdate() and EVP_DecryptFinal_ex() are the
102corresponding decryption operations. EVP_DecryptFinal() will return an 134corresponding decryption operations. EVP_DecryptFinal() will return an
103error code if the final block is not correctly formatted. The parameters 135error code if padding is enabled and the final block is not correctly
104and restrictions are identical to the encryption operations except that 136formatted. The parameters and restrictions are identical to the encryption
105the decrypted data buffer B<out> passed to EVP_DecryptUpdate() should 137operations except that if padding is enabled the decrypted data buffer B<out>
106have sufficient room for (B<inl> + cipher_block_size) bytes unless the 138passed to EVP_DecryptUpdate() should have sufficient room for
107cipher block size is 1 in which case B<inl> bytes is sufficient. 139(B<inl> + cipher_block_size) bytes unless the cipher block size is 1 in
108 140which case B<inl> bytes is sufficient.
109EVP_CipherInit(), EVP_CipherUpdate() and EVP_CipherFinal() are functions 141
110that can be used for decryption or encryption. The operation performed 142EVP_CipherInit_ex(), EVP_CipherUpdate() and EVP_CipherFinal_ex() are
111depends on the value of the B<enc> parameter. It should be set to 1 for 143functions that can be used for decryption or encryption. The operation
112encryption, 0 for decryption and -1 to leave the value unchanged (the 144performed depends on the value of the B<enc> parameter. It should be set
113actual value of 'enc' being supplied in a previous call). 145to 1 for encryption, 0 for decryption and -1 to leave the value unchanged
114 146(the actual value of 'enc' being supplied in a previous call).
115EVP_CIPHER_CTX_cleanup() clears all information from a cipher context. 147
116It should be called after all operations using a cipher are complete 148EVP_CIPHER_CTX_cleanup() clears all information from a cipher context
117so sensitive information does not remain in memory. 149and free up any allocated memory associate with it. It should be called
150after all operations using a cipher are complete so sensitive information
151does not remain in memory.
152
153EVP_EncryptInit(), EVP_DecryptInit() and EVP_CipherInit() behave in a
154similar way to EVP_EncryptInit_ex(), EVP_DecryptInit_ex and
155EVP_CipherInit_ex() except the B<ctx> paramter does not need to be
156initialized and they always use the default cipher implementation.
157
158EVP_EncryptFinal(), EVP_DecryptFinal() and EVP_CipherFinal() behave in a
159similar way to EVP_EncryptFinal_ex(), EVP_DecryptFinal_ex() and
160EVP_CipherFinal_ex() except B<ctx> is automatically cleaned up
161after the call.
118 162
119EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj() 163EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj()
120return an EVP_CIPHER structure when passed a cipher name, a NID or an 164return an EVP_CIPHER structure when passed a cipher name, a NID or an
@@ -125,6 +169,13 @@ passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX> structure. The actual NID
125value is an internal value which may not have a corresponding OBJECT 169value is an internal value which may not have a corresponding OBJECT
126IDENTIFIER. 170IDENTIFIER.
127 171
172EVP_CIPHER_CTX_set_padding() enables or disables padding. By default
173encryption operations are padded using standard block padding and the
174padding is checked and removed when decrypting. If the B<pad> parameter
175is zero then no padding is performed, the total amount of data encrypted
176or decrypted must then be a multiple of the block size or an error will
177occur.
178
128EVP_CIPHER_key_length() and EVP_CIPHER_CTX_key_length() return the key 179EVP_CIPHER_key_length() and EVP_CIPHER_CTX_key_length() return the key
129length of a cipher when passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX> 180length of a cipher when passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX>
130structure. The constant B<EVP_MAX_KEY_LENGTH> is the maximum key length 181structure. The constant B<EVP_MAX_KEY_LENGTH> is the maximum key length
@@ -185,14 +236,14 @@ RC5 can be set.
185 236
186=head1 RETURN VALUES 237=head1 RETURN VALUES
187 238
188EVP_EncryptInit(), EVP_EncryptUpdate() and EVP_EncryptFinal() return 1 for success 239EVP_CIPHER_CTX_init, EVP_EncryptInit_ex(), EVP_EncryptUpdate() and
189and 0 for failure. 240EVP_EncryptFinal_ex() return 1 for success and 0 for failure.
190 241
191EVP_DecryptInit() and EVP_DecryptUpdate() return 1 for success and 0 for failure. 242EVP_DecryptInit_ex() and EVP_DecryptUpdate() return 1 for success and 0 for failure.
192EVP_DecryptFinal() returns 0 if the decrypt failed or 1 for success. 243EVP_DecryptFinal_ex() returns 0 if the decrypt failed or 1 for success.
193 244
194EVP_CipherInit() and EVP_CipherUpdate() return 1 for success and 0 for failure. 245EVP_CipherInit_ex() and EVP_CipherUpdate() return 1 for success and 0 for failure.
195EVP_CipherFinal() returns 1 for a decryption failure or 1 for success. 246EVP_CipherFinal_ex() returns 0 for a decryption failure or 1 for success.
196 247
197EVP_CIPHER_CTX_cleanup() returns 1 for success and 0 for failure. 248EVP_CIPHER_CTX_cleanup() returns 1 for success and 0 for failure.
198 249
@@ -207,6 +258,8 @@ size.
207EVP_CIPHER_key_length() and EVP_CIPHER_CTX_key_length() return the key 258EVP_CIPHER_key_length() and EVP_CIPHER_CTX_key_length() return the key
208length. 259length.
209 260
261EVP_CIPHER_CTX_set_padding() always returns 1.
262
210EVP_CIPHER_iv_length() and EVP_CIPHER_CTX_iv_length() return the IV 263EVP_CIPHER_iv_length() and EVP_CIPHER_CTX_iv_length() return the IV
211length or zero if the cipher does not use an IV. 264length or zero if the cipher does not use an IV.
212 265
@@ -301,25 +354,26 @@ encrypted then 5 padding bytes of value 5 will be added.
301 354
302When decrypting the final block is checked to see if it has the correct form. 355When decrypting the final block is checked to see if it has the correct form.
303 356
304Although the decryption operation can produce an error, it is not a strong 357Although the decryption operation can produce an error if padding is enabled,
305test that the input data or key is correct. A random block has better than 358it is not a strong test that the input data or key is correct. A random block
3061 in 256 chance of being of the correct format and problems with the 359has better than 1 in 256 chance of being of the correct format and problems with
307input data earlier on will not produce a final decrypt error. 360the input data earlier on will not produce a final decrypt error.
308 361
309The functions EVP_EncryptInit(), EVP_EncryptUpdate(), EVP_EncryptFinal(), 362If padding is disabled then the decryption operation will always succeed if
310EVP_DecryptInit(), EVP_DecryptUpdate(), EVP_CipherInit() and EVP_CipherUpdate() 363the total amount of data decrypted is a multiple of the block size.
311and EVP_CIPHER_CTX_cleanup() did not return errors in OpenSSL version 0.9.5a or 364
312earlier. Software only versions of encryption algorithms will never return 365The functions EVP_EncryptInit(), EVP_EncryptFinal(), EVP_DecryptInit(),
313error codes for these functions, unless there is a programming error (for example 366EVP_CipherInit() and EVP_CipherFinal() are obsolete but are retained for
314and attempt to set the key before the cipher is set in EVP_EncryptInit() ). 367compatibility with existing code. New code should use EVP_EncryptInit_ex(),
368EVP_EncryptFinal_ex(), EVP_DecryptInit_ex(), EVP_DecryptFinal_ex(),
369EVP_CipherInit_ex() and EVP_CipherFinal_ex() because they can reuse an
370existing context without allocating and freeing it up on each call.
315 371
316=head1 BUGS 372=head1 BUGS
317 373
318For RC5 the number of rounds can currently only be set to 8, 12 or 16. This is 374For RC5 the number of rounds can currently only be set to 8, 12 or 16. This is
319a limitation of the current RC5 code rather than the EVP interface. 375a limitation of the current RC5 code rather than the EVP interface.
320 376
321It should be possible to disable PKCS padding: currently it isn't.
322
323EVP_MAX_KEY_LENGTH and EVP_MAX_IV_LENGTH only refer to the internal ciphers with 377EVP_MAX_KEY_LENGTH and EVP_MAX_IV_LENGTH only refer to the internal ciphers with
324default key lengths. If custom ciphers exceed these values the results are 378default key lengths. If custom ciphers exceed these values the results are
325unpredictable. This is because it has become standard practice to define a 379unpredictable. This is because it has become standard practice to define a
@@ -333,22 +387,113 @@ for certain common S/MIME ciphers (RC2, DES, triple DES) in CBC mode.
333Get the number of rounds used in RC5: 387Get the number of rounds used in RC5:
334 388
335 int nrounds; 389 int nrounds;
336 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC5_ROUNDS, 0, &i); 390 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC5_ROUNDS, 0, &nrounds);
337 391
338Get the RC2 effective key length: 392Get the RC2 effective key length:
339 393
340 int key_bits; 394 int key_bits;
341 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC2_KEY_BITS, 0, &i); 395 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC2_KEY_BITS, 0, &key_bits);
342 396
343Set the number of rounds used in RC5: 397Set the number of rounds used in RC5:
344 398
345 int nrounds; 399 int nrounds;
346 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC5_ROUNDS, i, NULL); 400 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC5_ROUNDS, nrounds, NULL);
347 401
348Set the number of rounds used in RC2: 402Set the effective key length used in RC2:
403
404 int key_bits;
405 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL);
406
407Encrypt a string using blowfish:
408
409 int do_crypt(char *outfile)
410 {
411 unsigned char outbuf[1024];
412 int outlen, tmplen;
413 /* Bogus key and IV: we'd normally set these from
414 * another source.
415 */
416 unsigned char key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
417 unsigned char iv[] = {1,2,3,4,5,6,7,8};
418 char intext[] = "Some Crypto Text";
419 EVP_CIPHER_CTX ctx;
420 FILE *out;
421 EVP_CIPHER_CTX_init(&ctx);
422 EVP_EncryptInit_ex(&ctx, NULL, EVP_bf_cbc(), key, iv);
423
424 if(!EVP_EncryptUpdate(&ctx, outbuf, &outlen, intext, strlen(intext)))
425 {
426 /* Error */
427 return 0;
428 }
429 /* Buffer passed to EVP_EncryptFinal() must be after data just
430 * encrypted to avoid overwriting it.
431 */
432 if(!EVP_EncryptFinal_ex(&ctx, outbuf + outlen, &tmplen))
433 {
434 /* Error */
435 return 0;
436 }
437 outlen += tmplen;
438 EVP_CIPHER_CTX_cleanup(&ctx);
439 /* Need binary mode for fopen because encrypted data is
440 * binary data. Also cannot use strlen() on it because
441 * it wont be null terminated and may contain embedded
442 * nulls.
443 */
444 out = fopen(outfile, "wb");
445 fwrite(outbuf, 1, outlen, out);
446 fclose(out);
447 return 1;
448 }
449
450The ciphertext from the above example can be decrypted using the B<openssl>
451utility with the command line:
452
453 S<openssl bf -in cipher.bin -K 000102030405060708090A0B0C0D0E0F -iv 0102030405060708 -d>
454
455General encryption, decryption function example using FILE I/O and RC2 with an
45680 bit key:
457
458 int do_crypt(FILE *in, FILE *out, int do_encrypt)
459 {
460 /* Allow enough space in output buffer for additional block */
461 inbuf[1024], outbuf[1024 + EVP_MAX_BLOCK_LENGTH];
462 int inlen, outlen;
463 /* Bogus key and IV: we'd normally set these from
464 * another source.
465 */
466 unsigned char key[] = "0123456789";
467 unsigned char iv[] = "12345678";
468 /* Don't set key or IV because we will modify the parameters */
469 EVP_CIPHER_CTX_init(&ctx);
470 EVP_CipherInit_ex(&ctx, EVP_rc2(), NULL, NULL, NULL, do_encrypt);
471 EVP_CIPHER_CTX_set_key_length(&ctx, 10);
472 /* We finished modifying parameters so now we can set key and IV */
473 EVP_CipherInit_ex(&ctx, NULL, NULL, key, iv, do_encrypt);
474
475 for(;;)
476 {
477 inlen = fread(inbuf, 1, 1024, in);
478 if(inlen <= 0) break;
479 if(!EVP_CipherUpdate(&ctx, outbuf, &outlen, inbuf, inlen))
480 {
481 /* Error */
482 return 0;
483 }
484 fwrite(outbuf, 1, outlen, out);
485 }
486 if(!EVP_CipherFinal_ex(&ctx, outbuf, &outlen))
487 {
488 /* Error */
489 return 0;
490 }
491 fwrite(outbuf, 1, outlen, out);
492
493 EVP_CIPHER_CTX_cleanup(&ctx);
494 return 1;
495 }
349 496
350 int nrounds;
351 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC2_KEY_BITS, i, NULL);
352 497
353=head1 SEE ALSO 498=head1 SEE ALSO
354 499
diff --git a/src/lib/libssl/src/doc/crypto/EVP_SignInit.pod b/src/lib/libssl/src/doc/crypto/EVP_SignInit.pod
index d5ce245ecd..b1ac129430 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_SignInit.pod
+++ b/src/lib/libssl/src/doc/crypto/EVP_SignInit.pod
@@ -8,10 +8,12 @@ EVP_SignInit, EVP_SignUpdate, EVP_SignFinal - EVP signing functions
8 8
9 #include <openssl/evp.h> 9 #include <openssl/evp.h>
10 10
11 void EVP_SignInit(EVP_MD_CTX *ctx, const EVP_MD *type); 11 int EVP_SignInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
12 void EVP_SignUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); 12 int EVP_SignUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
13 int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *sig,unsigned int *s, EVP_PKEY *pkey); 13 int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *sig,unsigned int *s, EVP_PKEY *pkey);
14 14
15 void EVP_SignInit(EVP_MD_CTX *ctx, const EVP_MD *type);
16
15 int EVP_PKEY_size(EVP_PKEY *pkey); 17 int EVP_PKEY_size(EVP_PKEY *pkey);
16 18
17=head1 DESCRIPTION 19=head1 DESCRIPTION
@@ -19,9 +21,9 @@ EVP_SignInit, EVP_SignUpdate, EVP_SignFinal - EVP signing functions
19The EVP signature routines are a high level interface to digital 21The EVP signature routines are a high level interface to digital
20signatures. 22signatures.
21 23
22EVP_SignInit() initializes a signing context B<ctx> to using digest 24EVP_SignInit_ex() sets up signing context B<ctx> to use digest
23B<type>: this will typically be supplied by a function such as 25B<type> from ENGINE B<impl>. B<ctx> must be initialized with
24EVP_sha1(). 26EVP_MD_CTX_init() before calling this function.
25 27
26EVP_SignUpdate() hashes B<cnt> bytes of data at B<d> into the 28EVP_SignUpdate() hashes B<cnt> bytes of data at B<d> into the
27signature context B<ctx>. This function can be called several times on the 29signature context B<ctx>. This function can be called several times on the
@@ -31,18 +33,18 @@ EVP_SignFinal() signs the data in B<ctx> using the private key B<pkey>
31and places the signature in B<sig>. If the B<s> parameter is not NULL 33and places the signature in B<sig>. If the B<s> parameter is not NULL
32then the number of bytes of data written (i.e. the length of the signature) 34then the number of bytes of data written (i.e. the length of the signature)
33will be written to the integer at B<s>, at most EVP_PKEY_size(pkey) bytes 35will be written to the integer at B<s>, at most EVP_PKEY_size(pkey) bytes
34will be written. After calling EVP_SignFinal() no additional calls to 36will be written.
35EVP_SignUpdate() can be made, but EVP_SignInit() can be called to initialize 37
36a new signature operation. 38EVP_SignInit() initializes a signing context B<ctx> to use the default
39implementation of digest B<type>.
37 40
38EVP_PKEY_size() returns the maximum size of a signature in bytes. The actual 41EVP_PKEY_size() returns the maximum size of a signature in bytes. The actual
39signature returned by EVP_SignFinal() may be smaller. 42signature returned by EVP_SignFinal() may be smaller.
40 43
41=head1 RETURN VALUES 44=head1 RETURN VALUES
42 45
43EVP_SignInit() and EVP_SignUpdate() do not return values. 46EVP_SignInit_ex(), EVP_SignUpdate() and EVP_SignFinal() return 1
44 47for success and 0 for failure.
45EVP_SignFinal() returns 1 for success and 0 for failure.
46 48
47EVP_PKEY_size() returns the maximum size of a signature in bytes. 49EVP_PKEY_size() returns the maximum size of a signature in bytes.
48 50
@@ -63,11 +65,18 @@ When signing with DSA private keys the random number generator must be seeded
63or the operation will fail. The random number generator does not need to be 65or the operation will fail. The random number generator does not need to be
64seeded for RSA signatures. 66seeded for RSA signatures.
65 67
68The call to EVP_SignFinal() internally finalizes a copy of the digest context.
69This means that calls to EVP_SignUpdate() and EVP_SignFinal() can be called
70later to digest and sign additional data.
71
72Since only a copy of the digest context is ever finalized the context must
73be cleaned up after use by calling EVP_MD_CTX_cleanup() or a memory leak
74will occur.
75
66=head1 BUGS 76=head1 BUGS
67 77
68Several of the functions do not return values: maybe they should. Although the 78Older versions of this documentation wrongly stated that calls to
69internal digest operations will never fail some future hardware based operations 79EVP_SignUpdate() could not be made after calling EVP_SignFinal().
70might.
71 80
72=head1 SEE ALSO 81=head1 SEE ALSO
73 82
@@ -82,4 +91,6 @@ L<SHA1(3)|SHA1(3)>, L<digest(1)|digest(1)>
82EVP_SignInit(), EVP_SignUpdate() and EVP_SignFinal() are 91EVP_SignInit(), EVP_SignUpdate() and EVP_SignFinal() are
83available in all versions of SSLeay and OpenSSL. 92available in all versions of SSLeay and OpenSSL.
84 93
94EVP_SignInit_ex() was added in OpenSSL 0.9.7
95
85=cut 96=cut
diff --git a/src/lib/libssl/src/doc/crypto/EVP_VerifyInit.pod b/src/lib/libssl/src/doc/crypto/EVP_VerifyInit.pod
index 736a0f4a82..80c656fde8 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_VerifyInit.pod
+++ b/src/lib/libssl/src/doc/crypto/EVP_VerifyInit.pod
@@ -8,30 +8,35 @@ EVP_VerifyInit, EVP_VerifyUpdate, EVP_VerifyFinal - EVP signature verification f
8 8
9 #include <openssl/evp.h> 9 #include <openssl/evp.h>
10 10
11 void EVP_VerifyInit(EVP_MD_CTX *ctx, const EVP_MD *type); 11 int EVP_VerifyInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
12 void EVP_VerifyUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); 12 int EVP_VerifyUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
13 int EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf, unsigned int siglen,EVP_PKEY *pkey); 13 int EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf, unsigned int siglen,EVP_PKEY *pkey);
14 14
15 int EVP_VerifyInit(EVP_MD_CTX *ctx, const EVP_MD *type);
16
15=head1 DESCRIPTION 17=head1 DESCRIPTION
16 18
17The EVP signature verification routines are a high level interface to digital 19The EVP signature verification routines are a high level interface to digital
18signatures. 20signatures.
19 21
20EVP_VerifyInit() initializes a verification context B<ctx> to using digest 22EVP_VerifyInit_ex() sets up verification context B<ctx> to use digest
21B<type>: this will typically be supplied by a function such as EVP_sha1(). 23B<type> from ENGINE B<impl>. B<ctx> must be initialized by calling
24EVP_MD_CTX_init() before calling this function.
22 25
23EVP_VerifyUpdate() hashes B<cnt> bytes of data at B<d> into the 26EVP_VerifyUpdate() hashes B<cnt> bytes of data at B<d> into the
24verification context B<ctx>. This function can be called several times on the 27verification context B<ctx>. This function can be called several times on the
25same B<ctx> to include additional data. 28same B<ctx> to include additional data.
26 29
27EVP_VerifyFinal() verifies the data in B<ctx> using the public key B<pkey> 30EVP_VerifyFinal() verifies the data in B<ctx> using the public key B<pkey>
28and against the B<siglen> bytes at B<sigbuf>. After calling EVP_VerifyFinal() 31and against the B<siglen> bytes at B<sigbuf>.
29no additional calls to EVP_VerifyUpdate() can be made, but EVP_VerifyInit() 32
30can be called to initialize a new verification operation. 33EVP_VerifyInit() initializes verification context B<ctx> to use the default
34implementation of digest B<type>.
31 35
32=head1 RETURN VALUES 36=head1 RETURN VALUES
33 37
34EVP_VerifyInit() and EVP_VerifyUpdate() do not return values. 38EVP_VerifyInit_ex() and EVP_VerifyUpdate() return 1 for success and 0 for
39failure.
35 40
36EVP_VerifyFinal() returns 1 for a correct signature, 0 for failure and -1 if some 41EVP_VerifyFinal() returns 1 for a correct signature, 0 for failure and -1 if some
37other error occurred. 42other error occurred.
@@ -49,11 +54,18 @@ digest algorithm must be used with the correct public key type. A list of
49algorithms and associated public key algorithms appears in 54algorithms and associated public key algorithms appears in
50L<EVP_DigestInit(3)|EVP_DigestInit(3)>. 55L<EVP_DigestInit(3)|EVP_DigestInit(3)>.
51 56
57The call to EVP_VerifyFinal() internally finalizes a copy of the digest context.
58This means that calls to EVP_VerifyUpdate() and EVP_VerifyFinal() can be called
59later to digest and verify additional data.
60
61Since only a copy of the digest context is ever finalized the context must
62be cleaned up after use by calling EVP_MD_CTX_cleanup() or a memory leak
63will occur.
64
52=head1 BUGS 65=head1 BUGS
53 66
54Several of the functions do not return values: maybe they should. Although the 67Older versions of this documentation wrongly stated that calls to
55internal digest operations will never fail some future hardware based operations 68EVP_VerifyUpdate() could not be made after calling EVP_VerifyFinal().
56might.
57 69
58=head1 SEE ALSO 70=head1 SEE ALSO
59 71
@@ -69,4 +81,6 @@ L<sha(3)|sha(3)>, L<digest(1)|digest(1)>
69EVP_VerifyInit(), EVP_VerifyUpdate() and EVP_VerifyFinal() are 81EVP_VerifyInit(), EVP_VerifyUpdate() and EVP_VerifyFinal() are
70available in all versions of SSLeay and OpenSSL. 82available in all versions of SSLeay and OpenSSL.
71 83
84EVP_VerifyInit_ex() was added in OpenSSL 0.9.7
85
72=cut 86=cut
diff --git a/src/lib/libssl/src/doc/crypto/OPENSSL_VERSION_NUMBER.pod b/src/lib/libssl/src/doc/crypto/OPENSSL_VERSION_NUMBER.pod
index 68ea723259..c39ac35e78 100644
--- a/src/lib/libssl/src/doc/crypto/OPENSSL_VERSION_NUMBER.pod
+++ b/src/lib/libssl/src/doc/crypto/OPENSSL_VERSION_NUMBER.pod
@@ -2,7 +2,7 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5OPENSSL_VERSION_NUMBER, SSLeay SSLeay_version - get OpenSSL version number 5OPENSSL_VERSION_NUMBER, SSLeay, SSLeay_version - get OpenSSL version number
6 6
7=head1 SYNOPSIS 7=head1 SYNOPSIS
8 8
@@ -11,7 +11,7 @@ OPENSSL_VERSION_NUMBER, SSLeay SSLeay_version - get OpenSSL version number
11 11
12 #include <openssl/crypto.h> 12 #include <openssl/crypto.h>
13 long SSLeay(void); 13 long SSLeay(void);
14 char *SSLeay_version(int t); 14 const char *SSLeay_version(int t);
15 15
16=head1 DESCRIPTION 16=head1 DESCRIPTION
17 17
@@ -55,20 +55,32 @@ SSLeay_version() returns different strings depending on B<t>:
55=over 4 55=over 4
56 56
57=item SSLEAY_VERSION 57=item SSLEAY_VERSION
58
58The text variant of the version number and the release date. For example, 59The text variant of the version number and the release date. For example,
59"OpenSSL 0.9.5a 1 Apr 2000". 60"OpenSSL 0.9.5a 1 Apr 2000".
60 61
61=item SSLEAY_CFLAGS 62=item SSLEAY_CFLAGS
62The flags given to the C compiler when compiling OpenSSL are returned in a 63
63string. 64The compiler flags set for the compilation process in the form
65"compiler: ..." if available or "compiler: information not available"
66otherwise.
67
68=item SSLEAY_BUILT_ON
69
70The date of the build process in the form "built on: ..." if available
71or "built on: date not available" otherwise.
64 72
65=item SSLEAY_PLATFORM 73=item SSLEAY_PLATFORM
66The platform name used when OpenSSL was configured is returned.
67 74
68=back 75The "Configure" target of the library build in the form "platform: ..."
76if available or "platform: information not available" otherwise.
77
78=item SSLEAY_DIR
69 79
70If the data request isn't available, a text saying that the information is 80The "OPENSSLDIR" setting of the library build in the form "OPENSSLDIR: "...""
71not available is returned. 81if available or "OPENSSLDIR: N/A" otherwise.
82
83=back
72 84
73For an unknown B<t>, the text "not available" is returned. 85For an unknown B<t>, the text "not available" is returned.
74 86
@@ -84,5 +96,6 @@ L<crypto(3)|crypto(3)>
84 96
85SSLeay() and SSLEAY_VERSION_NUMBER are available in all versions of SSLeay and OpenSSL. 97SSLeay() and SSLEAY_VERSION_NUMBER are available in all versions of SSLeay and OpenSSL.
86OPENSSL_VERSION_NUMBER is available in all versions of OpenSSL. 98OPENSSL_VERSION_NUMBER is available in all versions of OpenSSL.
99B<SSLEAY_DIR> was added in OpenSSL 0.9.7.
87 100
88=cut 101=cut
diff --git a/src/lib/libssl/src/doc/crypto/RAND_egd.pod b/src/lib/libssl/src/doc/crypto/RAND_egd.pod
index 71cab3ca04..62adbe19b2 100644
--- a/src/lib/libssl/src/doc/crypto/RAND_egd.pod
+++ b/src/lib/libssl/src/doc/crypto/RAND_egd.pod
@@ -11,6 +11,8 @@ RAND_egd - query entropy gathering daemon
11 int RAND_egd(const char *path); 11 int RAND_egd(const char *path);
12 int RAND_egd_bytes(const char *path, int bytes); 12 int RAND_egd_bytes(const char *path, int bytes);
13 13
14 int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
15
14=head1 DESCRIPTION 16=head1 DESCRIPTION
15 17
16RAND_egd() queries the entropy gathering daemon EGD on socket B<path>. 18RAND_egd() queries the entropy gathering daemon EGD on socket B<path>.
@@ -27,6 +29,11 @@ be generated, it is not necessary to request the full amount 255 bytes from
27the EGD socket. This can be advantageous, since the amount of entropy 29the EGD socket. This can be advantageous, since the amount of entropy
28that can be retrieved from EGD over time is limited. 30that can be retrieved from EGD over time is limited.
29 31
32RAND_query_egd_bytes() performs the actual query of the EGD daemon on socket
33B<path>. If B<buf> is given, B<bytes> bytes are queried and written into
34B<buf>. If B<buf> is NULL, B<bytes> bytes are queried and used to seed the
35OpenSSL built-in PRNG using L<RAND_add(3)|RAND_add(3)>.
36
30=head1 NOTES 37=head1 NOTES
31 38
32On systems without /dev/*random devices providing entropy from the kernel, 39On systems without /dev/*random devices providing entropy from the kernel,
@@ -47,12 +54,19 @@ http://www.aet.tu-cottbus.de/personen/jaenicke/postfix_tls/prngd.html .
47PRNGD does employ an internal PRNG itself and can therefore never run 54PRNGD does employ an internal PRNG itself and can therefore never run
48out of entropy. 55out of entropy.
49 56
57OpenSSL automatically queries EGD when entropy is requested via RAND_bytes()
58or the status is checked via RAND_status() for the first time, if the socket
59is located at /var/run/egd-pool, /dev/egd-pool or /etc/egd-pool.
60
50=head1 RETURN VALUE 61=head1 RETURN VALUE
51 62
52RAND_egd() and RAND_egd_bytes() return the number of bytes read from the 63RAND_egd() and RAND_egd_bytes() return the number of bytes read from the
53daemon on success, and -1 if the connection failed or the daemon did not 64daemon on success, and -1 if the connection failed or the daemon did not
54return enough data to fully seed the PRNG. 65return enough data to fully seed the PRNG.
55 66
67RAND_query_egd_bytes() returns the number of bytes read from the daemon on
68success, and -1 if the connection failed. The PRNG state is not considered.
69
56=head1 SEE ALSO 70=head1 SEE ALSO
57 71
58L<rand(3)|rand(3)>, L<RAND_add(3)|RAND_add(3)>, 72L<rand(3)|rand(3)>, L<RAND_add(3)|RAND_add(3)>,
@@ -64,4 +78,8 @@ RAND_egd() is available since OpenSSL 0.9.5.
64 78
65RAND_egd_bytes() is available since OpenSSL 0.9.6. 79RAND_egd_bytes() is available since OpenSSL 0.9.6.
66 80
81RAND_query_egd_bytes() is available since OpenSSL 0.9.7.
82
83The automatic query of /var/run/egd-pool et al was added in OpenSSL 0.9.7.
84
67=cut 85=cut
diff --git a/src/lib/libssl/src/doc/crypto/RSA_generate_key.pod b/src/lib/libssl/src/doc/crypto/RSA_generate_key.pod
index 0e0f0a764c..11bc0b3459 100644
--- a/src/lib/libssl/src/doc/crypto/RSA_generate_key.pod
+++ b/src/lib/libssl/src/doc/crypto/RSA_generate_key.pod
@@ -19,7 +19,7 @@ be seeded prior to calling RSA_generate_key().
19 19
20The modulus size will be B<num> bits, and the public exponent will be 20The modulus size will be B<num> bits, and the public exponent will be
21B<e>. Key sizes with B<num> E<lt> 1024 should be considered insecure. 21B<e>. Key sizes with B<num> E<lt> 1024 should be considered insecure.
22The exponent is an odd number, typically 3 or 65535. 22The exponent is an odd number, typically 3, 17 or 65537.
23 23
24A callback function may be used to provide feedback about the 24A callback function may be used to provide feedback about the
25progress of the key generation. If B<callback> is not B<NULL>, it 25progress of the key generation. If B<callback> is not B<NULL>, it
diff --git a/src/lib/libssl/src/doc/crypto/RSA_public_encrypt.pod b/src/lib/libssl/src/doc/crypto/RSA_public_encrypt.pod
index 23861c0004..8022a23f99 100644
--- a/src/lib/libssl/src/doc/crypto/RSA_public_encrypt.pod
+++ b/src/lib/libssl/src/doc/crypto/RSA_public_encrypt.pod
@@ -74,10 +74,6 @@ SSL, PKCS #1 v2.0
74 74
75L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_size(3)|RSA_size(3)> 75L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_size(3)|RSA_size(3)>
76 76
77=head1 NOTES
78
79The L<RSA_PKCS1_RSAref(3)|RSA_PKCS1_RSAref(3)> method supports only the RSA_PKCS1_PADDING mode.
80
81=head1 HISTORY 77=head1 HISTORY
82 78
83The B<padding> argument was added in SSLeay 0.8. RSA_NO_PADDING is 79The B<padding> argument was added in SSLeay 0.8. RSA_NO_PADDING is
diff --git a/src/lib/libssl/src/doc/crypto/RSA_set_method.pod b/src/lib/libssl/src/doc/crypto/RSA_set_method.pod
index b672712292..14917dd35f 100644
--- a/src/lib/libssl/src/doc/crypto/RSA_set_method.pod
+++ b/src/lib/libssl/src/doc/crypto/RSA_set_method.pod
@@ -3,7 +3,7 @@
3=head1 NAME 3=head1 NAME
4 4
5RSA_set_default_method, RSA_get_default_method, RSA_set_method, 5RSA_set_default_method, RSA_get_default_method, RSA_set_method,
6RSA_get_method, RSA_PKCS1_SSLeay, RSA_PKCS1_RSAref, 6RSA_get_method, RSA_PKCS1_SSLeay,
7RSA_null_method, RSA_flags, RSA_new_method - select RSA method 7RSA_null_method, RSA_flags, RSA_new_method - select RSA method
8 8
9=head1 SYNOPSIS 9=head1 SYNOPSIS
@@ -15,14 +15,12 @@ RSA_null_method, RSA_flags, RSA_new_method - select RSA method
15 15
16 RSA_METHOD *RSA_get_default_openssl_method(void); 16 RSA_METHOD *RSA_get_default_openssl_method(void);
17 17
18 RSA_METHOD *RSA_set_method(RSA *rsa, ENGINE *engine); 18 int RSA_set_method(RSA *rsa, ENGINE *engine);
19 19
20 RSA_METHOD *RSA_get_method(RSA *rsa); 20 RSA_METHOD *RSA_get_method(RSA *rsa);
21 21
22 RSA_METHOD *RSA_PKCS1_SSLeay(void); 22 RSA_METHOD *RSA_PKCS1_SSLeay(void);
23 23
24 RSA_METHOD *RSA_PKCS1_RSAref(void);
25
26 RSA_METHOD *RSA_null_method(void); 24 RSA_METHOD *RSA_null_method(void);
27 25
28 int RSA_flags(RSA *rsa); 26 int RSA_flags(RSA *rsa);
@@ -35,17 +33,8 @@ An B<RSA_METHOD> specifies the functions that OpenSSL uses for RSA
35operations. By modifying the method, alternative implementations 33operations. By modifying the method, alternative implementations
36such as hardware accelerators may be used. 34such as hardware accelerators may be used.
37 35
38Initially, the default is to use the OpenSSL internal implementation, 36Initially, the default is to use the OpenSSL internal implementation.
39unless OpenSSL was configured with the C<rsaref> or C<-DRSA_NULL> 37RSA_PKCS1_SSLeay() returns a pointer to that method.
40options. RSA_PKCS1_SSLeay() returns a pointer to that method.
41
42RSA_PKCS1_RSAref() returns a pointer to a method that uses the RSAref
43library. This is the default method in the C<rsaref> configuration;
44the function is not available in other configurations.
45RSA_null_method() returns a pointer to a method that does not support
46the RSA transformation. It is the default if OpenSSL is compiled with
47C<-DRSA_NULL>. These methods may be useful in the USA because of a
48patent on the RSA cryptosystem.
49 38
50RSA_set_default_openssl_method() makes B<meth> the default method for all B<RSA> 39RSA_set_default_openssl_method() makes B<meth> the default method for all B<RSA>
51structures created later. B<NB:> This is true only whilst the default engine 40structures created later. B<NB:> This is true only whilst the default engine
@@ -132,9 +121,8 @@ the default engine for RSA operations is used.
132 121
133=head1 RETURN VALUES 122=head1 RETURN VALUES
134 123
135RSA_PKCS1_SSLeay(), RSA_PKCS1_RSAref(), RSA_PKCS1_null_method(), 124RSA_PKCS1_SSLeay(), RSA_PKCS1_null_method(), RSA_get_default_openssl_method()
136RSA_get_default_openssl_method() and RSA_get_method() return pointers to 125and RSA_get_method() return pointers to the respective RSA_METHODs.
137the respective RSA_METHODs.
138 126
139RSA_set_default_openssl_method() returns no value. 127RSA_set_default_openssl_method() returns no value.
140 128
@@ -163,6 +151,6 @@ added in OpenSSL 0.9.4.
163RSA_set_default_openssl_method() and RSA_get_default_openssl_method() 151RSA_set_default_openssl_method() and RSA_get_default_openssl_method()
164replaced RSA_set_default_method() and RSA_get_default_method() respectively, 152replaced RSA_set_default_method() and RSA_get_default_method() respectively,
165and RSA_set_method() and RSA_new_method() were altered to use B<ENGINE>s 153and RSA_set_method() and RSA_new_method() were altered to use B<ENGINE>s
166rather than B<DH_METHOD>s during development of OpenSSL 0.9.6. 154rather than B<RSA_METHOD>s during development of OpenSSL 0.9.6.
167 155
168=cut 156=cut
diff --git a/src/lib/libssl/src/doc/crypto/blowfish.pod b/src/lib/libssl/src/doc/crypto/blowfish.pod
index 65b8be388c..ed71334f56 100644
--- a/src/lib/libssl/src/doc/crypto/blowfish.pod
+++ b/src/lib/libssl/src/doc/crypto/blowfish.pod
@@ -27,7 +27,7 @@ BF_cfb64_encrypt, BF_ofb64_encrypt, BF_options - Blowfish encryption
27 27
28=head1 DESCRIPTION 28=head1 DESCRIPTION
29 29
30This library implements the Blowfish cipher, which is invented and described 30This library implements the Blowfish cipher, which was invented and described
31by Counterpane (see http://www.counterpane.com/blowfish.html ). 31by Counterpane (see http://www.counterpane.com/blowfish.html ).
32 32
33Blowfish is a block cipher that operates on 64 bit (8 byte) blocks of data. 33Blowfish is a block cipher that operates on 64 bit (8 byte) blocks of data.
@@ -57,7 +57,7 @@ for the same message. B<ivec> may be initialized with anything, but the
57recipient needs to know what it was initialized with, or it won't be able 57recipient needs to know what it was initialized with, or it won't be able
58to decrypt. Some programs and protocols simplify this, like SSH, where 58to decrypt. Some programs and protocols simplify this, like SSH, where
59B<ivec> is simply initialized to zero. 59B<ivec> is simply initialized to zero.
60BF_cbc_encrypt() operates of data that is a multiple of 8 bytes long, while 60BF_cbc_encrypt() operates on data that is a multiple of 8 bytes long, while
61BF_cfb64_encrypt() and BF_ofb64_encrypt() are used to encrypt an variable 61BF_cfb64_encrypt() and BF_ofb64_encrypt() are used to encrypt an variable
62number of bytes (the amount does not have to be an exact multiple of 8). The 62number of bytes (the amount does not have to be an exact multiple of 8). The
63purpose of the latter two is to simulate stream ciphers, and therefore, they 63purpose of the latter two is to simulate stream ciphers, and therefore, they
diff --git a/src/lib/libssl/src/doc/crypto/bn.pod b/src/lib/libssl/src/doc/crypto/bn.pod
index d183028d61..210dfeac08 100644
--- a/src/lib/libssl/src/doc/crypto/bn.pod
+++ b/src/lib/libssl/src/doc/crypto/bn.pod
@@ -21,19 +21,27 @@ bn - multiprecision integer arithmetics
21 BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); 21 BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
22 BIGNUM *BN_dup(const BIGNUM *a); 22 BIGNUM *BN_dup(const BIGNUM *a);
23 23
24 BIGNUM *BN_swap(BIGNUM *a, BIGNUM *b);
25
24 int BN_num_bytes(const BIGNUM *a); 26 int BN_num_bytes(const BIGNUM *a);
25 int BN_num_bits(const BIGNUM *a); 27 int BN_num_bits(const BIGNUM *a);
26 int BN_num_bits_word(BN_ULONG w); 28 int BN_num_bits_word(BN_ULONG w);
27 29
28 int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b); 30 int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
29 int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); 31 int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
30 int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); 32 int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
33 int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx);
31 int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d, 34 int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d,
32 BN_CTX *ctx); 35 BN_CTX *ctx);
33 int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx);
34 int BN_mod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); 36 int BN_mod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
37 int BN_nnmod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
38 int BN_mod_add(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
39 BN_CTX *ctx);
40 int BN_mod_sub(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
41 BN_CTX *ctx);
35 int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, 42 int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
36 BN_CTX *ctx); 43 BN_CTX *ctx);
44 int BN_mod_sqr(BIGNUM *ret, BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
37 int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx); 45 int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx);
38 int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 46 int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
39 const BIGNUM *m, BN_CTX *ctx); 47 const BIGNUM *m, BN_CTX *ctx);
@@ -54,13 +62,14 @@ bn - multiprecision integer arithmetics
54 62
55 int BN_zero(BIGNUM *a); 63 int BN_zero(BIGNUM *a);
56 int BN_one(BIGNUM *a); 64 int BN_one(BIGNUM *a);
57 BIGNUM *BN_value_one(void); 65 const BIGNUM *BN_value_one(void);
58 int BN_set_word(BIGNUM *a, unsigned long w); 66 int BN_set_word(BIGNUM *a, unsigned long w);
59 unsigned long BN_get_word(BIGNUM *a); 67 unsigned long BN_get_word(BIGNUM *a);
60 68
61 int BN_rand(BIGNUM *rnd, int bits, int top, int bottom); 69 int BN_rand(BIGNUM *rnd, int bits, int top, int bottom);
62 int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom); 70 int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);
63 int BN_rand_range(BIGNUM *rnd, BIGNUM *range); 71 int BN_rand_range(BIGNUM *rnd, BIGNUM *range);
72 int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range);
64 73
65 BIGNUM *BN_generate_prime(BIGNUM *ret, int bits,int safe, BIGNUM *add, 74 BIGNUM *BN_generate_prime(BIGNUM *ret, int bits,int safe, BIGNUM *add,
66 BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg); 75 BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg);
@@ -138,7 +147,7 @@ of B<BIGNUM>s to external formats is described in L<BN_bn2bin(3)|BN_bn2bin(3)>.
138L<bn_internal(3)|bn_internal(3)>, 147L<bn_internal(3)|bn_internal(3)>,
139L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, 148L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>,
140L<BN_new(3)|BN_new(3)>, L<BN_CTX_new(3)|BN_CTX_new(3)>, 149L<BN_new(3)|BN_new(3)>, L<BN_CTX_new(3)|BN_CTX_new(3)>,
141L<BN_copy(3)|BN_copy(3)>, L<BN_num_bytes(3)|BN_num_bytes(3)>, 150L<BN_copy(3)|BN_copy(3)>, L<BN_swap(3)|BN_swap(3)>, L<BN_num_bytes(3)|BN_num_bytes(3)>,
142L<BN_add(3)|BN_add(3)>, L<BN_add_word(3)|BN_add_word(3)>, 151L<BN_add(3)|BN_add(3)>, L<BN_add_word(3)|BN_add_word(3)>,
143L<BN_cmp(3)|BN_cmp(3)>, L<BN_zero(3)|BN_zero(3)>, L<BN_rand(3)|BN_rand(3)>, 152L<BN_cmp(3)|BN_cmp(3)>, L<BN_zero(3)|BN_zero(3)>, L<BN_rand(3)|BN_rand(3)>,
144L<BN_generate_prime(3)|BN_generate_prime(3)>, L<BN_set_bit(3)|BN_set_bit(3)>, 153L<BN_generate_prime(3)|BN_generate_prime(3)>, L<BN_set_bit(3)|BN_set_bit(3)>,
diff --git a/src/lib/libssl/src/doc/crypto/bn_internal.pod b/src/lib/libssl/src/doc/crypto/bn_internal.pod
index 8da244aed4..d6f3cfe2ee 100644
--- a/src/lib/libssl/src/doc/crypto/bn_internal.pod
+++ b/src/lib/libssl/src/doc/crypto/bn_internal.pod
@@ -34,9 +34,9 @@ library internal functions
34 int nb); 34 int nb);
35 void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n); 35 void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n);
36 void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, 36 void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
37 BN_ULONG *tmp); 37 int dna,int dnb,BN_ULONG *tmp);
38 void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, 38 void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b,
39 int tn, int n, BN_ULONG *tmp); 39 int n, int tna,int tnb, BN_ULONG *tmp);
40 void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, 40 void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b,
41 int n2, BN_ULONG *tmp); 41 int n2, BN_ULONG *tmp);
42 void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, 42 void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l,
@@ -152,14 +152,15 @@ bn_mul_low_normal(B<r>, B<a>, B<b>, B<n>) operates on the B<n> word
152arrays B<r>, B<a> and B<b>. It computes the B<n> low words of 152arrays B<r>, B<a> and B<b>. It computes the B<n> low words of
153B<a>*B<b> and places the result in B<r>. 153B<a>*B<b> and places the result in B<r>.
154 154
155bn_mul_recursive(B<r>, B<a>, B<b>, B<n2>, B<t>) operates on the B<n2> 155bn_mul_recursive(B<r>, B<a>, B<b>, B<n2>, B<dna>, B<dnb>, B<t>) operates
156word arrays B<a> and B<b> and the 2*B<n2> word arrays B<r> and B<t>. 156on the word arrays B<a> and B<b> of length B<n2>+B<dna> and B<n2>+B<dnb>
157B<n2> must be a power of 2. It computes B<a>*B<b> and places the 157(B<dna> and B<dnb> are currently allowed to be 0 or negative) and the 2*B<n2>
158result in B<r>. 158word arrays B<r> and B<t>. B<n2> must be a power of 2. It computes
159B<a>*B<b> and places the result in B<r>.
159 160
160bn_mul_part_recursive(B<r>, B<a>, B<b>, B<tn>, B<n>, B<tmp>) operates 161bn_mul_part_recursive(B<r>, B<a>, B<b>, B<n>, B<tna>, B<tnb, B<tmp>)
161on the B<n>+B<tn> word arrays B<a> and B<b> and the 4*B<n> word arrays 162operates on the word arrays B<a> and B<b> of length B<n>+B<tna> and
162B<r> and B<tmp>. 163B<n>+B<tnb> and the 4*B<n> word arrays B<r> and B<tmp>.
163 164
164bn_mul_low_recursive(B<r>, B<a>, B<b>, B<n2>, B<tmp>) operates on the 165bn_mul_low_recursive(B<r>, B<a>, B<b>, B<n2>, B<tmp>) operates on the
165B<n2> word arrays B<r> and B<tmp> and the B<n2>/2 word arrays B<a> 166B<n2> word arrays B<r> and B<tmp> and the B<n2>/2 word arrays B<a>
diff --git a/src/lib/libssl/src/doc/crypto/crypto.pod b/src/lib/libssl/src/doc/crypto/crypto.pod
index 07ba7e5bc9..c12eec1409 100644
--- a/src/lib/libssl/src/doc/crypto/crypto.pod
+++ b/src/lib/libssl/src/doc/crypto/crypto.pod
@@ -46,7 +46,8 @@ L<sha(3)|sha(3)>
46 46
47=item AUXILIARY FUNCTIONS 47=item AUXILIARY FUNCTIONS
48 48
49L<err(3)|err(3)>, L<threads(3)|threads(3)>, L<rand(3)|rand(3)> 49L<err(3)|err(3)>, L<threads(3)|threads(3)>, L<rand(3)|rand(3)>,
50L<OPENSSL_VERSION_NUMBER(3)|OPENSSL_VERSION_NUMBER(3)>
50 51
51=item INPUT/OUTPUT, DATA ENCODING 52=item INPUT/OUTPUT, DATA ENCODING
52 53
diff --git a/src/lib/libssl/src/doc/crypto/des.pod b/src/lib/libssl/src/doc/crypto/des.pod
index 99080391b1..528c73acac 100644
--- a/src/lib/libssl/src/doc/crypto/des.pod
+++ b/src/lib/libssl/src/doc/crypto/des.pod
@@ -2,113 +2,105 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5des_random_key, des_set_key, des_key_sched, des_set_key_checked, 5DES_random_key, DES_set_key, DES_key_sched, DES_set_key_checked,
6des_set_key_unchecked, des_set_odd_parity, des_is_weak_key, 6DES_set_key_unchecked, DES_set_odd_parity, DES_is_weak_key,
7des_ecb_encrypt, des_ecb2_encrypt, des_ecb3_encrypt, des_ncbc_encrypt, 7DES_ecb_encrypt, DES_ecb2_encrypt, DES_ecb3_encrypt, DES_ncbc_encrypt,
8des_cfb_encrypt, des_ofb_encrypt, des_pcbc_encrypt, des_cfb64_encrypt, 8DES_cfb_encrypt, DES_ofb_encrypt, DES_pcbc_encrypt, DES_cfb64_encrypt,
9des_ofb64_encrypt, des_xcbc_encrypt, des_ede2_cbc_encrypt, 9DES_ofb64_encrypt, DES_xcbc_encrypt, DES_ede2_cbc_encrypt,
10des_ede2_cfb64_encrypt, des_ede2_ofb64_encrypt, des_ede3_cbc_encrypt, 10DES_ede2_cfb64_encrypt, DES_ede2_ofb64_encrypt, DES_ede3_cbc_encrypt,
11des_ede3_cbcm_encrypt, des_ede3_cfb64_encrypt, des_ede3_ofb64_encrypt, 11DES_ede3_cbcm_encrypt, DES_ede3_cfb64_encrypt, DES_ede3_ofb64_encrypt,
12des_read_password, des_read_2passwords, des_read_pw_string, 12DES_cbc_cksum, DES_quad_cksum, DES_string_to_key, DES_string_to_2keys,
13des_cbc_cksum, des_quad_cksum, des_string_to_key, des_string_to_2keys, 13DES_fcrypt, DES_crypt, DES_enc_read, DES_enc_write - DES encryption
14des_fcrypt, des_crypt, des_enc_read, des_enc_write - DES encryption
15 14
16=head1 SYNOPSIS 15=head1 SYNOPSIS
17 16
18 #include <openssl/des.h> 17 #include <openssl/des.h>
19 18
20 void des_random_key(des_cblock *ret); 19 void DES_random_key(DES_cblock *ret);
21 20
22 int des_set_key(const_des_cblock *key, des_key_schedule schedule); 21 int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule);
23 int des_key_sched(const_des_cblock *key, des_key_schedule schedule); 22 int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule);
24 int des_set_key_checked(const_des_cblock *key, 23 int DES_set_key_checked(const_DES_cblock *key,
25 des_key_schedule schedule); 24 DES_key_schedule *schedule);
26 void des_set_key_unchecked(const_des_cblock *key, 25 void DES_set_key_unchecked(const_DES_cblock *key,
27 des_key_schedule schedule); 26 DES_key_schedule *schedule);
28 27
29 void des_set_odd_parity(des_cblock *key); 28 void DES_set_odd_parity(DES_cblock *key);
30 int des_is_weak_key(const_des_cblock *key); 29 int DES_is_weak_key(const_DES_cblock *key);
31 30
32 void des_ecb_encrypt(const_des_cblock *input, des_cblock *output, 31 void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,
33 des_key_schedule ks, int enc); 32 DES_key_schedule *ks, int enc);
34 void des_ecb2_encrypt(const_des_cblock *input, des_cblock *output, 33 void DES_ecb2_encrypt(const_DES_cblock *input, DES_cblock *output,
35 des_key_schedule ks1, des_key_schedule ks2, int enc); 34 DES_key_schedule *ks1, DES_key_schedule *ks2, int enc);
36 void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output, 35 void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,
37 des_key_schedule ks1, des_key_schedule ks2, 36 DES_key_schedule *ks1, DES_key_schedule *ks2,
38 des_key_schedule ks3, int enc); 37 DES_key_schedule *ks3, int enc);
39 38
40 void des_ncbc_encrypt(const unsigned char *input, unsigned char *output, 39 void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output,
41 long length, des_key_schedule schedule, des_cblock *ivec, 40 long length, DES_key_schedule *schedule, DES_cblock *ivec,
42 int enc); 41 int enc);
43 void des_cfb_encrypt(const unsigned char *in, unsigned char *out, 42 void DES_cfb_encrypt(const unsigned char *in, unsigned char *out,
44 int numbits, long length, des_key_schedule schedule, 43 int numbits, long length, DES_key_schedule *schedule,
45 des_cblock *ivec, int enc); 44 DES_cblock *ivec, int enc);
46 void des_ofb_encrypt(const unsigned char *in, unsigned char *out, 45 void DES_ofb_encrypt(const unsigned char *in, unsigned char *out,
47 int numbits, long length, des_key_schedule schedule, 46 int numbits, long length, DES_key_schedule *schedule,
48 des_cblock *ivec); 47 DES_cblock *ivec);
49 void des_pcbc_encrypt(const unsigned char *input, unsigned char *output, 48 void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,
50 long length, des_key_schedule schedule, des_cblock *ivec, 49 long length, DES_key_schedule *schedule, DES_cblock *ivec,
51 int enc); 50 int enc);
52 void des_cfb64_encrypt(const unsigned char *in, unsigned char *out, 51 void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out,
53 long length, des_key_schedule schedule, des_cblock *ivec, 52 long length, DES_key_schedule *schedule, DES_cblock *ivec,
54 int *num, int enc); 53 int *num, int enc);
55 void des_ofb64_encrypt(const unsigned char *in, unsigned char *out, 54 void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out,
56 long length, des_key_schedule schedule, des_cblock *ivec, 55 long length, DES_key_schedule *schedule, DES_cblock *ivec,
57 int *num); 56 int *num);
58 57
59 void des_xcbc_encrypt(const unsigned char *input, unsigned char *output, 58 void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output,
60 long length, des_key_schedule schedule, des_cblock *ivec, 59 long length, DES_key_schedule *schedule, DES_cblock *ivec,
61 const_des_cblock *inw, const_des_cblock *outw, int enc); 60 const_DES_cblock *inw, const_DES_cblock *outw, int enc);
62 61
63 void des_ede2_cbc_encrypt(const unsigned char *input, 62 void DES_ede2_cbc_encrypt(const unsigned char *input,
64 unsigned char *output, long length, des_key_schedule ks1, 63 unsigned char *output, long length, DES_key_schedule *ks1,
65 des_key_schedule ks2, des_cblock *ivec, int enc); 64 DES_key_schedule *ks2, DES_cblock *ivec, int enc);
66 void des_ede2_cfb64_encrypt(const unsigned char *in, 65 void DES_ede2_cfb64_encrypt(const unsigned char *in,
67 unsigned char *out, long length, des_key_schedule ks1, 66 unsigned char *out, long length, DES_key_schedule *ks1,
68 des_key_schedule ks2, des_cblock *ivec, int *num, int enc); 67 DES_key_schedule *ks2, DES_cblock *ivec, int *num, int enc);
69 void des_ede2_ofb64_encrypt(const unsigned char *in, 68 void DES_ede2_ofb64_encrypt(const unsigned char *in,
70 unsigned char *out, long length, des_key_schedule ks1, 69 unsigned char *out, long length, DES_key_schedule *ks1,
71 des_key_schedule ks2, des_cblock *ivec, int *num); 70 DES_key_schedule *ks2, DES_cblock *ivec, int *num);
72 71
73 void des_ede3_cbc_encrypt(const unsigned char *input, 72 void DES_ede3_cbc_encrypt(const unsigned char *input,
74 unsigned char *output, long length, des_key_schedule ks1, 73 unsigned char *output, long length, DES_key_schedule *ks1,
75 des_key_schedule ks2, des_key_schedule ks3, des_cblock *ivec, 74 DES_key_schedule *ks2, DES_key_schedule *ks3, DES_cblock *ivec,
76 int enc); 75 int enc);
77 void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, 76 void DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
78 long length, des_key_schedule ks1, des_key_schedule ks2, 77 long length, DES_key_schedule *ks1, DES_key_schedule *ks2,
79 des_key_schedule ks3, des_cblock *ivec1, des_cblock *ivec2, 78 DES_key_schedule *ks3, DES_cblock *ivec1, DES_cblock *ivec2,
80 int enc); 79 int enc);
81 void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, 80 void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
82 long length, des_key_schedule ks1, des_key_schedule ks2, 81 long length, DES_key_schedule *ks1, DES_key_schedule *ks2,
83 des_key_schedule ks3, des_cblock *ivec, int *num, int enc); 82 DES_key_schedule *ks3, DES_cblock *ivec, int *num, int enc);
84 void des_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out, 83 void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out,
85 long length, des_key_schedule ks1, 84 long length, DES_key_schedule *ks1,
86 des_key_schedule ks2, des_key_schedule ks3, 85 DES_key_schedule *ks2, DES_key_schedule *ks3,
87 des_cblock *ivec, int *num); 86 DES_cblock *ivec, int *num);
88 87
89 int des_read_password(des_cblock *key, const char *prompt, int verify); 88 DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output,
90 int des_read_2passwords(des_cblock *key1, des_cblock *key2, 89 long length, DES_key_schedule *schedule,
91 const char *prompt, int verify); 90 const_DES_cblock *ivec);
92 int des_read_pw_string(char *buf, int length, const char *prompt, 91 DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],
93 int verify); 92 long length, int out_count, DES_cblock *seed);
94 93 void DES_string_to_key(const char *str, DES_cblock *key);
95 DES_LONG des_cbc_cksum(const unsigned char *input, des_cblock *output, 94 void DES_string_to_2keys(const char *str, DES_cblock *key1,
96 long length, des_key_schedule schedule, 95 DES_cblock *key2);
97 const_des_cblock *ivec); 96
98 DES_LONG des_quad_cksum(const unsigned char *input, des_cblock output[], 97 char *DES_fcrypt(const char *buf, const char *salt, char *ret);
99 long length, int out_count, des_cblock *seed); 98 char *DES_crypt(const char *buf, const char *salt);
100 void des_string_to_key(const char *str, des_cblock *key); 99
101 void des_string_to_2keys(const char *str, des_cblock *key1, 100 int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
102 des_cblock *key2); 101 DES_cblock *iv);
103 102 int DES_enc_write(int fd, const void *buf, int len,
104 char *des_fcrypt(const char *buf, const char *salt, char *ret); 103 DES_key_schedule *sched, DES_cblock *iv);
105 char *des_crypt(const char *buf, const char *salt);
106 char *crypt(const char *buf, const char *salt);
107
108 int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
109 des_cblock *iv);
110 int des_enc_write(int fd, const void *buf, int len,
111 des_key_schedule sched, des_cblock *iv);
112 104
113=head1 DESCRIPTION 105=head1 DESCRIPTION
114 106
@@ -116,56 +108,52 @@ This library contains a fast implementation of the DES encryption
116algorithm. 108algorithm.
117 109
118There are two phases to the use of DES encryption. The first is the 110There are two phases to the use of DES encryption. The first is the
119generation of a I<des_key_schedule> from a key, the second is the 111generation of a I<DES_key_schedule> from a key, the second is the
120actual encryption. A DES key is of type I<des_cblock>. This type is 112actual encryption. A DES key is of type I<DES_cblock>. This type is
121consists of 8 bytes with odd parity. The least significant bit in 113consists of 8 bytes with odd parity. The least significant bit in
122each byte is the parity bit. The key schedule is an expanded form of 114each byte is the parity bit. The key schedule is an expanded form of
123the key; it is used to speed the encryption process. 115the key; it is used to speed the encryption process.
124 116
125des_random_key() generates a random key. The PRNG must be seeded 117DES_random_key() generates a random key. The PRNG must be seeded
126prior to using this function (see L<rand(3)|rand(3)>; for backward 118prior to using this function (see L<rand(3)|rand(3)>). If the PRNG
127compatibility the function des_random_seed() is available as well). 119could not generate a secure key, 0 is returned.
128If the PRNG could not generate a secure key, 0 is returned. In
129earlier versions of the library, des_random_key() did not generate
130secure keys.
131 120
132Before a DES key can be used, it must be converted into the 121Before a DES key can be used, it must be converted into the
133architecture dependent I<des_key_schedule> via the 122architecture dependent I<DES_key_schedule> via the
134des_set_key_checked() or des_set_key_unchecked() function. 123DES_set_key_checked() or DES_set_key_unchecked() function.
135 124
136des_set_key_checked() will check that the key passed is of odd parity 125DES_set_key_checked() will check that the key passed is of odd parity
137and is not a week or semi-weak key. If the parity is wrong, then -1 126and is not a week or semi-weak key. If the parity is wrong, then -1
138is returned. If the key is a weak key, then -2 is returned. If an 127is returned. If the key is a weak key, then -2 is returned. If an
139error is returned, the key schedule is not generated. 128error is returned, the key schedule is not generated.
140 129
141des_set_key() (called des_key_sched() in the MIT library) works like 130DES_set_key() works like
142des_set_key_checked() if the I<des_check_key> flag is non-zero, 131DES_set_key_checked() if the I<DES_check_key> flag is non-zero,
143otherwise like des_set_key_unchecked(). These functions are available 132otherwise like DES_set_key_unchecked(). These functions are available
144for compatibility; it is recommended to use a function that does not 133for compatibility; it is recommended to use a function that does not
145depend on a global variable. 134depend on a global variable.
146 135
147des_set_odd_parity() (called des_fixup_key_parity() in the MIT 136DES_set_odd_parity() sets the parity of the passed I<key> to odd.
148library) sets the parity of the passed I<key> to odd.
149 137
150des_is_weak_key() returns 1 is the passed key is a weak key, 0 if it 138DES_is_weak_key() returns 1 is the passed key is a weak key, 0 if it
151is ok. The probability that a randomly generated key is weak is 139is ok. The probability that a randomly generated key is weak is
1521/2^52, so it is not really worth checking for them. 1401/2^52, so it is not really worth checking for them.
153 141
154The following routines mostly operate on an input and output stream of 142The following routines mostly operate on an input and output stream of
155I<des_cblock>s. 143I<DES_cblock>s.
156 144
157des_ecb_encrypt() is the basic DES encryption routine that encrypts or 145DES_ecb_encrypt() is the basic DES encryption routine that encrypts or
158decrypts a single 8-byte I<des_cblock> in I<electronic code book> 146decrypts a single 8-byte I<DES_cblock> in I<electronic code book>
159(ECB) mode. It always transforms the input data, pointed to by 147(ECB) mode. It always transforms the input data, pointed to by
160I<input>, into the output data, pointed to by the I<output> argument. 148I<input>, into the output data, pointed to by the I<output> argument.
161If the I<encrypt> argument is non-zero (DES_ENCRYPT), the I<input> 149If the I<encrypt> argument is non-zero (DES_ENCRYPT), the I<input>
162(cleartext) is encrypted in to the I<output> (ciphertext) using the 150(cleartext) is encrypted in to the I<output> (ciphertext) using the
163key_schedule specified by the I<schedule> argument, previously set via 151key_schedule specified by the I<schedule> argument, previously set via
164I<des_set_key>. If I<encrypt> is zero (DES_DECRYPT), the I<input> (now 152I<DES_set_key>. If I<encrypt> is zero (DES_DECRYPT), the I<input> (now
165ciphertext) is decrypted into the I<output> (now cleartext). Input 153ciphertext) is decrypted into the I<output> (now cleartext). Input
166and output may overlap. des_ecb_encrypt() does not return a value. 154and output may overlap. DES_ecb_encrypt() does not return a value.
167 155
168des_ecb3_encrypt() encrypts/decrypts the I<input> block by using 156DES_ecb3_encrypt() encrypts/decrypts the I<input> block by using
169three-key Triple-DES encryption in ECB mode. This involves encrypting 157three-key Triple-DES encryption in ECB mode. This involves encrypting
170the input with I<ks1>, decrypting with the key schedule I<ks2>, and 158the input with I<ks1>, decrypting with the key schedule I<ks2>, and
171then encrypting with I<ks3>. This routine greatly reduces the chances 159then encrypting with I<ks3>. This routine greatly reduces the chances
@@ -173,10 +161,10 @@ of brute force breaking of DES and has the advantage of if I<ks1>,
173I<ks2> and I<ks3> are the same, it is equivalent to just encryption 161I<ks2> and I<ks3> are the same, it is equivalent to just encryption
174using ECB mode and I<ks1> as the key. 162using ECB mode and I<ks1> as the key.
175 163
176The macro des_ecb2_encrypt() is provided to perform two-key Triple-DES 164The macro DES_ecb2_encrypt() is provided to perform two-key Triple-DES
177encryption by using I<ks1> for the final encryption. 165encryption by using I<ks1> for the final encryption.
178 166
179des_ncbc_encrypt() encrypts/decrypts using the I<cipher-block-chaining> 167DES_ncbc_encrypt() encrypts/decrypts using the I<cipher-block-chaining>
180(CBC) mode of DES. If the I<encrypt> argument is non-zero, the 168(CBC) mode of DES. If the I<encrypt> argument is non-zero, the
181routine cipher-block-chain encrypts the cleartext data pointed to by 169routine cipher-block-chain encrypts the cleartext data pointed to by
182the I<input> argument into the ciphertext pointed to by the I<output> 170the I<input> argument into the ciphertext pointed to by the I<output>
@@ -186,24 +174,24 @@ I<length> argument is not an integral multiple of eight bytes, the
186last block is copied to a temporary area and zero filled. The output 174last block is copied to a temporary area and zero filled. The output
187is always an integral multiple of eight bytes. 175is always an integral multiple of eight bytes.
188 176
189des_xcbc_encrypt() is RSA's DESX mode of DES. It uses I<inw> and 177DES_xcbc_encrypt() is RSA's DESX mode of DES. It uses I<inw> and
190I<outw> to 'whiten' the encryption. I<inw> and I<outw> are secret 178I<outw> to 'whiten' the encryption. I<inw> and I<outw> are secret
191(unlike the iv) and are as such, part of the key. So the key is sort 179(unlike the iv) and are as such, part of the key. So the key is sort
192of 24 bytes. This is much better than CBC DES. 180of 24 bytes. This is much better than CBC DES.
193 181
194des_ede3_cbc_encrypt() implements outer triple CBC DES encryption with 182DES_ede3_cbc_encrypt() implements outer triple CBC DES encryption with
195three keys. This means that each DES operation inside the CBC mode is 183three keys. This means that each DES operation inside the CBC mode is
196really an C<C=E(ks3,D(ks2,E(ks1,M)))>. This mode is used by SSL. 184really an C<C=E(ks3,D(ks2,E(ks1,M)))>. This mode is used by SSL.
197 185
198The des_ede2_cbc_encrypt() macro implements two-key Triple-DES by 186The DES_ede2_cbc_encrypt() macro implements two-key Triple-DES by
199reusing I<ks1> for the final encryption. C<C=E(ks1,D(ks2,E(ks1,M)))>. 187reusing I<ks1> for the final encryption. C<C=E(ks1,D(ks2,E(ks1,M)))>.
200This form of Triple-DES is used by the RSAREF library. 188This form of Triple-DES is used by the RSAREF library.
201 189
202des_pcbc_encrypt() encrypt/decrypts using the propagating cipher block 190DES_pcbc_encrypt() encrypt/decrypts using the propagating cipher block
203chaining mode used by Kerberos v4. Its parameters are the same as 191chaining mode used by Kerberos v4. Its parameters are the same as
204des_ncbc_encrypt(). 192DES_ncbc_encrypt().
205 193
206des_cfb_encrypt() encrypt/decrypts using cipher feedback mode. This 194DES_cfb_encrypt() encrypt/decrypts using cipher feedback mode. This
207method takes an array of characters as input and outputs and array of 195method takes an array of characters as input and outputs and array of
208characters. It does not require any padding to 8 character groups. 196characters. It does not require any padding to 8 character groups.
209Note: the I<ivec> variable is changed and the new changed value needs to 197Note: the I<ivec> variable is changed and the new changed value needs to
@@ -211,7 +199,7 @@ be passed to the next call to this function. Since this function runs
211a complete DES ECB encryption per I<numbits>, this function is only 199a complete DES ECB encryption per I<numbits>, this function is only
212suggested for use when sending small numbers of characters. 200suggested for use when sending small numbers of characters.
213 201
214des_cfb64_encrypt() 202DES_cfb64_encrypt()
215implements CFB mode of DES with 64bit feedback. Why is this 203implements CFB mode of DES with 64bit feedback. Why is this
216useful you ask? Because this routine will allow you to encrypt an 204useful you ask? Because this routine will allow you to encrypt an
217arbitrary number of bytes, no 8 byte padding. Each call to this 205arbitrary number of bytes, no 8 byte padding. Each call to this
@@ -219,10 +207,10 @@ routine will encrypt the input bytes to output and then update ivec
219and num. num contains 'how far' we are though ivec. If this does 207and num. num contains 'how far' we are though ivec. If this does
220not make much sense, read more about cfb mode of DES :-). 208not make much sense, read more about cfb mode of DES :-).
221 209
222des_ede3_cfb64_encrypt() and des_ede2_cfb64_encrypt() is the same as 210DES_ede3_cfb64_encrypt() and DES_ede2_cfb64_encrypt() is the same as
223des_cfb64_encrypt() except that Triple-DES is used. 211DES_cfb64_encrypt() except that Triple-DES is used.
224 212
225des_ofb_encrypt() encrypts using output feedback mode. This method 213DES_ofb_encrypt() encrypts using output feedback mode. This method
226takes an array of characters as input and outputs and array of 214takes an array of characters as input and outputs and array of
227characters. It does not require any padding to 8 character groups. 215characters. It does not require any padding to 8 character groups.
228Note: the I<ivec> variable is changed and the new changed value needs to 216Note: the I<ivec> variable is changed and the new changed value needs to
@@ -230,39 +218,22 @@ be passed to the next call to this function. Since this function runs
230a complete DES ECB encryption per numbits, this function is only 218a complete DES ECB encryption per numbits, this function is only
231suggested for use when sending small numbers of characters. 219suggested for use when sending small numbers of characters.
232 220
233des_ofb64_encrypt() is the same as des_cfb64_encrypt() using Output 221DES_ofb64_encrypt() is the same as DES_cfb64_encrypt() using Output
234Feed Back mode. 222Feed Back mode.
235 223
236des_ede3_ofb64_encrypt() and des_ede2_ofb64_encrypt() is the same as 224DES_ede3_ofb64_encrypt() and DES_ede2_ofb64_encrypt() is the same as
237des_ofb64_encrypt(), using Triple-DES. 225DES_ofb64_encrypt(), using Triple-DES.
238 226
239The following functions are included in the DES library for 227The following functions are included in the DES library for
240compatibility with the MIT Kerberos library. des_read_pw_string() 228compatibility with the MIT Kerberos library.
241is also available under the name EVP_read_pw_string(). 229
242 230DES_cbc_cksum() produces an 8 byte checksum based on the input stream
243des_read_pw_string() writes the string specified by I<prompt> to
244standard output, turns echo off and reads in input string from the
245terminal. The string is returned in I<buf>, which must have space for
246at least I<length> bytes. If I<verify> is set, the user is asked for
247the password twice and unless the two copies match, an error is
248returned. A return code of -1 indicates a system error, 1 failure due
249to use interaction, and 0 is success.
250
251des_read_password() does the same and converts the password to a DES
252key by calling des_string_to_key(); des_read_2password() operates in
253the same way as des_read_password() except that it generates two keys
254by using the des_string_to_2key() function. des_string_to_key() is
255available for backward compatibility with the MIT library. New
256applications should use a cryptographic hash function. The same
257applies for des_string_to_2key().
258
259des_cbc_cksum() produces an 8 byte checksum based on the input stream
260(via CBC encryption). The last 4 bytes of the checksum are returned 231(via CBC encryption). The last 4 bytes of the checksum are returned
261and the complete 8 bytes are placed in I<output>. This function is 232and the complete 8 bytes are placed in I<output>. This function is
262used by Kerberos v4. Other applications should use 233used by Kerberos v4. Other applications should use
263L<EVP_DigestInit(3)|EVP_DigestInit(3)> etc. instead. 234L<EVP_DigestInit(3)|EVP_DigestInit(3)> etc. instead.
264 235
265des_quad_cksum() is a Kerberos v4 function. It returns a 4 byte 236DES_quad_cksum() is a Kerberos v4 function. It returns a 4 byte
266checksum from the input bytes. The algorithm can be iterated over the 237checksum from the input bytes. The algorithm can be iterated over the
267input, depending on I<out_count>, 1, 2, 3 or 4 times. If I<output> is 238input, depending on I<out_count>, 1, 2, 3 or 4 times. If I<output> is
268non-NULL, the 8 bytes generated by each pass are written into 239non-NULL, the 8 bytes generated by each pass are written into
@@ -270,19 +241,19 @@ I<output>.
270 241
271The following are DES-based transformations: 242The following are DES-based transformations:
272 243
273des_fcrypt() is a fast version of the Unix crypt(3) function. This 244DES_fcrypt() is a fast version of the Unix crypt(3) function. This
274version takes only a small amount of space relative to other fast 245version takes only a small amount of space relative to other fast
275crypt() implementations. This is different to the normal crypt in 246crypt() implementations. This is different to the normal crypt in
276that the third parameter is the buffer that the return value is 247that the third parameter is the buffer that the return value is
277written into. It needs to be at least 14 bytes long. This function 248written into. It needs to be at least 14 bytes long. This function
278is thread safe, unlike the normal crypt. 249is thread safe, unlike the normal crypt.
279 250
280des_crypt() is a faster replacement for the normal system crypt(). 251DES_crypt() is a faster replacement for the normal system crypt().
281This function calls des_fcrypt() with a static array passed as the 252This function calls DES_fcrypt() with a static array passed as the
282third parameter. This emulates the normal non-thread safe semantics 253third parameter. This emulates the normal non-thread safe semantics
283of crypt(3). 254of crypt(3).
284 255
285des_enc_write() writes I<len> bytes to file descriptor I<fd> from 256DES_enc_write() writes I<len> bytes to file descriptor I<fd> from
286buffer I<buf>. The data is encrypted via I<pcbc_encrypt> (default) 257buffer I<buf>. The data is encrypted via I<pcbc_encrypt> (default)
287using I<sched> for the key and I<iv> as a starting vector. The actual 258using I<sched> for the key and I<iv> as a starting vector. The actual
288data send down I<fd> consists of 4 bytes (in network byte order) 259data send down I<fd> consists of 4 bytes (in network byte order)
@@ -290,40 +261,40 @@ containing the length of the following encrypted data. The encrypted
290data then follows, padded with random data out to a multiple of 8 261data then follows, padded with random data out to a multiple of 8
291bytes. 262bytes.
292 263
293des_enc_read() is used to read I<len> bytes from file descriptor 264DES_enc_read() is used to read I<len> bytes from file descriptor
294I<fd> into buffer I<buf>. The data being read from I<fd> is assumed to 265I<fd> into buffer I<buf>. The data being read from I<fd> is assumed to
295have come from des_enc_write() and is decrypted using I<sched> for 266have come from DES_enc_write() and is decrypted using I<sched> for
296the key schedule and I<iv> for the initial vector. 267the key schedule and I<iv> for the initial vector.
297 268
298B<Warning:> The data format used by des_enc_write() and des_enc_read() 269B<Warning:> The data format used by DES_enc_write() and DES_enc_read()
299has a cryptographic weakness: When asked to write more than MAXWRITE 270has a cryptographic weakness: When asked to write more than MAXWRITE
300bytes, des_enc_write() will split the data into several chunks that 271bytes, DES_enc_write() will split the data into several chunks that
301are all encrypted using the same IV. So don't use these functions 272are all encrypted using the same IV. So don't use these functions
302unless you are sure you know what you do (in which case you might not 273unless you are sure you know what you do (in which case you might not
303want to use them anyway). They cannot handle non-blocking sockets. 274want to use them anyway). They cannot handle non-blocking sockets.
304des_enc_read() uses an internal state and thus cannot be used on 275DES_enc_read() uses an internal state and thus cannot be used on
305multiple files. 276multiple files.
306 277
307I<des_rw_mode> is used to specify the encryption mode to use with 278I<DES_rw_mode> is used to specify the encryption mode to use with
308des_enc_read() and des_end_write(). If set to I<DES_PCBC_MODE> (the 279DES_enc_read() and DES_end_write(). If set to I<DES_PCBC_MODE> (the
309default), des_pcbc_encrypt is used. If set to I<DES_CBC_MODE> 280default), DES_pcbc_encrypt is used. If set to I<DES_CBC_MODE>
310des_cbc_encrypt is used. 281DES_cbc_encrypt is used.
311 282
312=head1 NOTES 283=head1 NOTES
313 284
314Single-key DES is insecure due to its short key size. ECB mode is 285Single-key DES is insecure due to its short key size. ECB mode is
315not suitable for most applications; see L<des_modes(7)|des_modes(7)>. 286not suitable for most applications; see L<DES_modes(7)|DES_modes(7)>.
316 287
317The L<evp(3)|evp(3)> library provides higher-level encryption functions. 288The L<evp(3)|evp(3)> library provides higher-level encryption functions.
318 289
319=head1 BUGS 290=head1 BUGS
320 291
321des_3cbc_encrypt() is flawed and must not be used in applications. 292DES_3cbc_encrypt() is flawed and must not be used in applications.
322 293
323des_cbc_encrypt() does not modify B<ivec>; use des_ncbc_encrypt() 294DES_cbc_encrypt() does not modify B<ivec>; use DES_ncbc_encrypt()
324instead. 295instead.
325 296
326des_cfb_encrypt() and des_ofb_encrypt() operates on input of 8 bits. 297DES_cfb_encrypt() and DES_ofb_encrypt() operates on input of 8 bits.
327What this means is that if you set numbits to 12, and length to 2, the 298What this means is that if you set numbits to 12, and length to 2, the
328first 12 bits will come from the 1st input byte and the low half of 299first 12 bits will come from the 1st input byte and the low half of
329the second input byte. The second 12 bits will have the low 8 bits 300the second input byte. The second 12 bits will have the low 8 bits
@@ -333,8 +304,9 @@ implemented this way because most people will be using a multiple of 8
333and because once you get into pulling bytes input bytes apart things 304and because once you get into pulling bytes input bytes apart things
334get ugly! 305get ugly!
335 306
336des_read_pw_string() is the most machine/OS dependent function and 307DES_string_to_key() is available for backward compatibility with the
337normally generates the most problems when porting this code. 308MIT library. New applications should use a cryptographic hash function.
309The same applies for DES_string_to_2key().
338 310
339=head1 CONFORMING TO 311=head1 CONFORMING TO
340 312
@@ -349,10 +321,20 @@ crypt(3), L<des_modes(7)|des_modes(7)>, L<evp(3)|evp(3)>, L<rand(3)|rand(3)>
349 321
350=head1 HISTORY 322=head1 HISTORY
351 323
324In OpenSSL 0.9.7, all des_ functions were renamed to DES_ to avoid
325clashes with older versions of libdes. Compatibility des_ functions
326are provided for a short while, as well as crypt().
327Declarations for these are in <openssl/des_old.h>. There is no DES_
328variant for des_random_seed().
329This will happen to other functions
330as well if they are deemed redundant (des_random_seed() just calls
331RAND_seed() and is present for backward compatibility only), buggy or
332already scheduled for removal.
333
352des_cbc_cksum(), des_cbc_encrypt(), des_ecb_encrypt(), 334des_cbc_cksum(), des_cbc_encrypt(), des_ecb_encrypt(),
353des_is_weak_key(), des_key_sched(), des_pcbc_encrypt(), 335des_is_weak_key(), des_key_sched(), des_pcbc_encrypt(),
354des_quad_cksum(), des_random_key(), des_read_password() and 336des_quad_cksum(), des_random_key() and des_string_to_key()
355des_string_to_key() are available in the MIT Kerberos library; 337are available in the MIT Kerberos library;
356des_check_key_parity(), des_fixup_key_parity() and des_is_weak_key() 338des_check_key_parity(), des_fixup_key_parity() and des_is_weak_key()
357are available in newer versions of that library. 339are available in newer versions of that library.
358 340
diff --git a/src/lib/libssl/src/doc/crypto/hmac.pod b/src/lib/libssl/src/doc/crypto/hmac.pod
index 631f40377e..3cc29dfc83 100644
--- a/src/lib/libssl/src/doc/crypto/hmac.pod
+++ b/src/lib/libssl/src/doc/crypto/hmac.pod
@@ -13,11 +13,16 @@ authentication code
13 int key_len, const unsigned char *d, int n, 13 int key_len, const unsigned char *d, int n,
14 unsigned char *md, unsigned int *md_len); 14 unsigned char *md, unsigned int *md_len);
15 15
16 void HMAC_CTX_init(HMAC_CTX *ctx);
17
16 void HMAC_Init(HMAC_CTX *ctx, const void *key, int key_len, 18 void HMAC_Init(HMAC_CTX *ctx, const void *key, int key_len,
17 const EVP_MD *md); 19 const EVP_MD *md);
20 void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int key_len,
21 const EVP_MD *md);
18 void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len); 22 void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len);
19 void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); 23 void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
20 24
25 void HMAC_CTX_cleanup(HMAC_CTX *ctx);
21 void HMAC_cleanup(HMAC_CTX *ctx); 26 void HMAC_cleanup(HMAC_CTX *ctx);
22 27
23=head1 DESCRIPTION 28=head1 DESCRIPTION
@@ -39,13 +44,31 @@ B<evp_md> can be EVP_sha1(), EVP_ripemd160() etc.
39B<key> and B<evp_md> may be B<NULL> if a key and hash function have 44B<key> and B<evp_md> may be B<NULL> if a key and hash function have
40been set in a previous call to HMAC_Init() for that B<HMAC_CTX>. 45been set in a previous call to HMAC_Init() for that B<HMAC_CTX>.
41 46
42HMAC_cleanup() erases the key and other data from the B<HMAC_CTX>. 47HMAC_CTX_init() initialises a B<HMAC_CTX> before first use. It must be
48called.
49
50HMAC_CTX_cleanup() erases the key and other data from the B<HMAC_CTX>
51and releases any associated resources. It must be called when an
52B<HMAC_CTX> is no longer required.
53
54HMAC_cleanup() is an alias for HMAC_CTX_cleanup() included for back
55compatibility with 0.9.6b, it is deprecated.
43 56
44The following functions may be used if the message is not completely 57The following functions may be used if the message is not completely
45stored in memory: 58stored in memory:
46 59
47HMAC_Init() initializes a B<HMAC_CTX> structure to use the hash 60HMAC_Init() initializes a B<HMAC_CTX> structure to use the hash
48function B<evp_md> and the key B<key> which is B<key_len> bytes long. 61function B<evp_md> and the key B<key> which is B<key_len> bytes
62long. It is deprecated and only included for backward compatibility
63with OpenSSL 0.9.6b.
64
65HMAC_Init_ex() initializes or reuses a B<HMAC_CTX> structure to use
66the function B<evp_md> and key B<key>. Either can be NULL, in which
67case the existing one will be reused. HMAC_CTX_init() must have been
68called before the first use of an B<HMAC_CTX> in this
69function. B<N.B. HMAC_Init() had this undocumented behaviour in
70previous versions of OpenSSL - failure to switch to HMAC_Init_ex() in
71programs that expect it will cause them to stop working>.
49 72
50HMAC_Update() can be called repeatedly with chunks of the message to 73HMAC_Update() can be called repeatedly with chunks of the message to
51be authenticated (B<len> bytes at B<data>). 74be authenticated (B<len> bytes at B<data>).
@@ -57,8 +80,8 @@ must have space for the hash function output.
57 80
58HMAC() returns a pointer to the message authentication code. 81HMAC() returns a pointer to the message authentication code.
59 82
60HMAC_Init(), HMAC_Update(), HMAC_Final() and HMAC_cleanup() do not 83HMAC_CTX_init(), HMAC_Init_ex(), HMAC_Update(), HMAC_Final() and
61return values. 84HMAC_CTX_cleanup() do not return values.
62 85
63=head1 CONFORMING TO 86=head1 CONFORMING TO
64 87
diff --git a/src/lib/libssl/src/doc/crypto/lhash.pod b/src/lib/libssl/src/doc/crypto/lhash.pod
index 4e87aee824..0bac11421e 100644
--- a/src/lib/libssl/src/doc/crypto/lhash.pod
+++ b/src/lib/libssl/src/doc/crypto/lhash.pod
@@ -2,43 +2,108 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5lh_new, lh_free, lh_insert, lh_delete, lh_retrieve, lh_doall, 5lh_new, lh_free, lh_insert, lh_delete, lh_retrieve, lh_doall, lh_doall_arg, lh_error - dynamic hash table
6lh_doall_arg, lh_error - dynamic hash table
7 6
8=head1 SYNOPSIS 7=head1 SYNOPSIS
9 8
10 #include <openssl/lhash.h> 9 #include <openssl/lhash.h>
11 10
12 LHASH *lh_new(unsigned long (*hash)(/*void *a*/), 11 LHASH *lh_new(LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE compare);
13 int (*compare)(/*void *a,void *b*/));
14 void lh_free(LHASH *table); 12 void lh_free(LHASH *table);
15 13
16 void *lh_insert(LHASH *table, void *data); 14 void *lh_insert(LHASH *table, void *data);
17 void *lh_delete(LHASH *table, void *data); 15 void *lh_delete(LHASH *table, void *data);
18 void *lh_retrieve(LHASH *table, void *data); 16 void *lh_retrieve(LHASH *table, void *data);
19 17
20 void lh_doall(LHASH *table, void (*func)(/*void *b*/)); 18 void lh_doall(LHASH *table, LHASH_DOALL_FN_TYPE func);
21 void lh_doall_arg(LHASH *table, void (*func)(/*void *a,void *b*/), 19 void lh_doall_arg(LHASH *table, LHASH_DOALL_ARG_FN_TYPE func,
22 void *arg); 20 void *arg);
23 21
24 int lh_error(LHASH *table); 22 int lh_error(LHASH *table);
25 23
24 typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *);
25 typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *);
26 typedef void (*LHASH_DOALL_FN_TYPE)(const void *);
27 typedef void (*LHASH_DOALL_ARG_FN_TYPE)(const void *, const void *);
28
26=head1 DESCRIPTION 29=head1 DESCRIPTION
27 30
28This library implements dynamic hash tables. The hash table entries 31This library implements dynamic hash tables. The hash table entries
29can be arbitrary structures. Usually they consist of key and value 32can be arbitrary structures. Usually they consist of key and value
30fields. 33fields.
31 34
32lh_new() creates a new B<LHASH> structure. B<hash> takes a pointer to 35lh_new() creates a new B<LHASH> structure to store arbitrary data
33the structure and returns an unsigned long hash value of its key 36entries, and provides the 'hash' and 'compare' callbacks to be used in
34field. The hash value is normally truncated to a power of 2, so make 37organising the table's entries. The B<hash> callback takes a pointer
35sure that your hash function returns well mixed low order 38to a table entry as its argument and returns an unsigned long hash
36bits. B<compare> takes two arguments, and returns 0 if their keys are 39value for its key field. The hash value is normally truncated to a
37equal, non-zero otherwise. 40power of 2, so make sure that your hash function returns well mixed
41low order bits. The B<compare> callback takes two arguments (pointers
42to two hash table entries), and returns 0 if their keys are equal,
43non-zero otherwise. If your hash table will contain items of some
44particular type and the B<hash> and B<compare> callbacks hash/compare
45these types, then the B<DECLARE_LHASH_HASH_FN> and
46B<IMPLEMENT_LHASH_COMP_FN> macros can be used to create callback
47wrappers of the prototypes required by lh_new(). These provide
48per-variable casts before calling the type-specific callbacks written
49by the application author. These macros, as well as those used for
50the "doall" callbacks, are defined as;
51
52 #define DECLARE_LHASH_HASH_FN(f_name,o_type) \
53 unsigned long f_name##_LHASH_HASH(const void *);
54 #define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \
55 unsigned long f_name##_LHASH_HASH(const void *arg) { \
56 o_type a = (o_type)arg; \
57 return f_name(a); }
58 #define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH
59
60 #define DECLARE_LHASH_COMP_FN(f_name,o_type) \
61 int f_name##_LHASH_COMP(const void *, const void *);
62 #define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \
63 int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \
64 o_type a = (o_type)arg1; \
65 o_type b = (o_type)arg2; \
66 return f_name(a,b); }
67 #define LHASH_COMP_FN(f_name) f_name##_LHASH_COMP
68
69 #define DECLARE_LHASH_DOALL_FN(f_name,o_type) \
70 void f_name##_LHASH_DOALL(const void *);
71 #define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \
72 void f_name##_LHASH_DOALL(const void *arg) { \
73 o_type a = (o_type)arg; \
74 f_name(a); }
75 #define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL
76
77 #define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
78 void f_name##_LHASH_DOALL_ARG(const void *, const void *);
79 #define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
80 void f_name##_LHASH_DOALL_ARG(const void *arg1, const void *arg2) { \
81 o_type a = (o_type)arg1; \
82 a_type b = (a_type)arg2; \
83 f_name(a,b); }
84 #define LHASH_DOALL_ARG_FN(f_name) f_name##_LHASH_DOALL_ARG
85
86An example of a hash table storing (pointers to) structures of type 'STUFF'
87could be defined as follows;
88
89 /* Calculates the hash value of 'tohash' (implemented elsewhere) */
90 unsigned long STUFF_hash(const STUFF *tohash);
91 /* Orders 'arg1' and 'arg2' (implemented elsewhere) */
92 int STUFF_cmp(const STUFF *arg1, const STUFF *arg2);
93 /* Create the type-safe wrapper functions for use in the LHASH internals */
94 static IMPLEMENT_LHASH_HASH_FN(STUFF_hash, const STUFF *)
95 static IMPLEMENT_LHASH_COMP_FN(STUFF_cmp, const STUFF *);
96 /* ... */
97 int main(int argc, char *argv[]) {
98 /* Create the new hash table using the hash/compare wrappers */
99 LHASH *hashtable = lh_new(LHASH_HASH_FN(STUFF_hash),
100 LHASH_COMP_FN(STUFF_cmp));
101 /* ... */
102 }
38 103
39lh_free() frees the B<LHASH> structure B<table>. Allocated hash table 104lh_free() frees the B<LHASH> structure B<table>. Allocated hash table
40entries will not be freed; consider using lh_doall() to deallocate any 105entries will not be freed; consider using lh_doall() to deallocate any
41remaining entries in the hash table. 106remaining entries in the hash table (see below).
42 107
43lh_insert() inserts the structure pointed to by B<data> into B<table>. 108lh_insert() inserts the structure pointed to by B<data> into B<table>.
44If there already is an entry with the same key, the old value is 109If there already is an entry with the same key, the old value is
@@ -52,23 +117,53 @@ a structure with the key field(s) set; the function will return a
52pointer to a fully populated structure. 117pointer to a fully populated structure.
53 118
54lh_doall() will, for every entry in the hash table, call B<func> with 119lh_doall() will, for every entry in the hash table, call B<func> with
55the data item as parameters. 120the data item as its parameter. For lh_doall() and lh_doall_arg(),
56This function can be quite useful when used as follows: 121function pointer casting should be avoided in the callbacks (see
57 void cleanup(STUFF *a) 122B<NOTE>) - instead, either declare the callbacks to match the
58 { STUFF_free(a); } 123prototype required in lh_new() or use the declare/implement macros to
59 lh_doall(hash,cleanup); 124create type-safe wrappers that cast variables prior to calling your
60 lh_free(hash); 125type-specific callbacks. An example of this is illustrated here where
61This can be used to free all the entries. lh_free() then cleans up the 126the callback is used to cleanup resources for items in the hash table
62'buckets' that point to nothing. When doing this, be careful if you 127prior to the hashtable itself being deallocated:
63delete entries from the hash table in B<func>: the table may decrease 128
64in size, moving item that you are currently on down lower in the hash 129 /* Cleans up resources belonging to 'a' (this is implemented elsewhere) */
65table. This could cause some entries to be skipped. The best 130 void STUFF_cleanup(STUFF *a);
66solution to this problem is to set hash-E<gt>down_load=0 before you 131 /* Implement a prototype-compatible wrapper for "STUFF_cleanup" */
67start. This will stop the hash table ever being decreased in size. 132 IMPLEMENT_LHASH_DOALL_FN(STUFF_cleanup, STUFF *)
68 133 /* ... then later in the code ... */
69lh_doall_arg() is the same as lh_doall() except that B<func> will 134 /* So to run "STUFF_cleanup" against all items in a hash table ... */
70be called with B<arg> as the second argument. 135 lh_doall(hashtable, LHASH_DOALL_FN(STUFF_cleanup));
71 136 /* Then the hash table itself can be deallocated */
137 lh_free(hashtable);
138
139When doing this, be careful if you delete entries from the hash table
140in your callbacks: the table may decrease in size, moving the item
141that you are currently on down lower in the hash table - this could
142cause some entries to be skipped during the iteration. The second
143best solution to this problem is to set hash-E<gt>down_load=0 before
144you start (which will stop the hash table ever decreasing in size).
145The best solution is probably to avoid deleting items from the hash
146table inside a "doall" callback!
147
148lh_doall_arg() is the same as lh_doall() except that B<func> will be
149called with B<arg> as the second argument and B<func> should be of
150type B<LHASH_DOALL_ARG_FN_TYPE> (a callback prototype that is passed
151both the table entry and an extra argument). As with lh_doall(), you
152can instead choose to declare your callback with a prototype matching
153the types you are dealing with and use the declare/implement macros to
154create compatible wrappers that cast variables before calling your
155type-specific callbacks. An example of this is demonstrated here
156(printing all hash table entries to a BIO that is provided by the
157caller):
158
159 /* Prints item 'a' to 'output_bio' (this is implemented elsewhere) */
160 void STUFF_print(const STUFF *a, BIO *output_bio);
161 /* Implement a prototype-compatible wrapper for "STUFF_print" */
162 static IMPLEMENT_LHASH_DOALL_ARG_FN(STUFF_print, const STUFF *, BIO *)
163 /* ... then later in the code ... */
164 /* Print out the entire hashtable to a particular BIO */
165 lh_doall_arg(hashtable, LHASH_DOALL_ARG_FN(STUFF_print), logging_bio);
166
72lh_error() can be used to determine if an error occurred in the last 167lh_error() can be used to determine if an error occurred in the last
73operation. lh_error() is a macro. 168operation. lh_error() is a macro.
74 169
@@ -91,6 +186,45 @@ otherwise.
91 186
92lh_free(), lh_doall() and lh_doall_arg() return no values. 187lh_free(), lh_doall() and lh_doall_arg() return no values.
93 188
189=head1 NOTE
190
191The various LHASH macros and callback types exist to make it possible
192to write type-safe code without resorting to function-prototype
193casting - an evil that makes application code much harder to
194audit/verify and also opens the window of opportunity for stack
195corruption and other hard-to-find bugs. It also, apparently, violates
196ANSI-C.
197
198The LHASH code regards table entries as constant data. As such, it
199internally represents lh_insert()'d items with a "const void *"
200pointer type. This is why callbacks such as those used by lh_doall()
201and lh_doall_arg() declare their prototypes with "const", even for the
202parameters that pass back the table items' data pointers - for
203consistency, user-provided data is "const" at all times as far as the
204LHASH code is concerned. However, as callers are themselves providing
205these pointers, they can choose whether they too should be treating
206all such parameters as constant.
207
208As an example, a hash table may be maintained by code that, for
209reasons of encapsulation, has only "const" access to the data being
210indexed in the hash table (ie. it is returned as "const" from
211elsewhere in their code) - in this case the LHASH prototypes are
212appropriate as-is. Conversely, if the caller is responsible for the
213life-time of the data in question, then they may well wish to make
214modifications to table item passed back in the lh_doall() or
215lh_doall_arg() callbacks (see the "STUFF_cleanup" example above). If
216so, the caller can either cast the "const" away (if they're providing
217the raw callbacks themselves) or use the macros to declare/implement
218the wrapper functions without "const" types.
219
220Callers that only have "const" access to data they're indexing in a
221table, yet declare callbacks without constant types (or cast the
222"const" away themselves), are therefore creating their own risks/bugs
223without being encouraged to do so by the API. On a related note,
224those auditing code should pay special attention to any instances of
225DECLARE/IMPLEMENT_LHASH_DOALL_[ARG_]_FN macros that provide types
226without any "const" qualifiers.
227
94=head1 BUGS 228=head1 BUGS
95 229
96lh_insert() returns B<NULL> both for success and error. 230lh_insert() returns B<NULL> both for success and error.
@@ -131,7 +265,7 @@ generating hashes that are the same for different values. It is
131probably worth changing your hash function if this is the case because 265probably worth changing your hash function if this is the case because
132even if your hash table has 10 items in a 'bucket', it can be searched 266even if your hash table has 10 items in a 'bucket', it can be searched
133with 10 B<unsigned long> compares and 10 linked list traverses. This 267with 10 B<unsigned long> compares and 10 linked list traverses. This
134will be much less expensive that 10 calls to you compare function. 268will be much less expensive that 10 calls to your compare function.
135 269
136lh_strhash() is a demo string hashing function: 270lh_strhash() is a demo string hashing function:
137 271
diff --git a/src/lib/libssl/src/doc/crypto/pem.pod b/src/lib/libssl/src/doc/crypto/pem.pod
new file mode 100644
index 0000000000..a4f8cc3337
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/pem.pod
@@ -0,0 +1,476 @@
1=pod
2
3=head1 NAME
4
5PEM - PEM routines
6
7=head1 SYNOPSIS
8
9 #include <openssl/pem.h>
10
11 EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x,
12 pem_password_cb *cb, void *u);
13
14 EVP_PKEY *PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x,
15 pem_password_cb *cb, void *u);
16
17 int PEM_write_bio_PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
18 unsigned char *kstr, int klen,
19 pem_password_cb *cb, void *u);
20
21 int PEM_write_PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
22 unsigned char *kstr, int klen,
23 pem_password_cb *cb, void *u);
24
25 int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
26 char *kstr, int klen,
27 pem_password_cb *cb, void *u);
28
29 int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
30 char *kstr, int klen,
31 pem_password_cb *cb, void *u);
32
33 int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
34 char *kstr, int klen,
35 pem_password_cb *cb, void *u);
36
37 int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
38 char *kstr, int klen,
39 pem_password_cb *cb, void *u);
40
41 EVP_PKEY *PEM_read_bio_PUBKEY(BIO *bp, EVP_PKEY **x,
42 pem_password_cb *cb, void *u);
43
44 EVP_PKEY *PEM_read_PUBKEY(FILE *fp, EVP_PKEY **x,
45 pem_password_cb *cb, void *u);
46
47 int PEM_write_bio_PUBKEY(BIO *bp, EVP_PKEY *x);
48 int PEM_write_PUBKEY(FILE *fp, EVP_PKEY *x);
49
50 RSA *PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **x,
51 pem_password_cb *cb, void *u);
52
53 RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **x,
54 pem_password_cb *cb, void *u);
55
56 int PEM_write_bio_RSAPrivateKey(BIO *bp, RSA *x, const EVP_CIPHER *enc,
57 unsigned char *kstr, int klen,
58 pem_password_cb *cb, void *u);
59
60 int PEM_write_RSAPrivateKey(FILE *fp, RSA *x, const EVP_CIPHER *enc,
61 unsigned char *kstr, int klen,
62 pem_password_cb *cb, void *u);
63
64 RSA *PEM_read_bio_RSAPublicKey(BIO *bp, RSA **x,
65 pem_password_cb *cb, void *u);
66
67 RSA *PEM_read_RSAPublicKey(FILE *fp, RSA **x,
68 pem_password_cb *cb, void *u);
69
70 int PEM_write_bio_RSAPublicKey(BIO *bp, RSA *x);
71
72 int PEM_write_RSAPublicKey(FILE *fp, RSA *x);
73
74 RSA *PEM_read_bio_RSA_PUBKEY(BIO *bp, RSA **x,
75 pem_password_cb *cb, void *u);
76
77 RSA *PEM_read_RSA_PUBKEY(FILE *fp, RSA **x,
78 pem_password_cb *cb, void *u);
79
80 int PEM_write_bio_RSA_PUBKEY(BIO *bp, RSA *x);
81
82 int PEM_write_RSA_PUBKEY(FILE *fp, RSA *x);
83
84 DSA *PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **x,
85 pem_password_cb *cb, void *u);
86
87 DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **x,
88 pem_password_cb *cb, void *u);
89
90 int PEM_write_bio_DSAPrivateKey(BIO *bp, DSA *x, const EVP_CIPHER *enc,
91 unsigned char *kstr, int klen,
92 pem_password_cb *cb, void *u);
93
94 int PEM_write_DSAPrivateKey(FILE *fp, DSA *x, const EVP_CIPHER *enc,
95 unsigned char *kstr, int klen,
96 pem_password_cb *cb, void *u);
97
98 DSA *PEM_read_bio_DSA_PUBKEY(BIO *bp, DSA **x,
99 pem_password_cb *cb, void *u);
100
101 DSA *PEM_read_DSA_PUBKEY(FILE *fp, DSA **x,
102 pem_password_cb *cb, void *u);
103
104 int PEM_write_bio_DSA_PUBKEY(BIO *bp, DSA *x);
105
106 int PEM_write_DSA_PUBKEY(FILE *fp, DSA *x);
107
108 DSA *PEM_read_bio_DSAparams(BIO *bp, DSA **x, pem_password_cb *cb, void *u);
109
110 DSA *PEM_read_DSAparams(FILE *fp, DSA **x, pem_password_cb *cb, void *u);
111
112 int PEM_write_bio_DSAparams(BIO *bp, DSA *x);
113
114 int PEM_write_DSAparams(FILE *fp, DSA *x);
115
116 DH *PEM_read_bio_DHparams(BIO *bp, DH **x, pem_password_cb *cb, void *u);
117
118 DH *PEM_read_DHparams(FILE *fp, DH **x, pem_password_cb *cb, void *u);
119
120 int PEM_write_bio_DHparams(BIO *bp, DH *x);
121
122 int PEM_write_DHparams(FILE *fp, DH *x);
123
124 X509 *PEM_read_bio_X509(BIO *bp, X509 **x, pem_password_cb *cb, void *u);
125
126 X509 *PEM_read_X509(FILE *fp, X509 **x, pem_password_cb *cb, void *u);
127
128 int PEM_write_bio_X509(BIO *bp, X509 *x);
129
130 int PEM_write_X509(FILE *fp, X509 *x);
131
132 X509 *PEM_read_bio_X509_AUX(BIO *bp, X509 **x, pem_password_cb *cb, void *u);
133
134 X509 *PEM_read_X509_AUX(FILE *fp, X509 **x, pem_password_cb *cb, void *u);
135
136 int PEM_write_bio_X509_AUX(BIO *bp, X509 *x);
137
138 int PEM_write_X509_AUX(FILE *fp, X509 *x);
139
140 X509_REQ *PEM_read_bio_X509_REQ(BIO *bp, X509_REQ **x,
141 pem_password_cb *cb, void *u);
142
143 X509_REQ *PEM_read_X509_REQ(FILE *fp, X509_REQ **x,
144 pem_password_cb *cb, void *u);
145
146 int PEM_write_bio_X509_REQ(BIO *bp, X509_REQ *x);
147
148 int PEM_write_X509_REQ(FILE *fp, X509_REQ *x);
149
150 int PEM_write_bio_X509_REQ_NEW(BIO *bp, X509_REQ *x);
151
152 int PEM_write_X509_REQ_NEW(FILE *fp, X509_REQ *x);
153
154 X509_CRL *PEM_read_bio_X509_CRL(BIO *bp, X509_CRL **x,
155 pem_password_cb *cb, void *u);
156 X509_CRL *PEM_read_X509_CRL(FILE *fp, X509_CRL **x,
157 pem_password_cb *cb, void *u);
158 int PEM_write_bio_X509_CRL(BIO *bp, X509_CRL *x);
159 int PEM_write_X509_CRL(FILE *fp, X509_CRL *x);
160
161 PKCS7 *PEM_read_bio_PKCS7(BIO *bp, PKCS7 **x, pem_password_cb *cb, void *u);
162
163 PKCS7 *PEM_read_PKCS7(FILE *fp, PKCS7 **x, pem_password_cb *cb, void *u);
164
165 int PEM_write_bio_PKCS7(BIO *bp, PKCS7 *x);
166
167 int PEM_write_PKCS7(FILE *fp, PKCS7 *x);
168
169 NETSCAPE_CERT_SEQUENCE *PEM_read_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp,
170 NETSCAPE_CERT_SEQUENCE **x,
171 pem_password_cb *cb, void *u);
172
173 NETSCAPE_CERT_SEQUENCE *PEM_read_NETSCAPE_CERT_SEQUENCE(FILE *fp,
174 NETSCAPE_CERT_SEQUENCE **x,
175 pem_password_cb *cb, void *u);
176
177 int PEM_write_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp, NETSCAPE_CERT_SEQUENCE *x);
178
179 int PEM_write_NETSCAPE_CERT_SEQUENCE(FILE *fp, NETSCAPE_CERT_SEQUENCE *x);
180
181=head1 DESCRIPTION
182
183The PEM functions read or write structures in PEM format. In
184this sense PEM format is simply base64 encoded data surrounded
185by header lines.
186
187For more details about the meaning of arguments see the
188B<PEM FUNCTION ARGUMENTS> section.
189
190Each operation has four functions associated with it. For
191clarity the term "B<foobar> functions" will be used to collectively
192refer to the PEM_read_bio_foobar(), PEM_read_foobar(),
193PEM_write_bio_foobar() and PEM_write_foobar() functions.
194
195The B<PrivateKey> functions read or write a private key in
196PEM format using an EVP_PKEY structure. The write routines use
197"traditional" private key format and can handle both RSA and DSA
198private keys. The read functions can additionally transparently
199handle PKCS#8 format encrypted and unencrypted keys too.
200
201PEM_write_bio_PKCS8PrivateKey() and PEM_write_PKCS8PrivateKey()
202write a private key in an EVP_PKEY structure in PKCS#8
203EncryptedPrivateKeyInfo format using PKCS#5 v2.0 password based encryption
204algorithms. The B<cipher> argument specifies the encryption algoritm to
205use: unlike all other PEM routines the encryption is applied at the
206PKCS#8 level and not in the PEM headers. If B<cipher> is NULL then no
207encryption is used and a PKCS#8 PrivateKeyInfo structure is used instead.
208
209PEM_write_bio_PKCS8PrivateKey_nid() and PEM_write_PKCS8PrivateKey_nid()
210also write out a private key as a PKCS#8 EncryptedPrivateKeyInfo however
211it uses PKCS#5 v1.5 or PKCS#12 encryption algorithms instead. The algorithm
212to use is specified in the B<nid> parameter and should be the NID of the
213corresponding OBJECT IDENTIFIER (see NOTES section).
214
215The B<PUBKEY> functions process a public key using an EVP_PKEY
216structure. The public key is encoded as a SubjectPublicKeyInfo
217structure.
218
219The B<RSAPrivateKey> functions process an RSA private key using an
220RSA structure. It handles the same formats as the B<PrivateKey>
221functions but an error occurs if the private key is not RSA.
222
223The B<RSAPublicKey> functions process an RSA public key using an
224RSA structure. The public key is encoded using a PKCS#1 RSAPublicKey
225structure.
226
227The B<RSA_PUBKEY> functions also process an RSA public key using
228an RSA structure. However the public key is encoded using a
229SubjectPublicKeyInfo structure and an error occurs if the public
230key is not RSA.
231
232The B<DSAPrivateKey> functions process a DSA private key using a
233DSA structure. It handles the same formats as the B<PrivateKey>
234functions but an error occurs if the private key is not DSA.
235
236The B<DSA_PUBKEY> functions process a DSA public key using
237a DSA structure. The public key is encoded using a
238SubjectPublicKeyInfo structure and an error occurs if the public
239key is not DSA.
240
241The B<DSAparams> functions process DSA parameters using a DSA
242structure. The parameters are encoded using a foobar structure.
243
244The B<DHparams> functions process DH parameters using a DH
245structure. The parameters are encoded using a PKCS#3 DHparameter
246structure.
247
248The B<X509> functions process an X509 certificate using an X509
249structure. They will also process a trusted X509 certificate but
250any trust settings are discarded.
251
252The B<X509_AUX> functions process a trusted X509 certificate using
253an X509 structure.
254
255The B<X509_REQ> and B<X509_REQ_NEW> functions process a PKCS#10
256certificate request using an X509_REQ structure. The B<X509_REQ>
257write functions use B<CERTIFICATE REQUEST> in the header whereas
258the B<X509_REQ_NEW> functions use B<NEW CERTIFICATE REQUEST>
259(as required by some CAs). The B<X509_REQ> read functions will
260handle either form so there are no B<X509_REQ_NEW> read functions.
261
262The B<X509_CRL> functions process an X509 CRL using an X509_CRL
263structure.
264
265The B<PKCS7> functions process a PKCS#7 ContentInfo using a PKCS7
266structure.
267
268The B<NETSCAPE_CERT_SEQUENCE> functions process a Netscape Certificate
269Sequence using a NETSCAPE_CERT_SEQUENCE structure.
270
271=head1 PEM FUNCTION ARGUMENTS
272
273The PEM functions have many common arguments.
274
275The B<bp> BIO parameter (if present) specifies the BIO to read from
276or write to.
277
278The B<fp> FILE parameter (if present) specifies the FILE pointer to
279read from or write to.
280
281The PEM read functions all take an argument B<TYPE **x> and return
282a B<TYPE *> pointer. Where B<TYPE> is whatever structure the function
283uses. If B<x> is NULL then the parameter is ignored. If B<x> is not
284NULL but B<*x> is NULL then the structure returned will be written
285to B<*x>. If neither B<x> nor B<*x> is NULL then an attempt is made
286to reuse the structure at B<*x> (but see BUGS and EXAMPLES sections).
287Irrespective of the value of B<x> a pointer to the structure is always
288returned (or NULL if an error occurred).
289
290The PEM functions which write private keys take an B<enc> parameter
291which specifies the encryption algorithm to use, encryption is done
292at the PEM level. If this parameter is set to NULL then the private
293key is written in unencrypted form.
294
295The B<cb> argument is the callback to use when querying for the pass
296phrase used for encrypted PEM structures (normally only private keys).
297
298For the PEM write routines if the B<kstr> parameter is not NULL then
299B<klen> bytes at B<kstr> are used as the passphrase and B<cb> is
300ignored.
301
302If the B<cb> parameters is set to NULL and the B<u> parameter is not
303NULL then the B<u> parameter is interpreted as a null terminated string
304to use as the passphrase. If both B<cb> and B<u> are NULL then the
305default callback routine is used which will typically prompt for the
306passphrase on the current terminal with echoing turned off.
307
308The default passphrase callback is sometimes inappropriate (for example
309in a GUI application) so an alternative can be supplied. The callback
310routine has the following form:
311
312 int cb(char *buf, int size, int rwflag, void *u);
313
314B<buf> is the buffer to write the passphrase to. B<size> is the maximum
315length of the passphrase (i.e. the size of buf). B<rwflag> is a flag
316which is set to 0 when reading and 1 when writing. A typical routine
317will ask the user to verify the passphrase (for example by prompting
318for it twice) if B<rwflag> is 1. The B<u> parameter has the same
319value as the B<u> parameter passed to the PEM routine. It allows
320arbitrary data to be passed to the callback by the application
321(for example a window handle in a GUI application). The callback
322B<must> return the number of characters in the passphrase or 0 if
323an error occurred.
324
325=head1 EXAMPLES
326
327Although the PEM routines take several arguments in almost all applications
328most of them are set to 0 or NULL.
329
330Read a certificate in PEM format from a BIO:
331
332 X509 *x;
333 x = PEM_read_bio(bp, NULL, 0, NULL);
334 if (x == NULL)
335 {
336 /* Error */
337 }
338
339Alternative method:
340
341 X509 *x = NULL;
342 if (!PEM_read_bio_X509(bp, &x, 0, NULL))
343 {
344 /* Error */
345 }
346
347Write a certificate to a BIO:
348
349 if (!PEM_write_bio_X509(bp, x))
350 {
351 /* Error */
352 }
353
354Write an unencrypted private key to a FILE pointer:
355
356 if (!PEM_write_PrivateKey(fp, key, NULL, NULL, 0, 0, NULL))
357 {
358 /* Error */
359 }
360
361Write a private key (using traditional format) to a BIO using
362triple DES encryption, the pass phrase is prompted for:
363
364 if (!PEM_write_bio_PrivateKey(bp, key, EVP_des_ede3_cbc(), NULL, 0, 0, NULL))
365 {
366 /* Error */
367 }
368
369Write a private key (using PKCS#8 format) to a BIO using triple
370DES encryption, using the pass phrase "hello":
371
372 if (!PEM_write_bio_PKCS8PrivateKey(bp, key, EVP_des_ede3_cbc(), NULL, 0, 0, "hello"))
373 {
374 /* Error */
375 }
376
377Read a private key from a BIO using the pass phrase "hello":
378
379 key = PEM_read_bio_PrivateKey(bp, NULL, 0, "hello");
380 if (key == NULL)
381 {
382 /* Error */
383 }
384
385Read a private key from a BIO using a pass phrase callback:
386
387 key = PEM_read_bio_PrivateKey(bp, NULL, pass_cb, "My Private Key");
388 if (key == NULL)
389 {
390 /* Error */
391 }
392
393Skeleton pass phrase callback:
394
395 int pass_cb(char *buf, int size, int rwflag, void *u);
396 {
397 int len;
398 char *tmp;
399 /* We'd probably do something else if 'rwflag' is 1 */
400 printf("Enter pass phrase for \"%s\"\n", u);
401
402 /* get pass phrase, length 'len' into 'tmp' */
403 tmp = "hello";
404 len = strlen(tmp);
405
406 if (len <= 0) return 0;
407 /* if too long, truncate */
408 if (len > size) len = size;
409 memcpy(buf, tmp, len);
410 return len;
411 }
412
413=head1 NOTES
414
415The old B<PrivateKey> write routines are retained for compatibility.
416New applications should write private keys using the
417PEM_write_bio_PKCS8PrivateKey() or PEM_write_PKCS8PrivateKey() routines
418because they are more secure (they use an iteration count of 2048 whereas
419the traditional routines use a count of 1) unless compatibility with older
420versions of OpenSSL is important.
421
422The B<PrivateKey> read routines can be used in all applications because
423they handle all formats transparently.
424
425A frequent cause of problems is attempting to use the PEM routines like
426this:
427
428 X509 *x;
429 PEM_read_bio_X509(bp, &x, 0, NULL);
430
431this is a bug because an attempt will be made to reuse the data at B<x>
432which is an uninitialised pointer.
433
434=head1 PEM ENCRYPTION FORMAT
435
436This old B<PrivateKey> routines use a non standard technique for encryption.
437
438The private key (or other data) takes the following form:
439
440 -----BEGIN RSA PRIVATE KEY-----
441 Proc-Type: 4,ENCRYPTED
442 DEK-Info: DES-EDE3-CBC,3F17F5316E2BAC89
443
444 ...base64 encoded data...
445 -----END RSA PRIVATE KEY-----
446
447The line beginning DEK-Info contains two comma separated pieces of information:
448the encryption algorithm name as used by EVP_get_cipherbyname() and an 8
449byte B<salt> encoded as a set of hexadecimal digits.
450
451After this is the base64 encoded encrypted data.
452
453The encryption key is determined using EVP_bytestokey(), using B<salt> and an
454iteration count of 1. The IV used is the value of B<salt> and *not* the IV
455returned by EVP_bytestokey().
456
457=head1 BUGS
458
459The PEM read routines in some versions of OpenSSL will not correctly reuse
460an existing structure. Therefore the following:
461
462 PEM_read_bio(bp, &x, 0, NULL);
463
464where B<x> already contains a valid certificate, may not work, whereas:
465
466 X509_free(x);
467 x = PEM_read_bio(bp, NULL, 0, NULL);
468
469is guaranteed to work.
470
471=head1 RETURN CODES
472
473The read routines return either a pointer to the structure read or NULL
474is an error occurred.
475
476The write routines return 1 for success or 0 for failure.
diff --git a/src/lib/libssl/src/doc/crypto/rsa.pod b/src/lib/libssl/src/doc/crypto/rsa.pod
index ef0d4df205..09ad30cab1 100644
--- a/src/lib/libssl/src/doc/crypto/rsa.pod
+++ b/src/lib/libssl/src/doc/crypto/rsa.pod
@@ -37,7 +37,6 @@ rsa - RSA public key cryptosystem
37 int RSA_set_method(RSA *rsa, ENGINE *engine); 37 int RSA_set_method(RSA *rsa, ENGINE *engine);
38 RSA_METHOD *RSA_get_method(RSA *rsa); 38 RSA_METHOD *RSA_get_method(RSA *rsa);
39 RSA_METHOD *RSA_PKCS1_SSLeay(void); 39 RSA_METHOD *RSA_PKCS1_SSLeay(void);
40 RSA_METHOD *RSA_PKCS1_RSAref(void);
41 RSA_METHOD *RSA_null_method(void); 40 RSA_METHOD *RSA_null_method(void);
42 int RSA_flags(RSA *rsa); 41 int RSA_flags(RSA *rsa);
43 RSA *RSA_new_method(ENGINE *engine); 42 RSA *RSA_new_method(ENGINE *engine);
diff --git a/src/lib/libssl/src/doc/crypto/threads.pod b/src/lib/libssl/src/doc/crypto/threads.pod
index bc7ff9b705..afa45cd76c 100644
--- a/src/lib/libssl/src/doc/crypto/threads.pod
+++ b/src/lib/libssl/src/doc/crypto/threads.pod
@@ -53,8 +53,10 @@ OpenSSL can safely be used in multi-threaded applications provided
53that at least two callback functions are set. 53that at least two callback functions are set.
54 54
55locking_function(int mode, int n, const char *file, int line) is 55locking_function(int mode, int n, const char *file, int line) is
56needed to perform locking on shared data structures. Multi-threaded 56needed to perform locking on shared data structures.
57applications will crash at random if it is not set. 57(Note that OpenSSL uses a number of global data structures that
58will be implicitly shared whenever multiple threads use OpenSSL.)
59Multi-threaded applications will crash at random if it is not set.
58 60
59locking_function() must be able to handle up to CRYPTO_num_locks() 61locking_function() must be able to handle up to CRYPTO_num_locks()
60different mutex locks. It sets the B<n>-th lock if B<mode> & 62different mutex locks. It sets the B<n>-th lock if B<mode> &
diff --git a/src/lib/libssl/src/doc/crypto/ui.pod b/src/lib/libssl/src/doc/crypto/ui.pod
new file mode 100644
index 0000000000..2b3535a746
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ui.pod
@@ -0,0 +1,194 @@
1=pod
2
3=head1 NAME
4
5UI_new, UI_new_method, UI_free, UI_add_input_string, UI_dup_input_string,
6UI_add_verify_string, UI_dup_verify_string, UI_add_input_boolean,
7UI_dup_input_boolean, UI_add_info_string, UI_dup_info_string,
8UI_add_error_string, UI_dup_error_string, UI_construct_prompt
9UI_add_user_data, UI_get0_user_data, UI_get0_result, UI_process,
10UI_ctrl, UI_set_default_method, UI_get_default_method, UI_get_method,
11UI_set_method, UI_OpenSSL, ERR_load_UI_strings - New User Interface
12
13=head1 SYNOPSIS
14
15 #include <openssl/ui.h>
16
17 typedef struct ui_st UI;
18 typedef struct ui_method_st UI_METHOD;
19
20 UI *UI_new(void);
21 UI *UI_new_method(const UI_METHOD *method);
22 void UI_free(UI *ui);
23
24 int UI_add_input_string(UI *ui, const char *prompt, int flags,
25 char *result_buf, int minsize, int maxsize);
26 int UI_dup_input_string(UI *ui, const char *prompt, int flags,
27 char *result_buf, int minsize, int maxsize);
28 int UI_add_verify_string(UI *ui, const char *prompt, int flags,
29 char *result_buf, int minsize, int maxsize, const char *test_buf);
30 int UI_dup_verify_string(UI *ui, const char *prompt, int flags,
31 char *result_buf, int minsize, int maxsize, const char *test_buf);
32 int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
33 const char *ok_chars, const char *cancel_chars,
34 int flags, char *result_buf);
35 int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
36 const char *ok_chars, const char *cancel_chars,
37 int flags, char *result_buf);
38 int UI_add_info_string(UI *ui, const char *text);
39 int UI_dup_info_string(UI *ui, const char *text);
40 int UI_add_error_string(UI *ui, const char *text);
41 int UI_dup_error_string(UI *ui, const char *text);
42
43 /* These are the possible flags. They can be or'ed together. */
44 #define UI_INPUT_FLAG_ECHO 0x01
45 #define UI_INPUT_FLAG_DEFAULT_PWD 0x02
46
47 char *UI_construct_prompt(UI *ui_method,
48 const char *object_desc, const char *object_name);
49
50 void *UI_add_user_data(UI *ui, void *user_data);
51 void *UI_get0_user_data(UI *ui);
52
53 const char *UI_get0_result(UI *ui, int i);
54
55 int UI_process(UI *ui);
56
57 int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)());
58 #define UI_CTRL_PRINT_ERRORS 1
59 #define UI_CTRL_IS_REDOABLE 2
60
61 void UI_set_default_method(const UI_METHOD *meth);
62 const UI_METHOD *UI_get_default_method(void);
63 const UI_METHOD *UI_get_method(UI *ui);
64 const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth);
65
66 UI_METHOD *UI_OpenSSL(void);
67
68=head1 DESCRIPTION
69
70UI stands for User Interface, and is general purpose set of routines to
71prompt the user for text-based information. Through user-written methods
72(see L<ui_create(3)|ui_create(3)>), prompting can be done in any way
73imaginable, be it plain text prompting, through dialog boxes or from a
74cell phone.
75
76All the functions work through a context of the type UI. This context
77contains all the information needed to prompt correctly as well as a
78reference to a UI_METHOD, which is an ordered vector of functions that
79carry out the actual prompting.
80
81The first thing to do is to create a UI with UI_new() or UI_new_method(),
82then add information to it with the UI_add or UI_dup functions. Also,
83user-defined random data can be passed down to the underlying method
84through calls to UI_add_user_data. The default UI method doesn't care
85about these data, but other methods might. Finally, use UI_process()
86to actually perform the prompting and UI_get0_result() to find the result
87to the prompt.
88
89A UI can contain more than one prompt, which are performed in the given
90sequence. Each prompt gets an index number which is returned by the
91UI_add and UI_dup functions, and has to be used to get the corresponding
92result with UI_get0_result().
93
94The functions are as follows:
95
96UI_new() creates a new UI using the default UI method. When done with
97this UI, it should be freed using UI_free().
98
99UI_new_method() creates a new UI using the given UI method. When done with
100this UI, it should be freed using UI_free().
101
102UI_OpenSSL() returns the built-in UI method (note: not the default one,
103since the default can be changed. See further on). This method is the
104most machine/OS dependent part of OpenSSL and normally generates the
105most problems when porting.
106
107UI_free() removes a UI from memory, along with all other pieces of memory
108that's connected to it, like duplicated input strings, results and others.
109
110UI_add_input_string() and UI_add_verify_string() add a prompt to the UI,
111as well as flags and a result buffer and the desired minimum and maximum
112sizes of the result. The given information is used to prompt for
113information, for example a password, and to verify a password (i.e. having
114the user enter it twice and check that the same string was entered twice).
115UI_add_verify_string() takes and extra argument that should be a pointer
116to the result buffer of the input string that it's supposed to verify, or
117verification will fail.
118
119UI_add_input_boolean() adds a prompt to the UI that's supposed to be answered
120in a boolean way, with a single character for yes and a different character
121for no. A set of characters that can be used to cancel the prompt is given
122as well. The prompt itself is really divided in two, one part being the
123descriptive text (given through the I<prompt> argument) and one describing
124the possible answers (given through the I<action_desc> argument).
125
126UI_add_info_string() and UI_add_error_string() add strings that are shown at
127the same time as the prompt for extra information or to show an error string.
128The difference between the two is only conceptual. With the builtin method,
129there's no technical difference between them. Other methods may make a
130difference between them, however.
131
132The flags currently supported are UI_INPUT_FLAG_ECHO, which is relevant for
133UI_add_input_string() and will have the users response be echoed (when
134prompting for a password, this flag should obviously not be used, and
135UI_INPUT_FLAG_DEFAULT_PWD, which means that a default password of some
136sort will be used (completely depending on the application and the UI
137method).
138
139UI_dup_input_string(), UI_dup_verify_string(), UI_dup_input_boolean(),
140UI_dup_info_string() and UI_dup_error_string() are basically the same
141as their UI_add counterparts, except that they make their own copies
142of all strings.
143
144UI_construct_prompt() is a helper function that can be used to create
145a prompt from two pieces of information: an description and a name.
146The default constructor (if there is none provided by the method used)
147creates a string "Enter I<description> for I<name>:". With the
148description "pass phrase" and the file name "foo.key", that becomes
149"Enter pass phrase for foo.key:". Other methods may create whatever
150string and may include encodings that will be processed by the other
151method functions.
152
153UI_add_user_data() adds a piece of memory for the method to use at any
154time. The builtin UI method doesn't care about this info. Note that several
155calls to this function doesn't add data, it replaces the previous blob
156with the one given as argument.
157
158UI_get0_user_data() retrieves the data that has last been given to the
159UI with UI_add_user_data().
160
161UI_get0_result() returns a pointer to the result buffer associated with
162the information indexed by I<i>.
163
164UI_process() goes through the information given so far, does all the printing
165and prompting and returns.
166
167UI_ctrl() adds extra control for the application author. For now, it
168understands two commands: UI_CTRL_PRINT_ERRORS, which makes UI_process()
169print the OpenSSL error stack as part of processing the UI, and
170UI_CTRL_IS_REDOABLE, which returns a flag saying if the used UI can
171be used again or not.
172
173UI_set_default_method() changes the default UI method to the one given.
174
175UI_get_default_method() returns a pointer to the current default UI method.
176
177UI_get_method() returns the UI method associated with a given UI.
178
179UI_set_method() changes the UI method associated with a given UI.
180
181=head1 SEE ALSO
182
183L<ui_create(3)|ui_create(3)>, L<ui_compat(3)|ui_compat(3)>
184
185=head1 HISTORY
186
187The UI section was first introduced in OpenSSL 0.9.7.
188
189=head1 AUTHOR
190
191Richard Levitte (richard@levitte.org) for the OpenSSL project
192(http://www.openssl.org).
193
194=cut
diff --git a/src/lib/libssl/src/doc/crypto/ui_compat.pod b/src/lib/libssl/src/doc/crypto/ui_compat.pod
new file mode 100644
index 0000000000..9ab3c69bf2
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ui_compat.pod
@@ -0,0 +1,55 @@
1=pod
2
3=head1 NAME
4
5des_read_password, des_read_2passwords, des_read_pw_string, des_read_pw -
6Compatibility user interface functions
7
8=head1 SYNOPSIS
9
10 int des_read_password(DES_cblock *key,const char *prompt,int verify);
11 int des_read_2passwords(DES_cblock *key1,DES_cblock *key2,
12 const char *prompt,int verify);
13
14 int des_read_pw_string(char *buf,int length,const char *prompt,int verify);
15 int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify);
16
17=head1 DESCRIPTION
18
19The DES library contained a few routines to prompt for passwords. These
20aren't necessarely dependent on DES, and have therefore become part of the
21UI compatibility library.
22
23des_read_pw() writes the string specified by I<prompt> to standard output
24turns echo off and reads an input string from the terminal. The string is
25returned in I<buf>, which must have spac for at least I<size> bytes.
26If I<verify> is set, the user is asked for the password twice and unless
27the two copies match, an error is returned. The second password is stored
28in I<buff>, which must therefore also be at least I<size> bytes. A return
29code of -1 indicates a system error, 1 failure due to use interaction, and
300 is success. All other functions described here use des_read_pw() to do
31the work.
32
33des_read_pw_string() is a variant of des_read_pw() that provides a buffer
34for you if I<verify> is set.
35
36des_read_password() calls des_read_pw() and converts the password to a
37DES key by calling DES_string_to_key(); des_read_2password() operates in
38the same way as des_read_password() except that it generates two keys
39by using the DES_string_to_2key() function.
40
41=head1 NOTES
42
43des_read_pw_string() is available in the MIT Kerberos library as well, and
44is also available under the name EVP_read_pw_string().
45
46=head1 SEE ALSO
47
48L<ui(3)|ui(3)>, L<ui_create(3)|ui_create(3)>
49
50=head1 AUTHOR
51
52Richard Levitte (richard@levitte.org) for the OpenSSL project
53(http://www.openssl.org).
54
55=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_COMP_add_compression_method.pod b/src/lib/libssl/src/doc/ssl/SSL_COMP_add_compression_method.pod
new file mode 100644
index 0000000000..2a98739114
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_COMP_add_compression_method.pod
@@ -0,0 +1,70 @@
1=pod
2
3=head1 NAME
4
5SSL_COMP_add_compression_method - handle SSL/TLS integrated compression methods
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm);
12
13=head1 DESCRIPTION
14
15SSL_COMP_add_compression_method() adds the compression method B<cm> with
16the identifier B<id> to the list of available compression methods. This
17list is globally maintained for all SSL operations within this application.
18It cannot be set for specific SSL_CTX or SSL objects.
19
20=head1 NOTES
21
22The TLS standard (or SSLv3) allows the integration of compression methods
23into the communication. The TLS RFC does however not specify compression
24methods or their corresponding identifiers, so there is currently no compatible
25way to integrate compression with unknown peers. It is therefore currently not
26recommended to integrate compression into applications. Applications for
27non-public use may agree on certain compression methods. Using different
28compression methods with the same identifier will lead to connection failure.
29
30An OpenSSL client speaking a protocol that allows compression (SSLv3, TLSv1)
31will unconditionally send the list of all compression methods enabled with
32SSL_COMP_add_compression_method() to the server during the handshake.
33Unlike the mechanisms to set a cipher list, there is no method available to
34restrict the list of compression method on a per connection basis.
35
36An OpenSSL server will match the identifiers listed by a client against
37its own compression methods and will unconditionally activate compression
38when a matching identifier is found. There is no way to restrict the list
39of compression methods supported on a per connection basis.
40
41The OpenSSL library has the compression methods B<COMP_rle()> and (when
42especially enabled during compilation) B<COMP_zlib()> available.
43
44=head1 WARNINGS
45
46Once the identities of the compression methods for the TLS protocol have
47been standardized, the compression API will most likely be changed. Using
48it in the current state is not recommended.
49
50=head1 RETURN VALUES
51
52SSL_COMP_add_compression_method() may return the following values:
53
54=over 4
55
56=item 1
57
58The operation succeeded.
59
60=item 0
61
62The operation failed. Check the error queue to find out the reason.
63
64=back
65
66=head1 SEE ALSO
67
68L<ssl(3)|ssl(3)>
69
70=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_add_extra_chain_cert.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_add_extra_chain_cert.pod
index 21a9db0e2a..ee28f5ccc3 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_add_extra_chain_cert.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_add_extra_chain_cert.pod
@@ -33,6 +33,7 @@ error stack to find out the reason for failure otherwise.
33 33
34L<ssl(3)|ssl(3)>, 34L<ssl(3)|ssl(3)>,
35L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>, 35L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,
36L<SSL_CTX_set_client_cert_cb(3)|SSL_CTX_set_client_cert_cb(3)>,
36L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)> 37L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>
37 38
38=cut 39=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_ctrl.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_ctrl.pod
new file mode 100644
index 0000000000..fb6adcf50c
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_ctrl.pod
@@ -0,0 +1,34 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_ctrl, SSL_CTX_callback_ctrl, SSL_ctrl, SSL_callback_ctrl - internal handling functions for SSL_CTX and SSL objects
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);
12 long SSL_CTX_callback_ctrl(SSL_CTX *, int cmd, void (*fp)());
13
14 long SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg);
15 long SSL_callback_ctrl(SSL *, int cmd, void (*fp)());
16
17=head1 DESCRIPTION
18
19The SSL_*_ctrl() family of functions is used to manipulate settings of
20the SSL_CTX and SSL objects. Depending on the command B<cmd> the arguments
21B<larg>, B<parg>, or B<fp> are evaluated. These functions should never
22be called directly. All functionalities needed are made available via
23other functions or macros.
24
25=head1 RETURN VALUES
26
27The return values of the SSL*_ctrl() functions depend on the command
28supplied via the B<cmd> parameter.
29
30=head1 SEE ALSO
31
32L<ssl(3)|ssl(3)>
33
34=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod
index c716cde164..55e592f5f8 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod
@@ -24,6 +24,8 @@ the certificates and keys.
24 24
25SSL_CTX_free() does not provide diagnostic information. 25SSL_CTX_free() does not provide diagnostic information.
26 26
27=head1 SEE ALSO
28
27L<SSL_CTX_new(3)|SSL_CTX_new(3)>, L<ssl(3)|ssl(3)> 29L<SSL_CTX_new(3)|SSL_CTX_new(3)>, L<ssl(3)|ssl(3)>
28 30
29=cut 31=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod
index 0f63537e78..84a799fc71 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod
@@ -58,7 +58,7 @@ failure.
58In server mode, when requesting a client certificate, the server must send 58In server mode, when requesting a client certificate, the server must send
59the list of CAs of which it will accept client certificates. This list 59the list of CAs of which it will accept client certificates. This list
60is not influenced by the contents of B<CAfile> or B<CApath> and must 60is not influenced by the contents of B<CAfile> or B<CApath> and must
61explicitely be set using the 61explicitly be set using the
62L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)> 62L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>
63family of functions. 63family of functions.
64 64
@@ -118,7 +118,7 @@ L<ssl(3)|ssl(3)>,
118L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>, 118L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>,
119L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>, 119L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>,
120L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>, 120L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,
121L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)> 121L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>,
122 122L<SSL_CTX_set_cert_store(3)|SSL_CTX_set_cert_store(3)>
123 123
124=cut 124=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_new.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_new.pod
index 1dae8b0bdd..465220a75c 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_new.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_new.pod
@@ -59,10 +59,6 @@ choice when compatibility is a concern.
59 59
60=back 60=back
61 61
62If a generic method is used, it is necessary to explicitly set client or
63server mode with L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>
64or SSL_set_accept_state().
65
66The list of protocols available can later be limited using the SSL_OP_NO_SSLv2, 62The list of protocols available can later be limited using the SSL_OP_NO_SSLv2,
67SSL_OP_NO_SSLv3, SSL_OP_NO_TLSv1 options of the B<SSL_CTX_set_options()> or 63SSL_OP_NO_SSLv3, SSL_OP_NO_TLSv1 options of the B<SSL_CTX_set_options()> or
68B<SSL_set_options()> functions. Using these options it is possible to choose 64B<SSL_set_options()> functions. Using these options it is possible to choose
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod
index b6f15b4404..6e0ef00632 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod
@@ -70,12 +70,16 @@ proposed by the client. The get_session_cb() is always called, also when
70session caching was disabled. The get_session_cb() is passed the 70session caching was disabled. The get_session_cb() is passed the
71B<ssl> connection, the session id of length B<length> at the memory location 71B<ssl> connection, the session id of length B<length> at the memory location
72B<data>. With the parameter B<copy> the callback can require the 72B<data>. With the parameter B<copy> the callback can require the
73SSL engine to increment the reference count of the SSL_SESSION object. 73SSL engine to increment the reference count of the SSL_SESSION object,
74Normally the reference count is not incremented and therefore the
75session must not be explicitly freed with
76L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>.
74 77
75=head1 SEE ALSO 78=head1 SEE ALSO
76 79
77L<ssl(3)|ssl(3)>, L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)>, 80L<ssl(3)|ssl(3)>, L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)>,
78L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>, 81L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
79L<SSL_CTX_flush_sessions(3)|<SSL_CTX_flush_sessions(3)> 82L<SSL_CTX_flush_sessions(3)|<SSL_CTX_flush_sessions(3)>,
83L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>
80 84
81=cut 85=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_store.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_store.pod
new file mode 100644
index 0000000000..81286ee650
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_store.pod
@@ -0,0 +1,57 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_cert_store, SSL_CTX_get_cert_store - manipulate X509 certificate verification storage
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_cert_store(SSL_CTX *ctx, X509_STORE *store);
12 X509_STORE *SSL_CTX_get_cert_store(SSL_CTX *ctx);
13
14=head1 DESCRIPTION
15
16SSL_CTX_set_cert_store() sets/replaces the certificate verification storage
17of B<ctx> to/with B<store>. If another X505_STORE object is currently
18set in B<ctx>, it will be X509_STORE_free()ed.
19
20SSL_CTX_get_cert_store() returns a pointer to the current certificate
21verification storage.
22
23=head1 NOTES
24
25In order to verify the certificates presented by the peer, trusted CA
26certificates must be accessed. These CA certificates are made available
27via lookup methods, handled inside the X509_STORE. From the X509_STORE
28the X509_STORE_CTX used when verifying certificates is created.
29
30Typically the trusted certificate store is handled indirectly via using
31L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>.
32Using the SSL_CTX_set_cert_store() and SSL_CTX_get_cert_store() functions
33it is possible to manipulate the X509_STORE object beyond the
34L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>
35call.
36
37Currently no detailed documentation on how to use the X509_STORE
38object is available. Not all members of the X509_STORE are used when
39the verification takes place. So will e.g. the verify_callback() be
40overridden with the verify_callback() set via the
41L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)> family of functions.
42This document must therefore be updated when documentation about the
43X509_STORE object and its handling becomes available.
44
45=head1 RETURN VALUES
46
47SSL_CTX_set_cert_store() does not return diagnostic output.
48
49SSL_CTX_get_cert_store() returns the current setting.
50
51=head1 SEE ALSO
52
53L<ssl(3)|ssl(3)>,
54L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>,
55L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>
56
57=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_verify_callback.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_verify_callback.pod
new file mode 100644
index 0000000000..c0f4f85708
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_verify_callback.pod
@@ -0,0 +1,75 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_cert_verify_callback - set peer certificate verification procedure
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*callback)(X509_STORE_CTX *,void *), void *arg);
12
13=head1 DESCRIPTION
14
15SSL_CTX_set_cert_verify_callback() sets the verification callback function for
16I<ctx>. SSL objects that are created from I<ctx> inherit the setting valid at
17the time when L<SSL_new(3)|SSL_new(3)> is called.
18
19=head1 NOTES
20
21Whenever a certificate is verified during a SSL/TLS handshake, a verification
22function is called. If the application does not explicitly specify a
23verification callback function, the built-in verification function is used.
24If a verification callback I<callback> is specified via
25SSL_CTX_set_cert_verify_callback(), the supplied callback function is called
26instead. By setting I<callback> to NULL, the default behaviour is restored.
27
28When the verification must be performed, I<callback> will be called with
29the arguments callback(X509_STORE_CTX *x509_store_ctx, void *arg). The
30argument I<arg> is specified by the application when setting I<callback>.
31
32I<callback> should return 1 to indicate verification success and 0 to
33indicate verification failure. If SSL_VERIFY_PEER is set and I<callback>
34returns 0, the handshake will fail. As the verification procedure may
35allow to continue the connection in case of failure (by always returning 1)
36the verification result must be set in any case using the B<error>
37member of I<x509_store_ctx> so that the calling application will be informed
38about the detailed result of the verification procedure!
39
40Within I<x509_store_ctx>, I<callback> has access to the I<verify_callback>
41function set using L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>.
42
43=head1 WARNINGS
44
45Do not mix the verification callback described in this function with the
46B<verify_callback> function called during the verification process. The
47latter is set using the L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>
48family of functions.
49
50Providing a complete verification procedure including certificate purpose
51settings etc is a complex task. The built-in procedure is quite powerful
52and in most cases it should be sufficient to modify its behaviour using
53the B<verify_callback> function.
54
55=head1 BUGS
56
57=head1 RETURN VALUES
58
59SSL_CTX_set_cert_verify_callback() does not provide diagnostic information.
60
61=head1 SEE ALSO
62
63L<ssl(3)|ssl(3)>, L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>,
64L<SSL_get_verify_result(3)|SSL_get_verify_result(3)>,
65L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>
66
67=head1 HISTORY
68
69Previous to OpenSSL 0.9.7, the I<arg> argument to B<SSL_CTX_set_cert_verify_callback>
70was ignored, and I<callback> was called simply as
71 int (*callback)(X509_STORE_CTX *)
72To compile software written for previous versions of OpenSSL, a dummy
73argument will have to be added to I<callback>.
74
75=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cipher_list.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cipher_list.pod
index 9a29eeeb95..ed64f64157 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cipher_list.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cipher_list.pod
@@ -34,9 +34,25 @@ a necessary condition. On the client side, the inclusion into the list is
34also sufficient. On the server side, additional restrictions apply. All ciphers 34also sufficient. On the server side, additional restrictions apply. All ciphers
35have additional requirements. ADH ciphers don't need a certificate, but 35have additional requirements. ADH ciphers don't need a certificate, but
36DH-parameters must have been set. All other ciphers need a corresponding 36DH-parameters must have been set. All other ciphers need a corresponding
37certificate and key. A RSA cipher can only be chosen, when a RSA certificate is 37certificate and key.
38available, the respective is valid for DSA ciphers. Ciphers using EDH need 38
39a certificate and key and DH-parameters. 39A RSA cipher can only be chosen, when a RSA certificate is available.
40RSA export ciphers with a keylength of 512 bits for the RSA key require
41a temporary 512 bit RSA key, as typically the supplied key has a length
42of 1024 bit (see
43L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>).
44RSA ciphers using EDH need a certificate and key and additional DH-parameters
45(see L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>).
46
47A DSA cipher can only be chosen, when a DSA certificate is available.
48DSA ciphers always use DH key exchange and therefore need DH-parameters
49(see L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>).
50
51When these conditions are not met for any cipher in the list (e.g. a
52client only supports export RSA ciphers with a asymmetric key length
53of 512 bits and the server is not configured to use temporary RSA
54keys), the "no shared cipher" (SSL_R_NO_SHARED_CIPHER) error is generated
55and the handshake will fail.
40 56
41=head1 RETURN VALUES 57=head1 RETURN VALUES
42 58
@@ -47,6 +63,8 @@ could be selected and 0 on complete failure.
47 63
48L<ssl(3)|ssl(3)>, L<SSL_get_ciphers(3)|SSL_get_ciphers(3)>, 64L<ssl(3)|ssl(3)>, L<SSL_get_ciphers(3)|SSL_get_ciphers(3)>,
49L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>, 65L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,
66L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>,
67L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>,
50L<ciphers(1)|ciphers(1)> 68L<ciphers(1)|ciphers(1)>
51 69
52=cut 70=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_cert_cb.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_cert_cb.pod
new file mode 100644
index 0000000000..53e1827713
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_cert_cb.pod
@@ -0,0 +1,90 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_client_cert_cb, SSL_CTX_get_client_cert_cb - handle client certificate callback function
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey));
12 int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
13 int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
14
15=head1 DESCRIPTION
16
17SSL_CTX_set_client_cert_cb() sets the B<client_cert_cb()> callback, that is
18called when a client certificate is requested by a server.
19When B<client_cert_cb()> is NULL, not callback function is used.
20
21SSL_CTX_get_client_cert_cb() returns a pointer to the currently set callback
22function.
23
24client_cert_cb() is the application defined callback. If it wants to
25set a certificate, a certificate/private key combination must be set
26using the B<x509> and B<pkey> arguments and "1" must be returned. The
27certificate will be installed into B<ssl>, see the NOTES and BUGS sections.
28If no certificate should be set, "0" has to be returned and the default
29certificate will be sent. A fatal error can be indicated by returning
30a negative value, in which case the handshake will be canceled.
31
32=head1 NOTES
33
34During a handshake (or renegotiation) a server may request a certificate
35from the client. A client certificate must only be sent, when the server
36did send the request.
37
38When no callback function is set, an OpenSSL client will send the certificate
39that was set using the
40L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)> family of functions.
41The TLS standard requires that only a certificate is sent, if it matches
42the list of acceptable CAs sent by the server. This constraint is
43violated by the default behavior of the OpenSSL library. Using the
44callback function it is possible to implement a proper selection routine
45or to allow a user interaction to choose the certificate to be sent.
46The callback function can obtain the list of acceptable CAs using the
47L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)> function.
48
49If a callback function is defined, the callback function will be called.
50If the callback function returns a certificate, the OpenSSL library
51will try to load the private key and certificate data into the SSL
52object using SSL_use_certificate() and SSL_use_private_key() functions.
53Thus it will permanently override the certificate and key previously
54installed and will not be reset by calling L<SSL_clear(3)|SSL_clear(3)>.
55If the callback returns no certificate, the OpenSSL library will send
56the certificate previously installed for the SSL_CTX object or the specific
57certificate of the SSL object, if available.
58
59=head1 BUGS
60
61The client_cert_cb() cannot return a complete certificate chain, it can
62only return one client certificate. If the chain only has a length of 2,
63the root CA certificate may be omitted according to the TLS standard and
64thus a standard conforming answer can be sent to the server. For a
65longer chain, the client must send the complete chain (with the option
66to leave out the root CA certificate). This can only be accomplished by
67either adding the intermediate CA certificates into the trusted
68certificate store for the SSL_CTX object (resulting in having to add
69CA certificates that otherwise maybe would not be trusted), or by adding
70the chain certificates using the
71L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>
72function, which is only available for the SSL_CTX object as a whole and that
73therefore probably can only apply for one client certificate, making
74the concept of the callback function (to allow the choice from several
75certificates) questionable.
76
77Once the SSL object has been used in conjunction with the callback function,
78the certificate will be set for the SSL object and will not be cleared
79even when L<SSL_clear(3)|SSL_clear(3)> is being called. It is therefore
80mandatory to destroy the SSL object using L<SSL_free(3)|SSL_free(3)>
81and create a new one to return to the previous state.
82
83=head1 SEE ALSO
84
85L<ssl(3)|ssl(3)>, L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,
86L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>,
87L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>,
88L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>
89
90=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_default_passwd_cb.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_default_passwd_cb.pod
index a5343a1cf3..2b87f01ca1 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_default_passwd_cb.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_default_passwd_cb.pod
@@ -40,6 +40,12 @@ then keep it in memory and use it several times. In the last case, the
40password could be stored into the B<userdata> storage and the 40password could be stored into the B<userdata> storage and the
41pem_passwd_cb() only returns the password already stored. 41pem_passwd_cb() only returns the password already stored.
42 42
43When asking for the password interactively, pem_passwd_cb() can use
44B<rwflag> to check, whether an item shall be encrypted (rwflag=1).
45In this case the password dialog may ask for the same password twice
46for comparison in order to catch typos, that would make decryption
47impossible.
48
43Other items in PEM formatting (certificates) can also be encrypted, it is 49Other items in PEM formatting (certificates) can also be encrypted, it is
44however not usual, as certificate information is considered public. 50however not usual, as certificate information is considered public.
45 51
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_generate_session_id.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_generate_session_id.pod
new file mode 100644
index 0000000000..798e8443a7
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_generate_session_id.pod
@@ -0,0 +1,150 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_generate_session_id, SSL_set_generate_session_id, SSL_has_matching_session_id - manipulate generation of SSL session IDs (server only)
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id,
12 unsigned int *id_len);
13
14 int SSL_CTX_set_generate_session_id(SSL_CTX *ctx, GEN_SESSION_CB cb);
15 int SSL_set_generate_session_id(SSL *ssl, GEN_SESSION_CB, cb);
16 int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id,
17 unsigned int id_len);
18
19=head1 DESCRIPTION
20
21SSL_CTX_set_generate_session_id() sets the callback function for generating
22new session ids for SSL/TLS sessions for B<ctx> to be B<cb>.
23
24SSL_set_generate_session_id() sets the callback function for generating
25new session ids for SSL/TLS sessions for B<ssl> to be B<cb>.
26
27SSL_has_matching_session_id() checks, whether a session with id B<id>
28(of length B<id_len>) is already contained in the internal session cache
29of the parent context of B<ssl>.
30
31=head1 NOTES
32
33When a new session is established between client and server, the server
34generates a session id. The session id is an arbitrary sequence of bytes.
35The length of the session id is 16 bytes for SSLv2 sessions and between
361 and 32 bytes for SSLv3/TLSv1. The session id is not security critical
37but must be unique for the server. Additionally, the session id is
38transmitted in the clear when reusing the session so it must not contain
39sensitive information.
40
41Without a callback being set, an OpenSSL server will generate a unique
42session id from pseudo random numbers of the maximum possible length.
43Using the callback function, the session id can be changed to contain
44additional information like e.g. a host id in order to improve load balancing
45or external caching techniques.
46
47The callback function receives a pointer to the memory location to put
48B<id> into and a pointer to the maximum allowed length B<id_len>. The
49buffer at location B<id> is only guaranteed to have the size B<id_len>.
50The callback is only allowed to generate a shorter id and reduce B<id_len>;
51the callback B<must never> increase B<id_len> or write to the location
52B<id> exceeding the given limit.
53
54If a SSLv2 session id is generated and B<id_len> is reduced, it will be
55restored after the callback has finished and the session id will be padded
56with 0x00. It is not recommended to change the B<id_len> for SSLv2 sessions.
57The callback can use the L<SSL_get_version(3)|SSL_get_version(3)> function
58to check, whether the session is of type SSLv2.
59
60The location B<id> is filled with 0x00 before the callback is called, so the
61callback may only fill part of the possible length and leave B<id_len>
62untouched while maintaining reproducibility.
63
64Since the sessions must be distinguished, session ids must be unique.
65Without the callback a random number is used, so that the probability
66of generating the same session id is extremely small (2^128 possible ids
67for an SSLv2 session, 2^256 for SSLv3/TLSv1). In order to assure the
68uniqueness of the generated session id, the callback must call
69SSL_has_matching_session_id() and generate another id if a conflict occurs.
70If an id conflict is not resolved, the handshake will fail.
71If the application codes e.g. a unique host id, a unique process number, and
72a unique sequence number into the session id, uniqueness could easily be
73achieved without randomness added (it should however be taken care that
74no confidential information is leaked this way). If the application can not
75guarantee uniqueness, it is recommended to use the maximum B<id_len> and
76fill in the bytes not used to code special information with random data
77to avoid collisions.
78
79SSL_has_matching_session_id() will only query the internal session cache,
80not the external one. Since the session id is generated before the
81handshake is completed, it is not immediately added to the cache. If
82another thread is using the same internal session cache, a race condition
83can occur in that another thread generates the same session id.
84Collisions can also occur when using an external session cache, since
85the external cache is not tested with SSL_has_matching_session_id()
86and the same race condition applies.
87
88When calling SSL_has_matching_session_id() for an SSLv2 session with
89reduced B<id_len>, the match operation will be performed using the
90fixed length required and with a 0x00 padded id.
91
92The callback must return 0 if it cannot generate a session id for whatever
93reason and return 1 on success.
94
95=head1 EXAMPLES
96
97The callback function listed will generate a session id with the
98server id given, and will fill the rest with pseudo random bytes:
99
100 const char session_id_prefix = "www-18";
101
102 #define MAX_SESSION_ID_ATTEMPTS 10
103 static int generate_session_id(const SSL *ssl, unsigned char *id,
104 unsigned int *id_len)
105 {
106 unsigned int count = 0;
107 const char *version;
108
109 version = SSL_get_version(ssl);
110 if (!strcmp(version, "SSLv2"))
111 /* we must not change id_len */;
112
113 do {
114 RAND_pseudo_bytes(id, *id_len);
115 /* Prefix the session_id with the required prefix. NB: If our
116 * prefix is too long, clip it - but there will be worse effects
117 * anyway, eg. the server could only possibly create 1 session
118 * ID (ie. the prefix!) so all future session negotiations will
119 * fail due to conflicts. */
120 memcpy(id, session_id_prefix,
121 (strlen(session_id_prefix) < *id_len) ?
122 strlen(session_id_prefix) : *id_len);
123 }
124 while(SSL_has_matching_session_id(ssl, id, *id_len) &&
125 (++count < MAX_SESSION_ID_ATTEMPTS));
126 if(count >= MAX_SESSION_ID_ATTEMPTS)
127 return 0;
128 return 1;
129 }
130
131
132=head1 RETURN VALUES
133
134SSL_CTX_set_generate_session_id() and SSL_set_generate_session_id()
135always return 1.
136
137SSL_has_matching_session_id() returns 1 if another session with the
138same id is already in the cache.
139
140=head1 SEE ALSO
141
142L<ssl(3)|ssl(3)>, L<SSL_get_version(3)|SSL_get_version(3)>
143
144=head1 HISTORY
145
146SSL_CTX_set_generate_session_id(), SSL_set_generate_session_id()
147and SSL_has_matching_session_id() have been introduced in
148OpenSSL 0.9.7.
149
150=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_info_callback.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_info_callback.pod
new file mode 100644
index 0000000000..63d0b8d33f
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_info_callback.pod
@@ -0,0 +1,153 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_info_callback, SSL_CTX_get_info_callback, SSL_set_info_callback, SSL_get_info_callback - handle information callback for SSL connections
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*callback)());
12 void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))();
13
14 void SSL_set_info_callback(SSL *ssl, void (*callback)());
15 void (*SSL_get_info_callback(SSL *ssl))();
16
17=head1 DESCRIPTION
18
19SSL_CTX_set_info_callback() sets the B<callback> function, that can be used to
20obtain state information for SSL objects created from B<ctx> during connection
21setup and use. The setting for B<ctx> is overridden from the setting for
22a specific SSL object, if specified.
23When B<callback> is NULL, not callback function is used.
24
25SSL_set_info_callback() sets the B<callback> function, that can be used to
26obtain state information for B<ssl> during connection setup and use.
27When B<callback> is NULL, the callback setting currently valid for
28B<ctx> is used.
29
30SSL_CTX_get_info_callback() returns a pointer to the currently set information
31callback function for B<ctx>.
32
33SSL_get_info_callback() returns a pointer to the currently set information
34callback function for B<ssl>.
35
36=head1 NOTES
37
38When setting up a connection and during use, it is possible to obtain state
39information from the SSL/TLS engine. When set, an information callback function
40is called whenever the state changes, an alert appears, or an error occurs.
41
42The callback function is called as B<callback(SSL *ssl, int where, int ret)>.
43The B<where> argument specifies information about where (in which context)
44the callback function was called. If B<ret> is 0, an error condition occurred.
45If an alert is handled, SSL_CB_ALERT is set and B<ret> specifies the alert
46information.
47
48B<where> is a bitmask made up of the following bits:
49
50=over 4
51
52=item SSL_CB_LOOP
53
54Callback has been called to indicate state change inside a loop.
55
56=item SSL_CB_EXIT
57
58Callback has been called to indicate error exit of a handshake function.
59(May be soft error with retry option for non-blocking setups.)
60
61=item SSL_CB_READ
62
63Callback has been called during read operation.
64
65=item SSL_CB_WRITE
66
67Callback has been called during write operation.
68
69=item SSL_CB_ALERT
70
71Callback has been called due to an alert being sent or received.
72
73=item SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ)
74
75=item SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE)
76
77=item SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP)
78
79=item SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT)
80
81=item SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP)
82
83=item SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT)
84
85=item SSL_CB_HANDSHAKE_START
86
87Callback has been called because a new handshake is started.
88
89=item SSL_CB_HANDSHAKE_DONE 0x20
90
91Callback has been called because a handshake is finished.
92
93=back
94
95The current state information can be obtained using the
96L<SSL_state_string(3)|SSL_state_string(3)> family of functions.
97
98The B<ret> information can be evaluated using the
99L<SSL_alert_type_string(3)|SSL_alert_type_string(3)> family of functions.
100
101=head1 RETURN VALUES
102
103SSL_set_info_callback() does not provide diagnostic information.
104
105SSL_get_info_callback() returns the current setting.
106
107=head1 EXAMPLES
108
109The following example callback function prints state strings, information
110about alerts being handled and error messages to the B<bio_err> BIO.
111
112 void apps_ssl_info_callback(SSL *s, int where, int ret)
113 {
114 const char *str;
115 int w;
116
117 w=where& ~SSL_ST_MASK;
118
119 if (w & SSL_ST_CONNECT) str="SSL_connect";
120 else if (w & SSL_ST_ACCEPT) str="SSL_accept";
121 else str="undefined";
122
123 if (where & SSL_CB_LOOP)
124 {
125 BIO_printf(bio_err,"%s:%s\n",str,SSL_state_string_long(s));
126 }
127 else if (where & SSL_CB_ALERT)
128 {
129 str=(where & SSL_CB_READ)?"read":"write";
130 BIO_printf(bio_err,"SSL3 alert %s:%s:%s\n",
131 str,
132 SSL_alert_type_string_long(ret),
133 SSL_alert_desc_string_long(ret));
134 }
135 else if (where & SSL_CB_EXIT)
136 {
137 if (ret == 0)
138 BIO_printf(bio_err,"%s:failed in %s\n",
139 str,SSL_state_string_long(s));
140 else if (ret < 0)
141 {
142 BIO_printf(bio_err,"%s:error in %s\n",
143 str,SSL_state_string_long(s));
144 }
145 }
146 }
147
148=head1 SEE ALSO
149
150L<ssl(3)|ssl(3)>, L<SSL_state_string(3)|SSL_state_string(3)>,
151L<SSL_alert_type_string(3)|SSL_alert_type_string(3)>
152
153=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_max_cert_list.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_max_cert_list.pod
new file mode 100644
index 0000000000..da68cb9fc2
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_max_cert_list.pod
@@ -0,0 +1,77 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_max_cert_list, SSL_CTX_get_max_cert_list, SSL_set_max_cert_list, SSL_get_max_cert_list, - manipulate allowed for the peer's certificate chain
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 long SSL_CTX_set_max_cert_list(SSL_CTX *ctx, long size);
12 long SSL_CTX_get_max_cert_list(SSL_CTX *ctx);
13
14 long SSL_set_max_cert_list(SSL *ssl, long size);
15 long SSL_get_max_cert_list(SSL *ctx);
16
17=head1 DESCRIPTION
18
19SSL_CTX_set_max_cert_list() sets the maximum size allowed for the peer's
20certificate chain for all SSL objects created from B<ctx> to be <size> bytes.
21The SSL objects inherit the setting valid for B<ctx> at the time
22L<SSL_new(3)|SSL_new(3)> is being called.
23
24SSL_CTX_get_max_cert_list() returns the currently set maximum size for B<ctx>.
25
26SSL_set_max_cert_list() sets the maximum size allowed for the peer's
27certificate chain for B<ssl> to be <size> bytes. This setting stays valid
28until a new value is set.
29
30SSL_get_max_cert_list() returns the currently set maximum size for B<ssl>.
31
32=head1 NOTES
33
34During the handshake process, the peer may send a certificate chain.
35The TLS/SSL standard does not give any maximum size of the certificate chain.
36The OpenSSL library handles incoming data by a dynamically allocated buffer.
37In order to prevent this buffer from growing without bounds due to data
38received from a faulty or malicious peer, a maximum size for the certificate
39chain is set.
40
41The default value for the maximum certificate chain size is 100kB (30kB
42on the 16bit DOS platform). This should be sufficient for usual certificate
43chains (OpenSSL's default maximum chain length is 10, see
44L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>, and certificates
45without special extensions have a typical size of 1-2kB).
46
47For special applications it can be necessary to extend the maximum certificate
48chain size allowed to be sent by the peer, see e.g. the work on
49"Internet X.509 Public Key Infrastructure Proxy Certificate Profile"
50and "TLS Delegation Protocol" at http://www.ietf.org/ and
51http://www.globus.org/ .
52
53Under normal conditions it should never be necessary to set a value smaller
54than the default, as the buffer is handled dynamically and only uses the
55memory actually required by the data sent by the peer.
56
57If the maximum certificate chain size allowed is exceeded, the handshake will
58fail with a SSL_R_EXCESSIVE_MESSAGE_SIZE error.
59
60=head1 RETURN VALUES
61
62SSL_CTX_set_max_cert_list() and SSL_set_max_cert_list() return the previously
63set value.
64
65SSL_CTX_get_max_cert_list() and SSL_get_max_cert_list() return the currently
66set value.
67
68=head1 SEE ALSO
69
70L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>,
71L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>
72
73=head1 HISTORY
74
75SSL*_set/get_max_cert_list() have been introduced in OpenSSL 0.9.7.
76
77=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_mode.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_mode.pod
index 9a035bb4d1..9822544e5e 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_mode.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_mode.pod
@@ -37,6 +37,9 @@ The following mode changes are available:
37Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success 37Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success
38when just a single record has been written). When not set (the default), 38when just a single record has been written). When not set (the default),
39SSL_write() will only report success once the complete chunk was written. 39SSL_write() will only report success once the complete chunk was written.
40Once SSL_write() returns with r, r bytes have been successfully written
41and the next call to SSL_write() must only send the n-r bytes left,
42imitating the behaviour of write().
40 43
41=item SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 44=item SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
42 45
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_msg_callback.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_msg_callback.pod
new file mode 100644
index 0000000000..a423932d0a
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_msg_callback.pod
@@ -0,0 +1,97 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_msg_callback, SSL_CTX_set_msg_callback_arg, SSL_set_msg_callback, SSL_get_msg_callback_arg - install callback for observing protocol messages
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
12 void SSL_CTX_set_msg_callback_arg(SSL_CTX *ctx, void *arg);
13
14 void SSL_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
15 void SSL_set_msg_callback_arg(SSL_CTX *ctx, void *arg);
16
17=head1 DESCRIPTION
18
19SSL_CTX_set_msg_callback() or SSL_set_msg_callback() can be used to
20define a message callback function I<cb> for observing all SSL/TLS
21protocol messages (such as handshake messages) that are received or
22sent. SSL_CTX_set_msg_callback_arg() and SSL_set_msg_callback_arg()
23can be used to set argument I<arg> to the callback function, which is
24available for arbitrary application use.
25
26SSL_CTX_set_msg_callback() and SSL_CTX_set_msg_callback_arg() specify
27default settings that will be copied to new B<SSL> objects by
28L<SSL_new(3)|SSL_new(3)>. SSL_set_msg_callback() and
29SSL_set_msg_callback_arg() modify the actual settings of an B<SSL>
30object. Using a B<0> pointer for I<cb> disables the message callback.
31
32When I<cb> is called by the SSL/TLS library for a protocol message,
33the function arguments have the following meaning:
34
35=over 4
36
37=item I<write_p>
38
39This flag is B<0> when a protocol message has been received and B<1>
40when a protocol message has been sent.
41
42=item I<version>
43
44The protocol version according to which the protocol message is
45interpreted by the library. Currently, this is one of
46B<SSL2_VERSION>, B<SSL3_VERSION> and B<TLS1_VERSION> (for SSL 2.0, SSL
473.0 and TLS 1.0, respectively).
48
49=item I<content_type>
50
51In the case of SSL 2.0, this is always B<0>. In the case of SSL 3.0
52or TLS 1.0, this is one of the B<ContentType> values defined in the
53protocol specification (B<change_cipher_spec(20)>, B<alert(21)>,
54B<handshake(22)>; but never B<application_data(23)> because the
55callback will only be called for protocol messages).
56
57=item I<buf>, I<len>
58
59I<buf> points to a buffer containing the protocol message, which
60consists of I<len> bytes. The buffer is no longer valid after the
61callback function has returned.
62
63=item I<ssl>
64
65The B<SSL> object that received or sent the message.
66
67=item I<arg>
68
69The user-defined argument optionally defined by
70SSL_CTX_set_msg_callback_arg() or SSL_set_msg_callback_arg().
71
72=head1 NOTES
73
74Protocol messages are passed to the callback function after decryption
75and fragment collection where applicable. (Thus record boundaries are
76not visible.)
77
78If processing a received protocol message results in an error,
79the callback function may not be called. For example, the callback
80function will never see messages that are considered too large to be
81processed.
82
83Due to automatic protocol version negotiation, I<version> is not
84necessarily the protocol version used by the sender of the message: If
85a TLS 1.0 ClientHello message is received by an SSL 3.0-only server,
86I<version> will be B<SSL3_VERSION>.
87
88=head1 SEE ALSO
89
90L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>
91
92=head1 HISTORY
93
94SSL_CTX_set_msg_callback(), SSL_CTX_set_msg_callback_arg(),
95SSL_set_msg_callback() and SSL_get_msg_callback_arg() were added in OpenSSL 0.9.7.
96
97=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod
index 3dc7cc74ad..c10055c6e7 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod
@@ -17,10 +17,10 @@ SSL_CTX_set_options, SSL_set_options, SSL_CTX_get_options, SSL_get_options - man
17=head1 DESCRIPTION 17=head1 DESCRIPTION
18 18
19SSL_CTX_set_options() adds the options set via bitmask in B<options> to B<ctx>. 19SSL_CTX_set_options() adds the options set via bitmask in B<options> to B<ctx>.
20Options already set before are not cleared. 20Options already set before are not cleared!
21 21
22SSL_set_options() adds the options set via bitmask in B<options> to B<ssl>. 22SSL_set_options() adds the options set via bitmask in B<options> to B<ssl>.
23Options already set before are not cleared. 23Options already set before are not cleared!
24 24
25SSL_CTX_get_options() returns the options set for B<ctx>. 25SSL_CTX_get_options() returns the options set for B<ctx>.
26 26
@@ -32,7 +32,12 @@ The behaviour of the SSL library can be changed by setting several options.
32The options are coded as bitmasks and can be combined by a logical B<or> 32The options are coded as bitmasks and can be combined by a logical B<or>
33operation (|). Options can only be added but can never be reset. 33operation (|). Options can only be added but can never be reset.
34 34
35During a handshake, the option settings of the SSL object used. When 35SSL_CTX_set_options() and SSL_set_options() affect the (external)
36protocol behaviour of the SSL library. The (internal) behaviour of
37the API can be changed by using the similar
38L<SSL_CTX_set_modes(3)|SSL_CTX_set_modes(3)> and SSL_set_modes() functions.
39
40During a handshake, the option settings of the SSL object are used. When
36a new SSL object is created from a context using SSL_new(), the current 41a new SSL object is created from a context using SSL_new(), the current
37option setting is copied. Changes to B<ctx> do not affect already created 42option setting is copied. Changes to B<ctx> do not affect already created
38SSL objects. SSL_clear() does not affect the settings. 43SSL objects. SSL_clear() does not affect the settings.
@@ -95,38 +100,62 @@ doing a re-connect, always takes the first cipher in the cipher list.
95 100
96... 101...
97 102
98=item SSL_OP_TLS_ROLLBACK_BUG
99
100Disable version rollback attack detection.
101
102During the client key exchange, the client must send the same information
103about acceptable SSL/TLS protocol levels as during the first hello. Some
104clients violate this rule by adapting to the server's answer. (Example:
105the client sends a SSLv2 hello and accepts up to SSLv3.1=TLSv1, the server
106only understands up to SSLv3. In this case the client must still use the
107same SSLv3.1=TLSv1 announcement. Some clients step down to SSLv3 with respect
108to the server's answer and violate the version rollback protection.)
109
110=item SSL_OP_ALL 103=item SSL_OP_ALL
111 104
112All of the above bug workarounds. 105All of the above bug workarounds.
113 106
114=back 107=back
115 108
116It is save and recommended to use SSL_OP_ALL to enable the bug workaround 109It is safe and recommended to use B<SSL_OP_ALL> to enable the bug workaround
117options. 110options.
118 111
119The following B<modifying> options are available: 112The following B<modifying> options are available:
120 113
121=over 4 114=over 4
122 115
116=item SSL_OP_TLS_ROLLBACK_BUG
117
118Disable version rollback attack detection.
119
120During the client key exchange, the client must send the same information
121about acceptable SSL/TLS protocol levels as during the first hello. Some
122clients violate this rule by adapting to the server's answer. (Example:
123the client sends a SSLv2 hello and accepts up to SSLv3.1=TLSv1, the server
124only understands up to SSLv3. In this case the client must still use the
125same SSLv3.1=TLSv1 announcement. Some clients step down to SSLv3 with respect
126to the server's answer and violate the version rollback protection.)
127
123=item SSL_OP_SINGLE_DH_USE 128=item SSL_OP_SINGLE_DH_USE
124 129
125Always create a new key when using temporary DH parameters. 130Always create a new key when using temporary/ephemeral DH parameters
131(see L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>).
132This option must be used to prevent small subgroup attacks, when
133the DH parameters were not generated using "strong" primes
134(e.g. when using DSA-parameters, see L<dhparam(1)|dhparam(1)>).
135If "strong" primes were used, it is not strictly necessary to generate
136a new DH key during each handshake but it is also recommended.
137B<SSL_OP_SINGLE_DH_USE> should therefore be enabled whenever
138temporary/ephemeral DH parameters are used.
126 139
127=item SSL_OP_EPHEMERAL_RSA 140=item SSL_OP_EPHEMERAL_RSA
128 141
129Also use the temporary RSA key when doing RSA operations. 142Always use ephemeral (temporary) RSA key when doing RSA operations
143(see L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>).
144According to the specifications this is only done, when a RSA key
145can only be used for signature operations (namely under export ciphers
146with restricted RSA keylength). By setting this option, ephemeral
147RSA keys are always used. This option breaks compatibility with the
148SSL/TLS specifications and may lead to interoperability problems with
149clients and should therefore never be used. Ciphers with EDH (ephemeral
150Diffie-Hellman) key exchange should be used instead.
151
152=item SSL_OP_CIPHER_SERVER_PREFERENCE
153
154When choosing a cipher, use the server's preferences instead of the client
155preferences. When not set, the SSL server will always follow the clients
156preferences. When set, the SSLv3/TLSv1 server will choose following its
157own preferences. Because of the different protocol, for SSLv2 the server
158will send his list of preferences to the client and the client chooses.
130 159
131=item SSL_OP_PKCS1_CHECK_1 160=item SSL_OP_PKCS1_CHECK_1
132 161
@@ -142,11 +171,6 @@ If we accept a netscape connection, demand a client cert, have a
142non-self-sighed CA which does not have it's CA in netscape, and the 171non-self-sighed CA which does not have it's CA in netscape, and the
143browser has a cert, it will crash/hang. Works for 3.x and 4.xbeta 172browser has a cert, it will crash/hang. Works for 3.x and 4.xbeta
144 173
145=item SSL_OP_NON_EXPORT_FIRST
146
147On servers try to use non-export (stronger) ciphers first. This option does
148not work under all circumstances (in the code it is declared "broken").
149
150=item SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 174=item SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG
151 175
152... 176...
@@ -163,6 +187,12 @@ Do not use the SSLv3 protocol.
163 187
164Do not use the TLSv1 protocol. 188Do not use the TLSv1 protocol.
165 189
190=item SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
191
192When performing renegotiation as a server, always start a new session
193(i.e., session resumption requests are only accepted in the initial
194handshake). This option is not needed for clients.
195
166=back 196=back
167 197
168=head1 RETURN VALUES 198=head1 RETURN VALUES
@@ -174,10 +204,19 @@ SSL_CTX_get_options() and SSL_get_options() return the current bitmask.
174 204
175=head1 SEE ALSO 205=head1 SEE ALSO
176 206
177L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>, L<SSL_clear(3)|SSL_clear(3)> 207L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>, L<SSL_clear(3)|SSL_clear(3)>,
208L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>,
209L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>,
210L<dhparam(1)|dhparam(1)>
178 211
179=head1 HISTORY 212=head1 HISTORY
180 213
181SSL_OP_TLS_ROLLBACK_BUG has been added in OpenSSL 0.9.6. 214B<SSL_OP_CIPHER_SERVER_PREFERENCE> and
215B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> have been added in
216OpenSSL 0.9.7.
217
218B<SSL_OP_TLS_ROLLBACK_BUG> has been added in OpenSSL 0.9.6 and was automatically
219enabled with B<SSL_OP_ALL>. As of 0.9.7, it is no longer included in B<SSL_OP_ALL>
220and must be explicitly set.
182 221
183=cut 222=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_quiet_shutdown.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_quiet_shutdown.pod
new file mode 100644
index 0000000000..1d0526d59a
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_quiet_shutdown.pod
@@ -0,0 +1,63 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_quiet_shutdown, SSL_CTX_get_quiet_shutdown, SSL_set_quiet_shutdown, SSL_get_quiet_shutdown - manipulate shutdown behaviour
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode);
12 int SSL_CTX_get_quiet_shutdown(SSL_CTX *ctx);
13
14 void SSL_set_quiet_shutdown(SSL *ssl, int mode);
15 int SSL_get_quiet_shutdown(SSL *ssl);
16
17=head1 DESCRIPTION
18
19SSL_CTX_set_quiet_shutdown() sets the "quiet shutdown" flag for B<ctx> to be
20B<mode>. SSL objects created from B<ctx> inherit the B<mode> valid at the time
21L<SSL_new(3)|SSL_new(3)> is called. B<mode> may be 0 or 1.
22
23SSL_CTX_get_quiet_shutdown() returns the "quiet shutdown" setting of B<ctx>.
24
25SSL_set_quiet_shutdown() sets the "quiet shutdown" flag for B<ssl> to be
26B<mode>. The setting stays valid until B<ssl> is removed with
27L<SSL_free(3)|SSL_free(3)> or SSL_set_quiet_shutdown() is called again.
28It is not changed when L<SSL_clear(3)|SSL_clear(3)> is called.
29B<mode> may be 0 or 1.
30
31SSL_get_quiet_shutdown() returns the "quiet shutdown" setting of B<ssl>.
32
33=head1 NOTES
34
35Normally when a SSL connection is finished, the parties must send out
36"close notify" alert messages using L<SSL_shutdown(3)|SSL_shutdown(3)>
37for a clean shutdown.
38
39When setting the "quiet shutdown" flag to 1, L<SSL_shutdown(3)|SSL_shutdown(3)>
40will set the internal flags to SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN.
41(L<SSL_shutdown(3)|SSL_shutdown(3)> then behaves like
42L<SSL_set_shutdown(3)|SSL_set_shutdown(3)> called with
43SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN.)
44The session is thus considered to be shutdown, but no "close notify" alert
45is sent to the peer. This behaviour violates the TLS standard.
46
47The default is normal shutdown behaviour as described by the TLS standard.
48
49=head1 RETURN VALUES
50
51SSL_CTX_set_quiet_shutdown() and SSL_set_quiet_shutdown() do not return
52diagnostic information.
53
54SSL_CTX_get_quiet_shutdown() and SSL_get_quiet_shutdown return the current
55setting.
56
57=head1 SEE ALSO
58
59L<ssl(3)|ssl(3)>, L<SSL_shutdown(3)|SSL_shutdown(3)>,
60L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>, L<SSL_new(3)|SSL_new(3)>,
61L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>
62
63=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod
index 8bbfc78720..9aa6c6b2e3 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod
@@ -97,6 +97,7 @@ SSL_CTX_get_session_cache_mode() returns the currently set cache mode.
97=head1 SEE ALSO 97=head1 SEE ALSO
98 98
99L<ssl(3)|ssl(3)>, L<SSL_set_session(3)|SSL_set_session(3)>, 99L<ssl(3)|ssl(3)>, L<SSL_set_session(3)|SSL_set_session(3)>,
100L<SSL_session_reused(3)|SSL_session_reused(3)>,
100L<SSL_CTX_sess_number(3)|SSL_CTX_sess_number(3)>, 101L<SSL_CTX_sess_number(3)|SSL_CTX_sess_number(3)>,
101L<SSL_CTX_sess_set_cache_size(3)|SSL_CTX_sess_set_cache_size(3)>, 102L<SSL_CTX_sess_set_cache_size(3)|SSL_CTX_sess_set_cache_size(3)>,
102L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>, 103L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>,
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_timeout.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_timeout.pod
index 21faed12d4..e3de27c473 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_timeout.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_timeout.pod
@@ -37,7 +37,10 @@ L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)> is called, either
37directly by the application or automatically (see 37directly by the application or automatically (see
38L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>) 38L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>)
39 39
40The default value for session timeout is 300 seconds. 40The default value for session timeout is decided on a per protocol
41basis, see L<SSL_get_default_timeout(3)|SSL_get_default_timeout(3)>.
42All currently supported protocols have the same default timeout value
43of 300 seconds.
41 44
42=head1 RETURN VALUES 45=head1 RETURN VALUES
43 46
@@ -50,6 +53,7 @@ SSL_CTX_get_timeout() returns the currently set timeout value.
50L<ssl(3)|ssl(3)>, 53L<ssl(3)|ssl(3)>,
51L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>, 54L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
52L<SSL_SESSION_get_time(3)|SSL_SESSION_get_time(3)>, 55L<SSL_SESSION_get_time(3)|SSL_SESSION_get_time(3)>,
53L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)> 56L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>,
57L<SSL_get_default_timeout(3)|SSL_get_default_timeout(3)>
54 58
55=cut 59=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_dh_callback.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_dh_callback.pod
new file mode 100644
index 0000000000..29d1f8a6fb
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_dh_callback.pod
@@ -0,0 +1,170 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_tmp_dh_callback, SSL_CTX_set_tmp_dh, SSL_set_tmp_dh_callback, SSL_set_tmp_dh - handle DH keys for ephemeral key exchange
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,
12 DH *(*tmp_dh_callback)(SSL *ssl, int is_export, int keylength));
13 long SSL_CTX_set_tmp_dh(SSL_CTX *ctx, DH *dh);
14
15 void SSL_set_tmp_dh_callback(SSL_CTX *ctx,
16 DH *(*tmp_dh_callback)(SSL *ssl, int is_export, int keylength));
17 long SSL_set_tmp_dh(SSL *ssl, DH *dh)
18
19 DH *(*tmp_dh_callback)(SSL *ssl, int is_export, int keylength));
20
21=head1 DESCRIPTION
22
23SSL_CTX_set_tmp_dh_callback() sets the callback function for B<ctx> to be
24used when a DH parameters are required to B<tmp_dh_callback>.
25The callback is inherited by all B<ssl> objects created from B<ctx>.
26
27SSL_CTX_set_tmp_dh() sets DH parameters to be used to be B<dh>.
28The key is inherited by all B<ssl> objects created from B<ctx>.
29
30SSL_set_tmp_dh_callback() sets the callback only for B<ssl>.
31
32SSL_set_tmp_dh() sets the parameters only for B<ssl>.
33
34These functions apply to SSL/TLS servers only.
35
36=head1 NOTES
37
38When using a cipher with RSA authentication, an ephemeral DH key exchange
39can take place. Ciphers with DSA keys always use ephemeral DH keys as well.
40In these cases, the session data are negotiated using the
41ephemeral/temporary DH key and the key supplied and certified
42by the certificate chain is only used for signing.
43Anonymous ciphers (without a permanent server key) also use ephemeral DH keys.
44
45Using ephemeral DH key exchange yields forward secrecy, as the connection
46can only be decrypted, when the DH key is known. By generating a temporary
47DH key inside the server application that is lost when the application
48is left, it becomes impossible for an attacker to decrypt past sessions,
49even if he gets hold of the normal (certified) key, as this key was
50only used for signing.
51
52In order to perform a DH key exchange the server must use a DH group
53(DH parameters) and generate a DH key. The server will always generate a new
54DH key during the negotiation, when the DH parameters are supplied via
55callback and/or when the SSL_OP_SINGLE_DH_USE option of
56L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)> is set. It will
57immediately create a DH key, when DH parameters are supplied via
58SSL_CTX_set_tmp_dh() and SSL_OP_SINGLE_DH_USE is not set. In this case,
59it may happen that a key is generated on initialization without later
60being needed, while on the other hand the computer time during the
61negotiation is being saved.
62
63If "strong" primes were used to generate the DH parameters, it is not strictly
64necessary to generate a new key for each handshake but it does improve forward
65secrecy. If it is not assured, that "strong" primes were used (see especially
66the section about DSA parameters below), SSL_OP_SINGLE_DH_USE must be used
67in order to prevent small subgroup attacks. Always using SSL_OP_SINGLE_DH_USE
68has an impact on the computer time needed during negotiation, but it is not
69very large, so application authors/users should consider to always enable
70this option.
71
72As generating DH parameters is extremely time consuming, an application
73should not generate the parameters on the fly but supply the parameters.
74DH parameters can be reused, as the actual key is newly generated during
75the negotiation. The risk in reusing DH parameters is that an attacker
76may specialize on a very often used DH group. Applications should therefore
77generate their own DH parameters during the installation process using the
78openssl L<dhparam(1)|dhparam(1)> application. In order to reduce the computer
79time needed for this generation, it is possible to use DSA parameters
80instead (see L<dhparam(1)|dhparam(1)>), but in this case SSL_OP_SINGLE_DH_USE
81is mandatory.
82
83Application authors may compile in DH parameters. Files dh512.pem,
84dh1024.pem, dh2048.pem, and dh4096 in the 'apps' directory of current
85version of the OpenSSL distribution contain the 'SKIP' DH parameters,
86which use safe primes and were generated verifiably pseudo-randomly.
87These files can be converted into C code using the B<-C> option of the
88L<dhparam(1)|dhparam(1)> application.
89Authors may also generate their own set of parameters using
90L<dhparam(1)|dhparam(1)>, but a user may not be sure how the parameters were
91generated. The generation of DH parameters during installation is therefore
92recommended.
93
94An application may either directly specify the DH parameters or
95can supply the DH parameters via a callback function. The callback approach
96has the advantage, that the callback may supply DH parameters for different
97key lengths.
98
99The B<tmp_dh_callback> is called with the B<keylength> needed and
100the B<is_export> information. The B<is_export> flag is set, when the
101ephemeral DH key exchange is performed with an export cipher.
102
103=head1 EXAMPLES
104
105Handle DH parameters for key lengths of 512 and 1024 bits. (Error handling
106partly left out.)
107
108 ...
109 /* Set up ephemeral DH stuff */
110 DH *dh_512 = NULL;
111 DH *dh_1024 = NULL;
112 FILE *paramfile;
113
114 ...
115 /* "openssl dhparam -out dh_param_512.pem -2 512" */
116 paramfile = fopen("dh_param_512.pem", "r");
117 if (paramfile) {
118 dh_512 = PEM_read_DHparams(paramfile, NULL, NULL, NULL);
119 fclose(paramfile);
120 }
121 /* "openssl dhparam -out dh_param_1024.pem -2 1024" */
122 paramfile = fopen("dh_param_1024.pem", "r");
123 if (paramfile) {
124 dh_1024 = PEM_read_DHparams(paramfile, NULL, NULL, NULL);
125 fclose(paramfile);
126 }
127 ...
128
129 /* "openssl dhparam -C -2 512" etc... */
130 DH *get_dh512() { ... }
131 DH *get_dh1024() { ... }
132
133 DH *tmp_dh_callback(SSL *s, int is_export, int keylength)
134 {
135 DH *dh_tmp=NULL;
136
137 switch (keylength) {
138 case 512:
139 if (!dh_512)
140 dh_512 = get_dh512();
141 dh_tmp = dh_512;
142 break;
143 case 1024:
144 if (!dh_1024)
145 dh_1024 = get_dh1024();
146 dh_tmp = dh_1024;
147 break;
148 default:
149 /* Generating a key on the fly is very costly, so use what is there */
150 setup_dh_parameters_like_above();
151 }
152 return(dh_tmp);
153 }
154
155=head1 RETURN VALUES
156
157SSL_CTX_set_tmp_dh_callback() and SSL_set_tmp_dh_callback() do not return
158diagnostic output.
159
160SSL_CTX_set_tmp_dh() and SSL_set_tmp_dh() do return 1 on success and 0
161on failure. Check the error queue to find out the reason of failure.
162
163=head1 SEE ALSO
164
165L<ssl(3)|ssl(3)>, L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>,
166L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>,
167L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>,
168L<ciphers(1)|ciphers(1)>, L<dhparam(1)|dhparam(1)>
169
170=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_rsa_callback.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_rsa_callback.pod
new file mode 100644
index 0000000000..f85775927d
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_rsa_callback.pod
@@ -0,0 +1,166 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_tmp_rsa_callback, SSL_CTX_set_tmp_rsa, SSL_CTX_need_tmp_rsa, SSL_set_tmp_rsa_callback, SSL_set_tmp_rsa, SSL_need_tmp_rsa - handle RSA keys for ephemeral key exchange
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,
12 RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength));
13 long SSL_CTX_set_tmp_rsa(SSL_CTX *ctx, RSA *rsa);
14 long SSL_CTX_need_tmp_rsa(SSL_CTX *ctx);
15
16 void SSL_set_tmp_rsa_callback(SSL_CTX *ctx,
17 RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength));
18 long SSL_set_tmp_rsa(SSL *ssl, RSA *rsa)
19 long SSL_need_tmp_rsa(SSL *ssl)
20
21 RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength));
22
23=head1 DESCRIPTION
24
25SSL_CTX_set_tmp_rsa_callback() sets the callback function for B<ctx> to be
26used when a temporary/ephemeral RSA key is required to B<tmp_rsa_callback>.
27The callback is inherited by all SSL objects newly created from B<ctx>
28with <SSL_new(3)|SSL_new(3)>. Already created SSL objects are not affected.
29
30SSL_CTX_set_tmp_rsa() sets the temporary/ephemeral RSA key to be used to be
31B<rsa>. The key is inherited by all SSL objects newly created from B<ctx>
32with <SSL_new(3)|SSL_new(3)>. Already created SSL objects are not affected.
33
34SSL_CTX_need_tmp_rsa() returns 1, if a temporary/ephemeral RSA key is needed
35for RSA-based strength-limited 'exportable' ciphersuites because a RSA key
36with a keysize larger than 512 bits is installed.
37
38SSL_set_tmp_rsa_callback() sets the callback only for B<ssl>.
39
40SSL_set_tmp_rsa() sets the key only for B<ssl>.
41
42SSL_need_tmp_rsa() returns 1, if a temporary/ephemeral RSA key is needed,
43for RSA-based strength-limited 'exportable' ciphersuites because a RSA key
44with a keysize larger than 512 bits is installed.
45
46These functions apply to SSL/TLS servers only.
47
48=head1 NOTES
49
50When using a cipher with RSA authentication, an ephemeral RSA key exchange
51can take place. In this case the session data are negotiated using the
52ephemeral/temporary RSA key and the RSA key supplied and certified
53by the certificate chain is only used for signing.
54
55Under previous export restrictions, ciphers with RSA keys shorter (512 bits)
56than the usual key length of 1024 bits were created. To use these ciphers
57with RSA keys of usual length, an ephemeral key exchange must be performed,
58as the normal (certified) key cannot be directly used.
59
60Using ephemeral RSA key exchange yields forward secrecy, as the connection
61can only be decrypted, when the RSA key is known. By generating a temporary
62RSA key inside the server application that is lost when the application
63is left, it becomes impossible for an attacker to decrypt past sessions,
64even if he gets hold of the normal (certified) RSA key, as this key was
65used for signing only. The downside is that creating a RSA key is
66computationally expensive.
67
68Additionally, the use of ephemeral RSA key exchange is only allowed in
69the TLS standard, when the RSA key can be used for signing only, that is
70for export ciphers. Using ephemeral RSA key exchange for other purposes
71violates the standard and can break interoperability with clients.
72It is therefore strongly recommended to not use ephemeral RSA key
73exchange and use EDH (Ephemeral Diffie-Hellman) key exchange instead
74in order to achieve forward secrecy (see
75L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>).
76
77On OpenSSL servers ephemeral RSA key exchange is therefore disabled by default
78and must be explicitly enabled using the SSL_OP_EPHEMERAL_RSA option of
79L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>, violating the TLS/SSL
80standard. When ephemeral RSA key exchange is required for export ciphers,
81it will automatically be used without this option!
82
83An application may either directly specify the key or can supply the key via
84a callback function. The callback approach has the advantage, that the
85callback may generate the key only in case it is actually needed. As the
86generation of a RSA key is however costly, it will lead to a significant
87delay in the handshake procedure. Another advantage of the callback function
88is that it can supply keys of different size (e.g. for SSL_OP_EPHEMERAL_RSA
89usage) while the explicit setting of the key is only useful for key size of
90512 bits to satisfy the export restricted ciphers and does give away key length
91if a longer key would be allowed.
92
93The B<tmp_rsa_callback> is called with the B<keylength> needed and
94the B<is_export> information. The B<is_export> flag is set, when the
95ephemeral RSA key exchange is performed with an export cipher.
96
97=head1 EXAMPLES
98
99Generate temporary RSA keys to prepare ephemeral RSA key exchange. As the
100generation of a RSA key costs a lot of computer time, they saved for later
101reuse. For demonstration purposes, two keys for 512 bits and 1024 bits
102respectively are generated.
103
104 ...
105 /* Set up ephemeral RSA stuff */
106 RSA *rsa_512 = NULL;
107 RSA *rsa_1024 = NULL;
108
109 rsa_512 = RSA_generate_key(512,RSA_F4,NULL,NULL);
110 if (rsa_512 == NULL)
111 evaluate_error_queue();
112
113 rsa_1024 = RSA_generate_key(1024,RSA_F4,NULL,NULL);
114 if (rsa_1024 == NULL)
115 evaluate_error_queue();
116
117 ...
118
119 RSA *tmp_rsa_callback(SSL *s, int is_export, int keylength)
120 {
121 RSA *rsa_tmp=NULL;
122
123 switch (keylength) {
124 case 512:
125 if (rsa_512)
126 rsa_tmp = rsa_512;
127 else { /* generate on the fly, should not happen in this example */
128 rsa_tmp = RSA_generate_key(keylength,RSA_F4,NULL,NULL);
129 rsa_512 = rsa_tmp; /* Remember for later reuse */
130 }
131 break;
132 case 1024:
133 if (rsa_1024)
134 rsa_tmp=rsa_1024;
135 else
136 should_not_happen_in_this_example();
137 break;
138 default:
139 /* Generating a key on the fly is very costly, so use what is there */
140 if (rsa_1024)
141 rsa_tmp=rsa_1024;
142 else
143 rsa_tmp=rsa_512; /* Use at least a shorter key */
144 }
145 return(rsa_tmp);
146 }
147
148=head1 RETURN VALUES
149
150SSL_CTX_set_tmp_rsa_callback() and SSL_set_tmp_rsa_callback() do not return
151diagnostic output.
152
153SSL_CTX_set_tmp_rsa() and SSL_set_tmp_rsa() do return 1 on success and 0
154on failure. Check the error queue to find out the reason of failure.
155
156SSL_CTX_need_tmp_rsa() and SSL_need_tmp_rsa() return 1 if a temporary
157RSA key is needed and 0 otherwise.
158
159=head1 SEE ALSO
160
161L<ssl(3)|ssl(3)>, L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>,
162L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>,
163L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>,
164L<SSL_new(3)|SSL_new(3)>, L<ciphers(1)|ciphers(1)>
165
166=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod
index fc0b76118f..5bb21ca535 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod
@@ -59,14 +59,14 @@ The handshake will be continued regardless of the verification result.
59 59
60B<Server mode:> the server sends a client certificate request to the client. 60B<Server mode:> the server sends a client certificate request to the client.
61The certificate returned (if any) is checked. If the verification process 61The certificate returned (if any) is checked. If the verification process
62fails as indicated by B<verify_callback>, the TLS/SSL handshake is 62fails, the TLS/SSL handshake is
63immediately terminated with an alert message containing the reason for 63immediately terminated with an alert message containing the reason for
64the verification failure. 64the verification failure.
65The behaviour can be controlled by the additional 65The behaviour can be controlled by the additional
66SSL_VERIFY_FAIL_IF_NO_PEER_CERT and SSL_VERIFY_CLIENT_ONCE flags. 66SSL_VERIFY_FAIL_IF_NO_PEER_CERT and SSL_VERIFY_CLIENT_ONCE flags.
67 67
68B<Client mode:> the server certificate is verified. If the verification process 68B<Client mode:> the server certificate is verified. If the verification process
69fails as indicated by B<verify_callback>, the TLS/SSL handshake is 69fails, the TLS/SSL handshake is
70immediately terminated with an alert message containing the reason for 70immediately terminated with an alert message containing the reason for
71the verification failure. If no server certificate is sent, because an 71the verification failure. If no server certificate is sent, because an
72anonymous cipher is used, SSL_VERIFY_PEER is ignored. 72anonymous cipher is used, SSL_VERIFY_PEER is ignored.
@@ -92,6 +92,15 @@ B<Client mode:> ignored
92Exactly one of the B<mode> flags SSL_VERIFY_NONE and SSL_VERIFY_PEER must be 92Exactly one of the B<mode> flags SSL_VERIFY_NONE and SSL_VERIFY_PEER must be
93set at any time. 93set at any time.
94 94
95The actual verification procedure is performed either using the built-in
96verification procedure or using another application provided verification
97function set with
98L<SSL_CTX_set_cert_verify_callback(3)|SSL_CTX_set_cert_verify_callback(3)>.
99The following descriptions apply in the case of the built-in procedure. An
100application provided procedure also has access to the verify depth information
101and the verify_callback() function, but the way this information is used
102may be different.
103
95SSL_CTX_set_verify_depth() and SSL_set_verify_depth() set the limit up 104SSL_CTX_set_verify_depth() and SSL_set_verify_depth() set the limit up
96to which depth certificates in a chain are used during the verification 105to which depth certificates in a chain are used during the verification
97procedure. If the certificate chain is longer than allowed, the certificates 106procedure. If the certificate chain is longer than allowed, the certificates
@@ -278,6 +287,7 @@ L<SSL_CTX_get_verify_mode(3)|SSL_CTX_get_verify_mode(3)>,
278L<SSL_get_verify_result(3)|SSL_get_verify_result(3)>, 287L<SSL_get_verify_result(3)|SSL_get_verify_result(3)>,
279L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>, 288L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>,
280L<SSL_get_peer_certificate(3)|SSL_get_peer_certificate(3)>, 289L<SSL_get_peer_certificate(3)|SSL_get_peer_certificate(3)>,
290L<SSL_CTX_set_cert_verify_callback(3)|SSL_CTX_set_cert_verify_callback(3)>,
281L<SSL_get_ex_data_X509_STORE_CTX_idx(3)|SSL_get_ex_data_X509_STORE_CTX_idx(3)>, 291L<SSL_get_ex_data_X509_STORE_CTX_idx(3)|SSL_get_ex_data_X509_STORE_CTX_idx(3)>,
282L<SSL_get_ex_new_index(3)|SSL_get_ex_new_index(3)> 292L<SSL_get_ex_new_index(3)|SSL_get_ex_new_index(3)>
283 293
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod
index 3b2fe6fc50..b8868f18bf 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod
@@ -149,6 +149,7 @@ L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>, L<SSL_clear(3)|SSL_clear(3)>,
149L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>, 149L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>,
150L<SSL_CTX_set_default_passwd_cb(3)|SSL_CTX_set_default_passwd_cb(3)>, 150L<SSL_CTX_set_default_passwd_cb(3)|SSL_CTX_set_default_passwd_cb(3)>,
151L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>, 151L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>,
152L<SSL_CTX_set_client_cert_cb(3)|SSL_CTX_set_client_cert_cb(3)>,
152L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)> 153L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>
153 154
154=cut 155=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_SESSION_free.pod b/src/lib/libssl/src/doc/ssl/SSL_SESSION_free.pod
index df30ccbb32..558de01df9 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_SESSION_free.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_SESSION_free.pod
@@ -16,10 +16,40 @@ SSL_SESSION_free() decrements the reference count of B<session> and removes
16the B<SSL_SESSION> structure pointed to by B<session> and frees up the allocated 16the B<SSL_SESSION> structure pointed to by B<session> and frees up the allocated
17memory, if the the reference count has reached 0. 17memory, if the the reference count has reached 0.
18 18
19=head1 NOTES
20
21SSL_SESSION objects are allocated, when a TLS/SSL handshake operation
22is successfully completed. Depending on the settings, see
23L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
24the SSL_SESSION objects are internally referenced by the SSL_CTX and
25linked into its session cache. SSL objects may be using the SSL_SESSION object;
26as a session may be reused, several SSL objects may be using one SSL_SESSION
27object at the same time. It is therefore crucial to keep the reference
28count (usage information) correct and not delete a SSL_SESSION object
29that is still used, as this may lead to program failures due to
30dangling pointers. These failures may also appear delayed, e.g.
31when an SSL_SESSION object was completely freed as the reference count
32incorrectly became 0, but it is still referenced in the internal
33session cache and the cache list is processed during a
34L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)> operation.
35
36SSL_SESSION_free() must only be called for SSL_SESSION objects, for
37which the reference count was explicitly incremented (e.g.
38by calling SSL_get1_session(), see L<SSL_get_session(3)|SSL_get_session(3)>)
39or when the SSL_SESSION object was generated outside a TLS handshake
40operation, e.g. by using L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)>.
41It must not be called on other SSL_SESSION objects, as this would cause
42incorrect reference counts and therefore program failures.
43
19=head1 RETURN VALUES 44=head1 RETURN VALUES
20 45
21SSL_SESSION_free() does not provide diagnostic information. 46SSL_SESSION_free() does not provide diagnostic information.
22 47
23L<ssl(3)|ssl(3)>, L<SSL_get_session(3)|SSL_get_session(3)> 48=head1 SEE ALSO
49
50L<ssl(3)|ssl(3)>, L<SSL_get_session(3)|SSL_get_session(3)>,
51L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
52L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>,
53 L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)>
24 54
25=cut 55=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.pod b/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.pod
index cd33b73aa3..ea3c2bcfe6 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.pod
@@ -58,6 +58,7 @@ If any of the function is passed the NULL pointer for the session B<s>,
58=head1 SEE ALSO 58=head1 SEE ALSO
59 59
60L<ssl(3)|ssl(3)>, 60L<ssl(3)|ssl(3)>,
61L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)> 61L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)>,
62L<SSL_get_default_timeout(3)|SSL_get_default_timeout(3)>
62 63
63=cut 64=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_accept.pod b/src/lib/libssl/src/doc/ssl/SSL_accept.pod
index 86f980de41..ac6caf9baa 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_accept.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_accept.pod
@@ -37,11 +37,6 @@ nothing is to be done, but select() can be used to check for the required
37condition. When using a buffering BIO, like a BIO pair, data must be written 37condition. When using a buffering BIO, like a BIO pair, data must be written
38into or retrieved out of the BIO before being able to continue. 38into or retrieved out of the BIO before being able to continue.
39 39
40When using a generic method (see L<SSL_CTX_new(3)|SSL_CTX_new(3)>), it
41is necessary to call SSL_set_accept_state()
42before calling SSL_accept() to explicitly switch the B<ssl> to server
43mode.
44
45=head1 RETURN VALUES 40=head1 RETURN VALUES
46 41
47The following return values can occur: 42The following return values can occur:
diff --git a/src/lib/libssl/src/doc/ssl/SSL_alert_type_string.pod b/src/lib/libssl/src/doc/ssl/SSL_alert_type_string.pod
new file mode 100644
index 0000000000..94e28cc307
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_alert_type_string.pod
@@ -0,0 +1,228 @@
1=pod
2
3=head1 NAME
4
5SSL_alert_type_string, SSL_alert_type_string_long, SSL_alert_desc_string, SSL_alert_desc_string_long - get textual description of alert information
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 const char *SSL_alert_type_string(int value);
12 const char *SSL_alert_type_string_long(int value);
13
14 const char *SSL_alert_desc_string(int value);
15 const char *SSL_alert_desc_string_long(int value);
16
17=head1 DESCRIPTION
18
19SSL_alert_type_string() returns a one letter string indicating the
20type of the alert specified by B<value>.
21
22SSL_alert_type_string_long() returns a string indicating the type of the alert
23specified by B<value>.
24
25SSL_alert_desc_string() returns a two letter string as a short form
26describing the reason of the alert specified by B<value>.
27
28SSL_alert_desc_string_long() returns a string describing the reason
29of the alert specified by B<value>.
30
31=head1 NOTES
32
33When one side of an SSL/TLS communication wants to inform the peer about
34a special situation, it sends an alert. The alert is sent as a special message
35and does not influence the normal data stream (unless its contents results
36in the communication being canceled).
37
38A warning alert is sent, when a non-fatal error condition occurs. The
39"close notify" alert is sent as a warning alert. Other examples for
40non-fatal errors are certificate errors ("certificate expired",
41"unsupported certificate"), for which a warning alert may be sent.
42(The sending party may however decide to send a fatal error.) The
43receiving side may cancel the connection on reception of a warning
44alert on it discretion.
45
46Several alert messages must be sent as fatal alert messages as specified
47by the TLS RFC. A fatal alert always leads to a connection abort.
48
49=head1 RETURN VALUES
50
51The following strings can occur for SSL_alert_type_string() or
52SSL_alert_type_string_long():
53
54=over 4
55
56=item "W"/"warning"
57
58=item "F"/"fatal"
59
60=item "U"/"unknown"
61
62This indicates that no support is available for this alert type.
63Probably B<value> does not contain a correct alert message.
64
65=back
66
67The following strings can occur for SSL_alert_desc_string() or
68SSL_alert_desc_string_long():
69
70=over 4
71
72=item "CN"/"close notify"
73
74The connection shall be closed. This is a warning alert.
75
76=item "UM"/"unexpected message"
77
78An inappropriate message was received. This alert is always fatal
79and should never be observed in communication between proper
80implementations.
81
82=item "BM"/"bad record mac"
83
84This alert is returned if a record is received with an incorrect
85MAC. This message is always fatal.
86
87=item "DF"/"decompression failure"
88
89The decompression function received improper input (e.g. data
90that would expand to excessive length). This message is always
91fatal.
92
93=item "HF"/"handshake failure"
94
95Reception of a handshake_failure alert message indicates that the
96sender was unable to negotiate an acceptable set of security
97parameters given the options available. This is a fatal error.
98
99=item "NC"/"no certificate"
100
101A client, that was asked to send a certificate, does not send a certificate
102(SSLv3 only).
103
104=item "BC"/"bad certificate"
105
106A certificate was corrupt, contained signatures that did not
107verify correctly, etc
108
109=item "UC"/"unsupported certificate"
110
111A certificate was of an unsupported type.
112
113=item "CR"/"certificate revoked"
114
115A certificate was revoked by its signer.
116
117=item "CE"/"certificate expired"
118
119A certificate has expired or is not currently valid.
120
121=item "CU"/"certificate unknown"
122
123Some other (unspecified) issue arose in processing the
124certificate, rendering it unacceptable.
125
126=item "IP"/"illegal parameter"
127
128A field in the handshake was out of range or inconsistent with
129other fields. This is always fatal.
130
131=item "DC"/"decryption failed"
132
133A TLSCiphertext decrypted in an invalid way: either it wasn't an
134even multiple of the block length or its padding values, when
135checked, weren't correct. This message is always fatal.
136
137=item "RO"/"record overflow"
138
139A TLSCiphertext record was received which had a length more than
1402^14+2048 bytes, or a record decrypted to a TLSCompressed record
141with more than 2^14+1024 bytes. This message is always fatal.
142
143=item "CA"/"unknown CA"
144
145A valid certificate chain or partial chain was received, but the
146certificate was not accepted because the CA certificate could not
147be located or couldn't be matched with a known, trusted CA. This
148message is always fatal.
149
150=item "AD"/"access denied"
151
152A valid certificate was received, but when access control was
153applied, the sender decided not to proceed with negotiation.
154This message is always fatal.
155
156=item "DE"/"decode error"
157
158A message could not be decoded because some field was out of the
159specified range or the length of the message was incorrect. This
160message is always fatal.
161
162=item "CY"/"decrypt error"
163
164A handshake cryptographic operation failed, including being
165unable to correctly verify a signature, decrypt a key exchange,
166or validate a finished message.
167
168=item "ER"/"export restriction"
169
170A negotiation not in compliance with export restrictions was
171detected; for example, attempting to transfer a 1024 bit
172ephemeral RSA key for the RSA_EXPORT handshake method. This
173message is always fatal.
174
175=item "PV"/"protocol version"
176
177The protocol version the client has attempted to negotiate is
178recognized, but not supported. (For example, old protocol
179versions might be avoided for security reasons). This message is
180always fatal.
181
182=item "IS"/"insufficient security"
183
184Returned instead of handshake_failure when a negotiation has
185failed specifically because the server requires ciphers more
186secure than those supported by the client. This message is always
187fatal.
188
189=item "IE"/"internal error"
190
191An internal error unrelated to the peer or the correctness of the
192protocol makes it impossible to continue (such as a memory
193allocation failure). This message is always fatal.
194
195=item "US"/"user canceled"
196
197This handshake is being canceled for some reason unrelated to a
198protocol failure. If the user cancels an operation after the
199handshake is complete, just closing the connection by sending a
200close_notify is more appropriate. This alert should be followed
201by a close_notify. This message is generally a warning.
202
203=item "NR"/"no renegotiation"
204
205Sent by the client in response to a hello request or by the
206server in response to a client hello after initial handshaking.
207Either of these would normally lead to renegotiation; when that
208is not appropriate, the recipient should respond with this alert;
209at that point, the original requester can decide whether to
210proceed with the connection. One case where this would be
211appropriate would be where a server has spawned a process to
212satisfy a request; the process might receive security parameters
213(key length, authentication, etc.) at startup and it might be
214difficult to communicate changes to these parameters after that
215point. This message is always a warning.
216
217=item "UK"/"unknown"
218
219This indicates that no description is available for this alert type.
220Probably B<value> does not contain a correct alert message.
221
222=back
223
224=head1 SEE ALSO
225
226L<ssl(3)|ssl(3)>, L<SSL_CTX_set_info_callback(3)|SSL_CTX_set_info_callback(3)>
227
228=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_clear.pod b/src/lib/libssl/src/doc/ssl/SSL_clear.pod
index 8b735d81dc..8e077e31c9 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_clear.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_clear.pod
@@ -25,6 +25,25 @@ if L<SSL_shutdown(3)|SSL_shutdown(3)> was not called for the connection
25or at least L<SSL_set_shutdown(3)|SSL_set_shutdown(3)> was used to 25or at least L<SSL_set_shutdown(3)|SSL_set_shutdown(3)> was used to
26set the SSL_SENT_SHUTDOWN state. 26set the SSL_SENT_SHUTDOWN state.
27 27
28If a session was closed cleanly, the session object will be kept and all
29settings corresponding. This explicitly means, that e.g. the special method
30used during the session will be kept for the next handshake. So if the
31session was a TLSv1 session, a SSL client object will use a TLSv1 client
32method for the next handshake and a SSL server object will use a TLSv1
33server method, even if SSLv23_*_methods were chosen on startup. This
34will might lead to connection failures (see L<SSL_new(3)|SSL_new(3)>)
35for a description of the method's properties.
36
37=head1 WARNINGS
38
39SSL_clear() resets the SSL object to allow for another connection. The
40reset operation however keeps several settings of the last sessions
41(some of these settings were made automatically during the last
42handshake). It only makes sense when opening a new session (or reusing
43an old one) with the same peer that shares these settings.
44SSL_clear() is not a short form for the sequence
45L<SSL_free(3)|SSL_free(3)>; L<SSL_new(3)|SSL_new(3)>; .
46
28=head1 RETURN VALUES 47=head1 RETURN VALUES
29 48
30The following return values can occur: 49The following return values can occur:
@@ -44,6 +63,7 @@ The SSL_clear() operation was successful.
44 63
45L<SSL_new(3)|SSL_new(3)>, L<SSL_free(3)|SSL_free(3)>, 64L<SSL_new(3)|SSL_new(3)>, L<SSL_free(3)|SSL_free(3)>,
46L<SSL_shutdown(3)|SSL_shutdown(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>, 65L<SSL_shutdown(3)|SSL_shutdown(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>,
47L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>, L<ssl(3)|ssl(3)> 66L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>, L<ssl(3)|ssl(3)>,
67L<SSL_CTX_set_client_cert_cb(3)|SSL_CTX_set_client_cert_cb(3)>
48 68
49=cut 69=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_connect.pod b/src/lib/libssl/src/doc/ssl/SSL_connect.pod
index bcc167745b..766f1876aa 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_connect.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_connect.pod
@@ -34,11 +34,6 @@ nothing is to be done, but select() can be used to check for the required
34condition. When using a buffering BIO, like a BIO pair, data must be written 34condition. When using a buffering BIO, like a BIO pair, data must be written
35into or retrieved out of the BIO before being able to continue. 35into or retrieved out of the BIO before being able to continue.
36 36
37When using a generic method (see L<SSL_CTX_new(3)|SSL_CTX_new(3)>), it
38is necessary to call L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>
39before calling SSL_connect() to explicitly switch the B<ssl> to client
40mode.
41
42=head1 RETURN VALUES 37=head1 RETURN VALUES
43 38
44The following return values can occur: 39The following return values can occur:
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_SSL_CTX.pod b/src/lib/libssl/src/doc/ssl/SSL_get_SSL_CTX.pod
new file mode 100644
index 0000000000..52d0227b19
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_get_SSL_CTX.pod
@@ -0,0 +1,26 @@
1=pod
2
3=head1 NAME
4
5SSL_get_SSL_CTX - get the SSL_CTX from which an SSL is created
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 SSL_CTX *SSL_get_SSL_CTX(SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_get_SSL_CTX() returns a pointer to the SSL_CTX object, from which
16B<ssl> was created with L<SSL_new(3)|SSL_new(3)>.
17
18=head1 RETURN VALUES
19
20The pointer to the SSL_CTX object is returned.
21
22=head1 SEE ALSO
23
24L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>
25
26=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_client_CA_list.pod b/src/lib/libssl/src/doc/ssl/SSL_get_client_CA_list.pod
index 40e01cf9c8..5693fdebb2 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_get_client_CA_list.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_get_client_CA_list.pod
@@ -47,6 +47,7 @@ the server did not send a list of CAs (client mode).
47=head1 SEE ALSO 47=head1 SEE ALSO
48 48
49L<ssl(3)|ssl(3)>, 49L<ssl(3)|ssl(3)>,
50L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)> 50L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>,
51L<SSL_CTX_set_client_cert_cb(3)|SSL_CTX_set_client_cert_cb(3)>
51 52
52=cut 53=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_default_timeout.pod b/src/lib/libssl/src/doc/ssl/SSL_get_default_timeout.pod
new file mode 100644
index 0000000000..8d43b31345
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_get_default_timeout.pod
@@ -0,0 +1,41 @@
1=pod
2
3=head1 NAME
4
5SSL_get_default_timeout - get default session timeout value
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 long SSL_get_default_timeout(SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_get_default_timeout() returns the default timeout value assigned to
16SSL_SESSION objects negotiated for the protocol valid for B<ssl>.
17
18=head1 NOTES
19
20Whenever a new session is negotiated, it is assigned a timeout value,
21after which it will not be accepted for session reuse. If the timeout
22value was not explicitly set using
23L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)>, the hardcoded default
24timeout for the protocol will be used.
25
26SSL_get_default_timeout() return this hardcoded value, which is 300 seconds
27for all currently supported protocols (SSLv2, SSLv3, and TLSv1).
28
29=head1 RETURN VALUES
30
31See description.
32
33=head1 SEE ALSO
34
35L<ssl(3)|ssl(3)>,
36L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
37L<SSL_SESSION_get_time(3)|SSL_SESSION_get_time(3)>,
38L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>,
39L<SSL_get_default_timeout(3)|SSL_get_default_timeout(3)>
40
41=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_error.pod b/src/lib/libssl/src/doc/ssl/SSL_get_error.pod
index d95eec78aa..f700bf0ace 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_get_error.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_get_error.pod
@@ -69,13 +69,13 @@ to read data. This is mainly because TLS/SSL handshakes may occur at any
69time during the protocol (initiated by either the client or the server); 69time during the protocol (initiated by either the client or the server);
70SSL_read(), SSL_peek(), and SSL_write() will handle any pending handshakes. 70SSL_read(), SSL_peek(), and SSL_write() will handle any pending handshakes.
71 71
72=item SSL_ERROR_WANT_CONNECT 72=item SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT
73 73
74The operation did not complete; the same TLS/SSL I/O function should be 74The operation did not complete; the same TLS/SSL I/O function should be
75called again later. The underlying BIO was not connected yet to the peer 75called again later. The underlying BIO was not connected yet to the peer
76and the call would block in connect(). The SSL function should be 76and the call would block in connect()/accept(). The SSL function should be
77called again when the connection is established. This messages can only 77called again when the connection is established. These messages can only
78appear with a BIO_s_connect() BIO. 78appear with a BIO_s_connect() or BIO_s_accept() BIO, respectively.
79In order to find out, when the connection has been successfully established, 79In order to find out, when the connection has been successfully established,
80on many platforms select() or poll() for writing on the socket file descriptor 80on many platforms select() or poll() for writing on the socket file descriptor
81can be used. 81can be used.
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_peer_certificate.pod b/src/lib/libssl/src/doc/ssl/SSL_get_peer_certificate.pod
index 18d1db5183..60635a9660 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_get_peer_certificate.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_get_peer_certificate.pod
@@ -19,7 +19,7 @@ peer presented. If the peer did not present a certificate, NULL is returned.
19 19
20Due to the protocol definition, a TLS/SSL server will always send a 20Due to the protocol definition, a TLS/SSL server will always send a
21certificate, if present. A client will only send a certificate when 21certificate, if present. A client will only send a certificate when
22explicitely requested to do so by the server (see 22explicitly requested to do so by the server (see
23L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>). If an anonymous cipher 23L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>). If an anonymous cipher
24is used, no certificates are sent. 24is used, no certificates are sent.
25 25
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_session.pod b/src/lib/libssl/src/doc/ssl/SSL_get_session.pod
index a0266e2ac6..dd9aba40b6 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_get_session.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_get_session.pod
@@ -37,8 +37,16 @@ if the session is valid, it can be removed at any time due to timeout
37during L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>. 37during L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>.
38 38
39If the data is to be kept, SSL_get1_session() will increment the reference 39If the data is to be kept, SSL_get1_session() will increment the reference
40count and the session will stay in memory until explicitly freed with 40count, so that the session will not be implicitly removed by other operations
41L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>, regardless of its state. 41but stays in memory. In order to remove the session
42L<SSL_SESSION_free(3)|SSL_SESSION_free(3)> must be explicitly called once
43to decrement the reference count again.
44
45SSL_SESSION objects keep internal link information about the session cache
46list, when being inserted into one SSL_CTX object's session cache.
47One SSL_SESSION object, regardless of its reference count, must therefore
48only be used with one SSL_CTX object (and the SSL objects created
49from this SSL_CTX object).
42 50
43=head1 RETURN VALUES 51=head1 RETURN VALUES
44 52
diff --git a/src/lib/libssl/src/doc/ssl/SSL_new.pod b/src/lib/libssl/src/doc/ssl/SSL_new.pod
index 3b084e867d..25300e978f 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_new.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_new.pod
@@ -38,6 +38,7 @@ The return value points to an allocated SSL structure.
38 38
39L<SSL_free(3)|SSL_free(3)>, L<SSL_clear(3)|SSL_clear(3)>, 39L<SSL_free(3)|SSL_free(3)>, L<SSL_clear(3)|SSL_clear(3)>,
40L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>, 40L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>,
41L<SSL_get_SSL_CTX(3)|SSL_get_SSL_CTX(3)>,
41L<ssl(3)|ssl(3)> 42L<ssl(3)|ssl(3)>
42 43
43=cut 44=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_read.pod b/src/lib/libssl/src/doc/ssl/SSL_read.pod
index cc7aa1a547..f6c37f77e4 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_read.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_read.pod
@@ -25,11 +25,10 @@ the SSL_read() operation. The behaviour of SSL_read() depends on the
25underlying BIO. 25underlying BIO.
26 26
27For the transparent negotiation to succeed, the B<ssl> must have been 27For the transparent negotiation to succeed, the B<ssl> must have been
28initialized to client or server mode. This is not the case if a generic 28initialized to client or server mode. This is being done by calling
29method is being used (see L<SSL_CTX_new(3)|SSL_CTX_new(3)>, so that
30L<SSL_set_connect_state(3)|SSL_set_connect_state(3)> or SSL_set_accept_state() 29L<SSL_set_connect_state(3)|SSL_set_connect_state(3)> or SSL_set_accept_state()
31must be used before the first call to an SSL_read() or 30before the first call to an SSL_read() or L<SSL_write(3)|SSL_write(3)>
32L<SSL_write(3)|SSL_write(3)> function). 31function.
33 32
34SSL_read() works based on the SSL/TLS records. The data are received in 33SSL_read() works based on the SSL/TLS records. The data are received in
35records (with a maximum record size of 16kB for SSLv3/TLSv1). Only when a 34records (with a maximum record size of 16kB for SSLv3/TLSv1). Only when a
@@ -84,9 +83,20 @@ bytes actually read from the TLS/SSL connection.
84 83
85=item 0 84=item 0
86 85
87The read operation was not successful, probably because no data was 86The read operation was not successful. The reason may either be a clean
88available. Call SSL_get_error() with the return value B<ret> to find out, 87shutdown due to a "close notify" alert sent by the peer (in which case
89whether an error occurred. 88the SSL_RECEIVED_SHUTDOWN flag in the ssl shutdown state is set
89(see L<SSL_shutdown(3)|SSL_shutdown(3)>,
90L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>). It is also possible, that
91the peer simply shut down the underlying transport and the shutdown is
92incomplete. Call SSL_get_error() with the return value B<ret> to find out,
93whether an error occurred or the connection was shut down cleanly
94(SSL_ERROR_ZERO_RETURN).
95
96SSLv2 (deprecated) does not support a shutdown alert protocol, so it can
97only be detected, whether the underlying connection was closed. It cannot
98be checked, whether the closure was initiated by the peer or by something
99else.
90 100
91=item E<lt>0 101=item E<lt>0
92 102
@@ -102,6 +112,7 @@ L<SSL_get_error(3)|SSL_get_error(3)>, L<SSL_write(3)|SSL_write(3)>,
102L<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)>, L<SSL_CTX_new(3)|SSL_CTX_new(3)>, 112L<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)>, L<SSL_CTX_new(3)|SSL_CTX_new(3)>,
103L<SSL_connect(3)|SSL_connect(3)>, L<SSL_accept(3)|SSL_accept(3)> 113L<SSL_connect(3)|SSL_connect(3)>, L<SSL_accept(3)|SSL_accept(3)>
104L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>, 114L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>,
115L<SSL_shutdown(3)|SSL_shutdown(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>,
105L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)> 116L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)>
106 117
107=cut 118=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_rstate_string.pod b/src/lib/libssl/src/doc/ssl/SSL_rstate_string.pod
new file mode 100644
index 0000000000..bdb8a1fcd5
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_rstate_string.pod
@@ -0,0 +1,59 @@
1=pod
2
3=head1 NAME
4
5SSL_rstate_string, SSL_rstate_string_long - get textual description of state of an SSL object during read operation
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 const char *SSL_rstate_string(SSL *ssl);
12 const char *SSL_rstate_string_long(SSL *ssl);
13
14=head1 DESCRIPTION
15
16SSL_rstate_string() returns a 2 letter string indicating the current read state
17of the SSL object B<ssl>.
18
19SSL_rstate_string_long() returns a string indicating the current read state of
20the SSL object B<ssl>.
21
22=head1 NOTES
23
24When performing a read operation, the SSL/TLS engine must parse the record,
25consisting of header and body. When working in a blocking environment,
26SSL_rstate_string[_long]() should always return "RD"/"read done".
27
28This function should only seldom be needed in applications.
29
30=head1 RETURN VALUES
31
32SSL_rstate_string() and SSL_rstate_string_long() can return the following
33values:
34
35=over 4
36
37=item "RH"/"read header"
38
39The header of the record is being evaluated.
40
41=item "RB"/"read body"
42
43The body of the record is being evaluated.
44
45=item "RD"/"read done"
46
47The record has been completely processed.
48
49=item "unknown"/"unknown"
50
51The read state is unknown. This should never happen.
52
53=back
54
55=head1 SEE ALSO
56
57L<ssl(3)|ssl(3)>
58
59=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_session_reused.pod b/src/lib/libssl/src/doc/ssl/SSL_session_reused.pod
new file mode 100644
index 0000000000..da7d06264d
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_session_reused.pod
@@ -0,0 +1,45 @@
1=pod
2
3=head1 NAME
4
5SSL_session_reused - query whether a reused session was negotiated during handshake
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_session_reused(SSL *ssl);
12
13=head1 DESCRIPTION
14
15Query, whether a reused session was negotiated during the handshake.
16
17=head1 NOTES
18
19During the negotiation, a client can propose to reuse a session. The server
20then looks up the session in its cache. If both client and server agree
21on the session, it will be reused and a flag is being set that can be
22queried by the application.
23
24=head1 RETURN VALUES
25
26The following return values can occur:
27
28=over 4
29
30=item 0
31
32A new session was negotiated.
33
34=item 1
35
36A session was reused.
37
38=back
39
40=head1 SEE ALSO
41
42L<ssl(3)|ssl(3)>, L<SSL_set_session(3)|SSL_set_session(3)>,
43L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>
44
45=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_set_connect_state.pod b/src/lib/libssl/src/doc/ssl/SSL_set_connect_state.pod
index a8c4463c64..7adf8adfed 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_set_connect_state.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_set_connect_state.pod
@@ -14,9 +14,9 @@ SSL_set_connect_state, SSL_get_accept_state - prepare SSL object to work in clie
14 14
15=head1 DESCRIPTION 15=head1 DESCRIPTION
16 16
17SSL_set_connect_state() B<ssl> to work in client mode. 17SSL_set_connect_state() sets B<ssl> to work in client mode.
18 18
19SSL_set_accept_state() B<ssl> to work in server mode. 19SSL_set_accept_state() sets B<ssl> to work in server mode.
20 20
21=head1 NOTES 21=head1 NOTES
22 22
@@ -27,12 +27,17 @@ server connections. (The method might have been changed with
27L<SSL_CTX_set_ssl_version(3)|SSL_CTX_set_ssl_version(3)> or 27L<SSL_CTX_set_ssl_version(3)|SSL_CTX_set_ssl_version(3)> or
28SSL_set_ssl_method().) 28SSL_set_ssl_method().)
29 29
30In order to successfully accomplish the handshake, the SSL routines need 30When beginning a new handshake, the SSL engine must know whether it must
31to know whether they should act in server or client mode. If the generic 31call the connect (client) or accept (server) routines. Even though it may
32method was used, this is not clear from the method itself and must be set 32be clear from the method chosen, whether client or server mode was
33with either SSL_set_connect_state() or SSL_set_accept_state(). If these 33requested, the handshake routines must be explicitly set.
34routines are not called, the default value set when L<SSL_new(3)|SSL_new(3)> 34
35is called is server mode. 35When using the L<SSL_connect(3)|SSL_connect(3)> or
36L<SSL_accept(3)|SSL_accept(3)> routines, the correct handshake
37routines are automatically set. When performing a transparent negotiation
38using L<SSL_write(3)|SSL_write(3)> or L<SSL_read(3)|SSL_read(3)>, the
39handshake routines must be explicitly set in advance using either
40SSL_set_connect_state() or SSL_set_accept_state().
36 41
37=head1 RETURN VALUES 42=head1 RETURN VALUES
38 43
@@ -42,6 +47,8 @@ information.
42=head1 SEE ALSO 47=head1 SEE ALSO
43 48
44L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>, L<SSL_CTX_new(3)|SSL_CTX_new(3)>, 49L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>, L<SSL_CTX_new(3)|SSL_CTX_new(3)>,
50L<SSL_connect(3)|SSL_connect(3)>, L<SSL_accept(3)|SSL_accept(3)>,
51L<SSL_write(3)|SSL_write(3)>, L<SSL_read(3)|SSL_read(3)>,
45L<SSL_CTX_set_ssl_version(3)|SSL_CTX_set_ssl_version(3)> 52L<SSL_CTX_set_ssl_version(3)|SSL_CTX_set_ssl_version(3)>
46 53
47=cut 54=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_set_session.pod b/src/lib/libssl/src/doc/ssl/SSL_set_session.pod
index c4f7878579..5f54714ad8 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_set_session.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_set_session.pod
@@ -16,12 +16,21 @@ SSL_set_session() sets B<session> to be used when the TLS/SSL connection
16is to be established. SSL_set_session() is only useful for TLS/SSL clients. 16is to be established. SSL_set_session() is only useful for TLS/SSL clients.
17When the session is set, the reference count of B<session> is incremented 17When the session is set, the reference count of B<session> is incremented
18by 1. If the session is not reused, the reference count is decremented 18by 1. If the session is not reused, the reference count is decremented
19again during SSL_connect(). 19again during SSL_connect(). Whether the session was reused can be queried
20with the L<SSL_session_reused(3)|SSL_session_reused(3)> call.
20 21
21If there is already a session set inside B<ssl> (because it was set with 22If there is already a session set inside B<ssl> (because it was set with
22SSL_set_session() before or because the same B<ssl> was already used for 23SSL_set_session() before or because the same B<ssl> was already used for
23a connection), SSL_SESSION_free() will be called for that session. 24a connection), SSL_SESSION_free() will be called for that session.
24 25
26=head1 NOTES
27
28SSL_SESSION objects keep internal link information about the session cache
29list, when being inserted into one SSL_CTX object's session cache.
30One SSL_SESSION object, regardless of its reference count, must therefore
31only be used with one SSL_CTX object (and the SSL objects created
32from this SSL_CTX object).
33
25=head1 RETURN VALUES 34=head1 RETURN VALUES
26 35
27The following return values can occur: 36The following return values can occur:
@@ -41,6 +50,8 @@ The operation succeeded.
41=head1 SEE ALSO 50=head1 SEE ALSO
42 51
43L<ssl(3)|ssl(3)>, L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>, 52L<ssl(3)|ssl(3)>, L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
53L<SSL_get_session(3)|SSL_get_session(3)>,
54L<SSL_session_reused(3)|SSL_session_reused(3)>,
44L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)> 55L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>
45 56
46=cut 57=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_set_shutdown.pod b/src/lib/libssl/src/doc/ssl/SSL_set_shutdown.pod
index 6b196c1f15..6289e635d9 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_set_shutdown.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_set_shutdown.pod
@@ -46,7 +46,10 @@ The shutdown state of the connection is used to determine the state of
46the ssl session. If the session is still open, when 46the ssl session. If the session is still open, when
47L<SSL_clear(3)|SSL_clear(3)> or L<SSL_free(3)|SSL_free(3)> is called, 47L<SSL_clear(3)|SSL_clear(3)> or L<SSL_free(3)|SSL_free(3)> is called,
48it is considered bad and removed according to RFC2246. 48it is considered bad and removed according to RFC2246.
49The actual condition for a correctly closed session is SSL_SENT_SHUTDOWN. 49The actual condition for a correctly closed session is SSL_SENT_SHUTDOWN
50(according to the TLS RFC, it is acceptable to only send the "close notify"
51alert but to not wait for the peer's answer, when the underlying connection
52is closed).
50SSL_set_shutdown() can be used to set this state without sending a 53SSL_set_shutdown() can be used to set this state without sending a
51close alert to the peer (see L<SSL_shutdown(3)|SSL_shutdown(3)>). 54close alert to the peer (see L<SSL_shutdown(3)|SSL_shutdown(3)>).
52 55
@@ -63,6 +66,7 @@ SSL_get_shutdown() returns the current setting.
63=head1 SEE ALSO 66=head1 SEE ALSO
64 67
65L<ssl(3)|ssl(3)>, L<SSL_shutdown(3)|SSL_shutdown(3)>, 68L<ssl(3)|ssl(3)>, L<SSL_shutdown(3)|SSL_shutdown(3)>,
69L<SSL_CTX_set_quiet_shutdown(3)|SSL_CTX_set_quiet_shutdown(3)>,
66L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)> 70L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>
67 71
68=cut 72=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_shutdown.pod b/src/lib/libssl/src/doc/ssl/SSL_shutdown.pod
index c4ae6704e7..6b5012be7a 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_shutdown.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_shutdown.pod
@@ -22,10 +22,52 @@ Whether the operation succeeds or not, the SSL_SENT_SHUTDOWN flag is set and
22a currently open session is considered closed and good and will be kept in the 22a currently open session is considered closed and good and will be kept in the
23session cache for further reuse. 23session cache for further reuse.
24 24
25The behaviour of SSL_shutdown() depends on the underlying BIO. 25The shutdown procedure consists of 2 steps: the sending of the "close notify"
26shutdown alert and the reception of the peer's "close notify" shutdown
27alert. According to the TLS standard, it is acceptable for an application
28to only send its shutdown alert and then close the underlying connection
29without waiting for the peer's response (this way resources can be saved,
30as the process can already terminate or serve another connection).
31When the underlying connection shall be used for more communications, the
32complete shutdown procedure (bidirectional "close notify" alerts) must be
33performed, so that the peers stay synchronized.
34
35SSL_shutdown() supports both uni- and bidirectional shutdown by its 2 step
36behaviour.
37
38=over 4
39
40=item When the application is the first party to send the "close notify"
41alert, SSL_shutdown() will only send the alert and the set the
42SSL_SENT_SHUTDOWN flag (so that the session is considered good and will
43be kept in cache). SSL_shutdown() will then return with 0. If a unidirectional
44shutdown is enough (the underlying connection shall be closed anyway), this
45first call to SSL_shutdown() is sufficient. In order to complete the
46bidirectional shutdown handshake, SSL_shutdown() must be called again.
47The second call will make SSL_shutdown() wait for the peer's "close notify"
48shutdown alert. On success, the second call to SSL_shutdown() will return
49with 1.
50
51=item If the peer already sent the "close notify" alert B<and> it was
52already processed implicitly inside another function
53(L<SSL_read(3)|SSL_read(3)>), the SSL_RECEIVED_SHUTDOWN flag is set.
54SSL_shutdown() will send the "close notify" alert, set the SSL_SENT_SHUTDOWN
55flag and will immediately return with 1.
56Whether SSL_RECEIVED_SHUTDOWN is already set can be checked using the
57SSL_get_shutdown() (see also L<SSL_set_shutdown(3)|SSL_set_shutdown(3)> call.
58
59=back
60
61It is therefore recommended, to check the return value of SSL_shutdown()
62and call SSL_shutdown() again, if the bidirectional shutdown is not yet
63complete (return value of the first call is 0). As the shutdown is not
64specially handled in the SSLv2 protocol, SSL_shutdown() will succeed on
65the first call.
66
67The behaviour of SSL_shutdown() additionally depends on the underlying BIO.
26 68
27If the underlying BIO is B<blocking>, SSL_shutdown() will only return once the 69If the underlying BIO is B<blocking>, SSL_shutdown() will only return once the
28handshake has been finished or an error occurred. 70handshake step has been finished or an error occurred.
29 71
30If the underlying BIO is B<non-blocking>, SSL_shutdown() will also return 72If the underlying BIO is B<non-blocking>, SSL_shutdown() will also return
31when the underlying BIO could not satisfy the needs of SSL_shutdown() 73when the underlying BIO could not satisfy the needs of SSL_shutdown()
@@ -38,6 +80,12 @@ nothing is to be done, but select() can be used to check for the required
38condition. When using a buffering BIO, like a BIO pair, data must be written 80condition. When using a buffering BIO, like a BIO pair, data must be written
39into or retrieved out of the BIO before being able to continue. 81into or retrieved out of the BIO before being able to continue.
40 82
83SSL_shutdown() can be modified to only set the connection to "shutdown"
84state but not actually send the "close notify" alert messages,
85see L<SSL_CTX_set_quiet_shutdown(3)|SSL_CTX_set_quiet_shutdown(3)>.
86When "quiet shutdown" is enabled, SSL_shutdown() will always succeed
87and return 1.
88
41=head1 RETURN VALUES 89=head1 RETURN VALUES
42 90
43The following return values can occur: 91The following return values can occur:
@@ -46,19 +94,23 @@ The following return values can occur:
46 94
47=item 1 95=item 1
48 96
49The shutdown was successfully completed. 97The shutdown was successfully completed. The "close notify" alert was sent
98and the peer's "close notify" alert was received.
50 99
51=item 0 100=item 0
52 101
53The shutdown was not successful. Call SSL_get_error() with the return 102The shutdown is not yet finished. Call SSL_shutdown() for a second time,
54value B<ret> to find out the reason. 103if a bidirectional shutdown shall be performed.
104The output of L<SSL_get_error(3)|SSL_get_error(3)> may be misleading, as an
105erroneous SSL_ERROR_SYSCALL may be flagged even though no error occurred.
55 106
56=item -1 107=item -1
57 108
58The shutdown was not successful because a fatal error occurred either 109The shutdown was not successful because a fatal error occurred either
59at the protocol level or a connection failure occurred. It can also occur of 110at the protocol level or a connection failure occurred. It can also occur if
60action is need to continue the operation for non-blocking BIOs. 111action is need to continue the operation for non-blocking BIOs.
61Call SSL_get_error() with the return value B<ret> to find out the reason. 112Call L<SSL_get_error(3)|SSL_get_error(3)> with the return value B<ret>
113to find out the reason.
62 114
63=back 115=back
64 116
@@ -66,6 +118,7 @@ Call SSL_get_error() with the return value B<ret> to find out the reason.
66 118
67L<SSL_get_error(3)|SSL_get_error(3)>, L<SSL_connect(3)|SSL_connect(3)>, 119L<SSL_get_error(3)|SSL_get_error(3)>, L<SSL_connect(3)|SSL_connect(3)>,
68L<SSL_accept(3)|SSL_accept(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>, 120L<SSL_accept(3)|SSL_accept(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>,
121L<SSL_CTX_set_quiet_shutdown(3)|SSL_CTX_set_quiet_shutdown(3)>,
69L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>, 122L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>,
70L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)> 123L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)>
71 124
diff --git a/src/lib/libssl/src/doc/ssl/SSL_state_string.pod b/src/lib/libssl/src/doc/ssl/SSL_state_string.pod
new file mode 100644
index 0000000000..b4be1aaa48
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_state_string.pod
@@ -0,0 +1,45 @@
1=pod
2
3=head1 NAME
4
5SSL_state_string, SSL_state_string_long - get textual description of state of an SSL object
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 const char *SSL_state_string(SSL *ssl);
12 const char *SSL_state_string_long(SSL *ssl);
13
14=head1 DESCRIPTION
15
16SSL_state_string() returns a 6 letter string indicating the current state
17of the SSL object B<ssl>.
18
19SSL_state_string_long() returns a string indicating the current state of
20the SSL object B<ssl>.
21
22=head1 NOTES
23
24During its use, an SSL objects passes several states. The state is internally
25maintained. Querying the state information is not very informative before
26or when a connection has been established. It however can be of significant
27interest during the handshake.
28
29When using non-blocking sockets, the function call performing the handshake
30may return with SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE condition,
31so that SSL_state_string[_long]() may be called.
32
33For both blocking or non-blocking sockets, the details state information
34can be used within the info_callback function set with the
35SSL_set_info_callback() call.
36
37=head1 RETURN VALUES
38
39Detailed description of possible states to be included later.
40
41=head1 SEE ALSO
42
43L<ssl(3)|ssl(3)>, L<SSL_CTX_set_info_callback(3)|SSL_CTX_set_info_callback(3)>
44
45=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_want.pod b/src/lib/libssl/src/doc/ssl/SSL_want.pod
new file mode 100644
index 0000000000..50cc89db80
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_want.pod
@@ -0,0 +1,77 @@
1=pod
2
3=head1 NAME
4
5SSL_want, SSL_want_nothing, SSL_want_read, SSL_want_write, SSL_want_x509_lookup - obtain state information TLS/SSL I/O operation
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_want(SSL *ssl);
12 int SSL_want_nothing(SSL *ssl);
13 int SSL_want_read(SSL *ssl);
14 int SSL_want_write(SSL *ssl);
15 int SSL_want_x509_lookup(SSL *ssl);
16
17=head1 DESCRIPTION
18
19SSL_want() returns state information for the SSL object B<ssl>.
20
21The other SSL_want_*() calls are shortcuts for the possible states returned
22by SSL_want().
23
24=head1 NOTES
25
26SSL_want() examines the internal state information of the SSL object. Its
27return values are similar to that of L<SSL_get_error(3)|SSL_get_error(3)>.
28Unlike L<SSL_get_error(3)|SSL_get_error(3)>, which also evaluates the
29error queue, the results are obtained by examining an internal state flag
30only. The information must therefore only be used for normal operation under
31non-blocking I/O. Error conditions are not handled and must be treated
32using L<SSL_get_error(3)|SSL_get_error(3)>.
33
34The result returned by SSL_want() should always be consistent with
35the result of L<SSL_get_error(3)|SSL_get_error(3)>.
36
37=head1 RETURN VALUES
38
39The following return values can currently occur for SSL_want():
40
41=over 4
42
43=item SSL_NOTHING
44
45There is no data to be written or to be read.
46
47=item SSL_WRITING
48
49There are data in the SSL buffer that must be written to the underlying
50B<BIO> layer in order to complete the actual SSL_*() operation.
51A call to L<SSL_get_error(3)|SSL_get_error(3)> should return
52SSL_ERROR_WANT_WRITE.
53
54=item SSL_READING
55
56More data must be read from the underlying B<BIO> layer in order to
57complete the actual SSL_*() operation.
58A call to L<SSL_get_error(3)|SSL_get_error(3)> should return
59SSL_ERROR_WANT_READ.
60
61=item SSL_X509_LOOKUP
62
63The operation did not complete because an application callback set by
64SSL_CTX_set_client_cert_cb() has asked to be called again.
65A call to L<SSL_get_error(3)|SSL_get_error(3)> should return
66SSL_ERROR_WANT_X509_LOOKUP.
67
68=back
69
70SSL_want_nothing(), SSL_want_read(), SSL_want_write(), SSL_want_x509_lookup()
71return 1, when the corresponding condition is true or 0 otherwise.
72
73=head1 SEE ALSO
74
75L<ssl(3)|ssl(3)>, L<err(3)|err(3)>, L<SSL_get_error(3)|SSL_get_error(3)>
76
77=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_write.pod b/src/lib/libssl/src/doc/ssl/SSL_write.pod
index b0dfefae20..dfa42e9aee 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_write.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_write.pod
@@ -25,11 +25,9 @@ the SSL_write() operation. The behaviour of SSL_write() depends on the
25underlying BIO. 25underlying BIO.
26 26
27For the transparent negotiation to succeed, the B<ssl> must have been 27For the transparent negotiation to succeed, the B<ssl> must have been
28initialized to client or server mode. This is not the case if a generic 28initialized to client or server mode. This is being done by calling
29method is being used (see L<SSL_CTX_new(3)|SSL_CTX_new(3)>, so that
30L<SSL_set_connect_state(3)|SSL_set_connect_state(3)> or SSL_set_accept_state() 29L<SSL_set_connect_state(3)|SSL_set_connect_state(3)> or SSL_set_accept_state()
31must be used before the first call to an L<SSL_read(3)|SSL_read(3)> 30before the first call to an L<SSL_read(3)|SSL_read(3)> or SSL_write() function.
32or SSL_write() function.
33 31
34If the underlying BIO is B<blocking>, SSL_write() will only return, once the 32If the underlying BIO is B<blocking>, SSL_write() will only return, once the
35write operation has been finished or an error occurred, except when a 33write operation has been finished or an error occurred, except when a
@@ -80,8 +78,14 @@ bytes actually written to the TLS/SSL connection.
80 78
81=item 0 79=item 0
82 80
83The write operation was not successful. Call SSL_get_error() with the return 81The write operation was not successful. Probably the underlying connection
84value B<ret> to find out, whether an error occurred. 82was closed. Call SSL_get_error() with the return value B<ret> to find out,
83whether an error occurred or the connection was shut down cleanly
84(SSL_ERROR_ZERO_RETURN).
85
86SSLv2 (deprecated) does not support a shutdown alert protocol, so it can
87only be detected, whether the underlying connection was closed. It cannot
88be checked, why the closure happened.
85 89
86=item E<lt>0 90=item E<lt>0
87 91
diff --git a/src/lib/libssl/src/doc/ssl/d2i_SSL_SESSION.pod b/src/lib/libssl/src/doc/ssl/d2i_SSL_SESSION.pod
index 9a1ba6c47b..0321a5a36f 100644
--- a/src/lib/libssl/src/doc/ssl/d2i_SSL_SESSION.pod
+++ b/src/lib/libssl/src/doc/ssl/d2i_SSL_SESSION.pod
@@ -30,7 +30,17 @@ session data on disk or into a database, it must be transformed into
30a binary ASN1 representation. 30a binary ASN1 representation.
31 31
32When using d2i_SSL_SESSION(), the SSL_SESSION object is automatically 32When using d2i_SSL_SESSION(), the SSL_SESSION object is automatically
33allocated. 33allocated. The reference count is 1, so that the session must be
34explicitly removed using L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
35unless the SSL_SESSION object is completely taken over, when being called
36inside the get_session_cb() (see
37L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>).
38
39SSL_SESSION objects keep internal link information about the session cache
40list, when being inserted into one SSL_CTX object's session cache.
41One SSL_SESSION object, regardless of its reference count, must therefore
42only be used with one SSL_CTX object (and the SSL objects created
43from this SSL_CTX object).
34 44
35When using i2d_SSL_SESSION(), the memory location pointed to by B<pp> must be 45When using i2d_SSL_SESSION(), the memory location pointed to by B<pp> must be
36large enough to hold the binary representation of the session. There is no 46large enough to hold the binary representation of the session. There is no
@@ -50,7 +60,7 @@ When the session is not valid, B<0> is returned and no operation is performed.
50 60
51=head1 SEE ALSO 61=head1 SEE ALSO
52 62
53L<ssl(3)|ssl(3)>, 63L<ssl(3)|ssl(3)>, L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
54L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)> 64L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>
55 65
56=cut 66=cut
diff --git a/src/lib/libssl/src/doc/ssl/ssl.pod b/src/lib/libssl/src/doc/ssl/ssl.pod
index 16292a05f2..ce41b3e17d 100644
--- a/src/lib/libssl/src/doc/ssl/ssl.pod
+++ b/src/lib/libssl/src/doc/ssl/ssl.pod
@@ -299,7 +299,7 @@ protocol context defined in the B<SSL_CTX> structure.
299 299
300=item void B<SSL_CTX_set_cert_store>(SSL_CTX *ctx, X509_STORE *cs); 300=item void B<SSL_CTX_set_cert_store>(SSL_CTX *ctx, X509_STORE *cs);
301 301
302=item void B<SSL_CTX_set_cert_verify_cb>(SSL_CTX *ctx, int (*cb)(SSL_CTX *), char *arg) 302=item void B<SSL_CTX_set_cert_verify_cb>(SSL_CTX *ctx, int (*cb)(), char *arg)
303 303
304=item int B<SSL_CTX_set_cipher_list>(SSL_CTX *ctx, char *str); 304=item int B<SSL_CTX_set_cipher_list>(SSL_CTX *ctx, char *str);
305 305
@@ -317,6 +317,10 @@ protocol context defined in the B<SSL_CTX> structure.
317 317
318=item void B<SSL_CTX_set_info_callback>(SSL_CTX *ctx, void (*cb)(SSL *ssl, int cb, int ret)); 318=item void B<SSL_CTX_set_info_callback>(SSL_CTX *ctx, void (*cb)(SSL *ssl, int cb, int ret));
319 319
320=item void B<SSL_CTX_set_msg_callback>(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
321
322=item void B<SSL_CTX_set_msg_callback_arg>(SSL_CTX *ctx, void *arg);
323
320=item void B<SSL_CTX_set_options>(SSL_CTX *ctx, unsigned long op); 324=item void B<SSL_CTX_set_options>(SSL_CTX *ctx, unsigned long op);
321 325
322=item void B<SSL_CTX_set_quiet_shutdown>(SSL_CTX *ctx, int mode); 326=item void B<SSL_CTX_set_quiet_shutdown>(SSL_CTX *ctx, int mode);
@@ -576,6 +580,10 @@ connection defined in the B<SSL> structure.
576 580
577=item void B<SSL_set_info_callback>(SSL *ssl, void (*cb);(void)) 581=item void B<SSL_set_info_callback>(SSL *ssl, void (*cb);(void))
578 582
583=item void B<SSL_set_msg_callback>(SSL *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
584
585=item void B<SSL_set_msg_callback_arg>(SSL *ctx, void *arg);
586
579=item void B<SSL_set_options>(SSL *ssl, unsigned long op); 587=item void B<SSL_set_options>(SSL *ssl, unsigned long op);
580 588
581=item void B<SSL_set_quiet_shutdown>(SSL *ssl, int mode); 589=item void B<SSL_set_quiet_shutdown>(SSL *ssl, int mode);
@@ -650,8 +658,10 @@ L<openssl(1)|openssl(1)>, L<crypto(3)|crypto(3)>,
650L<SSL_accept(3)|SSL_accept(3)>, L<SSL_clear(3)|SSL_clear(3)>, 658L<SSL_accept(3)|SSL_accept(3)>, L<SSL_clear(3)|SSL_clear(3)>,
651L<SSL_connect(3)|SSL_connect(3)>, 659L<SSL_connect(3)|SSL_connect(3)>,
652L<SSL_CIPHER_get_name(3)|SSL_CIPHER_get_name(3)>, 660L<SSL_CIPHER_get_name(3)|SSL_CIPHER_get_name(3)>,
661L<SSL_COMP_add_compression_method(3)|SSL_COMP_add_compression_method(3)>,
653L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>, 662L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>,
654L<SSL_CTX_add_session(3)|SSL_CTX_add_session(3)>, 663L<SSL_CTX_add_session(3)|SSL_CTX_add_session(3)>,
664L<SSL_CTX_ctrl(3)|SSL_CTX_ctrl(3)>,
655L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>, 665L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>,
656L<SSL_CTX_get_ex_new_index(3)|SSL_CTX_get_ex_new_index(3)>, 666L<SSL_CTX_get_ex_new_index(3)|SSL_CTX_get_ex_new_index(3)>,
657L<SSL_CTX_get_verify_mode(3)|SSL_CTX_get_verify_mode(3)>, 667L<SSL_CTX_get_verify_mode(3)|SSL_CTX_get_verify_mode(3)>,
@@ -661,18 +671,32 @@ L<SSL_CTX_sess_number(3)|SSL_CTX_sess_number(3)>,
661L<SSL_CTX_sess_set_cache_size(3)|SSL_CTX_sess_set_cache_size(3)>, 671L<SSL_CTX_sess_set_cache_size(3)|SSL_CTX_sess_set_cache_size(3)>,
662L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>, 672L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>,
663L<SSL_CTX_sessions(3)|SSL_CTX_sessions(3)>, 673L<SSL_CTX_sessions(3)|SSL_CTX_sessions(3)>,
674L<SSL_CTX_set_cert_store(3)|SSL_CTX_set_cert_store(3)>,
675L<SSL_CTX_set_cert_verify_callback(3)|SSL_CTX_set_cert_verify_callback(3)>,
676L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>,
664L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>, 677L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>,
678L<SSL_CTX_set_client_cert_cb(3)|SSL_CTX_set_client_cert_cb(3)>,
665L<SSL_CTX_set_default_passwd_cb(3)|SSL_CTX_set_default_passwd_cb(3)>, 679L<SSL_CTX_set_default_passwd_cb(3)|SSL_CTX_set_default_passwd_cb(3)>,
680L<SSL_CTX_set_generate_session_id(3)|SSL_CTX_set_generate_session_id(3)>,
681L<SSL_CTX_set_info_callback(3)|SSL_CTX_set_info_callback(3)>,
682L<SSL_CTX_set_max_cert_list(3)|SSL_CTX_set_max_cert_list(3)>,
666L<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)>, 683L<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)>,
684L<SSL_CTX_set_msg_callback(3)|SSL_CTX_set_msg_callback(3)>,
667L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>, 685L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>,
686L<SSL_CTX_set_quiet_shutdown(3)|SSL_CTX_set_quiet_shutdown(3)>,
668L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>, 687L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
669L<SSL_CTX_set_session_id_context(3)|SSL_CTX_set_session_id_context(3)>, 688L<SSL_CTX_set_session_id_context(3)|SSL_CTX_set_session_id_context(3)>,
670L<SSL_CTX_set_ssl_version(3)|SSL_CTX_set_ssl_version(3)>, 689L<SSL_CTX_set_ssl_version(3)|SSL_CTX_set_ssl_version(3)>,
671L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)>, 690L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)>,
691L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>,
692L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>,
672L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>, 693L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>,
673L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>, 694L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,
695L<SSL_alert_type_string(3)|SSL_alert_type_string(3)>,
696L<SSL_get_SSL_CTX(3)|SSL_get_SSL_CTX(3)>,
674L<SSL_get_ciphers(3)|SSL_get_ciphers(3)>, 697L<SSL_get_ciphers(3)|SSL_get_ciphers(3)>,
675L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>, 698L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>,
699L<SSL_get_default_timeout(3)|SSL_get_default_timeout(3)>,
676L<SSL_get_error(3)|SSL_get_error(3)>, 700L<SSL_get_error(3)|SSL_get_error(3)>,
677L<SSL_get_ex_data_X509_STORE_CTX_idx(3)|SSL_get_ex_data_X509_STORE_CTX_idx(3)>, 701L<SSL_get_ex_data_X509_STORE_CTX_idx(3)|SSL_get_ex_data_X509_STORE_CTX_idx(3)>,
678L<SSL_get_ex_new_index(3)|SSL_get_ex_new_index(3)>, 702L<SSL_get_ex_new_index(3)|SSL_get_ex_new_index(3)>,
@@ -685,12 +709,19 @@ L<SSL_get_version(3)|SSL_get_version(3)>,
685L<SSL_library_init(3)|SSL_library_init(3)>, 709L<SSL_library_init(3)|SSL_library_init(3)>,
686L<SSL_load_client_CA_file(3)|SSL_load_client_CA_file(3)>, 710L<SSL_load_client_CA_file(3)|SSL_load_client_CA_file(3)>,
687L<SSL_new(3)|SSL_new(3)>, 711L<SSL_new(3)|SSL_new(3)>,
688L<SSL_read(3)|SSL_read(3)>, L<SSL_set_bio(3)|SSL_set_bio(3)>, 712L<SSL_pending(3)|SSL_pending(3)>,
713L<SSL_read(3)|SSL_read(3)>,
714L<SSL_rstate_string(3)|SSL_rstate_string(3)>,
715L<SSL_session_reused(3)|SSL_session_reused(3)>,
716L<SSL_set_bio(3)|SSL_set_bio(3)>,
689L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>, 717L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>,
690L<SSL_set_fd(3)|SSL_set_fd(3)>, L<SSL_pending(3)|SSL_pending(3)>, 718L<SSL_set_fd(3)|SSL_set_fd(3)>,
691L<SSL_set_session(3)|SSL_set_session(3)>, 719L<SSL_set_session(3)|SSL_set_session(3)>,
692L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>, 720L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>,
693L<SSL_shutdown(3)|SSL_shutdown(3)>, L<SSL_write(3)|SSL_write(3)>, 721L<SSL_shutdown(3)|SSL_shutdown(3)>,
722L<SSL_state_string(3)|SSL_state_string(3)>,
723L<SSL_want(3)|SSL_want(3)>,
724L<SSL_write(3)|SSL_write(3)>,
694L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>, 725L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
695L<SSL_SESSION_get_ex_new_index(3)|SSL_SESSION_get_ex_new_index(3)>, 726L<SSL_SESSION_get_ex_new_index(3)|SSL_SESSION_get_ex_new_index(3)>,
696L<SSL_SESSION_get_time(3)|SSL_SESSION_get_time(3)>, 727L<SSL_SESSION_get_time(3)|SSL_SESSION_get_time(3)>,
diff --git a/src/lib/libssl/src/doc/ssleay.txt b/src/lib/libssl/src/doc/ssleay.txt
index fab8d42c42..c6049d5e53 100644
--- a/src/lib/libssl/src/doc/ssleay.txt
+++ b/src/lib/libssl/src/doc/ssleay.txt
@@ -1,6 +1,22 @@
1 1
2Bundle of old SSLeay documentation files [OBSOLETE!] 2Bundle of old SSLeay documentation files [OBSOLETE!]
3 3
4*** WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! ***
5
6OBSOLETE means that nothing in this document should be trusted. This
7document is provided mostly for historical purposes (it wasn't even up
8to date at the time SSLeay 0.8.1 was released) and as inspiration. If
9you copy some snippet of code from this document, please _check_ that
10it really is correct from all points of view. For example, you can
11check with the other documents in this directory tree, or by comparing
12with relevant parts of the include files.
13
14People have done the mistake of trusting what's written here. Please
15don't do that.
16
17*** WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! ***
18
19
4==== readme ======================================================== 20==== readme ========================================================
5 21
6This is the old 0.6.6 docuementation. Most of the cipher stuff is still 22This is the old 0.6.6 docuementation. Most of the cipher stuff is still
diff --git a/src/lib/libssl/src/doc/standards.txt b/src/lib/libssl/src/doc/standards.txt
index 61ccc5d7e0..596d9001e6 100644
--- a/src/lib/libssl/src/doc/standards.txt
+++ b/src/lib/libssl/src/doc/standards.txt
@@ -24,7 +24,8 @@ http://www.rsasecurity.com/rsalabs/pkcs/.
24Implemented: 24Implemented:
25------------ 25------------
26 26
27These are documents that describe things that are implemented in OpenSSL. 27These are documents that describe things that are implemented (in
28whole or at least great parts) in OpenSSL.
28 29
291319 The MD2 Message-Digest Algorithm. B. Kaliski. April 1992. 301319 The MD2 Message-Digest Algorithm. B. Kaliski. April 1992.
30 (Format: TXT=25661 bytes) (Status: INFORMATIONAL) 31 (Format: TXT=25661 bytes) (Status: INFORMATIONAL)
@@ -59,6 +60,11 @@ PKCS#8: Private-Key Information Syntax Standard
59 60
60PKCS#12: Personal Information Exchange Syntax Standard, version 1.0. 61PKCS#12: Personal Information Exchange Syntax Standard, version 1.0.
61 62
632560 X.509 Internet Public Key Infrastructure Online Certificate
64 Status Protocol - OCSP. M. Myers, R. Ankney, A. Malpani, S. Galperin,
65 C. Adams. June 1999. (Format: TXT=43243 bytes) (Status: PROPOSED
66 STANDARD)
67
62 68
63Related: 69Related:
64-------- 70--------
@@ -84,6 +90,10 @@ STARTTLS documents.
84 Certification and Related Services. B. Kaliski. February 1993. 90 Certification and Related Services. B. Kaliski. February 1993.
85 (Format: TXT=17537 bytes) (Status: PROPOSED STANDARD) 91 (Format: TXT=17537 bytes) (Status: PROPOSED STANDARD)
86 92
932256 A Summary of the X.500(96) User Schema for use with LDAPv3. M.
94 Wahl. December 1997. (Format: TXT=32377 bytes) (Status: PROPOSED
95 STANDARD)
96
872487 SMTP Service Extension for Secure SMTP over TLS. P. Hoffman. 972487 SMTP Service Extension for Secure SMTP over TLS. P. Hoffman.
88 January 1999. (Format: TXT=15120 bytes) (Status: PROPOSED STANDARD) 98 January 1999. (Format: TXT=15120 bytes) (Status: PROPOSED STANDARD)
89 99
@@ -114,8 +124,7 @@ To be implemented:
114These are documents that describe things that are planed to be 124These are documents that describe things that are planed to be
115implemented in the hopefully short future. 125implemented in the hopefully short future.
116 126
1172560 X.509 Internet Public Key Infrastructure Online Certificate 1272712 Addition of Kerberos Cipher Suites to Transport Layer Security
118 Status Protocol - OCSP. M. Myers, R. Ankney, A. Malpani, S. Galperin, 128 (TLS). A. Medvinsky, M. Hur. October 1999. (Format: TXT=13763 bytes)
119 C. Adams. June 1999. (Format: TXT=43243 bytes) (Status: PROPOSED 129 (Status: PROPOSED STANDARD)
120 STANDARD)
121 130