RFC 6234 - US Secure Hash Algorithms (SHA and SHA-based HMAC and HKDF)
Published: May 2011
Status: Informational
Authors: D. Eastlake 3rd (Huawei), T. Hansen (AT&T Labs)
Obsoletes: RFC 4634
Updates: RFC 3174
Abstract
The United States of America has adopted a suite of Secure Hash Algorithms (SHAs), including four beyond SHA-1, as part of a Federal Information Processing Standard (FIPS), namely SHA-224, SHA-256, SHA-384, and SHA-512. This document makes open source code performing these SHA hash functions conveniently available to the Internet community. The sample code supports input strings of arbitrary bit length. Much of the text herein was adapted by the authors from FIPS 180-2.
This document replaces RFC 4634, fixing errata and adding code for an HMAC-based extract-and-expand Key Derivation Function, HKDF (RFC 5869). As with RFC 4634, code to perform SHA-based Hashed Message Authentication Codes (HMACs) is also included.
Contents
- 1. Overview of Contents
- 2. Notation for Bit Strings and Integers
- 3. Operations on Words
- 4. Message Padding and Parsing
- 4.1 SHA-224 and SHA-256
- 4.2 SHA-384 and SHA-512
- 5. Functions and Constants Used
- 5.1 SHA-224 and SHA-256
- 5.2 SHA-384 and SHA-512
- 6. Computing the Message Digest
- 6.1 SHA-224 and SHA-256 Initialization
- 6.2 SHA-224 and SHA-256 Processing
- 6.3 SHA-384 and SHA-512 Initialization
- 6.4 SHA-384 and SHA-512 Processing
- 7. HKDF- and SHA-Based HMACs
- 7.1 SHA-Based HMACs
- 7.2 HKDF
- 8. C Code for SHAs, HMAC, and HKDF
- 8.1 The Header Files
- 8.1.1 The .h file
- 8.1.2 stdint-example.h
- 8.1.3 sha-private.h
- 8.2 The SHA Code
- 8.2.1 sha1.c
- 8.2.2 sha224-256.c
- 8.2.3 sha384-512.c
- 8.2.4 usha.c
- 8.3 The HMAC Code
- 8.4 The HKDF Code
- 8.5 The Test Driver
- 8.1 The Header Files
- 9. Security Considerations
- 10. Acknowledgements
- 11. References
- 11.1 Normative References
- 11.2 Informative References
Appendix
Related Resources
- Official Text: RFC 6234
- Official Page: RFC 6234 DataTracker
- Errata: RFC Editor Errata