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