e-CryptIt Engine Xojo Plugin

HMAC_SHA1 Class (console safe)

Implements Keyed-Hashing using SHA1 for message authentication in compliance with RFC 2104 and 2202.

This algorithm has been tested against official test vectors.

Object
   HMAC_SHA1

class HMAC_SHA1 implements

IHashAlgorithm

Constructors

HMAC_SHA1The constructor for the HMAC_SHA1 takes a key as a parameter.

Methods

Final (console safe) Use this function when you are done adding bytes to the HMAC_SHA1 class.
Update (console safe) Use this method to add data with MemoryBlock to the HMAC_SHA1 stream.
Update (console safe) Use this method to add data with string to the HMAC_SHA1 stream.

Test case for a known test vector

Dim key as String
Dim data as String
Dim hmac as HMAC_SHA1
Dim result as String
Dim hexResult as String
Dim i as Integer

key = "Jefe"
data = "what do ya want for nothing?"

// We do this in ASCII because the well known test vectors come in ASCII
key = ConvertEncoding(key,Encodings.ASCII)
data = ConvertEncoding(data,Encodings.ASCII)

hmac = new HMAC_SHA1(key)

hmac.Update(data)

result = hmac.Final()

// Convert to HEX
For i = 1 to 20
    hexResult = hexResult + Right("0"+Hex(Asc(Mid(result,i,1))),2)
next

if hexResult = "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79" then
    return true
else
    return false
end if

Supported Platforms:

  • MacOS X Carbon
  • MacOS X Cocoa 32 bit
  • MacOS X Cocoa 64 bit
  • Windows 32 bit
  • Windows 64 bit
  • Linux 32 bit
  • Linux 64 bit
  • Linux ARM