Page 1 of 1

What algorithm for HMAC?

Posted: Mon Nov 14, 2011 7:34 pm
by e3anderp
Hi,

I am planning to implement a small tool that will encrypt large numbers of files and I find the AES file format used in AESCrypt suitable for my needs - I see no reason to reinvent the wheel there.

Anyway, all is clear to me except one thing, the HMAC.

In another thread here on the forum there is a link to Wikipedia regarding the HMAC, but that page lists "examples of HMAC" using MD5, SHA1 and SHA256. RFC 2104 also states that any iterative hash algorithm can be used.

Given the length of the HMAC fields in the file format, is SHA256 the only algorithm that can be used (HMAC-SHA-256)?

Re: What algorithm for HMAC?

Posted: Mon Nov 14, 2011 10:08 pm
by paulej
HMAC can be used with any kind of hash. It's a fairly simple algorithm:

Code: Select all

H(K XOR opad, H(K XOR ipad, text))
Any hash function could be used, but AES Crypt only uses SHA256. Look at the Linux source code for the most straight-forward and readable example usage.

Re: What algorithm for HMAC?

Posted: Tue Nov 15, 2011 8:31 am
by e3anderp
OK, thanks for the info - I'll have a look att the Linux implementation.

I'm going to use C# and .NET for my Windows app, hopefully the HMACSHA256 class does the same thing as the Aescrypt HMAC implementation. (http://msdn.microsoft.com/en-us/library ... ha256.aspx)