Microchip® Advanced Software Framework

sha1_routines.h File Reference

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,
 
)    (x) = (((x) << (n)) | ((x) >> (32 - (n))))

Referenced by shaEngine().

#define memcpy_P   memmove
#define strcpy_P   strcpy
#define U16   uint16_t
#define U32   uint32_t
#define U8   uint8_t

void CL_hash ( U8 msg,
int  msgBytes,
U8 dest 
)

Perform SHA1 hash of data in software.

Parameters
[in]msgData to be hashed
[in]msgBytesData size in bytes
[out]destDigest 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.

Parameters
[in]ctxHash context
[out]destDigest 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.

Parameters
[in]ctxHash 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.

Parameters
[in]ctxHash context
[in]srcData to be added to the hash
[in]nbytesData 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().

void shaEngine ( U32 buf,
U32 h 
)

References leftRotate.

Referenced by CL_hashFinal(), and CL_hashUpdate().