summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/doc
diff options
context:
space:
mode:
authormarkus <>2002-09-05 12:51:50 +0000
committermarkus <>2002-09-05 12:51:50 +0000
commit15b5d84f9da2ce4bfae8580e56e34a859f74ad71 (patch)
treebf939e82d7fd73cc8a01cf6959002209972091bc /src/lib/libcrypto/doc
parent027351f729b9e837200dae6e1520cda6577ab930 (diff)
downloadopenbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.gz
openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.bz2
openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.zip
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/doc')
-rw-r--r--src/lib/libcrypto/doc/DH_set_method.pod64
-rw-r--r--src/lib/libcrypto/doc/DSA_set_method.pod63
-rw-r--r--src/lib/libcrypto/doc/ERR_error_string.pod16
-rw-r--r--src/lib/libcrypto/doc/ERR_get_error.pod30
-rw-r--r--src/lib/libcrypto/doc/ERR_remove_state.pod2
-rw-r--r--src/lib/libcrypto/doc/EVP_DigestInit.pod124
-rw-r--r--src/lib/libcrypto/doc/EVP_EncryptInit.pod412
-rw-r--r--src/lib/libcrypto/doc/EVP_OpenInit.pod28
-rw-r--r--src/lib/libcrypto/doc/EVP_SealInit.pod18
-rw-r--r--src/lib/libcrypto/doc/EVP_SignInit.pod41
-rw-r--r--src/lib/libcrypto/doc/EVP_VerifyInit.pod39
-rw-r--r--src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod59
-rw-r--r--src/lib/libcrypto/doc/OpenSSL_add_all_algorithms.pod5
-rw-r--r--src/lib/libcrypto/doc/RAND_add.pod25
-rw-r--r--src/lib/libcrypto/doc/RAND_load_file.pod2
-rw-r--r--src/lib/libcrypto/doc/RAND_set_rand_method.pod4
-rw-r--r--src/lib/libcrypto/doc/RSA_generate_key.pod2
-rw-r--r--src/lib/libcrypto/doc/RSA_get_ex_new_index.pod14
-rw-r--r--src/lib/libcrypto/doc/RSA_print.pod5
-rw-r--r--src/lib/libcrypto/doc/RSA_public_encrypt.pod6
-rw-r--r--src/lib/libcrypto/doc/RSA_set_method.pod83
-rw-r--r--src/lib/libcrypto/doc/bn.pod18
-rw-r--r--src/lib/libcrypto/doc/dh.pod9
-rw-r--r--src/lib/libcrypto/doc/dsa.pod9
-rw-r--r--src/lib/libcrypto/doc/evp.pod2
-rw-r--r--src/lib/libcrypto/doc/rsa.pod17
26 files changed, 797 insertions, 300 deletions
diff --git a/src/lib/libcrypto/doc/DH_set_method.pod b/src/lib/libcrypto/doc/DH_set_method.pod
index dca41d8dbc..d990bf8786 100644
--- a/src/lib/libcrypto/doc/DH_set_method.pod
+++ b/src/lib/libcrypto/doc/DH_set_method.pod
@@ -2,20 +2,21 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5DH_set_default_method, DH_get_default_method, DH_set_method, 5DH_set_default_openssl_method, DH_get_default_openssl_method,
6DH_new_method, DH_OpenSSL - select DH method 6DH_set_method, DH_new_method, DH_OpenSSL - select DH method
7 7
8=head1 SYNOPSIS 8=head1 SYNOPSIS
9 9
10 #include <openssl/dh.h> 10 #include <openssl/dh.h>
11 #include <openssl/engine.h>
11 12
12 void DH_set_default_method(DH_METHOD *meth); 13 void DH_set_default_openssl_method(DH_METHOD *meth);
13 14
14 DH_METHOD *DH_get_default_method(void); 15 DH_METHOD *DH_get_default_openssl_method(void);
15 16
16 DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth); 17 int DH_set_method(DH *dh, ENGINE *engine);
17 18
18 DH *DH_new_method(DH_METHOD *meth); 19 DH *DH_new_method(ENGINE *engine);
19 20
20 DH_METHOD *DH_OpenSSL(void); 21 DH_METHOD *DH_OpenSSL(void);
21 22
@@ -28,20 +29,26 @@ such as hardware accelerators may be used.
28Initially, the default is to use the OpenSSL internal implementation. 29Initially, the default is to use the OpenSSL internal implementation.
29DH_OpenSSL() returns a pointer to that method. 30DH_OpenSSL() returns a pointer to that method.
30 31
31DH_set_default_method() makes B<meth> the default method for all B<DH> 32DH_set_default_openssl_method() makes B<meth> the default method for all DH
32structures created later. 33structures created later. B<NB:> This is true only whilst the default engine
34for Diffie-Hellman operations remains as "openssl". ENGINEs provide an
35encapsulation for implementations of one or more algorithms, and all the DH
36functions mentioned here operate within the scope of the default
37"openssl" engine.
33 38
34DH_get_default_method() returns a pointer to the current default 39DH_get_default_openssl_method() returns a pointer to the current default
35method. 40method for the "openssl" engine.
36 41
37DH_set_method() selects B<meth> for all operations using the structure B<dh>. 42DH_set_method() selects B<engine> as the engine that will be responsible for
43all operations using the structure B<dh>. If this function completes successfully,
44then the B<dh> structure will have its own functional reference of B<engine>, so
45the caller should remember to free their own reference to B<engine> when they are
46finished with it. NB: An ENGINE's DH_METHOD can be retrieved (or set) by
47ENGINE_get_DH() or ENGINE_set_DH().
38 48
39DH_get_method() returns a pointer to the method currently selected 49DH_new_method() allocates and initializes a DH structure so that
40for B<dh>. 50B<engine> will be used for the DH operations. If B<engine> is NULL,
41 51the default engine for Diffie-Hellman opertaions is used.
42DH_new_method() allocates and initializes a B<DH> structure so that
43B<method> will be used for the DH operations. If B<method> is B<NULL>,
44the default method is used.
45 52
46=head1 THE DH_METHOD STRUCTURE 53=head1 THE DH_METHOD STRUCTURE
47 54
@@ -56,7 +63,7 @@ the default method is used.
56 /* compute shared secret */ 63 /* compute shared secret */
57 int (*compute_key)(unsigned char *key, BIGNUM *pub_key, DH *dh); 64 int (*compute_key)(unsigned char *key, BIGNUM *pub_key, DH *dh);
58 65
59 /* compute r = a ^ p mod m. May be NULL */ 66 /* compute r = a ^ p mod m (May be NULL for some implementations) */
60 int (*bn_mod_exp)(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p, 67 int (*bn_mod_exp)(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
61 const BIGNUM *m, BN_CTX *ctx, 68 const BIGNUM *m, BN_CTX *ctx,
62 BN_MONT_CTX *m_ctx); 69 BN_MONT_CTX *m_ctx);
@@ -75,17 +82,17 @@ the default method is used.
75 82
76=head1 RETURN VALUES 83=head1 RETURN VALUES
77 84
78DH_OpenSSL(), DH_get_default_method() and DH_get_method() return 85DH_OpenSSL() and DH_get_default_openssl_method() return pointers to the
79pointers to the respective B<DH_METHOD>s. 86respective B<DH_METHOD>s.
80 87
81DH_set_default_method() returns no value. 88DH_set_default_openssl_method() returns no value.
82 89
83DH_set_method() returns a pointer to the B<DH_METHOD> previously 90DH_set_method() returns non-zero if the ENGINE associated with B<dh>
84associated with B<dh>. 91was successfully changed to B<engine>.
85 92
86DH_new_method() returns B<NULL> and sets an error code that can be 93DH_new_method() returns NULL and sets an error code that can be
87obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise it 94obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails.
88returns a pointer to the newly allocated structure. 95Otherwise it returns a pointer to the newly allocated structure.
89 96
90=head1 SEE ALSO 97=head1 SEE ALSO
91 98
@@ -96,4 +103,9 @@ L<dh(3)|dh(3)>, L<DH_new(3)|DH_new(3)>
96DH_set_default_method(), DH_get_default_method(), DH_set_method(), 103DH_set_default_method(), DH_get_default_method(), DH_set_method(),
97DH_new_method() and DH_OpenSSL() were added in OpenSSL 0.9.4. 104DH_new_method() and DH_OpenSSL() were added in OpenSSL 0.9.4.
98 105
106DH_set_default_openssl_method() and DH_get_default_openssl_method()
107replaced DH_set_default_method() and DH_get_default_method() respectively,
108and DH_set_method() and DH_new_method() were altered to use B<ENGINE>s
109rather than B<DH_METHOD>s during development of OpenSSL 0.9.6.
110
99=cut 111=cut
diff --git a/src/lib/libcrypto/doc/DSA_set_method.pod b/src/lib/libcrypto/doc/DSA_set_method.pod
index 0b13ec9237..36a1052d27 100644
--- a/src/lib/libcrypto/doc/DSA_set_method.pod
+++ b/src/lib/libcrypto/doc/DSA_set_method.pod
@@ -2,20 +2,21 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5DSA_set_default_method, DSA_get_default_method, DSA_set_method, 5DSA_set_default_openssl_method, DSA_get_default_openssl_method,
6DSA_new_method, DSA_OpenSSL - select RSA method 6DSA_set_method, DSA_new_method, DSA_OpenSSL - select DSA method
7 7
8=head1 SYNOPSIS 8=head1 SYNOPSIS
9 9
10 #include <openssl/DSA.h> 10 #include <openssl/dsa.h>
11 #include <openssl/engine.h>
11 12
12 void DSA_set_default_method(DSA_METHOD *meth); 13 void DSA_set_default_openssl_method(DSA_METHOD *meth);
13 14
14 DSA_METHOD *DSA_get_default_method(void); 15 DSA_METHOD *DSA_get_default_openssl_method(void);
15 16
16 DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth); 17 int DSA_set_method(DSA *dsa, ENGINE *engine);
17 18
18 DSA *DSA_new_method(DSA_METHOD *meth); 19 DSA *DSA_new_method(ENGINE *engine);
19 20
20 DSA_METHOD *DSA_OpenSSL(void); 21 DSA_METHOD *DSA_OpenSSL(void);
21 22
@@ -28,20 +29,21 @@ such as hardware accelerators may be used.
28Initially, the default is to use the OpenSSL internal implementation. 29Initially, the default is to use the OpenSSL internal implementation.
29DSA_OpenSSL() returns a pointer to that method. 30DSA_OpenSSL() returns a pointer to that method.
30 31
31DSA_set_default_method() makes B<meth> the default method for all B<DSA> 32DSA_set_default_openssl_method() makes B<meth> the default method for
32structures created later. 33all DSA structures created later. B<NB:> This is true only whilst the
34default engine for DSA operations remains as "openssl". ENGINEs
35provide an encapsulation for implementations of one or more algorithms at a
36time, and all the DSA functions mentioned here operate within the scope
37of the default "openssl" engine.
33 38
34DSA_get_default_method() returns a pointer to the current default 39DSA_get_default_openssl_method() returns a pointer to the current default
35method. 40method for the "openssl" engine.
36 41
37DSA_set_method() selects B<meth> for all operations using the structure B<DSA>. 42DSA_set_method() selects B<engine> for all operations using the structure B<dsa>.
38 43
39DSA_get_method() returns a pointer to the method currently selected 44DSA_new_method() allocates and initializes a DSA structure so that
40for B<DSA>. 45B<engine> will be used for the DSA operations. If B<engine> is NULL,
41 46the default engine for DSA operations is used.
42DSA_new_method() allocates and initializes a B<DSA> structure so that
43B<method> will be used for the DSA operations. If B<method> is B<NULL>,
44the default method is used.
45 47
46=head1 THE DSA_METHOD STRUCTURE 48=head1 THE DSA_METHOD STRUCTURE
47 49
@@ -62,12 +64,13 @@ struct
62 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len, 64 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
63 DSA_SIG *sig, DSA *dsa); 65 DSA_SIG *sig, DSA *dsa);
64 66
65 /* compute rr = a1^p1 * a2^p2 mod m. May be NULL */ 67 /* compute rr = a1^p1 * a2^p2 mod m (May be NULL for some
68 implementations) */
66 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, 69 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
67 BIGNUM *a2, BIGNUM *p2, BIGNUM *m, 70 BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
68 BN_CTX *ctx, BN_MONT_CTX *in_mont); 71 BN_CTX *ctx, BN_MONT_CTX *in_mont);
69 72
70 /* compute r = a ^ p mod m. May be NULL */ 73 /* compute r = a ^ p mod m (May be NULL for some implementations) */
71 int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a, 74 int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a,
72 const BIGNUM *p, const BIGNUM *m, 75 const BIGNUM *p, const BIGNUM *m,
73 BN_CTX *ctx, BN_MONT_CTX *m_ctx); 76 BN_CTX *ctx, BN_MONT_CTX *m_ctx);
@@ -86,18 +89,17 @@ struct
86 89
87=head1 RETURN VALUES 90=head1 RETURN VALUES
88 91
89DSA_OpenSSL(), DSA_get_default_method() and DSA_get_method() return 92DSA_OpenSSL() and DSA_get_default_openssl_method() return pointers to the
90pointers to the respective B<DSA_METHOD>s. 93respective B<DSA_METHOD>s.
91 94
92DSA_set_default_method() returns no value. 95DSA_set_default_openssl_method() returns no value.
93 96
94DSA_set_method() returns a pointer to the B<DSA_METHOD> previously 97DSA_set_method() returns non-zero if the ENGINE associated with B<dsa>
95associated with B<dsa>. 98was successfully changed to B<engine>.
96 99
97DSA_new_method() returns B<NULL> and sets an error code that can be 100DSA_new_method() returns NULL and sets an error code that can be
98obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation 101obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation
99fails. Otherwise it returns a pointer to the newly allocated 102fails. Otherwise it returns a pointer to the newly allocated structure.
100structure.
101 103
102=head1 SEE ALSO 104=head1 SEE ALSO
103 105
@@ -108,4 +110,9 @@ L<dsa(3)|dsa(3)>, L<DSA_new(3)|DSA_new(3)>
108DSA_set_default_method(), DSA_get_default_method(), DSA_set_method(), 110DSA_set_default_method(), DSA_get_default_method(), DSA_set_method(),
109DSA_new_method() and DSA_OpenSSL() were added in OpenSSL 0.9.4. 111DSA_new_method() and DSA_OpenSSL() were added in OpenSSL 0.9.4.
110 112
113DSA_set_default_openssl_method() and DSA_get_default_openssl_method()
114replaced DSA_set_default_method() and DSA_get_default_method() respectively,
115and DSA_set_method() and DSA_new_method() were altered to use B<ENGINE>s
116rather than B<DSA_METHOD>s during development of OpenSSL 0.9.6.
117
111=cut 118=cut
diff --git a/src/lib/libcrypto/doc/ERR_error_string.pod b/src/lib/libcrypto/doc/ERR_error_string.pod
index 0d2417599c..e01beb817a 100644
--- a/src/lib/libcrypto/doc/ERR_error_string.pod
+++ b/src/lib/libcrypto/doc/ERR_error_string.pod
@@ -2,13 +2,16 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5ERR_error_string - obtain human-readable error message 5ERR_error_string, ERR_error_string_n, ERR_lib_error_string,
6ERR_func_error_string, ERR_reason_error_string - obtain human-readable
7error message
6 8
7=head1 SYNOPSIS 9=head1 SYNOPSIS
8 10
9 #include <openssl/err.h> 11 #include <openssl/err.h>
10 12
11 char *ERR_error_string(unsigned long e, char *buf); 13 char *ERR_error_string(unsigned long e, char *buf);
14 char *ERR_error_string_n(unsigned long e, char *buf, size_t len);
12 15
13 const char *ERR_lib_error_string(unsigned long e); 16 const char *ERR_lib_error_string(unsigned long e);
14 const char *ERR_func_error_string(unsigned long e); 17 const char *ERR_func_error_string(unsigned long e);
@@ -17,9 +20,13 @@ ERR_error_string - obtain human-readable error message
17=head1 DESCRIPTION 20=head1 DESCRIPTION
18 21
19ERR_error_string() generates a human-readable string representing the 22ERR_error_string() generates a human-readable string representing the
20error code B<e>, and places it at B<buf>. B<buf> must be at least 120 23error code I<e>, and places it at I<buf>. I<buf> must be at least 120
21bytes long. If B<buf> is B<NULL>, the error string is placed in a 24bytes long. If I<buf> is B<NULL>, the error string is placed in a
22static buffer. 25static buffer.
26ERR_error_string_n() is a variant of ERR_error_string() that writes
27at most I<len> characters (including the terminating 0)
28and truncates the string if necessary.
29For ERR_error_string_n(), I<buf> may not be B<NULL>.
23 30
24The string will have the following format: 31The string will have the following format:
25 32
@@ -45,7 +52,7 @@ all error codes currently in the queue.
45=head1 RETURN VALUES 52=head1 RETURN VALUES
46 53
47ERR_error_string() returns a pointer to a static buffer containing the 54ERR_error_string() returns a pointer to a static buffer containing the
48string if B<buf == NULL>, B<buf> otherwise. 55string if I<buf> B<== NULL>, I<buf> otherwise.
49 56
50ERR_lib_error_string(), ERR_func_error_string() and 57ERR_lib_error_string(), ERR_func_error_string() and
51ERR_reason_error_string() return the strings, and B<NULL> if 58ERR_reason_error_string() return the strings, and B<NULL> if
@@ -61,5 +68,6 @@ L<ERR_print_errors(3)|ERR_print_errors(3)>
61=head1 HISTORY 68=head1 HISTORY
62 69
63ERR_error_string() is available in all versions of SSLeay and OpenSSL. 70ERR_error_string() is available in all versions of SSLeay and OpenSSL.
71ERR_error_string_n() was added in OpenSSL 0.9.6.
64 72
65=cut 73=cut
diff --git a/src/lib/libcrypto/doc/ERR_get_error.pod b/src/lib/libcrypto/doc/ERR_get_error.pod
index 75ece00d97..9fdedbcb91 100644
--- a/src/lib/libcrypto/doc/ERR_get_error.pod
+++ b/src/lib/libcrypto/doc/ERR_get_error.pod
@@ -2,7 +2,10 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5ERR_get_error, ERR_peek_error - obtain error code 5ERR_get_error, ERR_peek_error, ERR_peek_last_error,
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
6 9
7=head1 SYNOPSIS 10=head1 SYNOPSIS
8 11
@@ -10,22 +13,29 @@ ERR_get_error, ERR_peek_error - obtain error code
10 13
11 unsigned long ERR_get_error(void); 14 unsigned long ERR_get_error(void);
12 unsigned long ERR_peek_error(void); 15 unsigned long ERR_peek_error(void);
16 unsigned long ERR_peek_last_error(void);
13 17
14 unsigned long ERR_get_error_line(const char **file, int *line); 18 unsigned long ERR_get_error_line(const char **file, int *line);
15 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);
16 21
17 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,
18 const char **data, int *flags); 23 const char **data, int *flags);
19 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,
20 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);
21 28
22=head1 DESCRIPTION 29=head1 DESCRIPTION
23 30
24ERR_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
25queue and removes the entry. This function can be called repeatedly 32queue and removes the entry. This function can be called repeatedly
26until there are no more error codes to return. 33until there are no more error codes to return.
27 34
28ERR_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
29error queue without modifying it. 39error queue without modifying it.
30 40
31See 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
@@ -33,14 +43,16 @@ location and reason of the error, and
33L<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
34messages. 44messages.
35 45
36ERR_get_error_line() and ERR_peek_error_line() are the same as the 46ERR_get_error_line(), ERR_peek_error_line() and
37above, 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
38the 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>.
39 50
40ERR_get_error_line_data() and ERR_peek_error_line_data() store 51ERR_get_error_line_data(), ERR_peek_error_line_data() and
41additional 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>
42and *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
43if *B<flags>&B<ERR_TXT_STRING>. If it has been allocated by Malloc(), 55if *B<flags>&B<ERR_TXT_STRING>. If it has been allocated by OPENSSL_malloc(),
44*B<flags>&B<ERR_TXT_MALLOCED> is true. 56*B<flags>&B<ERR_TXT_MALLOCED> is true.
45 57
46=head1 RETURN VALUES 58=head1 RETURN VALUES
@@ -58,5 +70,7 @@ ERR_get_error(), ERR_peek_error(), ERR_get_error_line() and
58ERR_peek_error_line() are available in all versions of SSLeay and 70ERR_peek_error_line() are available in all versions of SSLeay and
59OpenSSL. ERR_get_error_line_data() and ERR_peek_error_line_data() 71OpenSSL. ERR_get_error_line_data() and ERR_peek_error_line_data()
60were 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.
61 75
62=cut 76=cut
diff --git a/src/lib/libcrypto/doc/ERR_remove_state.pod b/src/lib/libcrypto/doc/ERR_remove_state.pod
index ebcdc0f5a5..72925fb9f4 100644
--- a/src/lib/libcrypto/doc/ERR_remove_state.pod
+++ b/src/lib/libcrypto/doc/ERR_remove_state.pod
@@ -16,7 +16,7 @@ ERR_remove_state() frees the error queue associated with thread B<pid>.
16If B<pid> == 0, the current thread will have its error queue removed. 16If B<pid> == 0, the current thread will have its error queue removed.
17 17
18Since error queue data structures are allocated automatically for new 18Since error queue data structures are allocated automatically for new
19threads, they must be freed when threads are terminated in oder to 19threads, they must be freed when threads are terminated in order to
20avoid memory leaks. 20avoid memory leaks.
21 21
22=head1 RETURN VALUE 22=head1 RETURN VALUE
diff --git a/src/lib/libcrypto/doc/EVP_DigestInit.pod b/src/lib/libcrypto/doc/EVP_DigestInit.pod
index 345b1ddfa7..b3a61f1c5d 100644
--- a/src/lib/libcrypto/doc/EVP_DigestInit.pod
+++ b/src/lib/libcrypto/doc/EVP_DigestInit.pod
@@ -2,21 +2,40 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5EVP_DigestInit, EVP_DigestUpdate, EVP_DigestFinal - EVP digest routines 5EVP_MD_CTX_init, EVP_MD_CTX_create, EVP_DigestInit_ex, EVP_DigestUpdate,
6EVP_DigestFinal_ex, EVP_MD_CTX_cleanup, EVP_MD_CTX_destroy, EVP_MAX_MD_SIZE,
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,
9EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_dss, EVP_dss1, EVP_mdc2,
10EVP_ripemd160, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj -
11EVP digest routines
6 12
7=head1 SYNOPSIS 13=head1 SYNOPSIS
8 14
9 #include <openssl/evp.h> 15 #include <openssl/evp.h>
10 16
11 void EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); 17 void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
12 void EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); 18 EVP_MD_CTX *EVP_MD_CTX_create(void);
13 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,
14 unsigned int *s); 23 unsigned int *s);
15 24
16 #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);
17 33
18 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);
19 35
36 #define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */
37
38
20 #define EVP_MD_type(e) ((e)->type) 39 #define EVP_MD_type(e) ((e)->type)
21 #define EVP_MD_pkey_type(e) ((e)->pkey_type) 40 #define EVP_MD_pkey_type(e) ((e)->pkey_type)
22 #define EVP_MD_size(e) ((e)->md_size) 41 #define EVP_MD_size(e) ((e)->md_size)
@@ -27,15 +46,15 @@ EVP_DigestInit, EVP_DigestUpdate, EVP_DigestFinal - EVP digest routines
27 #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)
28 #define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest) 47 #define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest)
29 48
30 EVP_MD *EVP_md_null(void); 49 const EVP_MD *EVP_md_null(void);
31 EVP_MD *EVP_md2(void); 50 const EVP_MD *EVP_md2(void);
32 EVP_MD *EVP_md5(void); 51 const EVP_MD *EVP_md5(void);
33 EVP_MD *EVP_sha(void); 52 const EVP_MD *EVP_sha(void);
34 EVP_MD *EVP_sha1(void); 53 const EVP_MD *EVP_sha1(void);
35 EVP_MD *EVP_dss(void); 54 const EVP_MD *EVP_dss(void);
36 EVP_MD *EVP_dss1(void); 55 const EVP_MD *EVP_dss1(void);
37 EVP_MD *EVP_mdc2(void); 56 const EVP_MD *EVP_mdc2(void);
38 EVP_MD *EVP_ripemd160(void); 57 const EVP_MD *EVP_ripemd160(void);
39 58
40 const EVP_MD *EVP_get_digestbyname(const char *name); 59 const EVP_MD *EVP_get_digestbyname(const char *name);
41 #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) 60 #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
@@ -45,25 +64,48 @@ EVP_DigestInit, EVP_DigestUpdate, EVP_DigestFinal - EVP digest routines
45 64
46The EVP digest routines are a high level interface to message digests. 65The EVP digest routines are a high level interface to message digests.
47 66
48EVP_DigestInit() initialises a digest context B<ctx> to use a digest 67EVP_MD_CTX_init() initializes digest contet B<ctx>.
49B<type>: this will typically be supplied by a function such as 68
50EVP_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.
51 75
52EVP_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
53digest context B<ctx>. This funtion can be called several times on the 77digest context B<ctx>. This function can be called several times on the
54same B<ctx> to hash additional data. 78same B<ctx> to hash additional data.
55 79
56EVP_DigestFinal() retrieves the digest value from B<ctx> and places 80EVP_DigestFinal_ex() retrieves the digest value from B<ctx> and places
57it 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
58bytes 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
59to 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.
60After calling EVP_DigestFinal() no additional calls to EVP_DigestUpdate() 84After calling EVP_DigestFinal_ex() no additional calls to EVP_DigestUpdate()
61can be made, but EVP_DigestInit() can be called to initialiase a new 85can be made, but EVP_DigestInit_ex() can be called to initialize a new
62digest operation. 86digest operation.
63 87
64EVP_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
65B<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
66hashed 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.
67 109
68EVP_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
69when 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
@@ -97,14 +139,15 @@ returns is of zero length.
97 139
98EVP_get_digestbyname(), EVP_get_digestbynid() and EVP_get_digestbyobj() 140EVP_get_digestbyname(), EVP_get_digestbynid() and EVP_get_digestbyobj()
99return an B<EVP_MD> structure when passed a digest name, a digest NID or 141return an B<EVP_MD> structure when passed a digest name, a digest NID or
100an ASN1_OBJECT structure respectively. The digest table must be initialised 142an ASN1_OBJECT structure respectively. The digest table must be initialized
101using, for example, OpenSSL_add_all_digests() for these functions to work. 143using, for example, OpenSSL_add_all_digests() for these functions to work.
102 144
103=head1 RETURN VALUES 145=head1 RETURN VALUES
104 146
105EVP_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.
106 149
107EVP_MD_CTX_copy() returns 1 if successful or 0 for failure. 150EVP_MD_CTX_copy_ex() returns 1 if successful or 0 for failure.
108 151
109EVP_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
110corresponding OBJECT IDENTIFIER or NID_undef if none exists. 153corresponding OBJECT IDENTIFIER or NID_undef if none exists.
@@ -129,6 +172,19 @@ transparent to the digest used and much more flexible.
129SHA1 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
130are still in common use. 173are still in common use.
131 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
132=head1 EXAMPLE 188=head1 EXAMPLE
133 189
134This 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
@@ -160,10 +216,12 @@ digest name passed on the command line.
160 exit(1); 216 exit(1);
161 } 217 }
162 218
163 EVP_DigestInit(&mdctx, md); 219 EVP_MD_CTX_init(&mdctx);
220 EVP_DigestInit_ex(&mdctx, md, NULL);
164 EVP_DigestUpdate(&mdctx, mess1, strlen(mess1)); 221 EVP_DigestUpdate(&mdctx, mess1, strlen(mess1));
165 EVP_DigestUpdate(&mdctx, mess2, strlen(mess2)); 222 EVP_DigestUpdate(&mdctx, mess2, strlen(mess2));
166 EVP_DigestFinal(&mdctx, md_value, &md_len); 223 EVP_DigestFinal_ex(&mdctx, md_value, &md_len);
224 EVP_MD_CTX_cleanup(&mdctx);
167 225
168 printf("Digest is: "); 226 printf("Digest is: ");
169 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]);
@@ -172,17 +230,10 @@ digest name passed on the command line.
172 230
173=head1 BUGS 231=head1 BUGS
174 232
175Several of the functions do not return values: maybe they should. Although the
176internal digest operations will never fail some future hardware based operations
177might.
178
179The link between digests and signing algorithms results in a situation where 233The link between digests and signing algorithms results in a situation where
180EVP_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
181even though they are identical digests. 235even though they are identical digests.
182 236
183The size of an B<EVP_MD_CTX> structure is determined at compile time: this results
184in code that must be recompiled if the size of B<EVP_MD_CTX> increases.
185
186=head1 SEE ALSO 237=head1 SEE ALSO
187 238
188L<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)>,
@@ -194,4 +245,7 @@ L<sha(3)|sha(3)>, L<digest(1)|digest(1)>
194EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() are 245EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() are
195available in all versions of SSLeay and OpenSSL. 246available in all versions of SSLeay and OpenSSL.
196 247
248EVP_DigestInit_ex(), EVP_DigestFinal_ex() and EVP_MD_CTX_copy_ex()
249were added in OpenSSL 0.9.7.
250
197=cut 251=cut
diff --git a/src/lib/libcrypto/doc/EVP_EncryptInit.pod b/src/lib/libcrypto/doc/EVP_EncryptInit.pod
index 77ed4ccdba..371b6a2287 100644
--- a/src/lib/libcrypto/doc/EVP_EncryptInit.pod
+++ b/src/lib/libcrypto/doc/EVP_EncryptInit.pod
@@ -2,34 +2,68 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5EVP_EncryptInit, EVP_EncryptUpdate, EVP_EncryptFinal - EVP cipher routines 5EVP_CIPHER_CTX_init, EVP_EncryptInit_ex, EVP_EncryptUpdate,
6EVP_EncryptFinal_ex, EVP_DecryptInit_ex, EVP_DecryptUpdate,
7EVP_DecryptFinal_ex, EVP_CipherInit_ex, EVP_CipherUpdate,
8EVP_CipherFinal_ex, EVP_CIPHER_CTX_set_key_length,
9EVP_CIPHER_CTX_ctrl, EVP_CIPHER_CTX_cleanup, EVP_EncryptInit,
10EVP_EncryptFinal, EVP_DecryptInit, EVP_DecryptFinal,
11EVP_CipherInit, EVP_CipherFinal, EVP_get_cipherbyname,
12EVP_get_cipherbynid, EVP_get_cipherbyobj, EVP_CIPHER_nid,
13EVP_CIPHER_block_size, EVP_CIPHER_key_length, EVP_CIPHER_iv_length,
14EVP_CIPHER_flags, EVP_CIPHER_mode, EVP_CIPHER_type, EVP_CIPHER_CTX_cipher,
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
6 20
7=head1 SYNOPSIS 21=head1 SYNOPSIS
8 22
9 #include <openssl/evp.h> 23 #include <openssl/evp.h>
10 24
11 void EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, 25 int EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
12 unsigned char *key, unsigned char *iv); 26
13 void EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, 27 int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
28 ENGINE *impl, unsigned char *key, unsigned char *iv);
29 int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
14 int *outl, unsigned char *in, int inl); 30 int *outl, unsigned char *in, int inl);
15 void EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, 31 int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out,
16 int *outl); 32 int *outl);
17 33
18 void EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, 34 int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
19 unsigned char *key, unsigned char *iv); 35 ENGINE *impl, unsigned char *key, unsigned char *iv);
20 void EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, 36 int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
21 int *outl, unsigned char *in, int inl); 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);
50 int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,
51 int *outl);
52
53 int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
54 unsigned char *key, unsigned char *iv);
22 int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, 55 int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
23 int *outl); 56 int *outl);
24 57
25 void EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, 58 int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
26 unsigned char *key, unsigned char *iv, int enc); 59 unsigned char *key, unsigned char *iv, int enc);
27 void EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
28 int *outl, unsigned char *in, int inl);
29 int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, 60 int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
30 int *outl); 61 int *outl);
31 62
32 void EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a); 63 int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *x, int padding);
64 int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
65 int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
66 int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
33 67
34 const EVP_CIPHER *EVP_get_cipherbyname(const char *name); 68 const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
35 #define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a)) 69 #define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
@@ -38,15 +72,21 @@ EVP_EncryptInit, EVP_EncryptUpdate, EVP_EncryptFinal - EVP cipher routines
38 #define EVP_CIPHER_nid(e) ((e)->nid) 72 #define EVP_CIPHER_nid(e) ((e)->nid)
39 #define EVP_CIPHER_block_size(e) ((e)->block_size) 73 #define EVP_CIPHER_block_size(e) ((e)->block_size)
40 #define EVP_CIPHER_key_length(e) ((e)->key_len) 74 #define EVP_CIPHER_key_length(e) ((e)->key_len)
41 #define EVP_CIPHER_iv_length(e) ((e)->iv_len) 75 #define EVP_CIPHER_iv_length(e) ((e)->iv_len)
42 76 #define EVP_CIPHER_flags(e) ((e)->flags)
77 #define EVP_CIPHER_mode(e) ((e)->flags) & EVP_CIPH_MODE)
43 int EVP_CIPHER_type(const EVP_CIPHER *ctx); 78 int EVP_CIPHER_type(const EVP_CIPHER *ctx);
79
44 #define EVP_CIPHER_CTX_cipher(e) ((e)->cipher) 80 #define EVP_CIPHER_CTX_cipher(e) ((e)->cipher)
45 #define EVP_CIPHER_CTX_nid(e) ((e)->cipher->nid) 81 #define EVP_CIPHER_CTX_nid(e) ((e)->cipher->nid)
46 #define EVP_CIPHER_CTX_block_size(e) ((e)->cipher->block_size) 82 #define EVP_CIPHER_CTX_block_size(e) ((e)->cipher->block_size)
47 #define EVP_CIPHER_CTX_key_length(e) ((e)->cipher->key_len) 83 #define EVP_CIPHER_CTX_key_length(e) ((e)->key_len)
48 #define EVP_CIPHER_CTX_iv_length(e) ((e)->cipher->iv_len) 84 #define EVP_CIPHER_CTX_iv_length(e) ((e)->cipher->iv_len)
85 #define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data)
86 #define EVP_CIPHER_CTX_set_app_data(e,d) ((e)->app_data=(char *)(d))
49 #define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c)) 87 #define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
88 #define EVP_CIPHER_CTX_flags(e) ((e)->cipher->flags)
89 #define EVP_CIPHER_CTX_mode(e) ((e)->cipher->flags & EVP_CIPH_MODE)
50 90
51 int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type); 91 int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
52 int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type); 92 int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
@@ -56,16 +96,19 @@ EVP_EncryptInit, EVP_EncryptUpdate, EVP_EncryptFinal - EVP cipher routines
56The EVP cipher routines are a high level interface to certain 96The EVP cipher routines are a high level interface to certain
57symmetric ciphers. 97symmetric ciphers.
58 98
59EVP_EncryptInit() initialises a cipher context B<ctx> for encryption 99EVP_CIPHER_CTX_init() initializes cipher contex B<ctx>.
60with cipher B<type>. B<type> is normally supplied by a function such 100
61as 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
62IV 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
63key and IV depends on the cipher. It is possible to set all parameters 103before calling this function. B<type> is normally supplied
64to 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
65parameters in subsequent calls. This is normally done when the 105default implementation is used. B<key> is the symmetric key to use
66EVP_CIPHER_asn1_to_param() function is called to set the cipher 106and B<iv> is the IV to use (if necessary), the actual number of bytes
67parameters from an ASN1 AlgorithmIdentifier and the key from a 107used for the key and IV depends on the cipher. It is possible to set
68different source. 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.
69 112
70EVP_EncryptUpdate() encrypts B<inl> bytes from the buffer B<in> and 113EVP_EncryptUpdate() encrypts B<inl> bytes from the buffer B<in> and
71writes the encrypted version to B<out>. This function can be called 114writes the encrypted version to B<out>. This function can be called
@@ -73,31 +116,49 @@ multiple times to encrypt successive blocks of data. The amount
73of data written depends on the block alignment of the encrypted data: 116of data written depends on the block alignment of the encrypted data:
74as 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
75to (inl + cipher_block_size - 1) so B<outl> should contain sufficient 118to (inl + cipher_block_size - 1) so B<outl> should contain sufficient
76room. The actual number of bytes written is placed in B<outl>. 119room. The actual number of bytes written is placed in B<outl>.
77 120
78EVP_EncryptFinal() encrypts the "final" data, that is any data that 121If padding is enabled (the default) then EVP_EncryptFinal_ex() encrypts
79remains in a partial block. It uses L<standard block padding|/NOTES> (aka PKCS 122the "final" data, that is any data that remains in a partial block.
80padding). The encrypted final data is written to B<out> which should 123It uses L<standard block padding|/NOTES> (aka PKCS padding). The encrypted
81have sufficient space for one cipher block. The number of bytes written 124final data is written to B<out> which should have sufficient space for
82is placed in B<outl>. After this function is called the encryption operation 125one cipher block. The number of bytes written is placed in B<outl>. After
83is finished and no further calls to EVP_EncryptUpdate() should be made. 126this function is called the encryption operation is finished and no further
84 127calls to EVP_EncryptUpdate() should be made.
85EVP_DecryptInit(), EVP_DecryptUpdate() and EVP_DecryptFinal() are the
86corresponding decryption operations. EVP_DecryptFinal() will return an
87error code if the final block is not correctly formatted. The parameters
88and restrictions are identical to the encryption operations except that
89the decrypted data buffer B<out> passed to EVP_DecryptUpdate() should
90have sufficient room for (B<inl> + cipher_block_size) bytes unless the
91cipher block size is 1 in which case B<inl> bytes is sufficient.
92 128
93EVP_CipherInit(), EVP_CipherUpdate() and EVP_CipherFinal() are functions 129If padding is disabled then EVP_EncryptFinal_ex() will not encrypt any more
94that can be used for decryption or encryption. The operation performed 130data and it will return an error if any data remains in a partial block:
95depends on the value of the B<enc> parameter. It should be set to 1 for 131that is if the total data length is not a multiple of the block size.
96encryption and 0 for decryption.
97 132
98EVP_CIPHER_CTX_cleanup() clears all information from a cipher context. 133EVP_DecryptInit_ex(), EVP_DecryptUpdate() and EVP_DecryptFinal_ex() are the
99It should be called after all operations using a cipher are complete 134corresponding decryption operations. EVP_DecryptFinal() will return an
100so sensitive information does not remain in memory. 135error code if padding is enabled and the final block is not correctly
136formatted. The parameters and restrictions are identical to the encryption
137operations except that if padding is enabled the decrypted data buffer B<out>
138passed to EVP_DecryptUpdate() should have sufficient room for
139(B<inl> + cipher_block_size) bytes unless the cipher block size is 1 in
140which case B<inl> bytes is sufficient.
141
142EVP_CipherInit_ex(), EVP_CipherUpdate() and EVP_CipherFinal_ex() are
143functions that can be used for decryption or encryption. The operation
144performed depends on the value of the B<enc> parameter. It should be set
145to 1 for encryption, 0 for decryption and -1 to leave the value unchanged
146(the actual value of 'enc' being supplied in a previous call).
147
148EVP_CIPHER_CTX_cleanup() clears all information from a cipher context
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.
101 162
102EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj() 163EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj()
103return 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
@@ -108,10 +169,23 @@ passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX> structure. The actual NID
108value is an internal value which may not have a corresponding OBJECT 169value is an internal value which may not have a corresponding OBJECT
109IDENTIFIER. 170IDENTIFIER.
110 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
111EVP_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
112length 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>
113structure. 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
114for all ciphers. 182for all ciphers. Note: although EVP_CIPHER_key_length() is fixed for a
183given cipher, the value of EVP_CIPHER_CTX_key_length() may be different
184for variable key length ciphers.
185
186EVP_CIPHER_CTX_set_key_length() sets the key length of the cipher ctx.
187If the cipher is a fixed length cipher then attempting to set the key
188length to any value other than the fixed value is an error.
115 189
116EVP_CIPHER_iv_length() and EVP_CIPHER_CTX_iv_length() return the IV 190EVP_CIPHER_iv_length() and EVP_CIPHER_CTX_iv_length() return the IV
117length of a cipher when passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX>. 191length of a cipher when passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX>.
@@ -133,6 +207,11 @@ B<NID_undef>.
133EVP_CIPHER_CTX_cipher() returns the B<EVP_CIPHER> structure when passed 207EVP_CIPHER_CTX_cipher() returns the B<EVP_CIPHER> structure when passed
134an B<EVP_CIPHER_CTX> structure. 208an B<EVP_CIPHER_CTX> structure.
135 209
210EVP_CIPHER_mode() and EVP_CIPHER_CTX_mode() return the block cipher mode:
211EVP_CIPH_ECB_MODE, EVP_CIPH_CBC_MODE, EVP_CIPH_CFB_MODE or
212EVP_CIPH_OFB_MODE. If the cipher is a stream cipher then
213EVP_CIPH_STREAM_CIPHER is returned.
214
136EVP_CIPHER_param_to_asn1() sets the AlgorithmIdentifier "parameter" based 215EVP_CIPHER_param_to_asn1() sets the AlgorithmIdentifier "parameter" based
137on the passed cipher. This will typically include any parameters and an 216on the passed cipher. This will typically include any parameters and an
138IV. The cipher IV (if any) must be set when this call is made. This call 217IV. The cipher IV (if any) must be set when this call is made. This call
@@ -149,21 +228,24 @@ key set to NULL, EVP_CIPHER_asn1_to_param() will be called and finally
149EVP_CipherInit() again with all parameters except the key set to NULL. It is 228EVP_CipherInit() again with all parameters except the key set to NULL. It is
150possible for this function to fail if the cipher does not have any ASN1 support 229possible for this function to fail if the cipher does not have any ASN1 support
151or the parameters cannot be set (for example the RC2 effective key length 230or the parameters cannot be set (for example the RC2 effective key length
152does not have an B<EVP_CIPHER> structure). 231is not supported.
232
233EVP_CIPHER_CTX_ctrl() allows various cipher specific parameters to be determined
234and set. Currently only the RC2 effective key length and the number of rounds of
235RC5 can be set.
153 236
154=head1 RETURN VALUES 237=head1 RETURN VALUES
155 238
156EVP_EncryptInit(), EVP_EncryptUpdate() and EVP_EncryptFinal() do not return 239EVP_CIPHER_CTX_init, EVP_EncryptInit_ex(), EVP_EncryptUpdate() and
157values. 240EVP_EncryptFinal_ex() return 1 for success and 0 for failure.
158 241
159EVP_DecryptInit() and EVP_DecryptUpdate() do not return values. 242EVP_DecryptInit_ex() and EVP_DecryptUpdate() return 1 for success and 0 for failure.
160EVP_DecryptFinal() returns 0 if the decrypt failed or 1 for success. 243EVP_DecryptFinal_ex() returns 0 if the decrypt failed or 1 for success.
161 244
162EVP_CipherInit() and EVP_CipherUpdate() do not return values. 245EVP_CipherInit_ex() and EVP_CipherUpdate() return 1 for success and 0 for failure.
163EVP_CipherFinal() returns 1 for a decryption failure or 1 for success, if 246EVP_CipherFinal_ex() returns 0 for a decryption failure or 1 for success.
164the operation is encryption then it always returns 1.
165 247
166EVP_CIPHER_CTX_cleanup() does not return a value. 248EVP_CIPHER_CTX_cleanup() returns 1 for success and 0 for failure.
167 249
168EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj() 250EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj()
169return an B<EVP_CIPHER> structure or NULL on error. 251return an B<EVP_CIPHER> structure or NULL on error.
@@ -176,6 +258,8 @@ size.
176EVP_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
177length. 259length.
178 260
261EVP_CIPHER_CTX_set_padding() always returns 1.
262
179EVP_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
180length or zero if the cipher does not use an IV. 264length or zero if the cipher does not use an IV.
181 265
@@ -187,6 +271,75 @@ EVP_CIPHER_CTX_cipher() returns an B<EVP_CIPHER> structure.
187EVP_CIPHER_param_to_asn1() and EVP_CIPHER_asn1_to_param() return 1 for 271EVP_CIPHER_param_to_asn1() and EVP_CIPHER_asn1_to_param() return 1 for
188success or zero for failure. 272success or zero for failure.
189 273
274=head1 CIPHER LISTING
275
276All algorithms have a fixed key length unless otherwise stated.
277
278=over 4
279
280=item EVP_enc_null()
281
282Null cipher: does nothing.
283
284=item EVP_des_cbc(void), EVP_des_ecb(void), EVP_des_cfb(void), EVP_des_ofb(void)
285
286DES in CBC, ECB, CFB and OFB modes respectively.
287
288=item EVP_des_ede_cbc(void), EVP_des_ede(), EVP_des_ede_ofb(void), EVP_des_ede_cfb(void)
289
290Two key triple DES in CBC, ECB, CFB and OFB modes respectively.
291
292=item EVP_des_ede3_cbc(void), EVP_des_ede3(), EVP_des_ede3_ofb(void), EVP_des_ede3_cfb(void)
293
294Three key triple DES in CBC, ECB, CFB and OFB modes respectively.
295
296=item EVP_desx_cbc(void)
297
298DESX algorithm in CBC mode.
299
300=item EVP_rc4(void)
301
302RC4 stream cipher. This is a variable key length cipher with default key length 128 bits.
303
304=item EVP_rc4_40(void)
305
306RC4 stream cipher with 40 bit key length. This is obsolete and new code should use EVP_rc4()
307and the EVP_CIPHER_CTX_set_key_length() function.
308
309=item EVP_idea_cbc() EVP_idea_ecb(void), EVP_idea_cfb(void), EVP_idea_ofb(void), EVP_idea_cbc(void)
310
311IDEA encryption algorithm in CBC, ECB, CFB and OFB modes respectively.
312
313=item EVP_rc2_cbc(void), EVP_rc2_ecb(void), EVP_rc2_cfb(void), EVP_rc2_ofb(void)
314
315RC2 encryption algorithm in CBC, ECB, CFB and OFB modes respectively. This is a variable key
316length cipher with an additional parameter called "effective key bits" or "effective key length".
317By default both are set to 128 bits.
318
319=item EVP_rc2_40_cbc(void), EVP_rc2_64_cbc(void)
320
321RC2 algorithm in CBC mode with a default key length and effective key length of 40 and 64 bits.
322These are obsolete and new code should use EVP_rc2_cbc(), EVP_CIPHER_CTX_set_key_length() and
323EVP_CIPHER_CTX_ctrl() to set the key length and effective key length.
324
325=item EVP_bf_cbc(void), EVP_bf_ecb(void), EVP_bf_cfb(void), EVP_bf_ofb(void);
326
327Blowfish encryption algorithm in CBC, ECB, CFB and OFB modes respectively. This is a variable key
328length cipher.
329
330=item EVP_cast5_cbc(void), EVP_cast5_ecb(void), EVP_cast5_cfb(void), EVP_cast5_ofb(void)
331
332CAST encryption algorithm in CBC, ECB, CFB and OFB modes respectively. This is a variable key
333length cipher.
334
335=item EVP_rc5_32_12_16_cbc(void), EVP_rc5_32_12_16_ecb(void), EVP_rc5_32_12_16_cfb(void), EVP_rc5_32_12_16_ofb(void)
336
337RC5 encryption algorithm in CBC, ECB, CFB and OFB modes respectively. This is a variable key length
338cipher with an additional "number of rounds" parameter. By default the key length is set to 128
339bits and 12 rounds.
340
341=back
342
190=head1 NOTES 343=head1 NOTES
191 344
192Where possible the B<EVP> interface to symmetric ciphers should be used in 345Where possible the B<EVP> interface to symmetric ciphers should be used in
@@ -201,19 +354,146 @@ encrypted then 5 padding bytes of value 5 will be added.
201 354
202When 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.
203 356
204Although the decryption operation can produce an error, it is not a strong 357Although the decryption operation can produce an error if padding is enabled,
205test 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
2061 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
207input data earlier on will not produce a final decrypt error. 360the input data earlier on will not produce a final decrypt error.
361
362If padding is disabled then the decryption operation will always succeed if
363the total amount of data decrypted is a multiple of the block size.
364
365The functions EVP_EncryptInit(), EVP_EncryptFinal(), EVP_DecryptInit(),
366EVP_CipherInit() and EVP_CipherFinal() are obsolete but are retained for
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.
208 371
209=head1 BUGS 372=head1 BUGS
210 373
211The current B<EVP> cipher interface is not as flexible as it should be. Only 374For RC5 the number of rounds can currently only be set to 8, 12 or 16. This is
212certain "spot" encryption algorithms can be used for ciphers which have various 375a limitation of the current RC5 code rather than the EVP interface.
213parameters associated with them (RC2, RC5 for example) this is inadequate. 376
377EVP_MAX_KEY_LENGTH and EVP_MAX_IV_LENGTH only refer to the internal ciphers with
378default key lengths. If custom ciphers exceed these values the results are
379unpredictable. This is because it has become standard practice to define a
380generic key as a fixed unsigned char array containing EVP_MAX_KEY_LENGTH bytes.
381
382The ASN1 code is incomplete (and sometimes inaccurate) it has only been tested
383for certain common S/MIME ciphers (RC2, DES, triple DES) in CBC mode.
384
385=head1 EXAMPLES
386
387Get the number of rounds used in RC5:
388
389 int nrounds;
390 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC5_ROUNDS, 0, &nrounds);
391
392Get the RC2 effective key length:
393
394 int key_bits;
395 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC2_KEY_BITS, 0, &key_bits);
396
397Set the number of rounds used in RC5:
398
399 int nrounds;
400 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC5_ROUNDS, nrounds, NULL);
401
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 }
214 496
215Several of the functions do not return error codes because the software versions
216can never fail. This is not true of hardware versions.
217 497
218=head1 SEE ALSO 498=head1 SEE ALSO
219 499
diff --git a/src/lib/libcrypto/doc/EVP_OpenInit.pod b/src/lib/libcrypto/doc/EVP_OpenInit.pod
index 9707a4b399..2e710da945 100644
--- a/src/lib/libcrypto/doc/EVP_OpenInit.pod
+++ b/src/lib/libcrypto/doc/EVP_OpenInit.pod
@@ -10,9 +10,9 @@ EVP_OpenInit, EVP_OpenUpdate, EVP_OpenFinal - EVP envelope decryption
10 10
11 int EVP_OpenInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type,unsigned char *ek, 11 int EVP_OpenInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type,unsigned char *ek,
12 int ekl,unsigned char *iv,EVP_PKEY *priv); 12 int ekl,unsigned char *iv,EVP_PKEY *priv);
13 void EVP_OpenUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, 13 int EVP_OpenUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
14 int *outl, unsigned char *in, int inl); 14 int *outl, unsigned char *in, int inl);
15 void EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, 15 int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,
16 int *outl); 16 int *outl);
17 17
18=head1 DESCRIPTION 18=head1 DESCRIPTION
@@ -21,7 +21,7 @@ The EVP envelope routines are a high level interface to envelope
21decryption. They decrypt a public key encrypted symmetric key and 21decryption. They decrypt a public key encrypted symmetric key and
22then decrypt data using it. 22then decrypt data using it.
23 23
24EVP_OpenInit() initialises a cipher context B<ctx> for decryption 24EVP_OpenInit() initializes a cipher context B<ctx> for decryption
25with cipher B<type>. It decrypts the encrypted symmetric key of length 25with cipher B<type>. It decrypts the encrypted symmetric key of length
26B<ekl> bytes passed in the B<ek> parameter using the private key B<priv>. 26B<ekl> bytes passed in the B<ek> parameter using the private key B<priv>.
27The IV is supplied in the B<iv> parameter. 27The IV is supplied in the B<iv> parameter.
@@ -29,20 +29,32 @@ The IV is supplied in the B<iv> parameter.
29EVP_OpenUpdate() and EVP_OpenFinal() have exactly the same properties 29EVP_OpenUpdate() and EVP_OpenFinal() have exactly the same properties
30as the EVP_DecryptUpdate() and EVP_DecryptFinal() routines, as 30as the EVP_DecryptUpdate() and EVP_DecryptFinal() routines, as
31documented on the L<EVP_EncryptInit(3)|EVP_EncryptInit(3)> manual 31documented on the L<EVP_EncryptInit(3)|EVP_EncryptInit(3)> manual
32page. 32page.
33
34=head1 NOTES
35
36It is possible to call EVP_OpenInit() twice in the same way as
37EVP_DecryptInit(). The first call should have B<priv> set to NULL
38and (after setting any cipher parameters) it should be called again
39with B<type> set to NULL.
40
41If the cipher passed in the B<type> parameter is a variable length
42cipher then the key length will be set to the value of the recovered
43key length. If the cipher is a fixed length cipher then the recovered
44key length must match the fixed cipher length.
33 45
34=head1 RETURN VALUES 46=head1 RETURN VALUES
35 47
36EVP_OpenInit() returns -1 on error or an non zero integer (actually the 48EVP_OpenInit() returns 0 on error or a non zero integer (actually the
37recovered secret key size) if successful. 49recovered secret key size) if successful.
38 50
39EVP_SealUpdate() does not return a value. 51EVP_OpenUpdate() returns 1 for success or 0 for failure.
40 52
41EVP_SealFinal() returns 0 if the decrypt failed or 1 for success. 53EVP_OpenFinal() returns 0 if the decrypt failed or 1 for success.
42 54
43=head1 SEE ALSO 55=head1 SEE ALSO
44 56
45L<evp(3)|evp(3)>,L<rand(3)|rand(3)> 57L<evp(3)|evp(3)>, L<rand(3)|rand(3)>,
46L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>, 58L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>,
47L<EVP_SealInit(3)|EVP_SealInit(3)> 59L<EVP_SealInit(3)|EVP_SealInit(3)>
48 60
diff --git a/src/lib/libcrypto/doc/EVP_SealInit.pod b/src/lib/libcrypto/doc/EVP_SealInit.pod
index 1579d110fa..0451eb648a 100644
--- a/src/lib/libcrypto/doc/EVP_SealInit.pod
+++ b/src/lib/libcrypto/doc/EVP_SealInit.pod
@@ -10,9 +10,9 @@ EVP_SealInit, EVP_SealUpdate, EVP_SealFinal - EVP envelope encryption
10 10
11 int EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek, 11 int EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek,
12 int *ekl, unsigned char *iv,EVP_PKEY **pubk, int npubk); 12 int *ekl, unsigned char *iv,EVP_PKEY **pubk, int npubk);
13 void EVP_SealUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, 13 int EVP_SealUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
14 int *outl, unsigned char *in, int inl); 14 int *outl, unsigned char *in, int inl);
15 void EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, 15 int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,
16 int *outl); 16 int *outl);
17 17
18=head1 DESCRIPTION 18=head1 DESCRIPTION
@@ -22,7 +22,7 @@ encryption. They generate a random key and then "envelope" it by
22using public key encryption. Data can then be encrypted using this 22using public key encryption. Data can then be encrypted using this
23key. 23key.
24 24
25EVP_SealInit() initialises a cipher context B<ctx> for encryption 25EVP_SealInit() initializes a cipher context B<ctx> for encryption
26with cipher B<type> using a random secret key and IV supplied in 26with cipher B<type> using a random secret key and IV supplied in
27the B<iv> parameter. B<type> is normally supplied by a function such 27the B<iv> parameter. B<type> is normally supplied by a function such
28as EVP_des_cbc(). The secret key is encrypted using one or more public 28as EVP_des_cbc(). The secret key is encrypted using one or more public
@@ -41,9 +41,10 @@ page.
41 41
42=head1 RETURN VALUES 42=head1 RETURN VALUES
43 43
44EVP_SealInit() returns -1 on error or B<npubk> if successful. 44EVP_SealInit() returns 0 on error or B<npubk> if successful.
45 45
46EVP_SealUpdate() and EVP_SealFinal() do not return values. 46EVP_SealUpdate() and EVP_SealFinal() return 1 for success and 0 for
47failure.
47 48
48=head1 NOTES 49=head1 NOTES
49 50
@@ -59,9 +60,14 @@ but symmetric encryption is fast. So symmetric encryption is used for
59bulk encryption and the small random symmetric key used is transferred 60bulk encryption and the small random symmetric key used is transferred
60using public key encryption. 61using public key encryption.
61 62
63It is possible to call EVP_SealInit() twice in the same way as
64EVP_EncryptInit(). The first call should have B<npubk> set to 0
65and (after setting any cipher parameters) it should be called again
66with B<type> set to NULL.
67
62=head1 SEE ALSO 68=head1 SEE ALSO
63 69
64L<evp(3)|evp(3)>,L<rand(3)|rand(3)> 70L<evp(3)|evp(3)>, L<rand(3)|rand(3)>,
65L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>, 71L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>,
66L<EVP_OpenInit(3)|EVP_OpenInit(3)> 72L<EVP_OpenInit(3)|EVP_OpenInit(3)>
67 73
diff --git a/src/lib/libcrypto/doc/EVP_SignInit.pod b/src/lib/libcrypto/doc/EVP_SignInit.pod
index bbc9203c9c..32e9d54809 100644
--- a/src/lib/libcrypto/doc/EVP_SignInit.pod
+++ b/src/lib/libcrypto/doc/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,30 +21,30 @@ 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() initialises 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 funtion can be called several times on the 29signature context B<ctx>. This function can be called several times on the
28same B<ctx> to include additional data. 30same B<ctx> to include additional data.
29 31
30EVP_SignFinal() signs the data in B<ctx> using the private key B<pkey> 32EVP_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 initialiase 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<sha(3)|sha(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/libcrypto/doc/EVP_VerifyInit.pod b/src/lib/libcrypto/doc/EVP_VerifyInit.pod
index 3b5e07f4ad..80c656fde8 100644
--- a/src/lib/libcrypto/doc/EVP_VerifyInit.pod
+++ b/src/lib/libcrypto/doc/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() initialises 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 funtion 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 initialiase 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,14 +54,22 @@ 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
72L<evp(3)|evp(3)>,
60L<EVP_SignInit(3)|EVP_SignInit(3)>, 73L<EVP_SignInit(3)|EVP_SignInit(3)>,
61L<EVP_DigestInit(3)|EVP_DigestInit(3)>, L<err(3)|err(3)>, 74L<EVP_DigestInit(3)|EVP_DigestInit(3)>, L<err(3)|err(3)>,
62L<evp(3)|evp(3)>, L<hmac(3)|hmac(3)>, L<md2(3)|md2(3)>, 75L<evp(3)|evp(3)>, L<hmac(3)|hmac(3)>, L<md2(3)|md2(3)>,
@@ -68,4 +81,6 @@ L<sha(3)|sha(3)>, L<digest(1)|digest(1)>
68EVP_VerifyInit(), EVP_VerifyUpdate() and EVP_VerifyFinal() are 81EVP_VerifyInit(), EVP_VerifyUpdate() and EVP_VerifyFinal() are
69available in all versions of SSLeay and OpenSSL. 82available in all versions of SSLeay and OpenSSL.
70 83
84EVP_VerifyInit_ex() was added in OpenSSL 0.9.7
85
71=cut 86=cut
diff --git a/src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod b/src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod
index b0b1058d19..c39ac35e78 100644
--- a/src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod
+++ b/src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod
@@ -2,7 +2,7 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5OPENSSL_VERSION_NUMBER, SSLeay - 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,11 +11,27 @@ OPENSSL_VERSION_NUMBER, SSLeay - 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 const char *SSLeay_version(int t);
14 15
15=head1 DESCRIPTION 16=head1 DESCRIPTION
16 17
17OPENSSL_VERSION_NUMBER is a numeric release version identifier: 18OPENSSL_VERSION_NUMBER is a numeric release version identifier:
18 19
20 MMNNFFPPS: major minor fix patch status
21
22The status nibble has one of the values 0 for development, 1 to e for betas
231 to 14, and f for release.
24
25for example
26
27 0x000906000 == 0.9.6 dev
28 0x000906023 == 0.9.6b beta 3
29 0x00090605f == 0.9.6e release
30
31Versions prior to 0.9.3 have identifiers E<lt> 0x0930.
32Versions between 0.9.3 and 0.9.5 had a version identifier with this
33interpretation:
34
19 MMNNFFRBB major minor fix final beta/patch 35 MMNNFFRBB major minor fix final beta/patch
20 36
21for example 37for example
@@ -23,13 +39,51 @@ for example
23 0x000904100 == 0.9.4 release 39 0x000904100 == 0.9.4 release
24 0x000905000 == 0.9.5 dev 40 0x000905000 == 0.9.5 dev
25 41
26Versions prior to 0.9.3 have identifiers E<lt> 0x0930. 42Version 0.9.5a had an interim interpretation that is like the current one,
43except the patch level got the highest bit set, to keep continuity. The
44number was therefore 0x0090581f.
45
46
27For backward compatibility, SSLEAY_VERSION_NUMBER is also defined. 47For backward compatibility, SSLEAY_VERSION_NUMBER is also defined.
28 48
29SSLeay() returns this number. The return value can be compared to the 49SSLeay() returns this number. The return value can be compared to the
30macro to make sure that the correct version of the library has been 50macro to make sure that the correct version of the library has been
31loaded, especially when using DLLs on Windows systems. 51loaded, especially when using DLLs on Windows systems.
32 52
53SSLeay_version() returns different strings depending on B<t>:
54
55=over 4
56
57=item SSLEAY_VERSION
58
59The text variant of the version number and the release date. For example,
60"OpenSSL 0.9.5a 1 Apr 2000".
61
62=item SSLEAY_CFLAGS
63
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.
72
73=item SSLEAY_PLATFORM
74
75The "Configure" target of the library build in the form "platform: ..."
76if available or "platform: information not available" otherwise.
77
78=item SSLEAY_DIR
79
80The "OPENSSLDIR" setting of the library build in the form "OPENSSLDIR: "...""
81if available or "OPENSSLDIR: N/A" otherwise.
82
83=back
84
85For an unknown B<t>, the text "not available" is returned.
86
33=head1 RETURN VALUE 87=head1 RETURN VALUE
34 88
35The version number. 89The version number.
@@ -42,5 +96,6 @@ L<crypto(3)|crypto(3)>
42 96
43SSLeay() 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.
44OPENSSL_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.
45 100
46=cut 101=cut
diff --git a/src/lib/libcrypto/doc/OpenSSL_add_all_algorithms.pod b/src/lib/libcrypto/doc/OpenSSL_add_all_algorithms.pod
index 1300fe190c..486c903430 100644
--- a/src/lib/libcrypto/doc/OpenSSL_add_all_algorithms.pod
+++ b/src/lib/libcrypto/doc/OpenSSL_add_all_algorithms.pod
@@ -2,7 +2,8 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5OpenSSL_add_all_algorithms() - add algorithms to internal table 5OpenSSL_add_all_algorithms, OpenSSL_add_all_ciphers, OpenSSL_add_all_digests -
6add algorithms to internal table
6 7
7=head1 SYNOPSIS 8=head1 SYNOPSIS
8 9
@@ -43,7 +44,7 @@ by EVP_sha1(). It just needs to add them if it (or any of the functions it calls
43needs to lookup algorithms. 44needs to lookup algorithms.
44 45
45The cipher and digest lookup functions are used in many parts of the library. If 46The cipher and digest lookup functions are used in many parts of the library. If
46the table is not initialised several functions will misbehave and complain they 47the table is not initialized several functions will misbehave and complain they
47cannot find algorithms. This includes the PEM, PKCS#12, SSL and S/MIME libraries. 48cannot find algorithms. This includes the PEM, PKCS#12, SSL and S/MIME libraries.
48This is a common query in the OpenSSL mailing lists. 49This is a common query in the OpenSSL mailing lists.
49 50
diff --git a/src/lib/libcrypto/doc/RAND_add.pod b/src/lib/libcrypto/doc/RAND_add.pod
index 0a13ec2a92..67c66f3e0c 100644
--- a/src/lib/libcrypto/doc/RAND_add.pod
+++ b/src/lib/libcrypto/doc/RAND_add.pod
@@ -2,7 +2,8 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5RAND_add, RAND_seed, RAND_screen - add entropy to the PRNG 5RAND_add, RAND_seed, RAND_status, RAND_event, RAND_screen - add
6entropy to the PRNG
6 7
7=head1 SYNOPSIS 8=head1 SYNOPSIS
8 9
@@ -14,6 +15,7 @@ RAND_add, RAND_seed, RAND_screen - add entropy to the PRNG
14 15
15 int RAND_status(void); 16 int RAND_status(void);
16 17
18 int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam);
17 void RAND_screen(void); 19 void RAND_screen(void);
18 20
19=head1 DESCRIPTION 21=head1 DESCRIPTION
@@ -40,17 +42,24 @@ or L<RAND_load_file(3)|RAND_load_file(3)>.
40 42
41RAND_seed() is equivalent to RAND_add() when B<num == entropy>. 43RAND_seed() is equivalent to RAND_add() when B<num == entropy>.
42 44
45RAND_event() collects the entropy from Windows events such as mouse
46movements and other user interaction. It should be called with the
47B<iMsg>, B<wParam> and B<lParam> arguments of I<all> messages sent to
48the window procedure. It will estimate the entropy contained in the
49event message (if any), and add it to the PRNG. The program can then
50process the messages as usual.
51
43The RAND_screen() function is available for the convenience of Windows 52The RAND_screen() function is available for the convenience of Windows
44programmers. It adds the current contents of the screen to the PRNG. 53programmers. It adds the current contents of the screen to the PRNG.
45For applications that can catch Windows events, seeding the PRNG with 54For applications that can catch Windows events, seeding the PRNG by
46the parameters of B<WM_MOUSEMOVE> events is a significantly better 55calling RAND_event() is a significantly better source of
47source of randomness. It should be noted that both methods cannot be 56randomness. It should be noted that both methods cannot be used on
48used on servers that run without user interaction. 57servers that run without user interaction.
49 58
50=head1 RETURN VALUES 59=head1 RETURN VALUES
51 60
52RAND_status() returns 1 if the PRNG has been seeded with enough data, 61RAND_status() and RAND_event() return 1 if the PRNG has been seeded
530 otherwise. 62with enough data, 0 otherwise.
54 63
55The other functions do not return values. 64The other functions do not return values.
56 65
@@ -63,6 +72,6 @@ L<RAND_load_file(3)|RAND_load_file(3)>, L<RAND_cleanup(3)|RAND_cleanup(3)>
63 72
64RAND_seed() and RAND_screen() are available in all versions of SSLeay 73RAND_seed() and RAND_screen() are available in all versions of SSLeay
65and OpenSSL. RAND_add() and RAND_status() have been added in OpenSSL 74and OpenSSL. RAND_add() and RAND_status() have been added in OpenSSL
660.9.5. 750.9.5, RAND_event() in OpenSSL 0.9.5a.
67 76
68=cut 77=cut
diff --git a/src/lib/libcrypto/doc/RAND_load_file.pod b/src/lib/libcrypto/doc/RAND_load_file.pod
index 8dd700ca3d..d8c134e621 100644
--- a/src/lib/libcrypto/doc/RAND_load_file.pod
+++ b/src/lib/libcrypto/doc/RAND_load_file.pod
@@ -8,7 +8,7 @@ RAND_load_file, RAND_write_file, RAND_file_name - PRNG seed file
8 8
9 #include <openssl/rand.h> 9 #include <openssl/rand.h>
10 10
11 const char *RAND_file_name(char *buf, int num); 11 const char *RAND_file_name(char *buf, size_t num);
12 12
13 int RAND_load_file(const char *filename, long max_bytes); 13 int RAND_load_file(const char *filename, long max_bytes);
14 14
diff --git a/src/lib/libcrypto/doc/RAND_set_rand_method.pod b/src/lib/libcrypto/doc/RAND_set_rand_method.pod
index 466e9b8767..464eba416d 100644
--- a/src/lib/libcrypto/doc/RAND_set_rand_method.pod
+++ b/src/lib/libcrypto/doc/RAND_set_rand_method.pod
@@ -34,10 +34,12 @@ RAND_get_rand_method() returns a pointer to the current method.
34 void (*cleanup)(void); 34 void (*cleanup)(void);
35 void (*add)(const void *buf, int num, int entropy); 35 void (*add)(const void *buf, int num, int entropy);
36 int (*pseudorand)(unsigned char *buf, int num); 36 int (*pseudorand)(unsigned char *buf, int num);
37 int (*status)(void);
37 } RAND_METHOD; 38 } RAND_METHOD;
38 39
39The components point to the implementation of RAND_seed(), 40The components point to the implementation of RAND_seed(),
40RAND_bytes(), RAND_cleanup(), RAND_add() and RAND_pseudo_rand(). 41RAND_bytes(), RAND_cleanup(), RAND_add(), RAND_pseudo_rand()
42and RAND_status().
41Each component may be NULL if the function is not implemented. 43Each component may be NULL if the function is not implemented.
42 44
43=head1 RETURN VALUES 45=head1 RETURN VALUES
diff --git a/src/lib/libcrypto/doc/RSA_generate_key.pod b/src/lib/libcrypto/doc/RSA_generate_key.pod
index fdaddbcb13..8714f7179d 100644
--- a/src/lib/libcrypto/doc/RSA_generate_key.pod
+++ b/src/lib/libcrypto/doc/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/libcrypto/doc/RSA_get_ex_new_index.pod b/src/lib/libcrypto/doc/RSA_get_ex_new_index.pod
index 920dc76325..46cc8f5359 100644
--- a/src/lib/libcrypto/doc/RSA_get_ex_new_index.pod
+++ b/src/lib/libcrypto/doc/RSA_get_ex_new_index.pod
@@ -17,14 +17,12 @@ RSA_get_ex_new_index, RSA_set_ex_data, RSA_get_ex_data - add application specifi
17 17
18 void *RSA_get_ex_data(RSA *r, int idx); 18 void *RSA_get_ex_data(RSA *r, int idx);
19 19
20 int new_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad, 20 typedef int new_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
21 int idx, long argl, void *argp); 21 int idx, long argl, void *argp);
22 22 typedef void free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
23 void free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad, 23 int idx, long argl, void *argp);
24 int idx, long argl, void *argp); 24 typedef int dup_func(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
25 25 int idx, long argl, void *argp);
26 int dup_func(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
27 int idx, long argl, void *argp);
28 26
29=head1 DESCRIPTION 27=head1 DESCRIPTION
30 28
diff --git a/src/lib/libcrypto/doc/RSA_print.pod b/src/lib/libcrypto/doc/RSA_print.pod
index dd968a5274..67876facc5 100644
--- a/src/lib/libcrypto/doc/RSA_print.pod
+++ b/src/lib/libcrypto/doc/RSA_print.pod
@@ -2,8 +2,9 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5RSA_print, RSA_print_fp, DHparams_print, DHparams_print_fp - print 5RSA_print, RSA_print_fp, DHparams_print, DHparams_print_fp, DSA_print,
6cryptographic parameters 6DSA_print_fp, DHparams_print, DHparams_print_fp - print cryptographic
7parameters
7 8
8=head1 SYNOPSIS 9=head1 SYNOPSIS
9 10
diff --git a/src/lib/libcrypto/doc/RSA_public_encrypt.pod b/src/lib/libcrypto/doc/RSA_public_encrypt.pod
index 910c4752b8..e20dfcb551 100644
--- a/src/lib/libcrypto/doc/RSA_public_encrypt.pod
+++ b/src/lib/libcrypto/doc/RSA_public_encrypt.pod
@@ -47,7 +47,7 @@ Encrypting user data directly with RSA is insecure.
47=back 47=back
48 48
49B<flen> must be less than RSA_size(B<rsa>) - 11 for the PKCS #1 v1.5 49B<flen> must be less than RSA_size(B<rsa>) - 11 for the PKCS #1 v1.5
50based padding modes, and less than RSA_size(B<rsa>) - 21 for 50based padding modes, and less than RSA_size(B<rsa>) - 41 for
51RSA_PKCS1_OAEP_PADDING. The random number generator must be seeded 51RSA_PKCS1_OAEP_PADDING. The random number generator must be seeded
52prior to calling RSA_public_encrypt(). 52prior to calling RSA_public_encrypt().
53 53
@@ -74,10 +74,6 @@ SSL, PKCS #1 v2.0
74 74
75L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_size(3)|RSA_size(3)> 75L<err(3)|err(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/libcrypto/doc/RSA_set_method.pod b/src/lib/libcrypto/doc/RSA_set_method.pod
index deb1183a23..14917dd35f 100644
--- a/src/lib/libcrypto/doc/RSA_set_method.pod
+++ b/src/lib/libcrypto/doc/RSA_set_method.pod
@@ -3,30 +3,29 @@
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_PKCS1_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
10 10
11 #include <openssl/rsa.h> 11 #include <openssl/rsa.h>
12 #include <openssl/engine.h>
12 13
13 void RSA_set_default_method(RSA_METHOD *meth); 14 void RSA_set_default_openssl_method(RSA_METHOD *meth);
14 15
15 RSA_METHOD *RSA_get_default_method(void); 16 RSA_METHOD *RSA_get_default_openssl_method(void);
16 17
17 RSA_METHOD *RSA_set_method(RSA *rsa, RSA_METHOD *meth); 18 int RSA_set_method(RSA *rsa, ENGINE *engine);
18 19
19 RSA_METHOD *RSA_get_method(RSA *rsa); 20 RSA_METHOD *RSA_get_method(RSA *rsa);
20 21
21 RSA_METHOD *RSA_PKCS1_SSLeay(void); 22 RSA_METHOD *RSA_PKCS1_SSLeay(void);
22 23
23 RSA_METHOD *RSA_PKCS1_RSAref(void);
24
25 RSA_METHOD *RSA_null_method(void); 24 RSA_METHOD *RSA_null_method(void);
26 25
27 int RSA_flags(RSA *rsa); 26 int RSA_flags(RSA *rsa);
28 27
29 RSA *RSA_new_method(RSA_METHOD *method); 28 RSA *RSA_new_method(ENGINE *engine);
30 29
31=head1 DESCRIPTION 30=head1 DESCRIPTION
32 31
@@ -34,35 +33,30 @@ An B<RSA_METHOD> specifies the functions that OpenSSL uses for RSA
34operations. By modifying the method, alternative implementations 33operations. By modifying the method, alternative implementations
35such as hardware accelerators may be used. 34such as hardware accelerators may be used.
36 35
37Initially, the default is to use the OpenSSL internal implementation, 36Initially, the default is to use the OpenSSL internal implementation.
38unless OpenSSL was configured with the C<rsaref> or C<-DRSA_NULL> 37RSA_PKCS1_SSLeay() returns a pointer to that method.
39options. RSA_PKCS1_SSLeay() returns a pointer to that method.
40
41RSA_PKCS1_RSAref() returns a pointer to a method that uses the RSAref
42library. This is the default method in the C<rsaref> configuration;
43the function is not available in other configurations.
44RSA_null_method() returns a pointer to a method that does not support
45the RSA transformation. It is the default if OpenSSL is compiled with
46C<-DRSA_NULL>. These methods may be useful in the USA because of a
47patent on the RSA cryptosystem.
48 38
49RSA_set_default_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>
50structures created later. 40structures created later. B<NB:> This is true only whilst the default engine
41for RSA operations remains as "openssl". ENGINEs provide an
42encapsulation for implementations of one or more algorithms at a time, and all
43the RSA functions mentioned here operate within the scope of the default
44"openssl" engine.
51 45
52RSA_get_default_method() returns a pointer to the current default 46RSA_get_default_openssl_method() returns a pointer to the current default
53method. 47method for the "openssl" engine.
54 48
55RSA_set_method() selects B<meth> for all operations using the key 49RSA_set_method() selects B<engine> for all operations using the key
56B<rsa>. 50B<rsa>.
57 51
58RSA_get_method() returns a pointer to the method currently selected 52RSA_get_method() returns a pointer to the RSA_METHOD from the currently
59for B<rsa>. 53selected ENGINE for B<rsa>.
60 54
61RSA_flags() returns the B<flags> that are set for B<rsa>'s current method. 55RSA_flags() returns the B<flags> that are set for B<rsa>'s current method.
62 56
63RSA_new_method() allocates and initializes an B<RSA> structure so that 57RSA_new_method() allocates and initializes an RSA structure so that
64B<method> will be used for the RSA operations. If B<method> is B<NULL>, 58B<engine> will be used for the RSA operations. If B<engine> is NULL,
65the default method is used. 59the default engine for RSA operations is used.
66 60
67=head1 THE RSA_METHOD STRUCTURE 61=head1 THE RSA_METHOD STRUCTURE
68 62
@@ -87,10 +81,11 @@ the default method is used.
87 int (*rsa_priv_dec)(int flen, unsigned char *from, 81 int (*rsa_priv_dec)(int flen, unsigned char *from,
88 unsigned char *to, RSA *rsa, int padding); 82 unsigned char *to, RSA *rsa, int padding);
89 83
90 /* compute r0 = r0 ^ I mod rsa->n. May be NULL */ 84 /* compute r0 = r0 ^ I mod rsa->n (May be NULL for some
85 implementations) */
91 int (*rsa_mod_exp)(BIGNUM *r0, BIGNUM *I, RSA *rsa); 86 int (*rsa_mod_exp)(BIGNUM *r0, BIGNUM *I, RSA *rsa);
92 87
93 /* compute r = a ^ p mod m. May be NULL */ 88 /* compute r = a ^ p mod m (May be NULL for some implementations) */
94 int (*bn_mod_exp)(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 89 int (*bn_mod_exp)(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
95 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); 90 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
96 91
@@ -126,18 +121,21 @@ the default method is used.
126 121
127=head1 RETURN VALUES 122=head1 RETURN VALUES
128 123
129RSA_PKCS1_SSLeay(), RSA_PKCS1_RSAref(), RSA_PKCS1_null_method(), 124RSA_PKCS1_SSLeay(), RSA_PKCS1_null_method(), RSA_get_default_openssl_method()
130RSA_get_default_method() and RSA_get_method() return pointers to the 125and RSA_get_method() return pointers to the respective RSA_METHODs.
131respective B<RSA_METHOD>s.
132 126
133RSA_set_default_method() returns no value. 127RSA_set_default_openssl_method() returns no value.
134 128
135RSA_set_method() returns a pointer to the B<RSA_METHOD> previously 129RSA_set_method() selects B<engine> as the engine that will be responsible for
136associated with B<rsa>. 130all operations using the structure B<rsa>. If this function completes successfully,
131then the B<rsa> structure will have its own functional reference of B<engine>, so
132the caller should remember to free their own reference to B<engine> when they are
133finished with it. NB: An ENGINE's RSA_METHOD can be retrieved (or set) by
134ENGINE_get_RSA() or ENGINE_set_RSA().
137 135
138RSA_new_method() returns B<NULL> and sets an error code that can be 136RSA_new_method() returns NULL and sets an error code that can be
139obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise it 137obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise
140returns a pointer to the newly allocated structure. 138it returns a pointer to the newly allocated structure.
141 139
142=head1 SEE ALSO 140=head1 SEE ALSO
143 141
@@ -150,4 +148,9 @@ RSA_get_default_method(), RSA_set_method() and RSA_get_method() as
150well as the rsa_sign and rsa_verify components of RSA_METHOD were 148well as the rsa_sign and rsa_verify components of RSA_METHOD were
151added in OpenSSL 0.9.4. 149added in OpenSSL 0.9.4.
152 150
151RSA_set_default_openssl_method() and RSA_get_default_openssl_method()
152replaced RSA_set_default_method() and RSA_get_default_method() respectively,
153and RSA_set_method() and RSA_new_method() were altered to use B<ENGINE>s
154rather than B<RSA_METHOD>s during development of OpenSSL 0.9.6.
155
153=cut 156=cut
diff --git a/src/lib/libcrypto/doc/bn.pod b/src/lib/libcrypto/doc/bn.pod
index 1504a1c92d..210dfeac08 100644
--- a/src/lib/libcrypto/doc/bn.pod
+++ b/src/lib/libcrypto/doc/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,12 +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);
71 int BN_rand_range(BIGNUM *rnd, BIGNUM *range);
72 int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range);
63 73
64 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,
65 BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg); 75 BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg);
@@ -137,7 +147,7 @@ of B<BIGNUM>s to external formats is described in L<BN_bn2bin(3)|BN_bn2bin(3)>.
137L<bn_internal(3)|bn_internal(3)>, 147L<bn_internal(3)|bn_internal(3)>,
138L<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)>,
139L<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)>,
140L<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)>,
141L<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)>,
142L<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)>,
143L<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/libcrypto/doc/dh.pod b/src/lib/libcrypto/doc/dh.pod
index 0a9b7c03a2..b4be4be405 100644
--- a/src/lib/libcrypto/doc/dh.pod
+++ b/src/lib/libcrypto/doc/dh.pod
@@ -7,6 +7,7 @@ dh - Diffie-Hellman key agreement
7=head1 SYNOPSIS 7=head1 SYNOPSIS
8 8
9 #include <openssl/dh.h> 9 #include <openssl/dh.h>
10 #include <openssl/engine.h>
10 11
11 DH * DH_new(void); 12 DH * DH_new(void);
12 void DH_free(DH *dh); 13 void DH_free(DH *dh);
@@ -20,10 +21,10 @@ dh - Diffie-Hellman key agreement
20 int DH_generate_key(DH *dh); 21 int DH_generate_key(DH *dh);
21 int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh); 22 int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
22 23
23 void DH_set_default_method(DH_METHOD *meth); 24 void DH_set_default_openssl_method(DH_METHOD *meth);
24 DH_METHOD *DH_get_default_method(void); 25 DH_METHOD *DH_get_default_openssl_method(void);
25 DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth); 26 int DH_set_method(DH *dh, ENGINE *engine);
26 DH *DH_new_method(DH_METHOD *meth); 27 DH *DH_new_method(ENGINE *engine);
27 DH_METHOD *DH_OpenSSL(void); 28 DH_METHOD *DH_OpenSSL(void);
28 29
29 int DH_get_ex_new_index(long argl, char *argp, int (*new_func)(), 30 int DH_get_ex_new_index(long argl, char *argp, int (*new_func)(),
diff --git a/src/lib/libcrypto/doc/dsa.pod b/src/lib/libcrypto/doc/dsa.pod
index 2c09244899..82d7fb77cd 100644
--- a/src/lib/libcrypto/doc/dsa.pod
+++ b/src/lib/libcrypto/doc/dsa.pod
@@ -7,6 +7,7 @@ dsa - Digital Signature Algorithm
7=head1 SYNOPSIS 7=head1 SYNOPSIS
8 8
9 #include <openssl/dsa.h> 9 #include <openssl/dsa.h>
10 #include <openssl/engine.h>
10 11
11 DSA * DSA_new(void); 12 DSA * DSA_new(void);
12 void DSA_free(DSA *dsa); 13 void DSA_free(DSA *dsa);
@@ -28,10 +29,10 @@ dsa - Digital Signature Algorithm
28 int DSA_verify(int dummy, const unsigned char *dgst, int len, 29 int DSA_verify(int dummy, const unsigned char *dgst, int len,
29 unsigned char *sigbuf, int siglen, DSA *dsa); 30 unsigned char *sigbuf, int siglen, DSA *dsa);
30 31
31 void DSA_set_default_method(DSA_METHOD *meth); 32 void DSA_set_default_openssl_method(DSA_METHOD *meth);
32 DSA_METHOD *DSA_get_default_method(void); 33 DSA_METHOD *DSA_get_default_openssl_method(void);
33 DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth); 34 int DSA_set_method(DSA *dsa, ENGINE *engine);
34 DSA *DSA_new_method(DSA_METHOD *meth); 35 DSA *DSA_new_method(ENGINE *engine);
35 DSA_METHOD *DSA_OpenSSL(void); 36 DSA_METHOD *DSA_OpenSSL(void);
36 37
37 int DSA_get_ex_new_index(long argl, char *argp, int (*new_func)(), 38 int DSA_get_ex_new_index(long argl, char *argp, int (*new_func)(),
diff --git a/src/lib/libcrypto/doc/evp.pod b/src/lib/libcrypto/doc/evp.pod
index f089dd49a2..edf47dbde6 100644
--- a/src/lib/libcrypto/doc/evp.pod
+++ b/src/lib/libcrypto/doc/evp.pod
@@ -10,7 +10,7 @@ evp - high-level cryptographic functions
10 10
11=head1 DESCRIPTION 11=head1 DESCRIPTION
12 12
13The EVP library provided a high-level interface to cryptographic 13The EVP library provides a high-level interface to cryptographic
14functions. 14functions.
15 15
16B<EVP_Seal>I<...> and B<EVP_Open>I<...> provide public key encryption 16B<EVP_Seal>I<...> and B<EVP_Open>I<...> provide public key encryption
diff --git a/src/lib/libcrypto/doc/rsa.pod b/src/lib/libcrypto/doc/rsa.pod
index 0486c044a6..09ad30cab1 100644
--- a/src/lib/libcrypto/doc/rsa.pod
+++ b/src/lib/libcrypto/doc/rsa.pod
@@ -7,6 +7,7 @@ rsa - RSA public key cryptosystem
7=head1 SYNOPSIS 7=head1 SYNOPSIS
8 8
9 #include <openssl/rsa.h> 9 #include <openssl/rsa.h>
10 #include <openssl/engine.h>
10 11
11 RSA * RSA_new(void); 12 RSA * RSA_new(void);
12 void RSA_free(RSA *rsa); 13 void RSA_free(RSA *rsa);
@@ -31,15 +32,14 @@ rsa - RSA public key cryptosystem
31 int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); 32 int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
32 void RSA_blinding_off(RSA *rsa); 33 void RSA_blinding_off(RSA *rsa);
33 34
34 void RSA_set_default_method(RSA_METHOD *meth); 35 void RSA_set_default_openssl_method(RSA_METHOD *meth);
35 RSA_METHOD *RSA_get_default_method(void); 36 RSA_METHOD *RSA_get_default_openssl_method(void);
36 RSA_METHOD *RSA_set_method(RSA *rsa, RSA_METHOD *meth); 37 int RSA_set_method(RSA *rsa, ENGINE *engine);
37 RSA_METHOD *RSA_get_method(RSA *rsa); 38 RSA_METHOD *RSA_get_method(RSA *rsa);
38 RSA_METHOD *RSA_PKCS1_SSLeay(void); 39 RSA_METHOD *RSA_PKCS1_SSLeay(void);
39 RSA_METHOD *RSA_PKCS1_RSAref(void);
40 RSA_METHOD *RSA_null_method(void); 40 RSA_METHOD *RSA_null_method(void);
41 int RSA_flags(RSA *rsa); 41 int RSA_flags(RSA *rsa);
42 RSA *RSA_new_method(RSA_METHOD *method); 42 RSA *RSA_new_method(ENGINE *engine);
43 43
44 int RSA_print(BIO *bp, RSA *x, int offset); 44 int RSA_print(BIO *bp, RSA *x, int offset);
45 int RSA_print_fp(FILE *fp, RSA *x, int offset); 45 int RSA_print_fp(FILE *fp, RSA *x, int offset);
@@ -86,8 +86,9 @@ contain public as well as private RSA keys:
86In public keys, the private exponent and the related secret values are 86In public keys, the private exponent and the related secret values are
87B<NULL>. 87B<NULL>.
88 88
89B<dmp1>, B<dmq1> and B<iqmp> may be B<NULL> in private keys, but the 89B<p>, B<q>, B<dmp1>, B<dmq1> and B<iqmp> may be B<NULL> in private
90RSA operations are much faster when these values are available. 90keys, but the RSA operations are much faster when these values are
91available.
91 92
92=head1 CONFORMING TO 93=head1 CONFORMING TO
93 94
@@ -95,7 +96,7 @@ SSL, PKCS #1 v2.0
95 96
96=head1 PATENTS 97=head1 PATENTS
97 98
98RSA is covered by a US patent which expires in September 2000. 99RSA was covered by a US patent which expired in September 2000.
99 100
100=head1 SEE ALSO 101=head1 SEE ALSO
101 102