diff options
author | markus <> | 2002-09-05 12:51:50 +0000 |
---|---|---|
committer | markus <> | 2002-09-05 12:51:50 +0000 |
commit | 15b5d84f9da2ce4bfae8580e56e34a859f74ad71 (patch) | |
tree | bf939e82d7fd73cc8a01cf6959002209972091bc /src/lib/libcrypto/doc | |
parent | 027351f729b9e837200dae6e1520cda6577ab930 (diff) | |
download | openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.gz openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.bz2 openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.zip |
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/doc')
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 | ||
5 | DH_set_default_method, DH_get_default_method, DH_set_method, | 5 | DH_set_default_openssl_method, DH_get_default_openssl_method, |
6 | DH_new_method, DH_OpenSSL - select DH method | 6 | DH_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. | |||
28 | Initially, the default is to use the OpenSSL internal implementation. | 29 | Initially, the default is to use the OpenSSL internal implementation. |
29 | DH_OpenSSL() returns a pointer to that method. | 30 | DH_OpenSSL() returns a pointer to that method. |
30 | 31 | ||
31 | DH_set_default_method() makes B<meth> the default method for all B<DH> | 32 | DH_set_default_openssl_method() makes B<meth> the default method for all DH |
32 | structures created later. | 33 | structures created later. B<NB:> This is true only whilst the default engine |
34 | for Diffie-Hellman operations remains as "openssl". ENGINEs provide an | ||
35 | encapsulation for implementations of one or more algorithms, and all the DH | ||
36 | functions mentioned here operate within the scope of the default | ||
37 | "openssl" engine. | ||
33 | 38 | ||
34 | DH_get_default_method() returns a pointer to the current default | 39 | DH_get_default_openssl_method() returns a pointer to the current default |
35 | method. | 40 | method for the "openssl" engine. |
36 | 41 | ||
37 | DH_set_method() selects B<meth> for all operations using the structure B<dh>. | 42 | DH_set_method() selects B<engine> as the engine that will be responsible for |
43 | all operations using the structure B<dh>. If this function completes successfully, | ||
44 | then the B<dh> structure will have its own functional reference of B<engine>, so | ||
45 | the caller should remember to free their own reference to B<engine> when they are | ||
46 | finished with it. NB: An ENGINE's DH_METHOD can be retrieved (or set) by | ||
47 | ENGINE_get_DH() or ENGINE_set_DH(). | ||
38 | 48 | ||
39 | DH_get_method() returns a pointer to the method currently selected | 49 | DH_new_method() allocates and initializes a DH structure so that |
40 | for B<dh>. | 50 | B<engine> will be used for the DH operations. If B<engine> is NULL, |
41 | 51 | the default engine for Diffie-Hellman opertaions is used. | |
42 | DH_new_method() allocates and initializes a B<DH> structure so that | ||
43 | B<method> will be used for the DH operations. If B<method> is B<NULL>, | ||
44 | the 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 | ||
78 | DH_OpenSSL(), DH_get_default_method() and DH_get_method() return | 85 | DH_OpenSSL() and DH_get_default_openssl_method() return pointers to the |
79 | pointers to the respective B<DH_METHOD>s. | 86 | respective B<DH_METHOD>s. |
80 | 87 | ||
81 | DH_set_default_method() returns no value. | 88 | DH_set_default_openssl_method() returns no value. |
82 | 89 | ||
83 | DH_set_method() returns a pointer to the B<DH_METHOD> previously | 90 | DH_set_method() returns non-zero if the ENGINE associated with B<dh> |
84 | associated with B<dh>. | 91 | was successfully changed to B<engine>. |
85 | 92 | ||
86 | DH_new_method() returns B<NULL> and sets an error code that can be | 93 | DH_new_method() returns NULL and sets an error code that can be |
87 | obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise it | 94 | obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. |
88 | returns a pointer to the newly allocated structure. | 95 | Otherwise 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)> | |||
96 | DH_set_default_method(), DH_get_default_method(), DH_set_method(), | 103 | DH_set_default_method(), DH_get_default_method(), DH_set_method(), |
97 | DH_new_method() and DH_OpenSSL() were added in OpenSSL 0.9.4. | 104 | DH_new_method() and DH_OpenSSL() were added in OpenSSL 0.9.4. |
98 | 105 | ||
106 | DH_set_default_openssl_method() and DH_get_default_openssl_method() | ||
107 | replaced DH_set_default_method() and DH_get_default_method() respectively, | ||
108 | and DH_set_method() and DH_new_method() were altered to use B<ENGINE>s | ||
109 | rather 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 | ||
5 | DSA_set_default_method, DSA_get_default_method, DSA_set_method, | 5 | DSA_set_default_openssl_method, DSA_get_default_openssl_method, |
6 | DSA_new_method, DSA_OpenSSL - select RSA method | 6 | DSA_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. | |||
28 | Initially, the default is to use the OpenSSL internal implementation. | 29 | Initially, the default is to use the OpenSSL internal implementation. |
29 | DSA_OpenSSL() returns a pointer to that method. | 30 | DSA_OpenSSL() returns a pointer to that method. |
30 | 31 | ||
31 | DSA_set_default_method() makes B<meth> the default method for all B<DSA> | 32 | DSA_set_default_openssl_method() makes B<meth> the default method for |
32 | structures created later. | 33 | all DSA structures created later. B<NB:> This is true only whilst the |
34 | default engine for DSA operations remains as "openssl". ENGINEs | ||
35 | provide an encapsulation for implementations of one or more algorithms at a | ||
36 | time, and all the DSA functions mentioned here operate within the scope | ||
37 | of the default "openssl" engine. | ||
33 | 38 | ||
34 | DSA_get_default_method() returns a pointer to the current default | 39 | DSA_get_default_openssl_method() returns a pointer to the current default |
35 | method. | 40 | method for the "openssl" engine. |
36 | 41 | ||
37 | DSA_set_method() selects B<meth> for all operations using the structure B<DSA>. | 42 | DSA_set_method() selects B<engine> for all operations using the structure B<dsa>. |
38 | 43 | ||
39 | DSA_get_method() returns a pointer to the method currently selected | 44 | DSA_new_method() allocates and initializes a DSA structure so that |
40 | for B<DSA>. | 45 | B<engine> will be used for the DSA operations. If B<engine> is NULL, |
41 | 46 | the default engine for DSA operations is used. | |
42 | DSA_new_method() allocates and initializes a B<DSA> structure so that | ||
43 | B<method> will be used for the DSA operations. If B<method> is B<NULL>, | ||
44 | the 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 | ||
89 | DSA_OpenSSL(), DSA_get_default_method() and DSA_get_method() return | 92 | DSA_OpenSSL() and DSA_get_default_openssl_method() return pointers to the |
90 | pointers to the respective B<DSA_METHOD>s. | 93 | respective B<DSA_METHOD>s. |
91 | 94 | ||
92 | DSA_set_default_method() returns no value. | 95 | DSA_set_default_openssl_method() returns no value. |
93 | 96 | ||
94 | DSA_set_method() returns a pointer to the B<DSA_METHOD> previously | 97 | DSA_set_method() returns non-zero if the ENGINE associated with B<dsa> |
95 | associated with B<dsa>. | 98 | was successfully changed to B<engine>. |
96 | 99 | ||
97 | DSA_new_method() returns B<NULL> and sets an error code that can be | 100 | DSA_new_method() returns NULL and sets an error code that can be |
98 | obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation | 101 | obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation |
99 | fails. Otherwise it returns a pointer to the newly allocated | 102 | fails. Otherwise it returns a pointer to the newly allocated structure. |
100 | structure. | ||
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)> | |||
108 | DSA_set_default_method(), DSA_get_default_method(), DSA_set_method(), | 110 | DSA_set_default_method(), DSA_get_default_method(), DSA_set_method(), |
109 | DSA_new_method() and DSA_OpenSSL() were added in OpenSSL 0.9.4. | 111 | DSA_new_method() and DSA_OpenSSL() were added in OpenSSL 0.9.4. |
110 | 112 | ||
113 | DSA_set_default_openssl_method() and DSA_get_default_openssl_method() | ||
114 | replaced DSA_set_default_method() and DSA_get_default_method() respectively, | ||
115 | and DSA_set_method() and DSA_new_method() were altered to use B<ENGINE>s | ||
116 | rather 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 | ||
5 | ERR_error_string - obtain human-readable error message | 5 | ERR_error_string, ERR_error_string_n, ERR_lib_error_string, |
6 | ERR_func_error_string, ERR_reason_error_string - obtain human-readable | ||
7 | error 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 | ||
19 | ERR_error_string() generates a human-readable string representing the | 22 | ERR_error_string() generates a human-readable string representing the |
20 | error code B<e>, and places it at B<buf>. B<buf> must be at least 120 | 23 | error code I<e>, and places it at I<buf>. I<buf> must be at least 120 |
21 | bytes long. If B<buf> is B<NULL>, the error string is placed in a | 24 | bytes long. If I<buf> is B<NULL>, the error string is placed in a |
22 | static buffer. | 25 | static buffer. |
26 | ERR_error_string_n() is a variant of ERR_error_string() that writes | ||
27 | at most I<len> characters (including the terminating 0) | ||
28 | and truncates the string if necessary. | ||
29 | For ERR_error_string_n(), I<buf> may not be B<NULL>. | ||
23 | 30 | ||
24 | The string will have the following format: | 31 | The 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 | ||
47 | ERR_error_string() returns a pointer to a static buffer containing the | 54 | ERR_error_string() returns a pointer to a static buffer containing the |
48 | string if B<buf == NULL>, B<buf> otherwise. | 55 | string if I<buf> B<== NULL>, I<buf> otherwise. |
49 | 56 | ||
50 | ERR_lib_error_string(), ERR_func_error_string() and | 57 | ERR_lib_error_string(), ERR_func_error_string() and |
51 | ERR_reason_error_string() return the strings, and B<NULL> if | 58 | ERR_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 | ||
63 | ERR_error_string() is available in all versions of SSLeay and OpenSSL. | 70 | ERR_error_string() is available in all versions of SSLeay and OpenSSL. |
71 | ERR_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 | ||
5 | ERR_get_error, ERR_peek_error - obtain error code | 5 | ERR_get_error, ERR_peek_error, ERR_peek_last_error, |
6 | ERR_get_error_line, ERR_peek_error_line, ERR_peek_last_error_line, | ||
7 | ERR_get_error_line_data, ERR_peek_error_line_data, | ||
8 | ERR_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 | ||
24 | ERR_get_error() returns the last error code from the thread's error | 31 | ERR_get_error() returns the earliest error code from the thread's error |
25 | queue and removes the entry. This function can be called repeatedly | 32 | queue and removes the entry. This function can be called repeatedly |
26 | until there are no more error codes to return. | 33 | until there are no more error codes to return. |
27 | 34 | ||
28 | ERR_peek_error() returns the last error code from the thread's | 35 | ERR_peek_error() returns the earliest error code from the thread's |
36 | error queue without modifying it. | ||
37 | |||
38 | ERR_peek_last_error() returns the latest error code from the thread's | ||
29 | error queue without modifying it. | 39 | error queue without modifying it. |
30 | 40 | ||
31 | See L<ERR_GET_LIB(3)|ERR_GET_LIB(3)> for obtaining information about | 41 | See L<ERR_GET_LIB(3)|ERR_GET_LIB(3)> for obtaining information about |
@@ -33,14 +43,16 @@ location and reason of the error, and | |||
33 | L<ERR_error_string(3)|ERR_error_string(3)> for human-readable error | 43 | L<ERR_error_string(3)|ERR_error_string(3)> for human-readable error |
34 | messages. | 44 | messages. |
35 | 45 | ||
36 | ERR_get_error_line() and ERR_peek_error_line() are the same as the | 46 | ERR_get_error_line(), ERR_peek_error_line() and |
37 | above, but they additionally store the file name and line number where | 47 | ERR_peek_last_error_line() are the same as the above, but they |
48 | additionally store the file name and line number where | ||
38 | the error occurred in *B<file> and *B<line>, unless these are B<NULL>. | 49 | the error occurred in *B<file> and *B<line>, unless these are B<NULL>. |
39 | 50 | ||
40 | ERR_get_error_line_data() and ERR_peek_error_line_data() store | 51 | ERR_get_error_line_data(), ERR_peek_error_line_data() and |
41 | additional data and flags associated with the error code in *B<data> | 52 | ERR_get_last_error_line_data() store additional data and flags |
53 | associated with the error code in *B<data> | ||
42 | and *B<flags>, unless these are B<NULL>. *B<data> contains a string | 54 | and *B<flags>, unless these are B<NULL>. *B<data> contains a string |
43 | if *B<flags>&B<ERR_TXT_STRING>. If it has been allocated by Malloc(), | 55 | if *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 | |||
58 | ERR_peek_error_line() are available in all versions of SSLeay and | 70 | ERR_peek_error_line() are available in all versions of SSLeay and |
59 | OpenSSL. ERR_get_error_line_data() and ERR_peek_error_line_data() | 71 | OpenSSL. ERR_get_error_line_data() and ERR_peek_error_line_data() |
60 | were added in SSLeay 0.9.0. | 72 | were added in SSLeay 0.9.0. |
73 | ERR_peek_last_error(), ERR_peek_last_error_line() and | ||
74 | ERR_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>. | |||
16 | If B<pid> == 0, the current thread will have its error queue removed. | 16 | If B<pid> == 0, the current thread will have its error queue removed. |
17 | 17 | ||
18 | Since error queue data structures are allocated automatically for new | 18 | Since error queue data structures are allocated automatically for new |
19 | threads, they must be freed when threads are terminated in oder to | 19 | threads, they must be freed when threads are terminated in order to |
20 | avoid memory leaks. | 20 | avoid 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 | ||
5 | EVP_DigestInit, EVP_DigestUpdate, EVP_DigestFinal - EVP digest routines | 5 | EVP_MD_CTX_init, EVP_MD_CTX_create, EVP_DigestInit_ex, EVP_DigestUpdate, |
6 | EVP_DigestFinal_ex, EVP_MD_CTX_cleanup, EVP_MD_CTX_destroy, EVP_MAX_MD_SIZE, | ||
7 | EVP_MD_CTX_copy_ex EVP_MD_CTX_copy, EVP_MD_type, EVP_MD_pkey_type, EVP_MD_size, | ||
8 | EVP_MD_block_size, EVP_MD_CTX_md, EVP_MD_CTX_size, EVP_MD_CTX_block_size, EVP_MD_CTX_type, | ||
9 | EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_dss, EVP_dss1, EVP_mdc2, | ||
10 | EVP_ripemd160, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj - | ||
11 | EVP 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 | ||
46 | The EVP digest routines are a high level interface to message digests. | 65 | The EVP digest routines are a high level interface to message digests. |
47 | 66 | ||
48 | EVP_DigestInit() initialises a digest context B<ctx> to use a digest | 67 | EVP_MD_CTX_init() initializes digest contet B<ctx>. |
49 | B<type>: this will typically be supplied by a function such as | 68 | |
50 | EVP_sha1(). | 69 | EVP_MD_CTX_create() allocates, initializes and returns a digest contet. |
70 | |||
71 | EVP_DigestInit_ex() sets up digest context B<ctx> to use a digest | ||
72 | B<type> from ENGINE B<impl>. B<ctx> must be initialized before calling this | ||
73 | function. B<type> will typically be supplied by a functionsuch as EVP_sha1(). | ||
74 | If B<impl> is NULL then the default implementation of digest B<type> is used. | ||
51 | 75 | ||
52 | EVP_DigestUpdate() hashes B<cnt> bytes of data at B<d> into the | 76 | EVP_DigestUpdate() hashes B<cnt> bytes of data at B<d> into the |
53 | digest context B<ctx>. This funtion can be called several times on the | 77 | digest context B<ctx>. This function can be called several times on the |
54 | same B<ctx> to hash additional data. | 78 | same B<ctx> to hash additional data. |
55 | 79 | ||
56 | EVP_DigestFinal() retrieves the digest value from B<ctx> and places | 80 | EVP_DigestFinal_ex() retrieves the digest value from B<ctx> and places |
57 | it in B<md>. If the B<s> parameter is not NULL then the number of | 81 | it in B<md>. If the B<s> parameter is not NULL then the number of |
58 | bytes of data written (i.e. the length of the digest) will be written | 82 | bytes of data written (i.e. the length of the digest) will be written |
59 | to the integer at B<s>, at most B<EVP_MAX_MD_SIZE> bytes will be written. | 83 | to the integer at B<s>, at most B<EVP_MAX_MD_SIZE> bytes will be written. |
60 | After calling EVP_DigestFinal() no additional calls to EVP_DigestUpdate() | 84 | After calling EVP_DigestFinal_ex() no additional calls to EVP_DigestUpdate() |
61 | can be made, but EVP_DigestInit() can be called to initialiase a new | 85 | can be made, but EVP_DigestInit_ex() can be called to initialize a new |
62 | digest operation. | 86 | digest operation. |
63 | 87 | ||
64 | EVP_MD_CTX_copy() can be used to copy the message digest state from | 88 | EVP_MD_CTX_cleanup() cleans up digest context B<ctx>, it should be called |
89 | after a digest context is no longer needed. | ||
90 | |||
91 | EVP_MD_CTX_destroy() cleans up digest context B<ctx> and frees up the | ||
92 | space allocated to it, it should be called only on a context created | ||
93 | using EVP_MD_CTX_create(). | ||
94 | |||
95 | EVP_MD_CTX_copy_ex() can be used to copy the message digest state from | ||
65 | B<in> to B<out>. This is useful if large amounts of data are to be | 96 | B<in> to B<out>. This is useful if large amounts of data are to be |
66 | hashed which only differ in the last few bytes. | 97 | hashed which only differ in the last few bytes. B<out> must be initialized |
98 | before calling this function. | ||
99 | |||
100 | EVP_DigestInit() behaves in the same way as EVP_DigestInit_ex() except | ||
101 | the passed context B<ctx> does not have to be initialized, and it always | ||
102 | uses the default digest implementation. | ||
103 | |||
104 | EVP_DigestFinal() is similar to EVP_DigestFinal_ex() except the digest | ||
105 | contet B<ctx> is automatically cleaned up. | ||
106 | |||
107 | EVP_MD_CTX_copy() is similar to EVP_MD_CTX_copy_ex() except the destination | ||
108 | B<out> does not have to be initialized. | ||
67 | 109 | ||
68 | EVP_MD_size() and EVP_MD_CTX_size() return the size of the message digest | 110 | EVP_MD_size() and EVP_MD_CTX_size() return the size of the message digest |
69 | when passed an B<EVP_MD> or an B<EVP_MD_CTX> structure, i.e. the size of the | 111 | when 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 | ||
98 | EVP_get_digestbyname(), EVP_get_digestbynid() and EVP_get_digestbyobj() | 140 | EVP_get_digestbyname(), EVP_get_digestbynid() and EVP_get_digestbyobj() |
99 | return an B<EVP_MD> structure when passed a digest name, a digest NID or | 141 | return an B<EVP_MD> structure when passed a digest name, a digest NID or |
100 | an ASN1_OBJECT structure respectively. The digest table must be initialised | 142 | an ASN1_OBJECT structure respectively. The digest table must be initialized |
101 | using, for example, OpenSSL_add_all_digests() for these functions to work. | 143 | using, for example, OpenSSL_add_all_digests() for these functions to work. |
102 | 144 | ||
103 | =head1 RETURN VALUES | 145 | =head1 RETURN VALUES |
104 | 146 | ||
105 | EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() do not return values. | 147 | EVP_DigestInit_ex(), EVP_DigestUpdate() and EVP_DigestFinal_ex() return 1 for |
148 | success and 0 for failure. | ||
106 | 149 | ||
107 | EVP_MD_CTX_copy() returns 1 if successful or 0 for failure. | 150 | EVP_MD_CTX_copy_ex() returns 1 if successful or 0 for failure. |
108 | 151 | ||
109 | EVP_MD_type(), EVP_MD_pkey_type() and EVP_MD_type() return the NID of the | 152 | EVP_MD_type(), EVP_MD_pkey_type() and EVP_MD_type() return the NID of the |
110 | corresponding OBJECT IDENTIFIER or NID_undef if none exists. | 153 | corresponding OBJECT IDENTIFIER or NID_undef if none exists. |
@@ -129,6 +172,19 @@ transparent to the digest used and much more flexible. | |||
129 | SHA1 is the digest of choice for new applications. The other digest algorithms | 172 | SHA1 is the digest of choice for new applications. The other digest algorithms |
130 | are still in common use. | 173 | are still in common use. |
131 | 174 | ||
175 | For most applications the B<impl> parameter to EVP_DigestInit_ex() will be | ||
176 | set to NULL to use the default digest implementation. | ||
177 | |||
178 | The functions EVP_DigestInit(), EVP_DigestFinal() and EVP_MD_CTX_copy() are | ||
179 | obsolete but are retained to maintain compatibility with existing code. New | ||
180 | applications should use EVP_DigestInit_ex(), EVP_DigestFinal_ex() and | ||
181 | EVP_MD_CTX_copy_ex() because they can efficiently reuse a digest context | ||
182 | instead of initializing and cleaning it up on each call and allow non default | ||
183 | implementations of digests to be specified. | ||
184 | |||
185 | In OpenSSL 0.9.7 and later if digest contexts are not cleaned up after use | ||
186 | memory leaks will occur. | ||
187 | |||
132 | =head1 EXAMPLE | 188 | =head1 EXAMPLE |
133 | 189 | ||
134 | This example digests the data "Test Message\n" and "Hello World\n", using the | 190 | This 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 | ||
175 | Several of the functions do not return values: maybe they should. Although the | ||
176 | internal digest operations will never fail some future hardware based operations | ||
177 | might. | ||
178 | |||
179 | The link between digests and signing algorithms results in a situation where | 233 | The link between digests and signing algorithms results in a situation where |
180 | EVP_sha1() must be used with RSA and EVP_dss1() must be used with DSS | 234 | EVP_sha1() must be used with RSA and EVP_dss1() must be used with DSS |
181 | even though they are identical digests. | 235 | even though they are identical digests. |
182 | 236 | ||
183 | The size of an B<EVP_MD_CTX> structure is determined at compile time: this results | ||
184 | in 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 | ||
188 | L<evp(3)|evp(3)>, L<hmac(3)|hmac(3)>, L<md2(3)|md2(3)>, | 239 | L<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)> | |||
194 | EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() are | 245 | EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() are |
195 | available in all versions of SSLeay and OpenSSL. | 246 | available in all versions of SSLeay and OpenSSL. |
196 | 247 | ||
248 | EVP_DigestInit_ex(), EVP_DigestFinal_ex() and EVP_MD_CTX_copy_ex() | ||
249 | were 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 | ||
5 | EVP_EncryptInit, EVP_EncryptUpdate, EVP_EncryptFinal - EVP cipher routines | 5 | EVP_CIPHER_CTX_init, EVP_EncryptInit_ex, EVP_EncryptUpdate, |
6 | EVP_EncryptFinal_ex, EVP_DecryptInit_ex, EVP_DecryptUpdate, | ||
7 | EVP_DecryptFinal_ex, EVP_CipherInit_ex, EVP_CipherUpdate, | ||
8 | EVP_CipherFinal_ex, EVP_CIPHER_CTX_set_key_length, | ||
9 | EVP_CIPHER_CTX_ctrl, EVP_CIPHER_CTX_cleanup, EVP_EncryptInit, | ||
10 | EVP_EncryptFinal, EVP_DecryptInit, EVP_DecryptFinal, | ||
11 | EVP_CipherInit, EVP_CipherFinal, EVP_get_cipherbyname, | ||
12 | EVP_get_cipherbynid, EVP_get_cipherbyobj, EVP_CIPHER_nid, | ||
13 | EVP_CIPHER_block_size, EVP_CIPHER_key_length, EVP_CIPHER_iv_length, | ||
14 | EVP_CIPHER_flags, EVP_CIPHER_mode, EVP_CIPHER_type, EVP_CIPHER_CTX_cipher, | ||
15 | EVP_CIPHER_CTX_nid, EVP_CIPHER_CTX_block_size, EVP_CIPHER_CTX_key_length, | ||
16 | EVP_CIPHER_CTX_iv_length, EVP_CIPHER_CTX_get_app_data, | ||
17 | EVP_CIPHER_CTX_set_app_data, EVP_CIPHER_CTX_type, EVP_CIPHER_CTX_flags, | ||
18 | EVP_CIPHER_CTX_mode, EVP_CIPHER_param_to_asn1, EVP_CIPHER_asn1_to_param, | ||
19 | EVP_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 | |||
56 | The EVP cipher routines are a high level interface to certain | 96 | The EVP cipher routines are a high level interface to certain |
57 | symmetric ciphers. | 97 | symmetric ciphers. |
58 | 98 | ||
59 | EVP_EncryptInit() initialises a cipher context B<ctx> for encryption | 99 | EVP_CIPHER_CTX_init() initializes cipher contex B<ctx>. |
60 | with cipher B<type>. B<type> is normally supplied by a function such | 100 | |
61 | as EVP_des_cbc() . B<key> is the symmetric key to use and B<iv> is the | 101 | EVP_EncryptInit_ex() sets up cipher context B<ctx> for encryption |
62 | IV to use (if necessary), the actual number of bytes used for the | 102 | with cipher B<type> from ENGINE B<impl>. B<ctx> must be initialized |
63 | key and IV depends on the cipher. It is possible to set all parameters | 103 | before calling this function. B<type> is normally supplied |
64 | to NULL except B<type> in an initial call and supply the remaining | 104 | by a function such as EVP_des_cbc(). If B<impl> is NULL then the |
65 | parameters in subsequent calls. This is normally done when the | 105 | default implementation is used. B<key> is the symmetric key to use |
66 | EVP_CIPHER_asn1_to_param() function is called to set the cipher | 106 | and B<iv> is the IV to use (if necessary), the actual number of bytes |
67 | parameters from an ASN1 AlgorithmIdentifier and the key from a | 107 | used for the key and IV depends on the cipher. It is possible to set |
68 | different source. | 108 | all parameters to NULL except B<type> in an initial call and supply |
109 | the remaining parameters in subsequent calls, all of which have B<type> | ||
110 | set to NULL. This is done when the default cipher parameters are not | ||
111 | appropriate. | ||
69 | 112 | ||
70 | EVP_EncryptUpdate() encrypts B<inl> bytes from the buffer B<in> and | 113 | EVP_EncryptUpdate() encrypts B<inl> bytes from the buffer B<in> and |
71 | writes the encrypted version to B<out>. This function can be called | 114 | writes 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 | |||
73 | of data written depends on the block alignment of the encrypted data: | 116 | of data written depends on the block alignment of the encrypted data: |
74 | as a result the amount of data written may be anything from zero bytes | 117 | as a result the amount of data written may be anything from zero bytes |
75 | to (inl + cipher_block_size - 1) so B<outl> should contain sufficient | 118 | to (inl + cipher_block_size - 1) so B<outl> should contain sufficient |
76 | room. The actual number of bytes written is placed in B<outl>. | 119 | room. The actual number of bytes written is placed in B<outl>. |
77 | 120 | ||
78 | EVP_EncryptFinal() encrypts the "final" data, that is any data that | 121 | If padding is enabled (the default) then EVP_EncryptFinal_ex() encrypts |
79 | remains in a partial block. It uses L<standard block padding|/NOTES> (aka PKCS | 122 | the "final" data, that is any data that remains in a partial block. |
80 | padding). The encrypted final data is written to B<out> which should | 123 | It uses L<standard block padding|/NOTES> (aka PKCS padding). The encrypted |
81 | have sufficient space for one cipher block. The number of bytes written | 124 | final data is written to B<out> which should have sufficient space for |
82 | is placed in B<outl>. After this function is called the encryption operation | 125 | one cipher block. The number of bytes written is placed in B<outl>. After |
83 | is finished and no further calls to EVP_EncryptUpdate() should be made. | 126 | this function is called the encryption operation is finished and no further |
84 | 127 | calls to EVP_EncryptUpdate() should be made. | |
85 | EVP_DecryptInit(), EVP_DecryptUpdate() and EVP_DecryptFinal() are the | ||
86 | corresponding decryption operations. EVP_DecryptFinal() will return an | ||
87 | error code if the final block is not correctly formatted. The parameters | ||
88 | and restrictions are identical to the encryption operations except that | ||
89 | the decrypted data buffer B<out> passed to EVP_DecryptUpdate() should | ||
90 | have sufficient room for (B<inl> + cipher_block_size) bytes unless the | ||
91 | cipher block size is 1 in which case B<inl> bytes is sufficient. | ||
92 | 128 | ||
93 | EVP_CipherInit(), EVP_CipherUpdate() and EVP_CipherFinal() are functions | 129 | If padding is disabled then EVP_EncryptFinal_ex() will not encrypt any more |
94 | that can be used for decryption or encryption. The operation performed | 130 | data and it will return an error if any data remains in a partial block: |
95 | depends on the value of the B<enc> parameter. It should be set to 1 for | 131 | that is if the total data length is not a multiple of the block size. |
96 | encryption and 0 for decryption. | ||
97 | 132 | ||
98 | EVP_CIPHER_CTX_cleanup() clears all information from a cipher context. | 133 | EVP_DecryptInit_ex(), EVP_DecryptUpdate() and EVP_DecryptFinal_ex() are the |
99 | It should be called after all operations using a cipher are complete | 134 | corresponding decryption operations. EVP_DecryptFinal() will return an |
100 | so sensitive information does not remain in memory. | 135 | error code if padding is enabled and the final block is not correctly |
136 | formatted. The parameters and restrictions are identical to the encryption | ||
137 | operations except that if padding is enabled the decrypted data buffer B<out> | ||
138 | passed to EVP_DecryptUpdate() should have sufficient room for | ||
139 | (B<inl> + cipher_block_size) bytes unless the cipher block size is 1 in | ||
140 | which case B<inl> bytes is sufficient. | ||
141 | |||
142 | EVP_CipherInit_ex(), EVP_CipherUpdate() and EVP_CipherFinal_ex() are | ||
143 | functions that can be used for decryption or encryption. The operation | ||
144 | performed depends on the value of the B<enc> parameter. It should be set | ||
145 | to 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 | |||
148 | EVP_CIPHER_CTX_cleanup() clears all information from a cipher context | ||
149 | and free up any allocated memory associate with it. It should be called | ||
150 | after all operations using a cipher are complete so sensitive information | ||
151 | does not remain in memory. | ||
152 | |||
153 | EVP_EncryptInit(), EVP_DecryptInit() and EVP_CipherInit() behave in a | ||
154 | similar way to EVP_EncryptInit_ex(), EVP_DecryptInit_ex and | ||
155 | EVP_CipherInit_ex() except the B<ctx> paramter does not need to be | ||
156 | initialized and they always use the default cipher implementation. | ||
157 | |||
158 | EVP_EncryptFinal(), EVP_DecryptFinal() and EVP_CipherFinal() behave in a | ||
159 | similar way to EVP_EncryptFinal_ex(), EVP_DecryptFinal_ex() and | ||
160 | EVP_CipherFinal_ex() except B<ctx> is automatically cleaned up | ||
161 | after the call. | ||
101 | 162 | ||
102 | EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj() | 163 | EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj() |
103 | return an EVP_CIPHER structure when passed a cipher name, a NID or an | 164 | return 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 | |||
108 | value is an internal value which may not have a corresponding OBJECT | 169 | value is an internal value which may not have a corresponding OBJECT |
109 | IDENTIFIER. | 170 | IDENTIFIER. |
110 | 171 | ||
172 | EVP_CIPHER_CTX_set_padding() enables or disables padding. By default | ||
173 | encryption operations are padded using standard block padding and the | ||
174 | padding is checked and removed when decrypting. If the B<pad> parameter | ||
175 | is zero then no padding is performed, the total amount of data encrypted | ||
176 | or decrypted must then be a multiple of the block size or an error will | ||
177 | occur. | ||
178 | |||
111 | EVP_CIPHER_key_length() and EVP_CIPHER_CTX_key_length() return the key | 179 | EVP_CIPHER_key_length() and EVP_CIPHER_CTX_key_length() return the key |
112 | length of a cipher when passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX> | 180 | length of a cipher when passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX> |
113 | structure. The constant B<EVP_MAX_KEY_LENGTH> is the maximum key length | 181 | structure. The constant B<EVP_MAX_KEY_LENGTH> is the maximum key length |
114 | for all ciphers. | 182 | for all ciphers. Note: although EVP_CIPHER_key_length() is fixed for a |
183 | given cipher, the value of EVP_CIPHER_CTX_key_length() may be different | ||
184 | for variable key length ciphers. | ||
185 | |||
186 | EVP_CIPHER_CTX_set_key_length() sets the key length of the cipher ctx. | ||
187 | If the cipher is a fixed length cipher then attempting to set the key | ||
188 | length to any value other than the fixed value is an error. | ||
115 | 189 | ||
116 | EVP_CIPHER_iv_length() and EVP_CIPHER_CTX_iv_length() return the IV | 190 | EVP_CIPHER_iv_length() and EVP_CIPHER_CTX_iv_length() return the IV |
117 | length of a cipher when passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX>. | 191 | length of a cipher when passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX>. |
@@ -133,6 +207,11 @@ B<NID_undef>. | |||
133 | EVP_CIPHER_CTX_cipher() returns the B<EVP_CIPHER> structure when passed | 207 | EVP_CIPHER_CTX_cipher() returns the B<EVP_CIPHER> structure when passed |
134 | an B<EVP_CIPHER_CTX> structure. | 208 | an B<EVP_CIPHER_CTX> structure. |
135 | 209 | ||
210 | EVP_CIPHER_mode() and EVP_CIPHER_CTX_mode() return the block cipher mode: | ||
211 | EVP_CIPH_ECB_MODE, EVP_CIPH_CBC_MODE, EVP_CIPH_CFB_MODE or | ||
212 | EVP_CIPH_OFB_MODE. If the cipher is a stream cipher then | ||
213 | EVP_CIPH_STREAM_CIPHER is returned. | ||
214 | |||
136 | EVP_CIPHER_param_to_asn1() sets the AlgorithmIdentifier "parameter" based | 215 | EVP_CIPHER_param_to_asn1() sets the AlgorithmIdentifier "parameter" based |
137 | on the passed cipher. This will typically include any parameters and an | 216 | on the passed cipher. This will typically include any parameters and an |
138 | IV. The cipher IV (if any) must be set when this call is made. This call | 217 | IV. 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 | |||
149 | EVP_CipherInit() again with all parameters except the key set to NULL. It is | 228 | EVP_CipherInit() again with all parameters except the key set to NULL. It is |
150 | possible for this function to fail if the cipher does not have any ASN1 support | 229 | possible for this function to fail if the cipher does not have any ASN1 support |
151 | or the parameters cannot be set (for example the RC2 effective key length | 230 | or the parameters cannot be set (for example the RC2 effective key length |
152 | does not have an B<EVP_CIPHER> structure). | 231 | is not supported. |
232 | |||
233 | EVP_CIPHER_CTX_ctrl() allows various cipher specific parameters to be determined | ||
234 | and set. Currently only the RC2 effective key length and the number of rounds of | ||
235 | RC5 can be set. | ||
153 | 236 | ||
154 | =head1 RETURN VALUES | 237 | =head1 RETURN VALUES |
155 | 238 | ||
156 | EVP_EncryptInit(), EVP_EncryptUpdate() and EVP_EncryptFinal() do not return | 239 | EVP_CIPHER_CTX_init, EVP_EncryptInit_ex(), EVP_EncryptUpdate() and |
157 | values. | 240 | EVP_EncryptFinal_ex() return 1 for success and 0 for failure. |
158 | 241 | ||
159 | EVP_DecryptInit() and EVP_DecryptUpdate() do not return values. | 242 | EVP_DecryptInit_ex() and EVP_DecryptUpdate() return 1 for success and 0 for failure. |
160 | EVP_DecryptFinal() returns 0 if the decrypt failed or 1 for success. | 243 | EVP_DecryptFinal_ex() returns 0 if the decrypt failed or 1 for success. |
161 | 244 | ||
162 | EVP_CipherInit() and EVP_CipherUpdate() do not return values. | 245 | EVP_CipherInit_ex() and EVP_CipherUpdate() return 1 for success and 0 for failure. |
163 | EVP_CipherFinal() returns 1 for a decryption failure or 1 for success, if | 246 | EVP_CipherFinal_ex() returns 0 for a decryption failure or 1 for success. |
164 | the operation is encryption then it always returns 1. | ||
165 | 247 | ||
166 | EVP_CIPHER_CTX_cleanup() does not return a value. | 248 | EVP_CIPHER_CTX_cleanup() returns 1 for success and 0 for failure. |
167 | 249 | ||
168 | EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj() | 250 | EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj() |
169 | return an B<EVP_CIPHER> structure or NULL on error. | 251 | return an B<EVP_CIPHER> structure or NULL on error. |
@@ -176,6 +258,8 @@ size. | |||
176 | EVP_CIPHER_key_length() and EVP_CIPHER_CTX_key_length() return the key | 258 | EVP_CIPHER_key_length() and EVP_CIPHER_CTX_key_length() return the key |
177 | length. | 259 | length. |
178 | 260 | ||
261 | EVP_CIPHER_CTX_set_padding() always returns 1. | ||
262 | |||
179 | EVP_CIPHER_iv_length() and EVP_CIPHER_CTX_iv_length() return the IV | 263 | EVP_CIPHER_iv_length() and EVP_CIPHER_CTX_iv_length() return the IV |
180 | length or zero if the cipher does not use an IV. | 264 | length 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. | |||
187 | EVP_CIPHER_param_to_asn1() and EVP_CIPHER_asn1_to_param() return 1 for | 271 | EVP_CIPHER_param_to_asn1() and EVP_CIPHER_asn1_to_param() return 1 for |
188 | success or zero for failure. | 272 | success or zero for failure. |
189 | 273 | ||
274 | =head1 CIPHER LISTING | ||
275 | |||
276 | All algorithms have a fixed key length unless otherwise stated. | ||
277 | |||
278 | =over 4 | ||
279 | |||
280 | =item EVP_enc_null() | ||
281 | |||
282 | Null cipher: does nothing. | ||
283 | |||
284 | =item EVP_des_cbc(void), EVP_des_ecb(void), EVP_des_cfb(void), EVP_des_ofb(void) | ||
285 | |||
286 | DES 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 | |||
290 | Two 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 | |||
294 | Three key triple DES in CBC, ECB, CFB and OFB modes respectively. | ||
295 | |||
296 | =item EVP_desx_cbc(void) | ||
297 | |||
298 | DESX algorithm in CBC mode. | ||
299 | |||
300 | =item EVP_rc4(void) | ||
301 | |||
302 | RC4 stream cipher. This is a variable key length cipher with default key length 128 bits. | ||
303 | |||
304 | =item EVP_rc4_40(void) | ||
305 | |||
306 | RC4 stream cipher with 40 bit key length. This is obsolete and new code should use EVP_rc4() | ||
307 | and 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 | |||
311 | IDEA 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 | |||
315 | RC2 encryption algorithm in CBC, ECB, CFB and OFB modes respectively. This is a variable key | ||
316 | length cipher with an additional parameter called "effective key bits" or "effective key length". | ||
317 | By default both are set to 128 bits. | ||
318 | |||
319 | =item EVP_rc2_40_cbc(void), EVP_rc2_64_cbc(void) | ||
320 | |||
321 | RC2 algorithm in CBC mode with a default key length and effective key length of 40 and 64 bits. | ||
322 | These are obsolete and new code should use EVP_rc2_cbc(), EVP_CIPHER_CTX_set_key_length() and | ||
323 | EVP_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 | |||
327 | Blowfish encryption algorithm in CBC, ECB, CFB and OFB modes respectively. This is a variable key | ||
328 | length cipher. | ||
329 | |||
330 | =item EVP_cast5_cbc(void), EVP_cast5_ecb(void), EVP_cast5_cfb(void), EVP_cast5_ofb(void) | ||
331 | |||
332 | CAST encryption algorithm in CBC, ECB, CFB and OFB modes respectively. This is a variable key | ||
333 | length 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 | |||
337 | RC5 encryption algorithm in CBC, ECB, CFB and OFB modes respectively. This is a variable key length | ||
338 | cipher with an additional "number of rounds" parameter. By default the key length is set to 128 | ||
339 | bits and 12 rounds. | ||
340 | |||
341 | =back | ||
342 | |||
190 | =head1 NOTES | 343 | =head1 NOTES |
191 | 344 | ||
192 | Where possible the B<EVP> interface to symmetric ciphers should be used in | 345 | Where 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 | ||
202 | When decrypting the final block is checked to see if it has the correct form. | 355 | When decrypting the final block is checked to see if it has the correct form. |
203 | 356 | ||
204 | Although the decryption operation can produce an error, it is not a strong | 357 | Although the decryption operation can produce an error if padding is enabled, |
205 | test that the input data or key is correct. A random block has better than | 358 | it is not a strong test that the input data or key is correct. A random block |
206 | 1 in 256 chance of being of the correct format and problems with the | 359 | has better than 1 in 256 chance of being of the correct format and problems with |
207 | input data earlier on will not produce a final decrypt error. | 360 | the input data earlier on will not produce a final decrypt error. |
361 | |||
362 | If padding is disabled then the decryption operation will always succeed if | ||
363 | the total amount of data decrypted is a multiple of the block size. | ||
364 | |||
365 | The functions EVP_EncryptInit(), EVP_EncryptFinal(), EVP_DecryptInit(), | ||
366 | EVP_CipherInit() and EVP_CipherFinal() are obsolete but are retained for | ||
367 | compatibility with existing code. New code should use EVP_EncryptInit_ex(), | ||
368 | EVP_EncryptFinal_ex(), EVP_DecryptInit_ex(), EVP_DecryptFinal_ex(), | ||
369 | EVP_CipherInit_ex() and EVP_CipherFinal_ex() because they can reuse an | ||
370 | existing context without allocating and freeing it up on each call. | ||
208 | 371 | ||
209 | =head1 BUGS | 372 | =head1 BUGS |
210 | 373 | ||
211 | The current B<EVP> cipher interface is not as flexible as it should be. Only | 374 | For RC5 the number of rounds can currently only be set to 8, 12 or 16. This is |
212 | certain "spot" encryption algorithms can be used for ciphers which have various | 375 | a limitation of the current RC5 code rather than the EVP interface. |
213 | parameters associated with them (RC2, RC5 for example) this is inadequate. | 376 | |
377 | EVP_MAX_KEY_LENGTH and EVP_MAX_IV_LENGTH only refer to the internal ciphers with | ||
378 | default key lengths. If custom ciphers exceed these values the results are | ||
379 | unpredictable. This is because it has become standard practice to define a | ||
380 | generic key as a fixed unsigned char array containing EVP_MAX_KEY_LENGTH bytes. | ||
381 | |||
382 | The ASN1 code is incomplete (and sometimes inaccurate) it has only been tested | ||
383 | for certain common S/MIME ciphers (RC2, DES, triple DES) in CBC mode. | ||
384 | |||
385 | =head1 EXAMPLES | ||
386 | |||
387 | Get 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 | |||
392 | Get 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 | |||
397 | Set 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 | |||
402 | Set 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 | |||
407 | Encrypt 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 | |||
450 | The ciphertext from the above example can be decrypted using the B<openssl> | ||
451 | utility with the command line: | ||
452 | |||
453 | S<openssl bf -in cipher.bin -K 000102030405060708090A0B0C0D0E0F -iv 0102030405060708 -d> | ||
454 | |||
455 | General encryption, decryption function example using FILE I/O and RC2 with an | ||
456 | 80 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 | ||
215 | Several of the functions do not return error codes because the software versions | ||
216 | can 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 | |||
21 | decryption. They decrypt a public key encrypted symmetric key and | 21 | decryption. They decrypt a public key encrypted symmetric key and |
22 | then decrypt data using it. | 22 | then decrypt data using it. |
23 | 23 | ||
24 | EVP_OpenInit() initialises a cipher context B<ctx> for decryption | 24 | EVP_OpenInit() initializes a cipher context B<ctx> for decryption |
25 | with cipher B<type>. It decrypts the encrypted symmetric key of length | 25 | with cipher B<type>. It decrypts the encrypted symmetric key of length |
26 | B<ekl> bytes passed in the B<ek> parameter using the private key B<priv>. | 26 | B<ekl> bytes passed in the B<ek> parameter using the private key B<priv>. |
27 | The IV is supplied in the B<iv> parameter. | 27 | The IV is supplied in the B<iv> parameter. |
@@ -29,20 +29,32 @@ The IV is supplied in the B<iv> parameter. | |||
29 | EVP_OpenUpdate() and EVP_OpenFinal() have exactly the same properties | 29 | EVP_OpenUpdate() and EVP_OpenFinal() have exactly the same properties |
30 | as the EVP_DecryptUpdate() and EVP_DecryptFinal() routines, as | 30 | as the EVP_DecryptUpdate() and EVP_DecryptFinal() routines, as |
31 | documented on the L<EVP_EncryptInit(3)|EVP_EncryptInit(3)> manual | 31 | documented on the L<EVP_EncryptInit(3)|EVP_EncryptInit(3)> manual |
32 | page. | 32 | page. |
33 | |||
34 | =head1 NOTES | ||
35 | |||
36 | It is possible to call EVP_OpenInit() twice in the same way as | ||
37 | EVP_DecryptInit(). The first call should have B<priv> set to NULL | ||
38 | and (after setting any cipher parameters) it should be called again | ||
39 | with B<type> set to NULL. | ||
40 | |||
41 | If the cipher passed in the B<type> parameter is a variable length | ||
42 | cipher then the key length will be set to the value of the recovered | ||
43 | key length. If the cipher is a fixed length cipher then the recovered | ||
44 | key length must match the fixed cipher length. | ||
33 | 45 | ||
34 | =head1 RETURN VALUES | 46 | =head1 RETURN VALUES |
35 | 47 | ||
36 | EVP_OpenInit() returns -1 on error or an non zero integer (actually the | 48 | EVP_OpenInit() returns 0 on error or a non zero integer (actually the |
37 | recovered secret key size) if successful. | 49 | recovered secret key size) if successful. |
38 | 50 | ||
39 | EVP_SealUpdate() does not return a value. | 51 | EVP_OpenUpdate() returns 1 for success or 0 for failure. |
40 | 52 | ||
41 | EVP_SealFinal() returns 0 if the decrypt failed or 1 for success. | 53 | EVP_OpenFinal() returns 0 if the decrypt failed or 1 for success. |
42 | 54 | ||
43 | =head1 SEE ALSO | 55 | =head1 SEE ALSO |
44 | 56 | ||
45 | L<evp(3)|evp(3)>,L<rand(3)|rand(3)> | 57 | L<evp(3)|evp(3)>, L<rand(3)|rand(3)>, |
46 | L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>, | 58 | L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>, |
47 | L<EVP_SealInit(3)|EVP_SealInit(3)> | 59 | L<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 | |||
22 | using public key encryption. Data can then be encrypted using this | 22 | using public key encryption. Data can then be encrypted using this |
23 | key. | 23 | key. |
24 | 24 | ||
25 | EVP_SealInit() initialises a cipher context B<ctx> for encryption | 25 | EVP_SealInit() initializes a cipher context B<ctx> for encryption |
26 | with cipher B<type> using a random secret key and IV supplied in | 26 | with cipher B<type> using a random secret key and IV supplied in |
27 | the B<iv> parameter. B<type> is normally supplied by a function such | 27 | the B<iv> parameter. B<type> is normally supplied by a function such |
28 | as EVP_des_cbc(). The secret key is encrypted using one or more public | 28 | as 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 | ||
44 | EVP_SealInit() returns -1 on error or B<npubk> if successful. | 44 | EVP_SealInit() returns 0 on error or B<npubk> if successful. |
45 | 45 | ||
46 | EVP_SealUpdate() and EVP_SealFinal() do not return values. | 46 | EVP_SealUpdate() and EVP_SealFinal() return 1 for success and 0 for |
47 | failure. | ||
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 | |||
59 | bulk encryption and the small random symmetric key used is transferred | 60 | bulk encryption and the small random symmetric key used is transferred |
60 | using public key encryption. | 61 | using public key encryption. |
61 | 62 | ||
63 | It is possible to call EVP_SealInit() twice in the same way as | ||
64 | EVP_EncryptInit(). The first call should have B<npubk> set to 0 | ||
65 | and (after setting any cipher parameters) it should be called again | ||
66 | with B<type> set to NULL. | ||
67 | |||
62 | =head1 SEE ALSO | 68 | =head1 SEE ALSO |
63 | 69 | ||
64 | L<evp(3)|evp(3)>,L<rand(3)|rand(3)> | 70 | L<evp(3)|evp(3)>, L<rand(3)|rand(3)>, |
65 | L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>, | 71 | L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>, |
66 | L<EVP_OpenInit(3)|EVP_OpenInit(3)> | 72 | L<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 | |||
19 | The EVP signature routines are a high level interface to digital | 21 | The EVP signature routines are a high level interface to digital |
20 | signatures. | 22 | signatures. |
21 | 23 | ||
22 | EVP_SignInit() initialises a signing context B<ctx> to using digest | 24 | EVP_SignInit_ex() sets up signing context B<ctx> to use digest |
23 | B<type>: this will typically be supplied by a function such as | 25 | B<type> from ENGINE B<impl>. B<ctx> must be initialized with |
24 | EVP_sha1(). | 26 | EVP_MD_CTX_init() before calling this function. |
25 | 27 | ||
26 | EVP_SignUpdate() hashes B<cnt> bytes of data at B<d> into the | 28 | EVP_SignUpdate() hashes B<cnt> bytes of data at B<d> into the |
27 | signature context B<ctx>. This funtion can be called several times on the | 29 | signature context B<ctx>. This function can be called several times on the |
28 | same B<ctx> to include additional data. | 30 | same B<ctx> to include additional data. |
29 | 31 | ||
30 | EVP_SignFinal() signs the data in B<ctx> using the private key B<pkey> | 32 | EVP_SignFinal() signs the data in B<ctx> using the private key B<pkey> |
31 | and places the signature in B<sig>. If the B<s> parameter is not NULL | 33 | and places the signature in B<sig>. If the B<s> parameter is not NULL |
32 | then the number of bytes of data written (i.e. the length of the signature) | 34 | then the number of bytes of data written (i.e. the length of the signature) |
33 | will be written to the integer at B<s>, at most EVP_PKEY_size(pkey) bytes | 35 | will be written to the integer at B<s>, at most EVP_PKEY_size(pkey) bytes |
34 | will be written. After calling EVP_SignFinal() no additional calls to | 36 | will be written. |
35 | EVP_SignUpdate() can be made, but EVP_SignInit() can be called to initialiase | 37 | |
36 | a new signature operation. | 38 | EVP_SignInit() initializes a signing context B<ctx> to use the default |
39 | implementation of digest B<type>. | ||
37 | 40 | ||
38 | EVP_PKEY_size() returns the maximum size of a signature in bytes. The actual | 41 | EVP_PKEY_size() returns the maximum size of a signature in bytes. The actual |
39 | signature returned by EVP_SignFinal() may be smaller. | 42 | signature returned by EVP_SignFinal() may be smaller. |
40 | 43 | ||
41 | =head1 RETURN VALUES | 44 | =head1 RETURN VALUES |
42 | 45 | ||
43 | EVP_SignInit() and EVP_SignUpdate() do not return values. | 46 | EVP_SignInit_ex(), EVP_SignUpdate() and EVP_SignFinal() return 1 |
44 | 47 | for success and 0 for failure. | |
45 | EVP_SignFinal() returns 1 for success and 0 for failure. | ||
46 | 48 | ||
47 | EVP_PKEY_size() returns the maximum size of a signature in bytes. | 49 | EVP_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 | |||
63 | or the operation will fail. The random number generator does not need to be | 65 | or the operation will fail. The random number generator does not need to be |
64 | seeded for RSA signatures. | 66 | seeded for RSA signatures. |
65 | 67 | ||
68 | The call to EVP_SignFinal() internally finalizes a copy of the digest context. | ||
69 | This means that calls to EVP_SignUpdate() and EVP_SignFinal() can be called | ||
70 | later to digest and sign additional data. | ||
71 | |||
72 | Since only a copy of the digest context is ever finalized the context must | ||
73 | be cleaned up after use by calling EVP_MD_CTX_cleanup() or a memory leak | ||
74 | will occur. | ||
75 | |||
66 | =head1 BUGS | 76 | =head1 BUGS |
67 | 77 | ||
68 | Several of the functions do not return values: maybe they should. Although the | 78 | Older versions of this documentation wrongly stated that calls to |
69 | internal digest operations will never fail some future hardware based operations | 79 | EVP_SignUpdate() could not be made after calling EVP_SignFinal(). |
70 | might. | ||
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)> | |||
82 | EVP_SignInit(), EVP_SignUpdate() and EVP_SignFinal() are | 91 | EVP_SignInit(), EVP_SignUpdate() and EVP_SignFinal() are |
83 | available in all versions of SSLeay and OpenSSL. | 92 | available in all versions of SSLeay and OpenSSL. |
84 | 93 | ||
94 | EVP_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 | ||
17 | The EVP signature verification routines are a high level interface to digital | 19 | The EVP signature verification routines are a high level interface to digital |
18 | signatures. | 20 | signatures. |
19 | 21 | ||
20 | EVP_VerifyInit() initialises a verification context B<ctx> to using digest | 22 | EVP_VerifyInit_ex() sets up verification context B<ctx> to use digest |
21 | B<type>: this will typically be supplied by a function such as EVP_sha1(). | 23 | B<type> from ENGINE B<impl>. B<ctx> must be initialized by calling |
24 | EVP_MD_CTX_init() before calling this function. | ||
22 | 25 | ||
23 | EVP_VerifyUpdate() hashes B<cnt> bytes of data at B<d> into the | 26 | EVP_VerifyUpdate() hashes B<cnt> bytes of data at B<d> into the |
24 | verification context B<ctx>. This funtion can be called several times on the | 27 | verification context B<ctx>. This function can be called several times on the |
25 | same B<ctx> to include additional data. | 28 | same B<ctx> to include additional data. |
26 | 29 | ||
27 | EVP_VerifyFinal() verifies the data in B<ctx> using the public key B<pkey> | 30 | EVP_VerifyFinal() verifies the data in B<ctx> using the public key B<pkey> |
28 | and against the B<siglen> bytes at B<sigbuf>. After calling EVP_VerifyFinal() | 31 | and against the B<siglen> bytes at B<sigbuf>. |
29 | no additional calls to EVP_VerifyUpdate() can be made, but EVP_VerifyInit() | 32 | |
30 | can be called to initialiase a new verification operation. | 33 | EVP_VerifyInit() initializes verification context B<ctx> to use the default |
34 | implementation of digest B<type>. | ||
31 | 35 | ||
32 | =head1 RETURN VALUES | 36 | =head1 RETURN VALUES |
33 | 37 | ||
34 | EVP_VerifyInit() and EVP_VerifyUpdate() do not return values. | 38 | EVP_VerifyInit_ex() and EVP_VerifyUpdate() return 1 for success and 0 for |
39 | failure. | ||
35 | 40 | ||
36 | EVP_VerifyFinal() returns 1 for a correct signature, 0 for failure and -1 if some | 41 | EVP_VerifyFinal() returns 1 for a correct signature, 0 for failure and -1 if some |
37 | other error occurred. | 42 | other error occurred. |
@@ -49,14 +54,22 @@ digest algorithm must be used with the correct public key type. A list of | |||
49 | algorithms and associated public key algorithms appears in | 54 | algorithms and associated public key algorithms appears in |
50 | L<EVP_DigestInit(3)|EVP_DigestInit(3)>. | 55 | L<EVP_DigestInit(3)|EVP_DigestInit(3)>. |
51 | 56 | ||
57 | The call to EVP_VerifyFinal() internally finalizes a copy of the digest context. | ||
58 | This means that calls to EVP_VerifyUpdate() and EVP_VerifyFinal() can be called | ||
59 | later to digest and verify additional data. | ||
60 | |||
61 | Since only a copy of the digest context is ever finalized the context must | ||
62 | be cleaned up after use by calling EVP_MD_CTX_cleanup() or a memory leak | ||
63 | will occur. | ||
64 | |||
52 | =head1 BUGS | 65 | =head1 BUGS |
53 | 66 | ||
54 | Several of the functions do not return values: maybe they should. Although the | 67 | Older versions of this documentation wrongly stated that calls to |
55 | internal digest operations will never fail some future hardware based operations | 68 | EVP_VerifyUpdate() could not be made after calling EVP_VerifyFinal(). |
56 | might. | ||
57 | 69 | ||
58 | =head1 SEE ALSO | 70 | =head1 SEE ALSO |
59 | 71 | ||
72 | L<evp(3)|evp(3)>, | ||
60 | L<EVP_SignInit(3)|EVP_SignInit(3)>, | 73 | L<EVP_SignInit(3)|EVP_SignInit(3)>, |
61 | L<EVP_DigestInit(3)|EVP_DigestInit(3)>, L<err(3)|err(3)>, | 74 | L<EVP_DigestInit(3)|EVP_DigestInit(3)>, L<err(3)|err(3)>, |
62 | L<evp(3)|evp(3)>, L<hmac(3)|hmac(3)>, L<md2(3)|md2(3)>, | 75 | L<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)> | |||
68 | EVP_VerifyInit(), EVP_VerifyUpdate() and EVP_VerifyFinal() are | 81 | EVP_VerifyInit(), EVP_VerifyUpdate() and EVP_VerifyFinal() are |
69 | available in all versions of SSLeay and OpenSSL. | 82 | available in all versions of SSLeay and OpenSSL. |
70 | 83 | ||
84 | EVP_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 | ||
5 | OPENSSL_VERSION_NUMBER, SSLeay - get OpenSSL version number | 5 | OPENSSL_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 | ||
17 | OPENSSL_VERSION_NUMBER is a numeric release version identifier: | 18 | OPENSSL_VERSION_NUMBER is a numeric release version identifier: |
18 | 19 | ||
20 | MMNNFFPPS: major minor fix patch status | ||
21 | |||
22 | The status nibble has one of the values 0 for development, 1 to e for betas | ||
23 | 1 to 14, and f for release. | ||
24 | |||
25 | for example | ||
26 | |||
27 | 0x000906000 == 0.9.6 dev | ||
28 | 0x000906023 == 0.9.6b beta 3 | ||
29 | 0x00090605f == 0.9.6e release | ||
30 | |||
31 | Versions prior to 0.9.3 have identifiers E<lt> 0x0930. | ||
32 | Versions between 0.9.3 and 0.9.5 had a version identifier with this | ||
33 | interpretation: | ||
34 | |||
19 | MMNNFFRBB major minor fix final beta/patch | 35 | MMNNFFRBB major minor fix final beta/patch |
20 | 36 | ||
21 | for example | 37 | for 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 | ||
26 | Versions prior to 0.9.3 have identifiers E<lt> 0x0930. | 42 | Version 0.9.5a had an interim interpretation that is like the current one, |
43 | except the patch level got the highest bit set, to keep continuity. The | ||
44 | number was therefore 0x0090581f. | ||
45 | |||
46 | |||
27 | For backward compatibility, SSLEAY_VERSION_NUMBER is also defined. | 47 | For backward compatibility, SSLEAY_VERSION_NUMBER is also defined. |
28 | 48 | ||
29 | SSLeay() returns this number. The return value can be compared to the | 49 | SSLeay() returns this number. The return value can be compared to the |
30 | macro to make sure that the correct version of the library has been | 50 | macro to make sure that the correct version of the library has been |
31 | loaded, especially when using DLLs on Windows systems. | 51 | loaded, especially when using DLLs on Windows systems. |
32 | 52 | ||
53 | SSLeay_version() returns different strings depending on B<t>: | ||
54 | |||
55 | =over 4 | ||
56 | |||
57 | =item SSLEAY_VERSION | ||
58 | |||
59 | The 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 | |||
64 | The compiler flags set for the compilation process in the form | ||
65 | "compiler: ..." if available or "compiler: information not available" | ||
66 | otherwise. | ||
67 | |||
68 | =item SSLEAY_BUILT_ON | ||
69 | |||
70 | The date of the build process in the form "built on: ..." if available | ||
71 | or "built on: date not available" otherwise. | ||
72 | |||
73 | =item SSLEAY_PLATFORM | ||
74 | |||
75 | The "Configure" target of the library build in the form "platform: ..." | ||
76 | if available or "platform: information not available" otherwise. | ||
77 | |||
78 | =item SSLEAY_DIR | ||
79 | |||
80 | The "OPENSSLDIR" setting of the library build in the form "OPENSSLDIR: "..."" | ||
81 | if available or "OPENSSLDIR: N/A" otherwise. | ||
82 | |||
83 | =back | ||
84 | |||
85 | For an unknown B<t>, the text "not available" is returned. | ||
86 | |||
33 | =head1 RETURN VALUE | 87 | =head1 RETURN VALUE |
34 | 88 | ||
35 | The version number. | 89 | The version number. |
@@ -42,5 +96,6 @@ L<crypto(3)|crypto(3)> | |||
42 | 96 | ||
43 | SSLeay() and SSLEAY_VERSION_NUMBER are available in all versions of SSLeay and OpenSSL. | 97 | SSLeay() and SSLEAY_VERSION_NUMBER are available in all versions of SSLeay and OpenSSL. |
44 | OPENSSL_VERSION_NUMBER is available in all versions of OpenSSL. | 98 | OPENSSL_VERSION_NUMBER is available in all versions of OpenSSL. |
99 | B<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 | ||
5 | OpenSSL_add_all_algorithms() - add algorithms to internal table | 5 | OpenSSL_add_all_algorithms, OpenSSL_add_all_ciphers, OpenSSL_add_all_digests - |
6 | add 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 | |||
43 | needs to lookup algorithms. | 44 | needs to lookup algorithms. |
44 | 45 | ||
45 | The cipher and digest lookup functions are used in many parts of the library. If | 46 | The cipher and digest lookup functions are used in many parts of the library. If |
46 | the table is not initialised several functions will misbehave and complain they | 47 | the table is not initialized several functions will misbehave and complain they |
47 | cannot find algorithms. This includes the PEM, PKCS#12, SSL and S/MIME libraries. | 48 | cannot find algorithms. This includes the PEM, PKCS#12, SSL and S/MIME libraries. |
48 | This is a common query in the OpenSSL mailing lists. | 49 | This 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 | ||
5 | RAND_add, RAND_seed, RAND_screen - add entropy to the PRNG | 5 | RAND_add, RAND_seed, RAND_status, RAND_event, RAND_screen - add |
6 | entropy 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 | ||
41 | RAND_seed() is equivalent to RAND_add() when B<num == entropy>. | 43 | RAND_seed() is equivalent to RAND_add() when B<num == entropy>. |
42 | 44 | ||
45 | RAND_event() collects the entropy from Windows events such as mouse | ||
46 | movements and other user interaction. It should be called with the | ||
47 | B<iMsg>, B<wParam> and B<lParam> arguments of I<all> messages sent to | ||
48 | the window procedure. It will estimate the entropy contained in the | ||
49 | event message (if any), and add it to the PRNG. The program can then | ||
50 | process the messages as usual. | ||
51 | |||
43 | The RAND_screen() function is available for the convenience of Windows | 52 | The RAND_screen() function is available for the convenience of Windows |
44 | programmers. It adds the current contents of the screen to the PRNG. | 53 | programmers. It adds the current contents of the screen to the PRNG. |
45 | For applications that can catch Windows events, seeding the PRNG with | 54 | For applications that can catch Windows events, seeding the PRNG by |
46 | the parameters of B<WM_MOUSEMOVE> events is a significantly better | 55 | calling RAND_event() is a significantly better source of |
47 | source of randomness. It should be noted that both methods cannot be | 56 | randomness. It should be noted that both methods cannot be used on |
48 | used on servers that run without user interaction. | 57 | servers that run without user interaction. |
49 | 58 | ||
50 | =head1 RETURN VALUES | 59 | =head1 RETURN VALUES |
51 | 60 | ||
52 | RAND_status() returns 1 if the PRNG has been seeded with enough data, | 61 | RAND_status() and RAND_event() return 1 if the PRNG has been seeded |
53 | 0 otherwise. | 62 | with enough data, 0 otherwise. |
54 | 63 | ||
55 | The other functions do not return values. | 64 | The 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 | ||
64 | RAND_seed() and RAND_screen() are available in all versions of SSLeay | 73 | RAND_seed() and RAND_screen() are available in all versions of SSLeay |
65 | and OpenSSL. RAND_add() and RAND_status() have been added in OpenSSL | 74 | and OpenSSL. RAND_add() and RAND_status() have been added in OpenSSL |
66 | 0.9.5. | 75 | 0.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 | ||
39 | The components point to the implementation of RAND_seed(), | 40 | The components point to the implementation of RAND_seed(), |
40 | RAND_bytes(), RAND_cleanup(), RAND_add() and RAND_pseudo_rand(). | 41 | RAND_bytes(), RAND_cleanup(), RAND_add(), RAND_pseudo_rand() |
42 | and RAND_status(). | ||
41 | Each component may be NULL if the function is not implemented. | 43 | Each 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 | ||
20 | The modulus size will be B<num> bits, and the public exponent will be | 20 | The modulus size will be B<num> bits, and the public exponent will be |
21 | B<e>. Key sizes with B<num> E<lt> 1024 should be considered insecure. | 21 | B<e>. Key sizes with B<num> E<lt> 1024 should be considered insecure. |
22 | The exponent is an odd number, typically 3 or 65535. | 22 | The exponent is an odd number, typically 3, 17 or 65537. |
23 | 23 | ||
24 | A callback function may be used to provide feedback about the | 24 | A callback function may be used to provide feedback about the |
25 | progress of the key generation. If B<callback> is not B<NULL>, it | 25 | progress 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 | ||
5 | RSA_print, RSA_print_fp, DHparams_print, DHparams_print_fp - print | 5 | RSA_print, RSA_print_fp, DHparams_print, DHparams_print_fp, DSA_print, |
6 | cryptographic parameters | 6 | DSA_print_fp, DHparams_print, DHparams_print_fp - print cryptographic |
7 | parameters | ||
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 | ||
49 | B<flen> must be less than RSA_size(B<rsa>) - 11 for the PKCS #1 v1.5 | 49 | B<flen> must be less than RSA_size(B<rsa>) - 11 for the PKCS #1 v1.5 |
50 | based padding modes, and less than RSA_size(B<rsa>) - 21 for | 50 | based padding modes, and less than RSA_size(B<rsa>) - 41 for |
51 | RSA_PKCS1_OAEP_PADDING. The random number generator must be seeded | 51 | RSA_PKCS1_OAEP_PADDING. The random number generator must be seeded |
52 | prior to calling RSA_public_encrypt(). | 52 | prior to calling RSA_public_encrypt(). |
53 | 53 | ||
@@ -74,10 +74,6 @@ SSL, PKCS #1 v2.0 | |||
74 | 74 | ||
75 | L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_size(3)|RSA_size(3)> | 75 | L<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 | |||
79 | The 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 | ||
83 | The B<padding> argument was added in SSLeay 0.8. RSA_NO_PADDING is | 79 | The 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 | ||
5 | RSA_set_default_method, RSA_get_default_method, RSA_set_method, | 5 | RSA_set_default_method, RSA_get_default_method, RSA_set_method, |
6 | RSA_get_method, RSA_PKCS1_SSLeay, RSA_PKCS1_RSAref, | 6 | RSA_get_method, RSA_PKCS1_SSLeay, |
7 | RSA_PKCS1_null_method, RSA_flags, RSA_new_method - select RSA method | 7 | RSA_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 | |||
34 | operations. By modifying the method, alternative implementations | 33 | operations. By modifying the method, alternative implementations |
35 | such as hardware accelerators may be used. | 34 | such as hardware accelerators may be used. |
36 | 35 | ||
37 | Initially, the default is to use the OpenSSL internal implementation, | 36 | Initially, the default is to use the OpenSSL internal implementation. |
38 | unless OpenSSL was configured with the C<rsaref> or C<-DRSA_NULL> | 37 | RSA_PKCS1_SSLeay() returns a pointer to that method. |
39 | options. RSA_PKCS1_SSLeay() returns a pointer to that method. | ||
40 | |||
41 | RSA_PKCS1_RSAref() returns a pointer to a method that uses the RSAref | ||
42 | library. This is the default method in the C<rsaref> configuration; | ||
43 | the function is not available in other configurations. | ||
44 | RSA_null_method() returns a pointer to a method that does not support | ||
45 | the RSA transformation. It is the default if OpenSSL is compiled with | ||
46 | C<-DRSA_NULL>. These methods may be useful in the USA because of a | ||
47 | patent on the RSA cryptosystem. | ||
48 | 38 | ||
49 | RSA_set_default_method() makes B<meth> the default method for all B<RSA> | 39 | RSA_set_default_openssl_method() makes B<meth> the default method for all B<RSA> |
50 | structures created later. | 40 | structures created later. B<NB:> This is true only whilst the default engine |
41 | for RSA operations remains as "openssl". ENGINEs provide an | ||
42 | encapsulation for implementations of one or more algorithms at a time, and all | ||
43 | the RSA functions mentioned here operate within the scope of the default | ||
44 | "openssl" engine. | ||
51 | 45 | ||
52 | RSA_get_default_method() returns a pointer to the current default | 46 | RSA_get_default_openssl_method() returns a pointer to the current default |
53 | method. | 47 | method for the "openssl" engine. |
54 | 48 | ||
55 | RSA_set_method() selects B<meth> for all operations using the key | 49 | RSA_set_method() selects B<engine> for all operations using the key |
56 | B<rsa>. | 50 | B<rsa>. |
57 | 51 | ||
58 | RSA_get_method() returns a pointer to the method currently selected | 52 | RSA_get_method() returns a pointer to the RSA_METHOD from the currently |
59 | for B<rsa>. | 53 | selected ENGINE for B<rsa>. |
60 | 54 | ||
61 | RSA_flags() returns the B<flags> that are set for B<rsa>'s current method. | 55 | RSA_flags() returns the B<flags> that are set for B<rsa>'s current method. |
62 | 56 | ||
63 | RSA_new_method() allocates and initializes an B<RSA> structure so that | 57 | RSA_new_method() allocates and initializes an RSA structure so that |
64 | B<method> will be used for the RSA operations. If B<method> is B<NULL>, | 58 | B<engine> will be used for the RSA operations. If B<engine> is NULL, |
65 | the default method is used. | 59 | the 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 | ||
129 | RSA_PKCS1_SSLeay(), RSA_PKCS1_RSAref(), RSA_PKCS1_null_method(), | 124 | RSA_PKCS1_SSLeay(), RSA_PKCS1_null_method(), RSA_get_default_openssl_method() |
130 | RSA_get_default_method() and RSA_get_method() return pointers to the | 125 | and RSA_get_method() return pointers to the respective RSA_METHODs. |
131 | respective B<RSA_METHOD>s. | ||
132 | 126 | ||
133 | RSA_set_default_method() returns no value. | 127 | RSA_set_default_openssl_method() returns no value. |
134 | 128 | ||
135 | RSA_set_method() returns a pointer to the B<RSA_METHOD> previously | 129 | RSA_set_method() selects B<engine> as the engine that will be responsible for |
136 | associated with B<rsa>. | 130 | all operations using the structure B<rsa>. If this function completes successfully, |
131 | then the B<rsa> structure will have its own functional reference of B<engine>, so | ||
132 | the caller should remember to free their own reference to B<engine> when they are | ||
133 | finished with it. NB: An ENGINE's RSA_METHOD can be retrieved (or set) by | ||
134 | ENGINE_get_RSA() or ENGINE_set_RSA(). | ||
137 | 135 | ||
138 | RSA_new_method() returns B<NULL> and sets an error code that can be | 136 | RSA_new_method() returns NULL and sets an error code that can be |
139 | obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise it | 137 | obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise |
140 | returns a pointer to the newly allocated structure. | 138 | it 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 | |||
150 | well as the rsa_sign and rsa_verify components of RSA_METHOD were | 148 | well as the rsa_sign and rsa_verify components of RSA_METHOD were |
151 | added in OpenSSL 0.9.4. | 149 | added in OpenSSL 0.9.4. |
152 | 150 | ||
151 | RSA_set_default_openssl_method() and RSA_get_default_openssl_method() | ||
152 | replaced RSA_set_default_method() and RSA_get_default_method() respectively, | ||
153 | and RSA_set_method() and RSA_new_method() were altered to use B<ENGINE>s | ||
154 | rather 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)>. | |||
137 | L<bn_internal(3)|bn_internal(3)>, | 147 | L<bn_internal(3)|bn_internal(3)>, |
138 | L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, | 148 | L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, |
139 | L<BN_new(3)|BN_new(3)>, L<BN_CTX_new(3)|BN_CTX_new(3)>, | 149 | L<BN_new(3)|BN_new(3)>, L<BN_CTX_new(3)|BN_CTX_new(3)>, |
140 | L<BN_copy(3)|BN_copy(3)>, L<BN_num_bytes(3)|BN_num_bytes(3)>, | 150 | L<BN_copy(3)|BN_copy(3)>, L<BN_swap(3)|BN_swap(3)>, L<BN_num_bytes(3)|BN_num_bytes(3)>, |
141 | L<BN_add(3)|BN_add(3)>, L<BN_add_word(3)|BN_add_word(3)>, | 151 | L<BN_add(3)|BN_add(3)>, L<BN_add_word(3)|BN_add_word(3)>, |
142 | L<BN_cmp(3)|BN_cmp(3)>, L<BN_zero(3)|BN_zero(3)>, L<BN_rand(3)|BN_rand(3)>, | 152 | L<BN_cmp(3)|BN_cmp(3)>, L<BN_zero(3)|BN_zero(3)>, L<BN_rand(3)|BN_rand(3)>, |
143 | L<BN_generate_prime(3)|BN_generate_prime(3)>, L<BN_set_bit(3)|BN_set_bit(3)>, | 153 | L<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 | ||
13 | The EVP library provided a high-level interface to cryptographic | 13 | The EVP library provides a high-level interface to cryptographic |
14 | functions. | 14 | functions. |
15 | 15 | ||
16 | B<EVP_Seal>I<...> and B<EVP_Open>I<...> provide public key encryption | 16 | B<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: | |||
86 | In public keys, the private exponent and the related secret values are | 86 | In public keys, the private exponent and the related secret values are |
87 | B<NULL>. | 87 | B<NULL>. |
88 | 88 | ||
89 | B<dmp1>, B<dmq1> and B<iqmp> may be B<NULL> in private keys, but the | 89 | B<p>, B<q>, B<dmp1>, B<dmq1> and B<iqmp> may be B<NULL> in private |
90 | RSA operations are much faster when these values are available. | 90 | keys, but the RSA operations are much faster when these values are |
91 | available. | ||
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 | ||
98 | RSA is covered by a US patent which expires in September 2000. | 99 | RSA was covered by a US patent which expired in September 2000. |
99 | 100 | ||
100 | =head1 SEE ALSO | 101 | =head1 SEE ALSO |
101 | 102 | ||