|

| |
SHA1, SHA2, HMAC and Key Derivation in C
1. 15th October 2002. Updated to remove the use of the
'standard' fixed width integer types.
2. 30th November 2002. Updated to add SHA1, to improve
performance of SH256 and to remove an error in SHA384 and SHA512 for data
digests larger than 2^29 bytes (reported by Jan Krhovjak).
3. 26th August 2003. Updated to add more functions.
4. 26th January 2004. Added SHA224 and
support for bit level hashing.
5. 7th June 2004. Reverted to a version that handles
Microsoft 64-bit types in VC++ version 6
6. 23rd February 2005. Change to allow use on machines
with no 64-bit integer support (suggested by Peter Gutmann)
7. 26th August 2005 - Minor update to bring code in line
with types used in my AES code.
8. 22nd November 2006 - Minor update for type definitions
(brg_types.h)
9. 7th January 2007 - Minor update to fix error in
shasum.c (reported by several people).
This code implements the US NIST
Secure Hash Algorithms in C. Both SHA1 and SHA2 are provided. Code is also
provided for HMAC and for key derivation as described in RFC2898 and PKCS#5.
The performance of this code in machine cycles per data
byte on Intel and AMD systems for different hash data lengths is:
|
Data Length |
1 |
10 |
100 |
1,000 |
10,000 |
100,000 |
|
AMD64 (64 bit mode) |
| SHA1 |
672 |
70.1 |
13.07 |
9.79 |
9.4 |
9.7 |
| SHA224 |
1436 |
145.3 |
27.9 |
21.1 |
20.4 |
20.4 |
| SHA256 |
1483 |
149.9 |
28.4 |
21.1 |
20.4 |
20.4 |
| SHA384 |
1864 |
187.9 |
19.9 |
13.9 |
13.5 |
13.4 |
| SHA512 |
1939 |
195.6 |
20.6 |
14.0 |
13.5 |
13.4 |
|
AMD64 (32 bit mode) |
| SHA1 |
764 |
77.7 |
14.8 |
10.9 |
10.5 |
10.7 |
| SHA224 |
1608 |
161.9 |
31.3 |
23.8 |
23.2 |
23.6 |
| SHA256 |
1628 |
163.9 |
31.8 |
24.1 |
23.4 |
23.3 |
| SHA384 |
7246 |
725.4 |
73.7 |
54.2 |
52.9 |
52.6 |
| SHA512 |
7487 |
749.8 |
75.8 |
54.4 |
52.9 |
52.5 |
|
Intel P3 |
| SHA1 |
1401 |
128.1 |
22.9 |
20.5 |
20.2 |
17.2 |
| SHA224 |
2865 |
294.1 |
59.4 |
42.7 |
41.4 |
41.0 |
| SHA256 |
2993 |
292.5 |
55.8 |
42.7 |
41.5 |
41.0 |
| SHA384 |
23253 |
2380.1 |
241.9 |
177.9 |
174.5 |
173.1 |
| SHA512 |
23653 |
2433.7 |
239.2 |
177.5 |
174.7 |
172.8 |
My current implementation is here
Back to Brian Gladman's Home Page.
This page has
been accessed
times since
10th October 2000..
|