CryptoAuthLib
Microchip CryptoAuthentication Library
sha1_routines.h
Go to the documentation of this file.
1 
28 #ifndef __SHA1_ROUTINES_DOT_H__
29 #define __SHA1_ROUTINES_DOT_H__
30 
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <stddef.h>
34 
35 #ifdef WIN32
36 #include <windows.h>
37 #include <assert.h>
38 #endif
39 
40 #include <stdint.h>
41 
42 
43 #ifndef U8
44 #define U8 uint8_t
45 #endif
46 
47 #ifndef U16
48 #define U16 uint16_t
49 #endif
50 
51 #ifndef U32
52 #define U32 uint32_t
53 #endif
54 
55 
56 #ifndef memcpy_P
57 #define memcpy_P memmove
58 #endif
59 
60 #ifndef strcpy_P
61 #define strcpy_P strcpy
62 #endif
63 
64 #ifndef _WDRESET
65 #define _WDRESET()
66 #define _NOP()
67 #endif
68 
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72 
73 typedef struct
74 {
75  U32 h[20 / 4]; // Ensure it's word aligned
76  U32 buf[64 / 4]; // Ensure it's word aligned
80 
81 #define leftRotate(x, n) (x) = (((x) << (n)) | ((x) >> (32 - (n))))
82 
83 void shaEngine(U32 *buf, U32 *h);
84 void CL_hashInit(CL_HashContext *ctx);
85 void CL_hashUpdate(CL_HashContext *ctx, const U8 *src, int nbytes);
86 void CL_hashFinal(CL_HashContext *ctx, U8 *dest);
87 void CL_hash(U8 *msg, int msgBytes, U8 *dest);
88 
89 #ifdef __cplusplus
90 }
91 #endif
92 
93 #endif // __SHA1_ROUTINES_DOT_H__
94 
Definition: sha1_routines.h:73
void shaEngine(U32 *buf, U32 *h)
Definition: sha1_routines.c:222
#define U8
Definition: sha1_routines.h:44
void CL_hash(U8 *msg, int msgBytes, U8 *dest)
Perform SHA1 hash of data in software.
Definition: sha1_routines.c:213
void CL_hashInit(CL_HashContext *ctx)
Initialize context for performing SHA1 hash in software.
Definition: sha1_routines.c:37
U32 byteCountHi
Definition: sha1_routines.h:78
void CL_hashFinal(CL_HashContext *ctx, U8 *dest)
Complete the SHA1 hash in software and return the digest.
Definition: sha1_routines.c:140
U32 byteCount
Definition: sha1_routines.h:77
void CL_hashUpdate(CL_HashContext *ctx, const U8 *src, int nbytes)
Add arbitrary data to a SHA1 hash.
Definition: sha1_routines.c:62
#define U32
Definition: sha1_routines.h:52