diff options
Diffstat (limited to 'src/lib/libcrypto/doc/EVP_DigestInit.pod')
| -rw-r--r-- | src/lib/libcrypto/doc/EVP_DigestInit.pod | 72 |
1 files changed, 26 insertions, 46 deletions
diff --git a/src/lib/libcrypto/doc/EVP_DigestInit.pod b/src/lib/libcrypto/doc/EVP_DigestInit.pod index 367691cc7a..37a751b1c5 100644 --- a/src/lib/libcrypto/doc/EVP_DigestInit.pod +++ b/src/lib/libcrypto/doc/EVP_DigestInit.pod | |||
| @@ -6,8 +6,7 @@ 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, | 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, | 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_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_sha224, EVP_sha256, | 9 | EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_dss, EVP_dss1, EVP_mdc2, |
| 10 | EVP_sha384, EVP_sha512, EVP_dss, EVP_dss1, EVP_mdc2, | ||
| 11 | EVP_ripemd160, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj - | 10 | EVP_ripemd160, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj - |
| 12 | EVP digest routines | 11 | EVP digest routines |
| 13 | 12 | ||
| @@ -34,15 +33,16 @@ EVP digest routines | |||
| 34 | 33 | ||
| 35 | 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); |
| 36 | 35 | ||
| 37 | #define EVP_MAX_MD_SIZE 64 /* SHA512 */ | 36 | #define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */ |
| 38 | 37 | ||
| 39 | int EVP_MD_type(const EVP_MD *md); | ||
| 40 | int EVP_MD_pkey_type(const EVP_MD *md); | ||
| 41 | int EVP_MD_size(const EVP_MD *md); | ||
| 42 | int EVP_MD_block_size(const EVP_MD *md); | ||
| 43 | 38 | ||
| 44 | const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx); | 39 | #define EVP_MD_type(e) ((e)->type) |
| 45 | #define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e)) | 40 | #define EVP_MD_pkey_type(e) ((e)->pkey_type) |
| 41 | #define EVP_MD_size(e) ((e)->md_size) | ||
| 42 | #define EVP_MD_block_size(e) ((e)->block_size) | ||
| 43 | |||
| 44 | #define EVP_MD_CTX_md(e) (e)->digest) | ||
| 45 | #define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest) | ||
| 46 | #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) |
| 47 | #define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest) | 47 | #define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest) |
| 48 | 48 | ||
| @@ -56,11 +56,6 @@ EVP digest routines | |||
| 56 | const EVP_MD *EVP_mdc2(void); | 56 | const EVP_MD *EVP_mdc2(void); |
| 57 | const EVP_MD *EVP_ripemd160(void); | 57 | const EVP_MD *EVP_ripemd160(void); |
| 58 | 58 | ||
| 59 | const EVP_MD *EVP_sha224(void); | ||
| 60 | const EVP_MD *EVP_sha256(void); | ||
| 61 | const EVP_MD *EVP_sha384(void); | ||
| 62 | const EVP_MD *EVP_sha512(void); | ||
| 63 | |||
| 64 | const EVP_MD *EVP_get_digestbyname(const char *name); | 59 | const EVP_MD *EVP_get_digestbyname(const char *name); |
| 65 | #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) | 60 | #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) |
| 66 | #define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a)) | 61 | #define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a)) |
| @@ -129,14 +124,12 @@ B<EVP_MD_CTX>. | |||
| 129 | 124 | ||
| 130 | EVP_MD_pkey_type() returns the NID of the public key signing algorithm associated | 125 | EVP_MD_pkey_type() returns the NID of the public key signing algorithm associated |
| 131 | with this digest. For example EVP_sha1() is associated with RSA so this will | 126 | with this digest. For example EVP_sha1() is associated with RSA so this will |
| 132 | return B<NID_sha1WithRSAEncryption>. Since digests and signature algorithms | 127 | return B<NID_sha1WithRSAEncryption>. This "link" between digests and signature |
| 133 | are no longer linked this function is only retained for compatibility | 128 | algorithms may not be retained in future versions of OpenSSL. |
| 134 | reasons. | ||
| 135 | 129 | ||
| 136 | EVP_md2(), EVP_md5(), EVP_sha(), EVP_sha1(), EVP_sha224(), EVP_sha256(), | 130 | EVP_md2(), EVP_md5(), EVP_sha(), EVP_sha1(), EVP_mdc2() and EVP_ripemd160() |
| 137 | EVP_sha384(), EVP_sha512(), EVP_mdc2() and EVP_ripemd160() return B<EVP_MD> | 131 | return B<EVP_MD> structures for the MD2, MD5, SHA, SHA1, MDC2 and RIPEMD160 digest |
| 138 | structures for the MD2, MD5, SHA, SHA1, SHA224, SHA256, SHA384, SHA512, MDC2 | 132 | algorithms respectively. The associated signature algorithm is RSA in each case. |
| 139 | and RIPEMD160 digest algorithms respectively. | ||
| 140 | 133 | ||
| 141 | EVP_dss() and EVP_dss1() return B<EVP_MD> structures for SHA and SHA1 digest | 134 | EVP_dss() and EVP_dss1() return B<EVP_MD> structures for SHA and SHA1 digest |
| 142 | algorithms but using DSS (DSA) for the signature algorithm. Note: there is | 135 | algorithms but using DSS (DSA) for the signature algorithm. Note: there is |
| @@ -178,8 +171,8 @@ The B<EVP> interface to message digests should almost always be used in | |||
| 178 | preference to the low level interfaces. This is because the code then becomes | 171 | preference to the low level interfaces. This is because the code then becomes |
| 179 | transparent to the digest used and much more flexible. | 172 | transparent to the digest used and much more flexible. |
| 180 | 173 | ||
| 181 | New applications should use the SHA2 digest algorithms such as SHA256. | 174 | SHA1 is the digest of choice for new applications. The other digest algorithms |
| 182 | The other digest algorithms are still in common use. | 175 | are still in common use. |
| 183 | 176 | ||
| 184 | For most applications the B<impl> parameter to EVP_DigestInit_ex() will be | 177 | For most applications the B<impl> parameter to EVP_DigestInit_ex() will be |
| 185 | set to NULL to use the default digest implementation. | 178 | set to NULL to use the default digest implementation. |
| @@ -194,19 +187,6 @@ implementations of digests to be specified. | |||
| 194 | In OpenSSL 0.9.7 and later if digest contexts are not cleaned up after use | 187 | In OpenSSL 0.9.7 and later if digest contexts are not cleaned up after use |
| 195 | memory leaks will occur. | 188 | memory leaks will occur. |
| 196 | 189 | ||
| 197 | Stack allocation of EVP_MD_CTX structures is common, for example: | ||
| 198 | |||
| 199 | EVP_MD_CTX mctx; | ||
| 200 | EVP_MD_CTX_init(&mctx); | ||
| 201 | |||
| 202 | This will cause binary compatibility issues if the size of EVP_MD_CTX | ||
| 203 | structure changes (this will only happen with a major release of OpenSSL). | ||
| 204 | Applications wishing to avoid this should use EVP_MD_CTX_create() instead: | ||
| 205 | |||
| 206 | EVP_MD_CTX *mctx; | ||
| 207 | mctx = EVP_MD_CTX_create(); | ||
| 208 | |||
| 209 | |||
| 210 | =head1 EXAMPLE | 190 | =head1 EXAMPLE |
| 211 | 191 | ||
| 212 | This example digests the data "Test Message\n" and "Hello World\n", using the | 192 | This example digests the data "Test Message\n" and "Hello World\n", using the |
| @@ -217,7 +197,7 @@ digest name passed on the command line. | |||
| 217 | 197 | ||
| 218 | main(int argc, char *argv[]) | 198 | main(int argc, char *argv[]) |
| 219 | { | 199 | { |
| 220 | EVP_MD_CTX *mdctx; | 200 | EVP_MD_CTX mdctx; |
| 221 | const EVP_MD *md; | 201 | const EVP_MD *md; |
| 222 | char mess1[] = "Test Message\n"; | 202 | char mess1[] = "Test Message\n"; |
| 223 | char mess2[] = "Hello World\n"; | 203 | char mess2[] = "Hello World\n"; |
| @@ -238,12 +218,12 @@ digest name passed on the command line. | |||
| 238 | exit(1); | 218 | exit(1); |
| 239 | } | 219 | } |
| 240 | 220 | ||
| 241 | mdctx = EVP_MD_CTX_create(); | 221 | EVP_MD_CTX_init(&mdctx); |
| 242 | EVP_DigestInit_ex(mdctx, md, NULL); | 222 | EVP_DigestInit_ex(&mdctx, md, NULL); |
| 243 | EVP_DigestUpdate(mdctx, mess1, strlen(mess1)); | 223 | EVP_DigestUpdate(&mdctx, mess1, strlen(mess1)); |
| 244 | EVP_DigestUpdate(mdctx, mess2, strlen(mess2)); | 224 | EVP_DigestUpdate(&mdctx, mess2, strlen(mess2)); |
| 245 | EVP_DigestFinal_ex(mdctx, md_value, &md_len); | 225 | EVP_DigestFinal_ex(&mdctx, md_value, &md_len); |
| 246 | EVP_MD_CTX_destroy(mdctx); | 226 | EVP_MD_CTX_cleanup(&mdctx); |
| 247 | 227 | ||
| 248 | printf("Digest is: "); | 228 | printf("Digest is: "); |
| 249 | for(i = 0; i < md_len; i++) printf("%02x", md_value[i]); | 229 | for(i = 0; i < md_len; i++) printf("%02x", md_value[i]); |
| @@ -252,9 +232,9 @@ digest name passed on the command line. | |||
| 252 | 232 | ||
| 253 | =head1 SEE ALSO | 233 | =head1 SEE ALSO |
| 254 | 234 | ||
| 255 | L<evp(3)|evp(3)>, L<hmac(3)|hmac(3)>, L<md2(3)|md2(3)>, | 235 | L<evp(3)|evp(3)>, L<HMAC(3)|HMAC(3)>, L<MD2(3)|MD2(3)>, |
| 256 | L<md5(3)|md5(3)>, L<mdc2(3)|mdc2(3)>, L<ripemd(3)|ripemd(3)>, | 236 | L<MD5(3)|MD5(3)>, L<MDC2(3)|MDC2(3)>, L<RIPEMD160(3)|RIPEMD160(3)>, |
| 257 | L<sha(3)|sha(3)>, L<dgst(1)|dgst(1)> | 237 | L<SHA1(3)|SHA1(3)> |
| 258 | 238 | ||
| 259 | =head1 HISTORY | 239 | =head1 HISTORY |
| 260 | 240 | ||
