• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) The Internet Society (2001).  All Rights Reserved.
3  *
4  * This document and translations of it may be copied and furnished to
5  * others, and derivative works that comment on or otherwise explain it
6  * or assist in its implementation may be prepared, copied, published
7  * and distributed, in whole or in part, without restriction of any
8  * kind, provided that the above copyright notice and this paragraph are
9  * included on all such copies and derivative works.  However, this
10  * document itself may not be modified in any way, such as by removing
11  * the copyright notice or references to the Internet Society or other
12  * Internet organizations, except as needed for the purpose of
13  * developing Internet standards in which case the procedures for
14  * copyrights defined in the Internet Standards process must be
15  * followed, or as required to translate it into languages other than
16  * English.
17  *
18  * The limited permissions granted above are perpetual and will not be
19  * revoked by the Internet Society or its successors or assigns.
20  *
21  * This document and the information contained herein is provided on an
22  * "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
23  * TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
24  * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
25  * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
26  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
27  */
28 
29 /*
30  *  sha1.h
31  *
32  *  Description:
33  *      This is the header file for code which implements the Secure
34  *      Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
35  *      April 17, 1995.
36  *
37  *      Many of the variable names in this code, especially the
38  *      single character names, were used because those were the names
39  *      used in the publication.
40  *
41  *      Please read the file sha1.c for more information.
42  *
43  */
44 
45 
46 #ifndef _SHA1_H_
47 #define _SHA1_H_
48 
49 #include <stdint.h>
50 /*
51  * If you do not have the ISO standard stdint.h header file, then you
52  * must typdef the following:
53  *    name              meaning
54  *  uint32_t         unsigned 32 bit integer
55  *  uint8_t          unsigned 8 bit integer (i.e., unsigned char)
56  *  int_least16_t    integer of >= 16 bits
57  *
58  */
59 
60 #ifndef _SHA_enum_
61 #define _SHA_enum_
62 enum
63 {
64     shaSuccess = 0,
65     shaNull,            /* Null pointer parameter */
66     shaInputTooLong,    /* input data too long */
67     shaStateError       /* called Input after Result */
68 };
69 #endif
70 #define SHA1HashSize 20
71 
72 /*
73  *  This structure will hold context information for the SHA-1
74  *  hashing operation
75  */
76 typedef struct SHA1Context
77 {
78     uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest  */
79 
80     uint32_t Length_Low;            /* Message length in bits      */
81     uint32_t Length_High;           /* Message length in bits      */
82 
83                                /* Index into message block array   */
84     int_least16_t Message_Block_Index;
85     uint8_t Message_Block[64];      /* 512-bit message blocks      */
86 
87     int Computed;               /* Is the digest computed?         */
88     int Corrupted;             /* Is the message digest corrupted? */
89 } SHA1Context;
90 
91 /*
92  *  Function Prototypes
93  */
94 int SHA1Reset(  SHA1Context *);
95 int SHA1Input(  SHA1Context *,
96                 const uint8_t *,
97                 unsigned int);
98 int SHA1Result( SHA1Context *,
99                 uint8_t Message_Digest[SHA1HashSize]);
100 
101 #endif
102