1 /*! 2 * \copy 3 * Copyright (c) 1998, 2009 Paul E. Jones <paulej@packetizer.com> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 * 31 */ 32 33 /* 34 * Description: 35 * This class implements the Secure Hashing Standard as defined 36 * in FIPS PUB 180-1 published April 17, 1995. 37 * 38 * Many of the variable names in the SHA1Context, especially the 39 * single character names, were used because those were the names 40 * used in the publication. 41 * 42 * Please read the file sha1.c for more information. 43 * 44 */ 45 46 #ifndef _SHA1_H_ 47 #define _SHA1_H_ 48 49 #ifdef __cplusplus 50 extern "C" { 51 #endif 52 53 /* 54 * This structure will hold context information for the hashing 55 * operation 56 */ 57 typedef struct SHA1Context { 58 unsigned Message_Digest[5]; /* Message Digest (output) */ 59 60 unsigned Length_Low; /* Message length in bits */ 61 unsigned Length_High; /* Message length in bits */ 62 63 unsigned char Message_Block[64]; /* 512-bit message blocks */ 64 int Message_Block_Index; /* Index into message block array */ 65 66 int Computed; /* Is the digest computed? */ 67 int Corrupted; /* Is the message digest corruped? */ 68 } SHA1Context; 69 70 /* 71 * Function Prototypes 72 */ 73 void SHA1Reset (SHA1Context*); 74 int SHA1Result (SHA1Context*, unsigned char*); 75 void SHA1Input (SHA1Context*, 76 const unsigned char*, 77 unsigned); 78 79 #define SHA_DIGEST_LENGTH 20 80 81 #ifdef __cplusplus 82 } 83 #endif 84 85 #endif 86