1 #ifndef SHA1_INCLUDED
2 #define SHA1_INCLUDED
3 
4 /* Copyright (c) 2002, 2006 MySQL AB, 2009 Sun Microsystems, Inc.
5    Use is subject to license terms.
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; version 2 of the License.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
21 /*
22  This is the header file for code which implements the Secure
23  Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
24  April 17, 1995.
25 
26  Many of the variable names in this code, especially the
27  single character names, were used because those were the names
28  used in the publication.
29 
30  Please read the file sha1.c for more information.
31 
32  Modified 2002 by Peter Zaitsev to better follow MySQL standards
33 
34   Original Source from: http://www.faqs.org/rfcs/rfc3174.html
35 
36   Copyright (C) The Internet Society (2001).  All Rights Reserved.
37 
38   This document and translations of it may be copied and furnished to
39   others, and derivative works that comment on or otherwise explain it
40   or assist in its implementation may be prepared, copied, published
41   and distributed, in whole or in part, without restriction of any
42   kind, provided that the above copyright notice and this paragraph are
43   included on all such copies and derivative works.  However, this
44   document itself may not be modified in any way, such as by removing
45   the copyright notice or references to the Internet Society or other
46   Internet organizations, except as needed for the purpose of
47   developing Internet standards in which case the procedures for
48   copyrights defined in the Internet Standards process must be
49   followed, or as required to translate it into languages other than
50   English.
51 
52   The limited permissions granted above are perpetual and will not be
53   revoked by the Internet Society or its successors or assigns.
54 
55   This document and the information contained herein is provided on an
56   "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
57   TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
58   BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
59   HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
60   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
61 
62   Acknowledgement
63   Funding for the RFC Editor function is currently provided by the
64   Internet Society.
65 */
66 
67 
68 enum sha_result_codes
69 {
70   SHA_SUCCESS = 0,
71   SHA_NULL,		/* Null pointer parameter */
72   SHA_INPUT_TOO_LONG,	/* input data too long */
73   SHA_STATE_ERROR	/* called Input after Result */
74 };
75 
76 #define SHA1_HASH_SIZE 20 /* Hash size in bytes */
77 
78 /*
79   This structure will hold context information for the SHA-1
80   hashing operation
81 */
82 
83 typedef struct SHA1_CONTEXT
84 {
85   ulonglong  Length;		/* Message length in bits      */
86   uint32 Intermediate_Hash[SHA1_HASH_SIZE/4]; /* Message Digest  */
87   int Computed;			/* Is the digest computed?	   */
88   int Corrupted;		/* Is the message digest corrupted? */
89   int16 Message_Block_Index;	/* Index into message block array   */
90   uint8 Message_Block[64];	/* 512-bit message blocks      */
91 } SHA1_CONTEXT;
92 
93 /*
94   Function Prototypes
95 */
96 
97 C_MODE_START
98 
99 int mysql_sha1_reset(SHA1_CONTEXT*);
100 int mysql_sha1_input(SHA1_CONTEXT*, const uint8 *, unsigned int);
101 int mysql_sha1_result(SHA1_CONTEXT* , uint8 Message_Digest[SHA1_HASH_SIZE]);
102 
103 C_MODE_END
104 
105 #endif /* SHA__INCLUDED */
106