*** empty log message ***
[openssl.git] / doc / sha.doc
1 The SHA (Secure Hash Algorithm) library.
2 SHA is a message digest algorithm that can be used to condense an arbitrary
3 length message down to a 20 byte hash.  The functions all need to be passed
4 a SHA_CTX which is used to hold the SHA context during multiple SHA_Update()
5 function calls.  The normal method of use for this library is as follows
6 This library contains both SHA and SHA-1 digest algorithms.  SHA-1 is
7 an update to SHA (which should really be called SHA-0 now) which
8 tweaks the algorithm slightly.  The SHA-1 algorithm is used by simply
9 using SHA1_Init(), SHA1_Update(), SHA1_Final() and SHA1() instead of the
10 SHA*() calls
11
12 SHA_Init(...);
13 SHA_Update(...);
14 ...
15 SHA_Update(...);
16 SHA_Final(...);
17
18 This library requires the inclusion of 'sha.h'.
19
20 The functions are as follows:
21
22 void SHA_Init(
23 SHA_CTX *c);
24         This function needs to be called to initiate a SHA_CTX structure for
25         use.
26         
27 void SHA_Update(
28 SHA_CTX *c;
29 unsigned char *data;
30 unsigned long len);
31         This updates the message digest context being generated with 'len'
32         bytes from the 'data' pointer.  The number of bytes can be any
33         length.
34
35 void SHA_Final(
36 unsigned char *md;
37 SHA_CTX *c;
38         This function is called when a message digest of the data digested
39         with SHA_Update() is wanted.  The message digest is put in the 'md'
40         array and is SHA_DIGEST_LENGTH (20) bytes long.
41
42 unsigned char *SHA(
43 unsigned char *d;
44 unsigned long n;
45 unsigned char *md;
46         This function performs a SHA_Init(), followed by a SHA_Update()
47         followed by a SHA_Final() (using a local SHA_CTX).
48         The resulting digest is put into 'md' if it is not NULL.
49         Regardless of the value of 'md', the message
50         digest is returned from the function.  If 'md' was NULL, the message
51         digest returned is being stored in a static structure.
52