1.Dd April 5, 2007
2.Dt CC_SHA 3cc
3.Os
4.Sh NAME
5.Nm CC_SHA1_Init
6.Nm CC_SHA1_Update
7.Nm CC_SHA1_Final
8.Nm CC_SHA1
9.Pp
10.Nm CC_SHA224_Init
11.Nm CC_SHA224_Update
12.Nm CC_SHA224_Final
13.Nm CC_SHA224
14.Pp
15.Nm CC_SHA256_Init
16.Nm CC_SHA256_Update
17.Nm CC_SHA256_Final
18.Nm CC_SHA256
19.Pp
20.Nm CC_SHA384_Init
21.Nm CC_SHA384_Update
22.Nm CC_SHA384_Final
23.Nm CC_SHA384
24.Pp
25.Nm CC_SHA512_Init
26.Nm CC_SHA512_Update
27.Nm CC_SHA512_Final
28.Nm CC_SHA512
29.Pp
30.Nd Secure Hash Algorithms
31.Sh SYNOPSIS
32.In CommonCrypto/CommonDigest.h
33.Pp
34.Ft extern int
35.Fn CC_SHA1_Init "CC_SHA1_CTX *c"
36.Ft extern int
37.Fn CC_SHA1_Update "CC_SHA1_CTX *c" "const void *data" "CC_LONG len"
38.Ft extern int
39.Fn CC_SHA1_Final "unsigned char *md" "CC_SHA1_CTX *c"
40.Ft extern unsigned char *
41.Fn CC_SHA1 "const void *data" "CC_LONG len" "unsigned char *md"
42.Pp
43.Ft extern int
44.Fn CC_SHA224_Init "CC_SHA256_CTX *c"
45.Ft extern int
46.Fn CC_SHA224_Update "CC_SHA256_CTX *c" "const void *data" "CC_LONG len"
47.Ft extern int
48.Fn CC_SHA224_Final "unsigned char *md" "CC_SHA256_CTX *c"
49.Ft extern unsigned char *
50.Fn CC_SHA224 "const void *data" "CC_LONG len" "unsigned char *md"
51.Pp
52.Ft extern int
53.Fn CC_SHA256_Init "CC_SHA256_CTX *c"
54.Ft extern int
55.Fn CC_SHA256_Update "CC_SHA256_CTX *c" "const void *data" "CC_LONG len"
56.Ft extern int
57.Fn CC_SHA256_Final "unsigned char *md" "CC_SHA256_CTX *c"
58.Ft extern unsigned char *
59.Fn CC_SHA256 "const void *data" "CC_LONG len" "unsigned char *md"
60.Pp
61.Ft extern int
62.Fn CC_SHA384_Init "CC_SHA512_CTX *c"
63.Ft extern int
64.Fn CC_SHA384_Update "CC_SHA512_CTX *c" "const void *data" "CC_LONG len"
65.Ft extern int
66.Fn CC_SHA384_Final "unsigned char *md" "CC_SHA512_CTX *c"
67.Ft extern unsigned char *
68.Fn CC_SHA384 "const void *data" "CC_LONG len" "unsigned char *md"
69.Pp
70.Ft extern int
71.Fn CC_SHA512_Init "CC_SHA512_CTX *c"
72.Ft extern int
73.Fn CC_SHA512_Update "CC_SHA512_CTX *c" "const void *data" "CC_LONG len"
74.Ft extern int
75.Fn CC_SHA512_Final "unsigned char *md" "CC_SHA512_CTX *c"
76.Ft extern unsigned char *
77.Fn CC_SHA512 "const void *data" "CC_LONG len" "unsigned char *md"
78.Sh DESCRIPTION
79SHA\-1 (Secure Hash Algorithm) is a cryptographic hash function with a
80160 bit output.
81.Pp
82.Fn CC_SHA1
83computes the SHA\-1 message digest of the len
84bytes at data and places it in md (which must have space for
85.Ft CC_SHA1_DIGEST_LENGTH
86== 20 bytes of output). It returns the md pointer.
87.Pp
88.Fn CC_SHA1_Init
89initializes a
90.Ft CC_SHA1_CTX
91structure.
92.Pp
93.Fn CC_SHA1_Update
94can be called repeatedly with chunks of the message to
95be hashed (len bytes at data).
96.Pp
97.Fn CC_SHA1_Final
98places the message digest in md, which must have space
99for
100.Ft CC_SHA1_DIGEST_LENGTH
101== 20 bytes of output, and erases the
102.Ft CC_SHA1_CTX .
103.Pp
104The successor versions of SHA\-1, SHA-2, are also implemented for hash
105bit lengths of 224, 256, 384, and 512.  The functions to call to invoke the larger hash-size
106versions of the algorithms include the hash size as part of the function names:
107.Pp
108.Fn CC_SHA224_Init ,
109.Fn CC_SHA224_Update ,
110.Fn CC_SHA224_Final ,
111.Fn CC_SHA224
112.Pp
113.Fn CC_SHA256_Init ,
114.Fn CC_SHA256_Update ,
115.Fn CC_SHA256_Final ,
116.Fn CC_SHA256
117.Pp
118.Fn CC_SHA384_Init ,
119.Fn CC_SHA384_Update ,
120.Fn CC_SHA384_Final ,
121.Fn CC_SHA384
122.Pp
123.Fn CC_SHA512_Init ,
124.Fn CC_SHA512_Update ,
125.Fn CC_SHA512_Final ,
126.Fn CC_SHA512
127.Sh RETURN VALUES
128All routines return 1 except for the one-shot routines (
129.Fn CC_SHA1 ,
130etc.), which
131return the pointer passed in via the md parameter.
132.Sh CONFORMING TO
133SHA\-1: US Federal Information Processing Standard FIPS PUB 180\-1 (Secure Hash
134Standard),
135ANSI X9.30
136.Pp
137SHA\-2: US Federal Information Processing Standard FIPS PUB 180\-2 (Secure Hash
138Standard)
139.Sh HISTORY
140These functions are available in OS X 10.4 and later.
141.Pp
142These functions provide similar functionality to the routines found in OpenSSL 0.9.6
143and may use the same implementation.
144.Sh SEE ALSO
145.Xr CC_MD5 3cc ,
146.Xr CCCryptor 3cc ,
147.Xr CCHmac 3cc ,
148.Xr CC_crypto 3cc
149