Software implementation of the SHA1 algorithm.
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
Data Structures | |
struct | CL_HashContext |
Macros | |
#define | _NOP() |
#define | _WDRESET() |
#define | leftRotate(x, n) (x) = (((x) << (n)) | ((x) >> (32 - (n)))) |
#define | memcpy_P memmove |
#define | strcpy_P strcpy |
#define | U16 uint16_t |
#define | U32 uint32_t |
#define | U8 uint8_t |
Functions | |
void | CL_hash (U8 *msg, int msgBytes, U8 *dest) |
Perform SHA1 hash of data in software. More... | |
void | CL_hashFinal (CL_HashContext *ctx, U8 *dest) |
Complete the SHA1 hash in software and return the digest. More... | |
void | CL_hashInit (CL_HashContext *ctx) |
Initialize context for performing SHA1 hash in software. More... | |
void | CL_hashUpdate (CL_HashContext *ctx, const U8 *src, int nbytes) |
Add arbitrary data to a SHA1 hash. More... | |
void | shaEngine (U32 *buf, U32 *h) |
#define _NOP | ( | ) |
#define _WDRESET | ( | ) |
#define leftRotate | ( | x, | |
n | |||
) | (x) = (((x) << (n)) | ((x) >> (32 - (n)))) |
Referenced by shaEngine().
#define memcpy_P memmove |
Referenced by CL_hashInit(), flashUpdateAppStartAddr(), and hwFlashWriteEepromPage().
#define strcpy_P strcpy |
#define U16 uint16_t |
#define U32 uint32_t |
#define U8 uint8_t |
Perform SHA1 hash of data in software.
[in] | msg | Data to be hashed |
[in] | msgBytes | Data size in bytes |
[out] | dest | Digest is returned here (20 bytes) |
References CL_hashFinal(), CL_hashInit(), and CL_hashUpdate().
void CL_hashFinal | ( | CL_HashContext * | ctx, |
U8 * | dest | ||
) |
Complete the SHA1 hash in software and return the digest.
[in] | ctx | Hash context |
[out] | dest | Digest is returned here (20 bytes) |
References CL_HashContext::buf, CL_HashContext::byteCount, CL_HashContext::byteCountHi, CL_HashContext::h, i, ptr, and shaEngine().
Referenced by atcac_sw_sha1_finish(), and CL_hash().
void CL_hashInit | ( | CL_HashContext * | ctx | ) |
Initialize context for performing SHA1 hash in software.
[in] | ctx | Hash context |
References CL_HashContext::h, and memcpy_P.
Referenced by atcac_sw_sha1_init(), and CL_hash().
void CL_hashUpdate | ( | CL_HashContext * | ctx, |
const U8 * | src, | ||
int | nbytes | ||
) |
Add arbitrary data to a SHA1 hash.
[in] | ctx | Hash context |
[in] | src | Data to be added to the hash |
[in] | nbytes | Data size in bytes |
References CL_HashContext::buf, CL_HashContext::byteCount, CL_HashContext::byteCountHi, CL_HashContext::h, i, and shaEngine().
Referenced by atcac_sw_sha1_update(), and CL_hash().
References leftRotate.
Referenced by CL_hashFinal(), and CL_hashUpdate().