Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45.
[cascardo/ovs.git] / lib / sha1.h
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 #ifndef _SHA1_H_
17 #define _SHA1_H_
18
19 #include <stdint.h>
20 /*
21  * If you do not have the ISO standard stdint.h header file, then you
22  * must typdef the following:
23  *    name              meaning
24  *  uint32_t         unsigned 32 bit integer
25  *  uint8_t          unsigned 8 bit integer (i.e., unsigned char)
26  *  int_least16_t    integer of >= 16 bits
27  *
28  */
29
30 #ifndef _SHA_enum_
31 #define _SHA_enum_
32 enum
33 {
34     shaSuccess = 0,
35     shaNull,            /* Null pointer parameter */
36     shaInputTooLong,    /* input data too long */
37     shaStateError       /* called Input after Result */
38 };
39 #endif
40 #define SHA1HashSize 20
41
42 /*
43  *  This structure will hold context information for the SHA-1
44  *  hashing operation
45  */
46 typedef struct SHA1Context
47 {
48     uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest  */
49
50     uint32_t Length_Low;            /* Message length in bits      */
51     uint32_t Length_High;           /* Message length in bits      */
52
53                                /* Index into message block array   */
54     int_least16_t Message_Block_Index;
55     uint8_t Message_Block[64];      /* 512-bit message blocks      */
56
57     int Computed;               /* Is the digest computed?         */
58     int Corrupted;             /* Is the message digest corrupted? */
59 } SHA1Context;
60
61 /*
62  *  Function Prototypes
63  */
64 int SHA1Reset(  SHA1Context *);
65 int SHA1Input(  SHA1Context *,
66                 const uint8_t *,
67                 unsigned int);
68 int SHA1Result( SHA1Context *,
69                 uint8_t Message_Digest[SHA1HashSize]);
70
71 void SHA1Bytes(const void *data, unsigned int n,
72                uint8_t Message_Digest[SHA1HashSize]);
73
74 #endif