CryptoAuthLib
Microchip CryptoAuthentication Library
sha1_routines.h File Reference

Software implementation of the SHA1 algorithm. More...

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  CL_HashContext
 

Macros

#define U8   uint8_t
 
#define U16   uint16_t
 
#define U32   uint32_t
 
#define memcpy_P   memmove
 
#define strcpy_P   strcpy
 
#define _WDRESET()
 
#define _NOP()
 
#define leftRotate(x, n)   (x) = (((x) << (n)) | ((x) >> (32 - (n))))
 

Functions

void shaEngine (U32 *buf, U32 *h)
 
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 CL_hashFinal (CL_HashContext *ctx, U8 *dest)
 Complete the SHA1 hash in software and return the digest. More...
 
void CL_hash (U8 *msg, int msgBytes, U8 *dest)
 Perform SHA1 hash of data in software. More...
 

Detailed Description

Software implementation of the SHA1 algorithm.

Macro Definition Documentation

◆ _NOP

#define _NOP ( )

◆ _WDRESET

#define _WDRESET ( )

◆ leftRotate

#define leftRotate (   x,
 
)    (x) = (((x) << (n)) | ((x) >> (32 - (n))))

◆ memcpy_P

#define memcpy_P   memmove

◆ strcpy_P

#define strcpy_P   strcpy

◆ U16

#define U16   uint16_t

◆ U32

#define U32   uint32_t

◆ U8

#define U8   uint8_t

Function Documentation

◆ CL_hash()

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)

◆ CL_hashFinal()

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)

◆ CL_hashInit()

void CL_hashInit ( CL_HashContext ctx)

Initialize context for performing SHA1 hash in software.

Parameters
[in]ctxHash context

◆ CL_hashUpdate()

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

◆ shaEngine()

void shaEngine ( U32 buf,
U32 h 
)