summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/doc/EVP_DigestInit.pod
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/doc/EVP_DigestInit.pod')
-rw-r--r--src/lib/libcrypto/doc/EVP_DigestInit.pod202
1 files changed, 0 insertions, 202 deletions
diff --git a/src/lib/libcrypto/doc/EVP_DigestInit.pod b/src/lib/libcrypto/doc/EVP_DigestInit.pod
deleted file mode 100644
index fefc858f7e..0000000000
--- a/src/lib/libcrypto/doc/EVP_DigestInit.pod
+++ /dev/null
@@ -1,202 +0,0 @@
1=pod
2
3=head1 NAME
4
5EVP_DigestInit, EVP_DigestUpdate, EVP_DigestFinal, EVP_MAX_MD_SIZE,
6EVP_MD_CTX_copy, EVP_MD_type, EVP_MD_pkey_type, EVP_MD_size, EVP_MD_block_size,
7EVP_MD_CTX_md, EVP_MD_CTX_size, EVP_MD_CTX_block_size, EVP_MD_CTX_type,
8EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_dss, EVP_dss1, EVP_mdc2,
9EVP_ripemd160, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj -
10EVP digest routines
11
12=head1 SYNOPSIS
13
14 #include <openssl/evp.h>
15
16 void EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
17 void EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
18 void EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md,
19 unsigned int *s);
20
21 #define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */
22
23 int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in);
24
25 #define EVP_MD_type(e) ((e)->type)
26 #define EVP_MD_pkey_type(e) ((e)->pkey_type)
27 #define EVP_MD_size(e) ((e)->md_size)
28 #define EVP_MD_block_size(e) ((e)->block_size)
29
30 #define EVP_MD_CTX_md(e) (e)->digest)
31 #define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest)
32 #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)
34
35 EVP_MD *EVP_md_null(void);
36 EVP_MD *EVP_md2(void);
37 EVP_MD *EVP_md5(void);
38 EVP_MD *EVP_sha(void);
39 EVP_MD *EVP_sha1(void);
40 EVP_MD *EVP_dss(void);
41 EVP_MD *EVP_dss1(void);
42 EVP_MD *EVP_mdc2(void);
43 EVP_MD *EVP_ripemd160(void);
44
45 const EVP_MD *EVP_get_digestbyname(const char *name);
46 #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
47 #define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
48
49=head1 DESCRIPTION
50
51The EVP digest routines are a high level interface to message digests.
52
53EVP_DigestInit() initializes a digest context B<ctx> to use a digest
54B<type>: this will typically be supplied by a function such as
55EVP_sha1().
56
57EVP_DigestUpdate() hashes B<cnt> bytes of data at B<d> into the
58digest context B<ctx>. This function can be called several times on the
59same B<ctx> to hash additional data.
60
61EVP_DigestFinal() retrieves the digest value from B<ctx> and places
62it in B<md>. If the B<s> parameter is not NULL then the number of
63bytes of data written (i.e. the length of the digest) will be written
64to the integer at B<s>, at most B<EVP_MAX_MD_SIZE> bytes will be written.
65After calling EVP_DigestFinal() no additional calls to EVP_DigestUpdate()
66can be made, but EVP_DigestInit() can be called to initialize a new
67digest operation.
68
69EVP_MD_CTX_copy() can be used to copy the message digest state from
70B<in> to B<out>. This is useful if large amounts of data are to be
71hashed which only differ in the last few bytes.
72
73EVP_MD_size() and EVP_MD_CTX_size() return the size of the message digest
74when passed an B<EVP_MD> or an B<EVP_MD_CTX> structure, i.e. the size of the
75hash.
76
77EVP_MD_block_size() and EVP_MD_CTX_block_size() return the block size of the
78message digest when passed an B<EVP_MD> or an B<EVP_MD_CTX> structure.
79
80EVP_MD_type() and EVP_MD_CTX_type() return the NID of the OBJECT IDENTIFIER
81representing the given message digest when passed an B<EVP_MD> structure.
82For example EVP_MD_type(EVP_sha1()) returns B<NID_sha1>. This function is
83normally used when setting ASN1 OIDs.
84
85EVP_MD_CTX_md() returns the B<EVP_MD> structure corresponding to the passed
86B<EVP_MD_CTX>.
87
88EVP_MD_pkey_type() returns the NID of the public key signing algorithm associated
89with this digest. For example EVP_sha1() is associated with RSA so this will
90return B<NID_sha1WithRSAEncryption>. This "link" between digests and signature
91algorithms may not be retained in future versions of OpenSSL.
92
93EVP_md2(), EVP_md5(), EVP_sha(), EVP_sha1(), EVP_mdc2() and EVP_ripemd160()
94return B<EVP_MD> structures for the MD2, MD5, SHA, SHA1, MDC2 and RIPEMD160 digest
95algorithms respectively. The associated signature algorithm is RSA in each case.
96
97EVP_dss() and EVP_dss1() return B<EVP_MD> structures for SHA and SHA1 digest
98algorithms but using DSS (DSA) for the signature algorithm.
99
100EVP_md_null() is a "null" message digest that does nothing: i.e. the hash it
101returns is of zero length.
102
103EVP_get_digestbyname(), EVP_get_digestbynid() and EVP_get_digestbyobj()
104return an B<EVP_MD> structure when passed a digest name, a digest NID or
105an ASN1_OBJECT structure respectively. The digest table must be initialized
106using, for example, OpenSSL_add_all_digests() for these functions to work.
107
108=head1 RETURN VALUES
109
110EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() do not return values.
111
112EVP_MD_CTX_copy() returns 1 if successful or 0 for failure.
113
114EVP_MD_type(), EVP_MD_pkey_type() and EVP_MD_type() return the NID of the
115corresponding OBJECT IDENTIFIER or NID_undef if none exists.
116
117EVP_MD_size(), EVP_MD_block_size(), EVP_MD_CTX_size(e), EVP_MD_size(),
118EVP_MD_CTX_block_size() and EVP_MD_block_size() return the digest or block
119size in bytes.
120
121EVP_md_null(), EVP_md2(), EVP_md5(), EVP_sha(), EVP_sha1(), EVP_dss(),
122EVP_dss1(), EVP_mdc2() and EVP_ripemd160() return pointers to the
123corresponding EVP_MD structures.
124
125EVP_get_digestbyname(), EVP_get_digestbynid() and EVP_get_digestbyobj()
126return either an B<EVP_MD> structure or NULL if an error occurs.
127
128=head1 NOTES
129
130The B<EVP> interface to message digests should almost always be used in
131preference to the low level interfaces. This is because the code then becomes
132transparent to the digest used and much more flexible.
133
134SHA1 is the digest of choice for new applications. The other digest algorithms
135are still in common use.
136
137=head1 EXAMPLE
138
139This example digests the data "Test Message\n" and "Hello World\n", using the
140digest name passed on the command line.
141
142 #include <stdio.h>
143 #include <openssl/evp.h>
144
145 main(int argc, char *argv[])
146 {
147 EVP_MD_CTX mdctx;
148 const EVP_MD *md;
149 char mess1[] = "Test Message\n";
150 char mess2[] = "Hello World\n";
151 unsigned char md_value[EVP_MAX_MD_SIZE];
152 int md_len, i;
153
154 OpenSSL_add_all_digests();
155
156 if(!argv[1]) {
157 printf("Usage: mdtest digestname\n");
158 exit(1);
159 }
160
161 md = EVP_get_digestbyname(argv[1]);
162
163 if(!md) {
164 printf("Unknown message digest %s\n", argv[1]);
165 exit(1);
166 }
167
168 EVP_DigestInit(&mdctx, md);
169 EVP_DigestUpdate(&mdctx, mess1, strlen(mess1));
170 EVP_DigestUpdate(&mdctx, mess2, strlen(mess2));
171 EVP_DigestFinal(&mdctx, md_value, &md_len);
172
173 printf("Digest is: ");
174 for(i = 0; i < md_len; i++) printf("%02x", md_value[i]);
175 printf("\n");
176 }
177
178=head1 BUGS
179
180Several of the functions do not return values: maybe they should. Although the
181internal digest operations will never fail some future hardware based operations
182might.
183
184The link between digests and signing algorithms results in a situation where
185EVP_sha1() must be used with RSA and EVP_dss1() must be used with DSS
186even though they are identical digests.
187
188The size of an B<EVP_MD_CTX> structure is determined at compile time: this results
189in code that must be recompiled if the size of B<EVP_MD_CTX> increases.
190
191=head1 SEE ALSO
192
193L<evp(3)|evp(3)>, L<HMAC(3)|HMAC(3)>, L<MD2(3)|MD2(3)>,
194L<MD5(3)|MD5(3)>, L<MDC2(3)|MDC2(3)>, L<RIPEMD160(3)|RIPEMD160(3)>,
195L<SHA1(3)|SHA1(3)>
196
197=head1 HISTORY
198
199EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() are
200available in all versions of SSLeay and OpenSSL.
201
202=cut