MATH_CalcHMACSHA256

Syntax

#include <nitro/math/dgt.h>

static inline void MATH_CalcHMACSHA256( void* digest, const void* data, u32 dataLength, const void* key, u32 keyLength );

Arguments

digest Pointer to the memory location that holds the calculated keyed-hash value.
data Pointer to the input data.
dataLength Size of the input data.
key Pointer to the key.
keyLength The key size.

Return Values

None.

Description

This function calculates an HMAC (hash message authentication code) using SHA-256. The length of the generated keyed-hash value is 256 bits, or MATH_SHA256_DIGEST_SIZE (32) bytes. Use the "digest" argument to pass an area that can store a value of this size. Any size and alignment position can be used for the input data and key. However, if the key is smaller than MATH_SHA256_DIGEST_SIZE, it becomes weaker. Even if the key is larger than MATH_SHA256_DIGEST_SIZE, little additional strength is gained.

Internally, the stack size will be approximately 90 bytes greater than the size of the MATHSHA256Context structure. Make sure sufficient stack is available when calling. SHA-256 is an algorithm to find the message digest value. For details, refer to the Federal Information Processing Standard, FIPS PUB 180-2. HMAC is a keyed-hashing algorithm for message authentication. The algorithm that uses SHA-256 internally as a hash function is called HMAC-SHA-256. For details, see RFC 2104.

See Also

Revision History

2008/05/23 Initial version.


CONFIDENTIAL