| 1 | /* |
| 2 | * sha1.h |
| 3 | * |
| 4 | * Description: |
| 5 | * This is the header file for code which implements the Secure |
| 6 | * Hashing Algorithm 1 as defined in FIPS PUB 180-1 published |
| 7 | * April 17, 1995. |
| 8 | * |
| 9 | * Many of the variable names in this code, especially the |
| 10 | * single character names, were used because those were the names |
| 11 | * used in the publication. |
| 12 | * |
| 13 | * Please read the file sha1.c for more information. |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #ifndef BASE_SHA1_RFC3174_H_INCLUDED |
| 18 | #define BASE_SHA1_RFC3174_H_INCLUDED |
| 19 | #pragma once |
| 20 | |
| 21 | #ifdef __cplusplus |
| 22 | extern "C" { |
| 23 | #endif |
| 24 | |
| 25 | /* |
| 26 | * If you do not have the ISO standard stdint.h header file, then you |
| 27 | * must typdef the following: |
| 28 | * name meaning |
| 29 | * uint32_t unsigned 32 bit integer |
| 30 | * uint8_t unsigned 8 bit integer (i.e., unsigned char) |
| 31 | * int_least16_t integer of >= 16 bits |
| 32 | * |
| 33 | */ |
| 34 | |
| 35 | #ifndef _SHA_enum_ |
| 36 | #define _SHA_enum_ |
| 37 | enum |
| 38 | { |
| 39 | shaSuccess = 0, |
| 40 | shaNull, /* Null pointer parameter */ |
| 41 | shaInputTooLong, /* input data too long */ |
| 42 | shaStateError /* called Input after Result */ |
| 43 | }; |
| 44 | #endif |
| 45 | #define SHA1HashSize 20 |
| 46 | |
| 47 | /* |
| 48 | * This structure will hold context information for the SHA-1 |
| 49 | * hashing operation |
| 50 | */ |
| 51 | typedef struct SHA1Context |
| 52 | { |
| 53 | uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */ |
| 54 | |
| 55 | uint32_t Length_Low; /* Message length in bits */ |
| 56 | uint32_t Length_High; /* Message length in bits */ |
| 57 | |
| 58 | /* Index into message block array */ |
| 59 | int16_t Message_Block_Index; |
| 60 | uint8_t Message_Block[64]; /* 512-bit message blocks */ |
| 61 | |
| 62 | int Computed; /* Is the digest computed? */ |
| 63 | int Corrupted; /* Is the message digest corrupted? */ |
| 64 | } SHA1Context; |
| 65 | |
| 66 | /* |
| 67 | * Function Prototypes |
| 68 | */ |
| 69 | |
| 70 | int SHA1Reset( SHA1Context *); |
| 71 | int SHA1Input( SHA1Context *, |
| 72 | const uint8_t *, |
| 73 | unsigned int); |
| 74 | int SHA1Result( SHA1Context *, |
| 75 | uint8_t Message_Digest[SHA1HashSize]); |
| 76 | |
| 77 | #ifdef __cplusplus |
| 78 | } |
| 79 | #endif |
| 80 | |
| 81 | #endif // BASE_SHA1_RFC3174_H_INCLUDED |
| 82 | |