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