winzip icon

SHA2-based HMACs FIPS-180-4 [Update April 2020]

Submitted on: 4/2/2020 6:53:31 AM
By: Rde 
Level: Advanced
User Rating: By 2 Users
Compatibility: VB 5.0, VB 6.0
Views: 7192
author picture
      SHA2-based HMACs FIPS-180-4 [Update April 2020]

Hashed-key Message Authentication Codes (HMACs)

HMAC was devised by Hugo Krawczyk

The HMAC mechanism is described in RFC 2104: Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed-Hashing for Message Authentication", RFC 2104, February 1997.

A Hash-based Message Authentication Code can be used to determine if messages sent over insecure channels have been modified. This works by each party at boths ends sharing a secret key used to sign the sent message and to also authenticate the received message. If the key is compromised (no longer secret) then the authentication cannot be guaranteed.

HMAC is used for message integrity checks between two parties that share a secret key, and works in combination with a SHA-2 message digest algorithm.

HMAC is a method for computing a keyed MAC using a SHA-2 hash function. It uses a key to mix in with the input data to produce the final message digest.

This class makes very fast open source code performing all official SHA-2 hash functions (224-256-384-512-512/224-512/256) available to any OS on 32-bit x86 with rudimentary mmx.

Since SHA-2 is defined in terms of an arbitrary number of bits, this HMAC code has been written to allow the message input to HMAC to have an arbitrary number of octets and bits.

More information about HMAC can be found at:

Now includes option for Finalize to also return the message bit length. Latest 2020 update offers improved performance of the as$embler algorithm and provides all official digest size additions to the specification. Update April 2020 supersedes all prior versions.

100% compatible with the SHA-2 specification.
The official publication is available free of charge from:

winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net

Other 25 submission(s) by this author


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)

To post feedback, first please login.