diff options
Diffstat (limited to 'src/lib/libcrypto/doc')
-rw-r--r-- | src/lib/libcrypto/doc/DH_set_method.pod | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/doc/DSA_set_method.pod | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/doc/ERR_get_error.pod | 29 | ||||
-rw-r--r-- | src/lib/libcrypto/doc/EVP_BytesToKey.pod | 67 | ||||
-rw-r--r-- | src/lib/libcrypto/doc/EVP_DigestInit.pod | 119 | ||||
-rw-r--r-- | src/lib/libcrypto/doc/EVP_EncryptInit.pod | 289 | ||||
-rw-r--r-- | src/lib/libcrypto/doc/EVP_SignInit.pod | 39 | ||||
-rw-r--r-- | src/lib/libcrypto/doc/EVP_VerifyInit.pod | 36 | ||||
-rw-r--r-- | src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod | 29 | ||||
-rw-r--r-- | src/lib/libcrypto/doc/RSA_generate_key.pod | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/doc/RSA_public_encrypt.pod | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/doc/RSA_set_method.pod | 26 | ||||
-rw-r--r-- | src/lib/libcrypto/doc/bn.pod | 17 | ||||
-rw-r--r-- | src/lib/libcrypto/doc/rsa.pod | 1 |
14 files changed, 484 insertions, 180 deletions
diff --git a/src/lib/libcrypto/doc/DH_set_method.pod b/src/lib/libcrypto/doc/DH_set_method.pod index 62088eea1b..d990bf8786 100644 --- a/src/lib/libcrypto/doc/DH_set_method.pod +++ b/src/lib/libcrypto/doc/DH_set_method.pod | |||
@@ -82,8 +82,8 @@ the default engine for Diffie-Hellman opertaions is used. | |||
82 | 82 | ||
83 | =head1 RETURN VALUES | 83 | =head1 RETURN VALUES |
84 | 84 | ||
85 | DH_OpenSSL() and DH_get_default_method() return pointers to the respective | 85 | DH_OpenSSL() and DH_get_default_openssl_method() return pointers to the |
86 | DH_METHODs. | 86 | respective B<DH_METHOD>s. |
87 | 87 | ||
88 | DH_set_default_openssl_method() returns no value. | 88 | DH_set_default_openssl_method() returns no value. |
89 | 89 | ||
diff --git a/src/lib/libcrypto/doc/DSA_set_method.pod b/src/lib/libcrypto/doc/DSA_set_method.pod index c56dfd0f47..36a1052d27 100644 --- a/src/lib/libcrypto/doc/DSA_set_method.pod +++ b/src/lib/libcrypto/doc/DSA_set_method.pod | |||
@@ -90,7 +90,7 @@ struct | |||
90 | =head1 RETURN VALUES | 90 | =head1 RETURN VALUES |
91 | 91 | ||
92 | DSA_OpenSSL() and DSA_get_default_openssl_method() return pointers to the | 92 | DSA_OpenSSL() and DSA_get_default_openssl_method() return pointers to the |
93 | respective DSA_METHODs. | 93 | respective B<DSA_METHOD>s. |
94 | 94 | ||
95 | DSA_set_default_openssl_method() returns no value. | 95 | DSA_set_default_openssl_method() returns no value. |
96 | 96 | ||
diff --git a/src/lib/libcrypto/doc/ERR_get_error.pod b/src/lib/libcrypto/doc/ERR_get_error.pod index 3551bacb8d..9fdedbcb91 100644 --- a/src/lib/libcrypto/doc/ERR_get_error.pod +++ b/src/lib/libcrypto/doc/ERR_get_error.pod | |||
@@ -2,8 +2,10 @@ | |||
2 | 2 | ||
3 | =head1 NAME | 3 | =head1 NAME |
4 | 4 | ||
5 | ERR_get_error, ERR_peek_error, ERR_get_error_line, ERR_peek_error_line, | 5 | ERR_get_error, ERR_peek_error, ERR_peek_last_error, |
6 | ERR_get_error_line_data, ERR_peek_error_line_data - obtain error code and data | 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 | ||
7 | 9 | ||
8 | =head1 SYNOPSIS | 10 | =head1 SYNOPSIS |
9 | 11 | ||
@@ -11,22 +13,29 @@ ERR_get_error_line_data, ERR_peek_error_line_data - obtain error code and data | |||
11 | 13 | ||
12 | unsigned long ERR_get_error(void); | 14 | unsigned long ERR_get_error(void); |
13 | unsigned long ERR_peek_error(void); | 15 | unsigned long ERR_peek_error(void); |
16 | unsigned long ERR_peek_last_error(void); | ||
14 | 17 | ||
15 | unsigned long ERR_get_error_line(const char **file, int *line); | 18 | unsigned long ERR_get_error_line(const char **file, int *line); |
16 | unsigned long ERR_peek_error_line(const char **file, int *line); | 19 | unsigned long ERR_peek_error_line(const char **file, int *line); |
20 | unsigned long ERR_peek_last_error_line(const char **file, int *line); | ||
17 | 21 | ||
18 | unsigned long ERR_get_error_line_data(const char **file, int *line, | 22 | unsigned long ERR_get_error_line_data(const char **file, int *line, |
19 | const char **data, int *flags); | 23 | const char **data, int *flags); |
20 | unsigned long ERR_peek_error_line_data(const char **file, int *line, | 24 | unsigned long ERR_peek_error_line_data(const char **file, int *line, |
21 | const char **data, int *flags); | 25 | const char **data, int *flags); |
26 | unsigned long ERR_peek_last_error_line_data(const char **file, int *line, | ||
27 | const char **data, int *flags); | ||
22 | 28 | ||
23 | =head1 DESCRIPTION | 29 | =head1 DESCRIPTION |
24 | 30 | ||
25 | 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 |
26 | queue and removes the entry. This function can be called repeatedly | 32 | queue and removes the entry. This function can be called repeatedly |
27 | until there are no more error codes to return. | 33 | until there are no more error codes to return. |
28 | 34 | ||
29 | 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 | ||
30 | error queue without modifying it. | 39 | error queue without modifying it. |
31 | 40 | ||
32 | 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 |
@@ -34,12 +43,14 @@ location and reason of the error, and | |||
34 | 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 |
35 | messages. | 44 | messages. |
36 | 45 | ||
37 | ERR_get_error_line() and ERR_peek_error_line() are the same as the | 46 | ERR_get_error_line(), ERR_peek_error_line() and |
38 | 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 | ||
39 | 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>. |
40 | 50 | ||
41 | ERR_get_error_line_data() and ERR_peek_error_line_data() store | 51 | ERR_get_error_line_data(), ERR_peek_error_line_data() and |
42 | 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> | ||
43 | 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 |
44 | if *B<flags>&B<ERR_TXT_STRING>. If it has been allocated by OPENSSL_malloc(), | 55 | if *B<flags>&B<ERR_TXT_STRING>. If it has been allocated by OPENSSL_malloc(), |
45 | *B<flags>&B<ERR_TXT_MALLOCED> is true. | 56 | *B<flags>&B<ERR_TXT_MALLOCED> is true. |
@@ -59,5 +70,7 @@ ERR_get_error(), ERR_peek_error(), ERR_get_error_line() and | |||
59 | 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 |
60 | 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() |
61 | 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. | ||
62 | 75 | ||
63 | =cut | 76 | =cut |
diff --git a/src/lib/libcrypto/doc/EVP_BytesToKey.pod b/src/lib/libcrypto/doc/EVP_BytesToKey.pod new file mode 100644 index 0000000000..5ce4add082 --- /dev/null +++ b/src/lib/libcrypto/doc/EVP_BytesToKey.pod | |||
@@ -0,0 +1,67 @@ | |||
1 | =pod | ||
2 | |||
3 | =head1 NAME | ||
4 | |||
5 | EVP_BytesToKey - password based encryption routine | ||
6 | |||
7 | =head1 SYNOPSIS | ||
8 | |||
9 | #include <openssl/evp.h> | ||
10 | |||
11 | int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md, | ||
12 | const unsigned char *salt, | ||
13 | const unsigned char *data, int datal, int count, | ||
14 | unsigned char *key,unsigned char *iv); | ||
15 | |||
16 | =head1 DESCRIPTION | ||
17 | |||
18 | EVP_BytesToKey() derives a key and IV from various parameters. B<type> is | ||
19 | the cipher to derive the key and IV for. B<md> is the message digest to use. | ||
20 | The B<salt> paramter is used as a salt in the derivation: it should point to | ||
21 | an 8 byte buffer or NULL if no salt is used. B<data> is a buffer containing | ||
22 | B<datal> bytes which is used to derive the keying data. B<count> is the | ||
23 | iteration count to use. The derived key and IV will be written to B<key> | ||
24 | and B<iv> respectively. | ||
25 | |||
26 | =head1 NOTES | ||
27 | |||
28 | A typical application of this function is to derive keying material for an | ||
29 | encryption algorithm from a password in the B<data> parameter. | ||
30 | |||
31 | Increasing the B<count> parameter slows down the algorithm which makes it | ||
32 | harder for an attacker to peform a brute force attack using a large number | ||
33 | of candidate passwords. | ||
34 | |||
35 | If the total key and IV length is less than the digest length and | ||
36 | B<MD5> is used then the derivation algorithm is compatible with PKCS#5 v1.5 | ||
37 | otherwise a non standard extension is used to derive the extra data. | ||
38 | |||
39 | Newer applications should use more standard algorithms such as PKCS#5 | ||
40 | v2.0 for key derivation. | ||
41 | |||
42 | =head1 KEY DERIVATION ALGORITHM | ||
43 | |||
44 | The key and IV is derived by concatenating D_1, D_2, etc until | ||
45 | enough data is available for the key and IV. D_i is defined as: | ||
46 | |||
47 | D_i = HASH^count(D_(i-1) || data || salt) | ||
48 | |||
49 | where || denotes concatentaion, D_0 is empty, HASH is the digest | ||
50 | algorithm in use, HASH^1(data) is simply HASH(data), HASH^2(data) | ||
51 | is HASH(HASH(data)) and so on. | ||
52 | |||
53 | The initial bytes are used for the key and the subsequent bytes for | ||
54 | the IV. | ||
55 | |||
56 | =head1 RETURN VALUES | ||
57 | |||
58 | EVP_BytesToKey() returns the size of the derived key in bytes. | ||
59 | |||
60 | =head1 SEE ALSO | ||
61 | |||
62 | L<evp(3)|evp(3)>, L<rand(3)|rand(3)>, | ||
63 | L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>, | ||
64 | |||
65 | =head1 HISTORY | ||
66 | |||
67 | =cut | ||
diff --git a/src/lib/libcrypto/doc/EVP_DigestInit.pod b/src/lib/libcrypto/doc/EVP_DigestInit.pod index fefc858f7e..acd4d0167a 100644 --- a/src/lib/libcrypto/doc/EVP_DigestInit.pod +++ b/src/lib/libcrypto/doc/EVP_DigestInit.pod | |||
@@ -2,9 +2,10 @@ | |||
2 | 2 | ||
3 | =head1 NAME | 3 | =head1 NAME |
4 | 4 | ||
5 | EVP_DigestInit, EVP_DigestUpdate, EVP_DigestFinal, EVP_MAX_MD_SIZE, | 5 | EVP_MD_CTX_init, EVP_MD_CTX_create, EVP_DigestInit_ex, EVP_DigestUpdate, |
6 | EVP_MD_CTX_copy, EVP_MD_type, EVP_MD_pkey_type, EVP_MD_size, EVP_MD_block_size, | 6 | EVP_DigestFinal_ex, EVP_MD_CTX_cleanup, EVP_MD_CTX_destroy, EVP_MAX_MD_SIZE, |
7 | EVP_MD_CTX_md, EVP_MD_CTX_size, EVP_MD_CTX_block_size, EVP_MD_CTX_type, | 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, | ||
8 | EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_dss, EVP_dss1, EVP_mdc2, | 9 | EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_dss, EVP_dss1, EVP_mdc2, |
9 | EVP_ripemd160, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj - | 10 | EVP_ripemd160, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj - |
10 | EVP digest routines | 11 | EVP digest routines |
@@ -13,15 +14,28 @@ EVP digest routines | |||
13 | 14 | ||
14 | #include <openssl/evp.h> | 15 | #include <openssl/evp.h> |
15 | 16 | ||
16 | void EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); | 17 | void EVP_MD_CTX_init(EVP_MD_CTX *ctx); |
17 | void EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); | 18 | EVP_MD_CTX *EVP_MD_CTX_create(void); |
18 | void EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, | 19 | |
20 | int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); | ||
21 | int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); | ||
22 | int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, | ||
19 | unsigned int *s); | 23 | unsigned int *s); |
20 | 24 | ||
21 | #define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */ | 25 | int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx); |
26 | void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx); | ||
27 | |||
28 | int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in); | ||
29 | |||
30 | int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); | ||
31 | int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, | ||
32 | unsigned int *s); | ||
22 | 33 | ||
23 | int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in); | 34 | int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in); |
24 | 35 | ||
36 | #define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */ | ||
37 | |||
38 | |||
25 | #define EVP_MD_type(e) ((e)->type) | 39 | #define EVP_MD_type(e) ((e)->type) |
26 | #define EVP_MD_pkey_type(e) ((e)->pkey_type) | 40 | #define EVP_MD_pkey_type(e) ((e)->pkey_type) |
27 | #define EVP_MD_size(e) ((e)->md_size) | 41 | #define EVP_MD_size(e) ((e)->md_size) |
@@ -32,15 +46,15 @@ EVP digest routines | |||
32 | #define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest) | 46 | #define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest) |
33 | #define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest) | 47 | #define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest) |
34 | 48 | ||
35 | EVP_MD *EVP_md_null(void); | 49 | const EVP_MD *EVP_md_null(void); |
36 | EVP_MD *EVP_md2(void); | 50 | const EVP_MD *EVP_md2(void); |
37 | EVP_MD *EVP_md5(void); | 51 | const EVP_MD *EVP_md5(void); |
38 | EVP_MD *EVP_sha(void); | 52 | const EVP_MD *EVP_sha(void); |
39 | EVP_MD *EVP_sha1(void); | 53 | const EVP_MD *EVP_sha1(void); |
40 | EVP_MD *EVP_dss(void); | 54 | const EVP_MD *EVP_dss(void); |
41 | EVP_MD *EVP_dss1(void); | 55 | const EVP_MD *EVP_dss1(void); |
42 | EVP_MD *EVP_mdc2(void); | 56 | const EVP_MD *EVP_mdc2(void); |
43 | EVP_MD *EVP_ripemd160(void); | 57 | const EVP_MD *EVP_ripemd160(void); |
44 | 58 | ||
45 | const EVP_MD *EVP_get_digestbyname(const char *name); | 59 | const EVP_MD *EVP_get_digestbyname(const char *name); |
46 | #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) | 60 | #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) |
@@ -50,25 +64,48 @@ EVP digest routines | |||
50 | 64 | ||
51 | 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. |
52 | 66 | ||
53 | EVP_DigestInit() initializes a digest context B<ctx> to use a digest | 67 | EVP_MD_CTX_init() initializes digest contet B<ctx>. |
54 | B<type>: this will typically be supplied by a function such as | 68 | |
55 | 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. | ||
56 | 75 | ||
57 | 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 |
58 | digest context B<ctx>. This function can be called several times on the | 77 | digest context B<ctx>. This function can be called several times on the |
59 | same B<ctx> to hash additional data. | 78 | same B<ctx> to hash additional data. |
60 | 79 | ||
61 | EVP_DigestFinal() retrieves the digest value from B<ctx> and places | 80 | EVP_DigestFinal_ex() retrieves the digest value from B<ctx> and places |
62 | 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 |
63 | 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 |
64 | 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. |
65 | After calling EVP_DigestFinal() no additional calls to EVP_DigestUpdate() | 84 | After calling EVP_DigestFinal_ex() no additional calls to EVP_DigestUpdate() |
66 | can be made, but EVP_DigestInit() can be called to initialize a new | 85 | can be made, but EVP_DigestInit_ex() can be called to initialize a new |
67 | digest operation. | 86 | digest operation. |
68 | 87 | ||
69 | 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 | ||
70 | 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 |
71 | 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. | ||
72 | 109 | ||
73 | 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 |
74 | 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 |
@@ -107,9 +144,10 @@ using, for example, OpenSSL_add_all_digests() for these functions to work. | |||
107 | 144 | ||
108 | =head1 RETURN VALUES | 145 | =head1 RETURN VALUES |
109 | 146 | ||
110 | 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. | ||
111 | 149 | ||
112 | 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. |
113 | 151 | ||
114 | 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 |
115 | corresponding OBJECT IDENTIFIER or NID_undef if none exists. | 153 | corresponding OBJECT IDENTIFIER or NID_undef if none exists. |
@@ -134,6 +172,19 @@ transparent to the digest used and much more flexible. | |||
134 | 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 |
135 | are still in common use. | 173 | are still in common use. |
136 | 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 | |||
137 | =head1 EXAMPLE | 188 | =head1 EXAMPLE |
138 | 189 | ||
139 | 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 |
@@ -165,10 +216,12 @@ digest name passed on the command line. | |||
165 | exit(1); | 216 | exit(1); |
166 | } | 217 | } |
167 | 218 | ||
168 | EVP_DigestInit(&mdctx, md); | 219 | EVP_MD_CTX_init(&mdctx); |
220 | EVP_DigestInit_ex(&mdctx, md, NULL); | ||
169 | EVP_DigestUpdate(&mdctx, mess1, strlen(mess1)); | 221 | EVP_DigestUpdate(&mdctx, mess1, strlen(mess1)); |
170 | EVP_DigestUpdate(&mdctx, mess2, strlen(mess2)); | 222 | EVP_DigestUpdate(&mdctx, mess2, strlen(mess2)); |
171 | EVP_DigestFinal(&mdctx, md_value, &md_len); | 223 | EVP_DigestFinal_ex(&mdctx, md_value, &md_len); |
224 | EVP_MD_CTX_cleanup(&mdctx); | ||
172 | 225 | ||
173 | printf("Digest is: "); | 226 | printf("Digest is: "); |
174 | for(i = 0; i < md_len; i++) printf("%02x", md_value[i]); | 227 | for(i = 0; i < md_len; i++) printf("%02x", md_value[i]); |
@@ -177,17 +230,10 @@ digest name passed on the command line. | |||
177 | 230 | ||
178 | =head1 BUGS | 231 | =head1 BUGS |
179 | 232 | ||
180 | Several of the functions do not return values: maybe they should. Although the | ||
181 | internal digest operations will never fail some future hardware based operations | ||
182 | might. | ||
183 | |||
184 | 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 |
185 | 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 |
186 | even though they are identical digests. | 235 | even though they are identical digests. |
187 | 236 | ||
188 | The size of an B<EVP_MD_CTX> structure is determined at compile time: this results | ||
189 | in code that must be recompiled if the size of B<EVP_MD_CTX> increases. | ||
190 | |||
191 | =head1 SEE ALSO | 237 | =head1 SEE ALSO |
192 | 238 | ||
193 | 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)>, |
@@ -199,4 +245,7 @@ L<SHA1(3)|SHA1(3)> | |||
199 | EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() are | 245 | EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() are |
200 | available in all versions of SSLeay and OpenSSL. | 246 | available in all versions of SSLeay and OpenSSL. |
201 | 247 | ||
248 | EVP_DigestInit_ex(), EVP_DigestFinal_ex() and EVP_MD_CTX_copy_ex() | ||
249 | were added in OpenSSL 0.9.7. | ||
250 | |||
202 | =cut | 251 | =cut |
diff --git a/src/lib/libcrypto/doc/EVP_EncryptInit.pod b/src/lib/libcrypto/doc/EVP_EncryptInit.pod index 9afe2396e2..371b6a2287 100644 --- a/src/lib/libcrypto/doc/EVP_EncryptInit.pod +++ b/src/lib/libcrypto/doc/EVP_EncryptInit.pod | |||
@@ -2,43 +2,65 @@ | |||
2 | 2 | ||
3 | =head1 NAME | 3 | =head1 NAME |
4 | 4 | ||
5 | EVP_EncryptInit, EVP_EncryptUpdate, EVP_EncryptFinal, EVP_DecryptInit, | 5 | EVP_CIPHER_CTX_init, EVP_EncryptInit_ex, EVP_EncryptUpdate, |
6 | EVP_DecryptUpdate, EVP_DecryptFinal, EVP_CipherInit, EVP_CipherUpdate, | 6 | EVP_EncryptFinal_ex, EVP_DecryptInit_ex, EVP_DecryptUpdate, |
7 | EVP_CipherFinal, EVP_CIPHER_CTX_set_key_length, EVP_CIPHER_CTX_ctrl, | 7 | EVP_DecryptFinal_ex, EVP_CipherInit_ex, EVP_CipherUpdate, |
8 | EVP_CIPHER_CTX_cleanup, EVP_get_cipherbyname, EVP_get_cipherbynid, | 8 | EVP_CipherFinal_ex, EVP_CIPHER_CTX_set_key_length, |
9 | EVP_get_cipherbyobj, EVP_CIPHER_nid, EVP_CIPHER_block_size, | 9 | EVP_CIPHER_CTX_ctrl, EVP_CIPHER_CTX_cleanup, EVP_EncryptInit, |
10 | EVP_CIPHER_key_length, EVP_CIPHER_iv_length, EVP_CIPHER_flags, | 10 | EVP_EncryptFinal, EVP_DecryptInit, EVP_DecryptFinal, |
11 | EVP_CIPHER_mode, EVP_CIPHER_type, EVP_CIPHER_CTX_cipher, EVP_CIPHER_CTX_nid, | 11 | EVP_CipherInit, EVP_CipherFinal, EVP_get_cipherbyname, |
12 | EVP_CIPHER_CTX_block_size, EVP_CIPHER_CTX_key_length, EVP_CIPHER_CTX_iv_length, | 12 | EVP_get_cipherbynid, EVP_get_cipherbyobj, EVP_CIPHER_nid, |
13 | EVP_CIPHER_CTX_get_app_data, EVP_CIPHER_CTX_set_app_data, EVP_CIPHER_CTX_type, | 13 | EVP_CIPHER_block_size, EVP_CIPHER_key_length, EVP_CIPHER_iv_length, |
14 | EVP_CIPHER_CTX_flags, EVP_CIPHER_CTX_mode, EVP_CIPHER_param_to_asn1, | 14 | EVP_CIPHER_flags, EVP_CIPHER_mode, EVP_CIPHER_type, EVP_CIPHER_CTX_cipher, |
15 | EVP_CIPHER_asn1_to_param - EVP cipher routines | 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 | ||
16 | 20 | ||
17 | =head1 SYNOPSIS | 21 | =head1 SYNOPSIS |
18 | 22 | ||
19 | #include <openssl/evp.h> | 23 | #include <openssl/evp.h> |
20 | 24 | ||
21 | int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, | 25 | int EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a); |
22 | unsigned char *key, unsigned char *iv); | 26 | |
27 | int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, | ||
28 | ENGINE *impl, unsigned char *key, unsigned char *iv); | ||
23 | int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, | 29 | int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, |
24 | int *outl, unsigned char *in, int inl); | 30 | int *outl, unsigned char *in, int inl); |
31 | int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
32 | int *outl); | ||
33 | |||
34 | int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, | ||
35 | ENGINE *impl, unsigned char *key, unsigned char *iv); | ||
36 | int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
37 | int *outl, unsigned char *in, int inl); | ||
38 | int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, | ||
39 | int *outl); | ||
40 | |||
41 | int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, | ||
42 | ENGINE *impl, unsigned char *key, unsigned char *iv, int enc); | ||
43 | int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
44 | int *outl, unsigned char *in, int inl); | ||
45 | int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, | ||
46 | int *outl); | ||
47 | |||
48 | int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, | ||
49 | unsigned char *key, unsigned char *iv); | ||
25 | int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, | 50 | int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, |
26 | int *outl); | 51 | int *outl); |
27 | 52 | ||
28 | int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, | 53 | int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, |
29 | unsigned char *key, unsigned char *iv); | 54 | unsigned char *key, unsigned char *iv); |
30 | int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
31 | int *outl, unsigned char *in, int inl); | ||
32 | int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, | 55 | int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, |
33 | int *outl); | 56 | int *outl); |
34 | 57 | ||
35 | int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, | 58 | int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, |
36 | unsigned char *key, unsigned char *iv, int enc); | 59 | unsigned char *key, unsigned char *iv, int enc); |
37 | int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
38 | int *outl, unsigned char *in, int inl); | ||
39 | int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, | 60 | int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, |
40 | int *outl); | 61 | int *outl); |
41 | 62 | ||
63 | int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *x, int padding); | ||
42 | int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); | 64 | int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); |
43 | int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); | 65 | int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); |
44 | int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a); | 66 | int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a); |
@@ -74,14 +96,19 @@ EVP_CIPHER_asn1_to_param - EVP cipher routines | |||
74 | The EVP cipher routines are a high level interface to certain | 96 | The EVP cipher routines are a high level interface to certain |
75 | symmetric ciphers. | 97 | symmetric ciphers. |
76 | 98 | ||
77 | EVP_EncryptInit() initializes a cipher context B<ctx> for encryption | 99 | EVP_CIPHER_CTX_init() initializes cipher contex B<ctx>. |
78 | with cipher B<type>. B<type> is normally supplied by a function such | 100 | |
79 | 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 |
80 | 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 |
81 | key and IV depends on the cipher. It is possible to set all parameters | 103 | before calling this function. B<type> is normally supplied |
82 | 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 |
83 | parameters in subsequent calls, all of which have B<type> set to NULL. | 105 | default implementation is used. B<key> is the symmetric key to use |
84 | This is done when the default cipher parameters are not appropriate. | 106 | and B<iv> is the IV to use (if necessary), the actual number of bytes |
107 | used for the key and IV depends on the cipher. It is possible to set | ||
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. | ||
85 | 112 | ||
86 | 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 |
87 | 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 |
@@ -89,32 +116,49 @@ multiple times to encrypt successive blocks of data. The amount | |||
89 | 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: |
90 | 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 |
91 | 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 |
92 | 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>. |
120 | |||
121 | If padding is enabled (the default) then EVP_EncryptFinal_ex() encrypts | ||
122 | the "final" data, that is any data that remains in a partial block. | ||
123 | It uses L<standard block padding|/NOTES> (aka PKCS padding). The encrypted | ||
124 | final data is written to B<out> which should have sufficient space for | ||
125 | one cipher block. The number of bytes written is placed in B<outl>. After | ||
126 | this function is called the encryption operation is finished and no further | ||
127 | calls to EVP_EncryptUpdate() should be made. | ||
93 | 128 | ||
94 | EVP_EncryptFinal() encrypts the "final" data, that is any data that | 129 | If padding is disabled then EVP_EncryptFinal_ex() will not encrypt any more |
95 | remains in a partial block. It uses L<standard block padding|/NOTES> (aka PKCS | 130 | data and it will return an error if any data remains in a partial block: |
96 | padding). The encrypted final data is written to B<out> which should | 131 | that is if the total data length is not a multiple of the block size. |
97 | have sufficient space for one cipher block. The number of bytes written | ||
98 | is placed in B<outl>. After this function is called the encryption operation | ||
99 | is finished and no further calls to EVP_EncryptUpdate() should be made. | ||
100 | 132 | ||
101 | EVP_DecryptInit(), EVP_DecryptUpdate() and EVP_DecryptFinal() are the | 133 | EVP_DecryptInit_ex(), EVP_DecryptUpdate() and EVP_DecryptFinal_ex() are the |
102 | corresponding decryption operations. EVP_DecryptFinal() will return an | 134 | corresponding decryption operations. EVP_DecryptFinal() will return an |
103 | error code if the final block is not correctly formatted. The parameters | 135 | error code if padding is enabled and the final block is not correctly |
104 | and restrictions are identical to the encryption operations except that | 136 | formatted. The parameters and restrictions are identical to the encryption |
105 | the decrypted data buffer B<out> passed to EVP_DecryptUpdate() should | 137 | operations except that if padding is enabled the decrypted data buffer B<out> |
106 | have sufficient room for (B<inl> + cipher_block_size) bytes unless the | 138 | passed to EVP_DecryptUpdate() should have sufficient room for |
107 | cipher block size is 1 in which case B<inl> bytes is sufficient. | 139 | (B<inl> + cipher_block_size) bytes unless the cipher block size is 1 in |
108 | 140 | which case B<inl> bytes is sufficient. | |
109 | EVP_CipherInit(), EVP_CipherUpdate() and EVP_CipherFinal() are functions | 141 | |
110 | that can be used for decryption or encryption. The operation performed | 142 | EVP_CipherInit_ex(), EVP_CipherUpdate() and EVP_CipherFinal_ex() are |
111 | depends on the value of the B<enc> parameter. It should be set to 1 for | 143 | functions that can be used for decryption or encryption. The operation |
112 | encryption, 0 for decryption and -1 to leave the value unchanged (the | 144 | performed depends on the value of the B<enc> parameter. It should be set |
113 | actual value of 'enc' being supplied in a previous call). | 145 | to 1 for encryption, 0 for decryption and -1 to leave the value unchanged |
114 | 146 | (the actual value of 'enc' being supplied in a previous call). | |
115 | EVP_CIPHER_CTX_cleanup() clears all information from a cipher context. | 147 | |
116 | It should be called after all operations using a cipher are complete | 148 | EVP_CIPHER_CTX_cleanup() clears all information from a cipher context |
117 | so sensitive information does not remain in memory. | 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. | ||
118 | 162 | ||
119 | EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj() | 163 | EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj() |
120 | 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 |
@@ -125,6 +169,13 @@ passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX> structure. The actual NID | |||
125 | 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 |
126 | IDENTIFIER. | 170 | IDENTIFIER. |
127 | 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 | |||
128 | 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 |
129 | 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> |
130 | 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 |
@@ -185,14 +236,14 @@ RC5 can be set. | |||
185 | 236 | ||
186 | =head1 RETURN VALUES | 237 | =head1 RETURN VALUES |
187 | 238 | ||
188 | EVP_EncryptInit(), EVP_EncryptUpdate() and EVP_EncryptFinal() return 1 for success | 239 | EVP_CIPHER_CTX_init, EVP_EncryptInit_ex(), EVP_EncryptUpdate() and |
189 | and 0 for failure. | 240 | EVP_EncryptFinal_ex() return 1 for success and 0 for failure. |
190 | 241 | ||
191 | EVP_DecryptInit() and EVP_DecryptUpdate() return 1 for success and 0 for failure. | 242 | EVP_DecryptInit_ex() and EVP_DecryptUpdate() return 1 for success and 0 for failure. |
192 | 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. |
193 | 244 | ||
194 | EVP_CipherInit() and EVP_CipherUpdate() return 1 for success and 0 for failure. | 245 | EVP_CipherInit_ex() and EVP_CipherUpdate() return 1 for success and 0 for failure. |
195 | EVP_CipherFinal() returns 1 for a decryption failure or 1 for success. | 246 | EVP_CipherFinal_ex() returns 0 for a decryption failure or 1 for success. |
196 | 247 | ||
197 | EVP_CIPHER_CTX_cleanup() returns 1 for success and 0 for failure. | 248 | EVP_CIPHER_CTX_cleanup() returns 1 for success and 0 for failure. |
198 | 249 | ||
@@ -207,6 +258,8 @@ size. | |||
207 | 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 |
208 | length. | 259 | length. |
209 | 260 | ||
261 | EVP_CIPHER_CTX_set_padding() always returns 1. | ||
262 | |||
210 | 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 |
211 | length or zero if the cipher does not use an IV. | 264 | length or zero if the cipher does not use an IV. |
212 | 265 | ||
@@ -301,25 +354,26 @@ encrypted then 5 padding bytes of value 5 will be added. | |||
301 | 354 | ||
302 | 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. |
303 | 356 | ||
304 | 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, |
305 | 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 |
306 | 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 |
307 | input data earlier on will not produce a final decrypt error. | 360 | the input data earlier on will not produce a final decrypt error. |
308 | 361 | ||
309 | The functions EVP_EncryptInit(), EVP_EncryptUpdate(), EVP_EncryptFinal(), | 362 | If padding is disabled then the decryption operation will always succeed if |
310 | EVP_DecryptInit(), EVP_DecryptUpdate(), EVP_CipherInit() and EVP_CipherUpdate() | 363 | the total amount of data decrypted is a multiple of the block size. |
311 | and EVP_CIPHER_CTX_cleanup() did not return errors in OpenSSL version 0.9.5a or | 364 | |
312 | earlier. Software only versions of encryption algorithms will never return | 365 | The functions EVP_EncryptInit(), EVP_EncryptFinal(), EVP_DecryptInit(), |
313 | error codes for these functions, unless there is a programming error (for example | 366 | EVP_CipherInit() and EVP_CipherFinal() are obsolete but are retained for |
314 | and attempt to set the key before the cipher is set in EVP_EncryptInit() ). | 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. | ||
315 | 371 | ||
316 | =head1 BUGS | 372 | =head1 BUGS |
317 | 373 | ||
318 | For RC5 the number of rounds can currently only be set to 8, 12 or 16. This is | 374 | For RC5 the number of rounds can currently only be set to 8, 12 or 16. This is |
319 | a limitation of the current RC5 code rather than the EVP interface. | 375 | a limitation of the current RC5 code rather than the EVP interface. |
320 | 376 | ||
321 | It should be possible to disable PKCS padding: currently it isn't. | ||
322 | |||
323 | EVP_MAX_KEY_LENGTH and EVP_MAX_IV_LENGTH only refer to the internal ciphers with | 377 | EVP_MAX_KEY_LENGTH and EVP_MAX_IV_LENGTH only refer to the internal ciphers with |
324 | default key lengths. If custom ciphers exceed these values the results are | 378 | default key lengths. If custom ciphers exceed these values the results are |
325 | unpredictable. This is because it has become standard practice to define a | 379 | unpredictable. This is because it has become standard practice to define a |
@@ -333,22 +387,113 @@ for certain common S/MIME ciphers (RC2, DES, triple DES) in CBC mode. | |||
333 | Get the number of rounds used in RC5: | 387 | Get the number of rounds used in RC5: |
334 | 388 | ||
335 | int nrounds; | 389 | int nrounds; |
336 | EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC5_ROUNDS, 0, &i); | 390 | EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC5_ROUNDS, 0, &nrounds); |
337 | 391 | ||
338 | Get the RC2 effective key length: | 392 | Get the RC2 effective key length: |
339 | 393 | ||
340 | int key_bits; | 394 | int key_bits; |
341 | EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC2_KEY_BITS, 0, &i); | 395 | EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC2_KEY_BITS, 0, &key_bits); |
342 | 396 | ||
343 | Set the number of rounds used in RC5: | 397 | Set the number of rounds used in RC5: |
344 | 398 | ||
345 | int nrounds; | 399 | int nrounds; |
346 | EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC5_ROUNDS, i, NULL); | 400 | EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC5_ROUNDS, nrounds, NULL); |
347 | 401 | ||
348 | Set the number of rounds used in RC2: | 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 | } | ||
349 | 496 | ||
350 | int nrounds; | ||
351 | EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC2_KEY_BITS, i, NULL); | ||
352 | 497 | ||
353 | =head1 SEE ALSO | 498 | =head1 SEE ALSO |
354 | 499 | ||
diff --git a/src/lib/libcrypto/doc/EVP_SignInit.pod b/src/lib/libcrypto/doc/EVP_SignInit.pod index d5ce245ecd..b1ac129430 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,9 +21,9 @@ 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() initializes 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 function can be called several times on the | 29 | signature context B<ctx>. This function can be called several times on the |
@@ -31,18 +33,18 @@ EVP_SignFinal() signs the data in B<ctx> using the private key B<pkey> | |||
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 initialize | 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<SHA1(3)|SHA1(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 736a0f4a82..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() initializes 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 function 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 initialize 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,11 +54,18 @@ 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 | ||
@@ -69,4 +81,6 @@ L<sha(3)|sha(3)>, L<digest(1)|digest(1)> | |||
69 | EVP_VerifyInit(), EVP_VerifyUpdate() and EVP_VerifyFinal() are | 81 | EVP_VerifyInit(), EVP_VerifyUpdate() and EVP_VerifyFinal() are |
70 | available in all versions of SSLeay and OpenSSL. | 82 | available in all versions of SSLeay and OpenSSL. |
71 | 83 | ||
84 | EVP_VerifyInit_ex() was added in OpenSSL 0.9.7 | ||
85 | |||
72 | =cut | 86 | =cut |
diff --git a/src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod b/src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod index 68ea723259..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 SSLeay_version - 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,7 +11,7 @@ OPENSSL_VERSION_NUMBER, SSLeay SSLeay_version - get OpenSSL version number | |||
11 | 11 | ||
12 | #include <openssl/crypto.h> | 12 | #include <openssl/crypto.h> |
13 | long SSLeay(void); | 13 | long SSLeay(void); |
14 | char *SSLeay_version(int t); | 14 | const char *SSLeay_version(int t); |
15 | 15 | ||
16 | =head1 DESCRIPTION | 16 | =head1 DESCRIPTION |
17 | 17 | ||
@@ -55,20 +55,32 @@ SSLeay_version() returns different strings depending on B<t>: | |||
55 | =over 4 | 55 | =over 4 |
56 | 56 | ||
57 | =item SSLEAY_VERSION | 57 | =item SSLEAY_VERSION |
58 | |||
58 | The text variant of the version number and the release date. For example, | 59 | The text variant of the version number and the release date. For example, |
59 | "OpenSSL 0.9.5a 1 Apr 2000". | 60 | "OpenSSL 0.9.5a 1 Apr 2000". |
60 | 61 | ||
61 | =item SSLEAY_CFLAGS | 62 | =item SSLEAY_CFLAGS |
62 | The flags given to the C compiler when compiling OpenSSL are returned in a | 63 | |
63 | string. | 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. | ||
64 | 72 | ||
65 | =item SSLEAY_PLATFORM | 73 | =item SSLEAY_PLATFORM |
66 | The platform name used when OpenSSL was configured is returned. | ||
67 | 74 | ||
68 | =back | 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 | ||
69 | 79 | ||
70 | If the data request isn't available, a text saying that the information is | 80 | The "OPENSSLDIR" setting of the library build in the form "OPENSSLDIR: "..."" |
71 | not available is returned. | 81 | if available or "OPENSSLDIR: N/A" otherwise. |
82 | |||
83 | =back | ||
72 | 84 | ||
73 | For an unknown B<t>, the text "not available" is returned. | 85 | For an unknown B<t>, the text "not available" is returned. |
74 | 86 | ||
@@ -84,5 +96,6 @@ L<crypto(3)|crypto(3)> | |||
84 | 96 | ||
85 | 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. |
86 | 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. | ||
87 | 100 | ||
88 | =cut | 101 | =cut |
diff --git a/src/lib/libcrypto/doc/RSA_generate_key.pod b/src/lib/libcrypto/doc/RSA_generate_key.pod index 0e0f0a764c..11bc0b3459 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_public_encrypt.pod b/src/lib/libcrypto/doc/RSA_public_encrypt.pod index 23861c0004..8022a23f99 100644 --- a/src/lib/libcrypto/doc/RSA_public_encrypt.pod +++ b/src/lib/libcrypto/doc/RSA_public_encrypt.pod | |||
@@ -74,10 +74,6 @@ SSL, PKCS #1 v2.0 | |||
74 | 74 | ||
75 | L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_size(3)|RSA_size(3)> | 75 | L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_size(3)|RSA_size(3)> |
76 | 76 | ||
77 | =head1 NOTES | ||
78 | |||
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 b672712292..14917dd35f 100644 --- a/src/lib/libcrypto/doc/RSA_set_method.pod +++ b/src/lib/libcrypto/doc/RSA_set_method.pod | |||
@@ -3,7 +3,7 @@ | |||
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_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 |
@@ -15,14 +15,12 @@ RSA_null_method, RSA_flags, RSA_new_method - select RSA method | |||
15 | 15 | ||
16 | RSA_METHOD *RSA_get_default_openssl_method(void); | 16 | RSA_METHOD *RSA_get_default_openssl_method(void); |
17 | 17 | ||
18 | RSA_METHOD *RSA_set_method(RSA *rsa, ENGINE *engine); | 18 | int RSA_set_method(RSA *rsa, ENGINE *engine); |
19 | 19 | ||
20 | RSA_METHOD *RSA_get_method(RSA *rsa); | 20 | RSA_METHOD *RSA_get_method(RSA *rsa); |
21 | 21 | ||
22 | RSA_METHOD *RSA_PKCS1_SSLeay(void); | 22 | RSA_METHOD *RSA_PKCS1_SSLeay(void); |
23 | 23 | ||
24 | RSA_METHOD *RSA_PKCS1_RSAref(void); | ||
25 | |||
26 | RSA_METHOD *RSA_null_method(void); | 24 | RSA_METHOD *RSA_null_method(void); |
27 | 25 | ||
28 | int RSA_flags(RSA *rsa); | 26 | int RSA_flags(RSA *rsa); |
@@ -35,17 +33,8 @@ An B<RSA_METHOD> specifies the functions that OpenSSL uses for RSA | |||
35 | operations. By modifying the method, alternative implementations | 33 | operations. By modifying the method, alternative implementations |
36 | such as hardware accelerators may be used. | 34 | such as hardware accelerators may be used. |
37 | 35 | ||
38 | Initially, the default is to use the OpenSSL internal implementation, | 36 | Initially, the default is to use the OpenSSL internal implementation. |
39 | unless OpenSSL was configured with the C<rsaref> or C<-DRSA_NULL> | 37 | RSA_PKCS1_SSLeay() returns a pointer to that method. |
40 | options. RSA_PKCS1_SSLeay() returns a pointer to that method. | ||
41 | |||
42 | RSA_PKCS1_RSAref() returns a pointer to a method that uses the RSAref | ||
43 | library. This is the default method in the C<rsaref> configuration; | ||
44 | the function is not available in other configurations. | ||
45 | RSA_null_method() returns a pointer to a method that does not support | ||
46 | the RSA transformation. It is the default if OpenSSL is compiled with | ||
47 | C<-DRSA_NULL>. These methods may be useful in the USA because of a | ||
48 | patent on the RSA cryptosystem. | ||
49 | 38 | ||
50 | RSA_set_default_openssl_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> |
51 | structures created later. B<NB:> This is true only whilst the default engine | 40 | structures created later. B<NB:> This is true only whilst the default engine |
@@ -132,9 +121,8 @@ the default engine for RSA operations is used. | |||
132 | 121 | ||
133 | =head1 RETURN VALUES | 122 | =head1 RETURN VALUES |
134 | 123 | ||
135 | RSA_PKCS1_SSLeay(), RSA_PKCS1_RSAref(), RSA_PKCS1_null_method(), | 124 | RSA_PKCS1_SSLeay(), RSA_PKCS1_null_method(), RSA_get_default_openssl_method() |
136 | RSA_get_default_openssl_method() and RSA_get_method() return pointers to | 125 | and RSA_get_method() return pointers to the respective RSA_METHODs. |
137 | the respective RSA_METHODs. | ||
138 | 126 | ||
139 | RSA_set_default_openssl_method() returns no value. | 127 | RSA_set_default_openssl_method() returns no value. |
140 | 128 | ||
@@ -163,6 +151,6 @@ added in OpenSSL 0.9.4. | |||
163 | RSA_set_default_openssl_method() and RSA_get_default_openssl_method() | 151 | RSA_set_default_openssl_method() and RSA_get_default_openssl_method() |
164 | replaced RSA_set_default_method() and RSA_get_default_method() respectively, | 152 | replaced RSA_set_default_method() and RSA_get_default_method() respectively, |
165 | and RSA_set_method() and RSA_new_method() were altered to use B<ENGINE>s | 153 | and RSA_set_method() and RSA_new_method() were altered to use B<ENGINE>s |
166 | rather than B<DH_METHOD>s during development of OpenSSL 0.9.6. | 154 | rather than B<RSA_METHOD>s during development of OpenSSL 0.9.6. |
167 | 155 | ||
168 | =cut | 156 | =cut |
diff --git a/src/lib/libcrypto/doc/bn.pod b/src/lib/libcrypto/doc/bn.pod index d183028d61..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,13 +62,14 @@ bn - multiprecision integer arithmetics | |||
54 | 62 | ||
55 | int BN_zero(BIGNUM *a); | 63 | int BN_zero(BIGNUM *a); |
56 | int BN_one(BIGNUM *a); | 64 | int BN_one(BIGNUM *a); |
57 | BIGNUM *BN_value_one(void); | 65 | const BIGNUM *BN_value_one(void); |
58 | int BN_set_word(BIGNUM *a, unsigned long w); | 66 | int BN_set_word(BIGNUM *a, unsigned long w); |
59 | unsigned long BN_get_word(BIGNUM *a); | 67 | unsigned long BN_get_word(BIGNUM *a); |
60 | 68 | ||
61 | int BN_rand(BIGNUM *rnd, int bits, int top, int bottom); | 69 | int BN_rand(BIGNUM *rnd, int bits, int top, int bottom); |
62 | int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom); | 70 | int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom); |
63 | int BN_rand_range(BIGNUM *rnd, BIGNUM *range); | 71 | int BN_rand_range(BIGNUM *rnd, BIGNUM *range); |
72 | int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range); | ||
64 | 73 | ||
65 | BIGNUM *BN_generate_prime(BIGNUM *ret, int bits,int safe, BIGNUM *add, | 74 | BIGNUM *BN_generate_prime(BIGNUM *ret, int bits,int safe, BIGNUM *add, |
66 | BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg); | 75 | BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg); |
@@ -138,7 +147,7 @@ of B<BIGNUM>s to external formats is described in L<BN_bn2bin(3)|BN_bn2bin(3)>. | |||
138 | L<bn_internal(3)|bn_internal(3)>, | 147 | L<bn_internal(3)|bn_internal(3)>, |
139 | 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)>, |
140 | 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)>, |
141 | 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)>, |
142 | 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)>, |
143 | 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)>, |
144 | 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/rsa.pod b/src/lib/libcrypto/doc/rsa.pod index ef0d4df205..09ad30cab1 100644 --- a/src/lib/libcrypto/doc/rsa.pod +++ b/src/lib/libcrypto/doc/rsa.pod | |||
@@ -37,7 +37,6 @@ rsa - RSA public key cryptosystem | |||
37 | int RSA_set_method(RSA *rsa, ENGINE *engine); | 37 | int RSA_set_method(RSA *rsa, ENGINE *engine); |
38 | RSA_METHOD *RSA_get_method(RSA *rsa); | 38 | RSA_METHOD *RSA_get_method(RSA *rsa); |
39 | RSA_METHOD *RSA_PKCS1_SSLeay(void); | 39 | RSA_METHOD *RSA_PKCS1_SSLeay(void); |
40 | RSA_METHOD *RSA_PKCS1_RSAref(void); | ||
41 | RSA_METHOD *RSA_null_method(void); | 40 | RSA_METHOD *RSA_null_method(void); |
42 | int RSA_flags(RSA *rsa); | 41 | int RSA_flags(RSA *rsa); |
43 | RSA *RSA_new_method(ENGINE *engine); | 42 | RSA *RSA_new_method(ENGINE *engine); |