Implementation of HASH algorithms.
Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | A_SHA_DIGEST_LEN 20 |
#define | F1(x, y, z) (((x) & (y)) | (~(x) & (z))) |
#define | F2(x, y, z) (((x) & (z)) | ((y) & ~(z))) |
#define | F3(x, y, z) ((x) ^ (y) ^ (z)) |
#define | F4(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) |
#define | F5(x, y, z) ((y) ^ ((x) | ~(z))) |
#define | SHA1_CH(x, y, z) F1(x,y,z) |
SHA1 specific defines. More... | |
#define | SHA1_INERMEDIATE(A, B, C, D, E, W, K) |
#define | SHA1_MAJ(x, y, z) F4(x,y,z) |
#define | SHA256_CAP_SIGMA0(x) (SHA_ROTR(x, 2) ^ SHA_ROTR(x,13) ^ SHA_ROTR(x,22)) |
#define | SHA256_CAP_SIGMA1(x) (SHA_ROTR(x, 6) ^ SHA_ROTR(x,11) ^ SHA_ROTR(x,25)) |
#define | SHA256_CH(x, y, z) (z ^ (x & (y ^ z))) |
#define | SHA256_MAJ(x, y, z) ((x & y) | (z & (x | y))) |
#define | SHA256_SMALL_SIGMA0(x) (SHA_ROTR(x, 7) ^ SHA_ROTR(x,18) ^ SHA_SHR(x, 3)) |
SHA256 specific defines. More... | |
#define | SHA256_SMALL_SIGMA1(x) (SHA_ROTR(x,17) ^ SHA_ROTR(x,19) ^ SHA_SHR(x,10)) |
#define | SHA_PAD_BYTE 0x80 |
#define | SHA_PARITY(x, y, z) F3(x,y,z) |
Functions | |
void | DRV_hmac_sha1 (uint8 *pu8Key, uint32 u32KeyLength, uint8 *pu8Data, uint32 u32DataLength, uint8 *pu8Digest) |
void | DRV_HMAC_Vector (tpfHash fpHash, uint8 *pu8Key, uint32 u32KeyLength, tstrBuffer *pstrInData, uint8 u8NumInputs, uint8 *pu8Out) |
Perform the HMAC operation on a given vector of data streams using the hash function passed to the DRV_HMAC_Vector. More... | |
void | DRV_SHA1_Hash (tstrHashContext *pstrSha1Context, uint8 u8Flags, uint8 *pu8Data, uint32 u32DataLength, uint8 *pu8Digest) |
uint8 | pbkdf2_sha1 (uint8 *key, uint8 key_len, uint8 *data, uint8 data_len, uint8 *digest) |
This function runs the PBKDF2 on the data with a given key. More... | |
uint8 | pbkdf2_sha1_f (uint8 *key, uint8 key_length, uint8 *data, uint32 data_len, uint32 iterations, uint32 count, uint8 *digest) |
This function iterates the hashing of digest as per the key. More... | |
void | SHA1ProcessBlock (uint32 *pu32Sha1State, const uint8 *pu8MessageBlock) |
void | Sha_HashFinish (tstrHashContext *pstrHashCxt, uint8 *pu8LengthPadding) |
void | Sha_HashUpdate (tstrHashContext *pstrHashCxt, uint8 *pu8Data, uint32 u32DataLength) |
#define A_SHA_DIGEST_LEN 20 |
Referenced by pbkdf2_sha1(), and pbkdf2_sha1_f().
#define F1 | ( | x, | |
y, | |||
z | |||
) | (((x) & (y)) | (~(x) & (z))) |
#define F2 | ( | x, | |
y, | |||
z | |||
) | (((x) & (z)) | ((y) & ~(z))) |
#define F3 | ( | x, | |
y, | |||
z | |||
) | ((x) ^ (y) ^ (z)) |
#define F4 | ( | x, | |
y, | |||
z | |||
) | (((x) & (y)) | ((x) & (z)) | ((y) & (z))) |
#define F5 | ( | x, | |
y, | |||
z | |||
) | ((y) ^ ((x) | ~(z))) |
#define SHA1_CH | ( | x, | |
y, | |||
z | |||
) | F1(x,y,z) |
SHA1 specific defines.
Referenced by SHA1ProcessBlock().
#define SHA1_INERMEDIATE | ( | A, | |
B, | |||
C, | |||
D, | |||
E, | |||
W, | |||
K | |||
) |
Referenced by SHA1ProcessBlock().
#define SHA1_MAJ | ( | x, | |
y, | |||
z | |||
) | F4(x,y,z) |
Referenced by SHA1ProcessBlock().
#define SHA256_CH | ( | x, | |
y, | |||
z | |||
) | (z ^ (x & (y ^ z))) |
#define SHA256_MAJ | ( | x, | |
y, | |||
z | |||
) | ((x & y) | (z & (x | y))) |
SHA256 specific defines.
#define SHA_PAD_BYTE 0x80 |
Referenced by Sha_HashFinish().
#define SHA_PARITY | ( | x, | |
y, | |||
z | |||
) | F3(x,y,z) |
Referenced by SHA1ProcessBlock().
void DRV_hmac_sha1 | ( | uint8 * | pu8Key, |
uint32 | u32KeyLength, | ||
uint8 * | pu8Data, | ||
uint32 | u32DataLength, | ||
uint8 * | pu8Digest | ||
) |
References DRV_HMAC_Vector(), DRV_SHA1_Hash(), tstrBuffer::pu8Data, and tstrBuffer::u16BufferSize.
Referenced by pbkdf2_sha1_f().
void DRV_HMAC_Vector | ( | tpfHash | fpHash, |
uint8 * | pu8Key, | ||
uint32 | u32KeyLength, | ||
tstrBuffer * | pstrInData, | ||
uint8 | u8NumInputs, | ||
uint8 * | pu8Out | ||
) |
Perform the HMAC operation on a given vector of data streams using the hash function passed to the DRV_HMAC_Vector.
References M2M_MEMSET, NULL, SHA_BLOCK_SIZE, SHA_FLAGS_FINISH, SHA_FLAGS_FULL_HASH, SHA_FLAGS_INIT, SHA_FLAGS_UPDATE, SHA_MAX_DIGEST_SIZE, and tstrHashContext::u8DigestSize.
Referenced by DRV_hmac_sha1().
void DRV_SHA1_Hash | ( | tstrHashContext * | pstrSha1Context, |
uint8 | u8Flags, | ||
uint8 * | pu8Data, | ||
uint32 | u32DataLength, | ||
uint8 * | pu8Digest | ||
) |
References tstrHashContext::au32HashState, tstrHashContext::fpHash, M2M_MEMSET, NULL, PUTU32, SHA1_DIGEST_SIZE, SHA1ProcessBlock(), SHA_BLOCK_SIZE, SHA_FLAGS_FINISH, SHA_FLAGS_INIT, SHA_FLAGS_UPDATE, Sha_HashFinish(), Sha_HashUpdate(), tstrHashContext::u32TotalLength, tstrHashContext::u8BlockSize, and tstrHashContext::u8DigestSize.
Referenced by DRV_hmac_sha1().
This function runs the PBKDF2 on the data with a given key.
To obtain the PSK from the password, PBKDF2 is run on SSID (data) with password (key).
References A_SHA_DIGEST_LEN, and pbkdf2_sha1_f().
Referenced by m2m_wifi_connect(), and m2m_wifi_enable_ap().
uint8 pbkdf2_sha1_f | ( | uint8 * | key, |
uint8 | key_length, | ||
uint8 * | data, | ||
uint32 | data_len, | ||
uint32 | iterations, | ||
uint32 | count, | ||
uint8 * | digest | ||
) |
This function iterates the hashing of digest as per the key.
References A_SHA_DIGEST_LEN, DRV_hmac_sha1(), and m2m_memcpy().
Referenced by pbkdf2_sha1().
References GETU32, SHA1_CH, SHA1_INERMEDIATE, SHA1_MAJ, SHA_PARITY, and SHA_ROTL.
Referenced by DRV_SHA1_Hash(), and SHA1_HashSW().
void Sha_HashFinish | ( | tstrHashContext * | pstrHashCxt, |
uint8 * | pu8LengthPadding | ||
) |
References tstrHashContext::au32HashState, tstrHashContext::au8CurrentBlock, tstrHashContext::fpHash, M2M_MEMCPY, M2M_MEMSET, NULL, SHA_PAD_BYTE, tstrHashContext::u32TotalLength, and tstrHashContext::u8BlockSize.
Referenced by DRV_SHA1_Hash(), MD4_Hash(), MD5_HashSW(), SHA1_HashSW(), SHA224_HashSW(), SHA256_HashSW(), and SHA512_HashSW().
void Sha_HashUpdate | ( | tstrHashContext * | pstrHashCxt, |
uint8 * | pu8Data, | ||
uint32 | u32DataLength | ||
) |
References tstrHashContext::au32HashState, tstrHashContext::au8CurrentBlock, tstrHashContext::fpHash, M2M_MEMCPY, NULL, tstrHashContext::u32TotalLength, and tstrHashContext::u8BlockSize.
Referenced by DRV_SHA1_Hash(), MD4_Hash(), MD5_HashSW(), SHA1_HashSW(), SHA224_HashSW(), SHA256_HashSW(), and SHA512_HashSW().