1
by brian
clean slate |
1 |
/* Copyright (C) 2002, 2006 MySQL AB
|
2 |
||
3 |
This program is free software; you can redistribute it and/or modify
|
|
4 |
it under the terms of the GNU General Public License as published by
|
|
5 |
the Free Software Foundation; version 2 of the License.
|
|
6 |
||
7 |
This program is distributed in the hope that it will be useful,
|
|
8 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
GNU General Public License for more details.
|
|
11 |
||
12 |
You should have received a copy of the GNU General Public License
|
|
13 |
along with this program; if not, write to the Free Software
|
|
14 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
15 |
||
16 |
/*
|
|
17 |
This is the header file for code which implements the Secure
|
|
18 |
Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
|
|
19 |
April 17, 1995.
|
|
20 |
||
21 |
Many of the variable names in this code, especially the
|
|
22 |
single character names, were used because those were the names
|
|
23 |
used in the publication.
|
|
24 |
||
25 |
Please read the file sha1.c for more information.
|
|
26 |
||
27 |
Modified 2002 by Peter Zaitsev to better follow MySQL standards
|
|
28 |
*/
|
|
29 |
||
30 |
||
31 |
enum sha_result_codes |
|
32 |
{
|
|
33 |
SHA_SUCCESS = 0, |
|
34 |
SHA_NULL, /* Null pointer parameter */ |
|
35 |
SHA_INPUT_TOO_LONG, /* input data too long */ |
|
36 |
SHA_STATE_ERROR /* called Input after Result */ |
|
37 |
};
|
|
38 |
||
39 |
#define SHA1_HASH_SIZE 20 /* Hash size in bytes */ |
|
40 |
||
41 |
/*
|
|
42 |
This structure will hold context information for the SHA-1
|
|
43 |
hashing operation
|
|
44 |
*/
|
|
45 |
||
46 |
typedef struct SHA1_CONTEXT |
|
47 |
{
|
|
151
by Brian Aker
Ulonglong to uint64_t |
48 |
uint64_t Length; /* Message length in bits */ |
205
by Brian Aker
uint32 -> uin32_t |
49 |
uint32_t Intermediate_Hash[SHA1_HASH_SIZE/4]; /* Message Digest */ |
1
by brian
clean slate |
50 |
int Computed; /* Is the digest computed? */ |
51 |
int Corrupted; /* Is the message digest corrupted? */ |
|
206
by Brian Aker
Removed final uint dead types. |
52 |
int16_t Message_Block_Index; /* Index into message block array */ |
53 |
uint8_t Message_Block[64]; /* 512-bit message blocks */ |
|
1
by brian
clean slate |
54 |
} SHA1_CONTEXT; |
55 |
||
56 |
/*
|
|
57 |
Function Prototypes
|
|
58 |
*/
|
|
59 |
||
398.1.9
by Monty Taylor
Cleaned up stuff out of global.h. |
60 |
#ifdef __cplusplus
|
61 |
extern "C" { |
|
62 |
#endif
|
|
63 |
||
64 |
int mysql_sha1_reset(SHA1_CONTEXT*); |
|
65 |
int mysql_sha1_input(SHA1_CONTEXT*, const uint8_t *, unsigned int); |
|
66 |
int mysql_sha1_result(SHA1_CONTEXT* , uint8_t Message_Digest[SHA1_HASH_SIZE]); |
|
67 |
||
68 |
#ifdef __cplusplus
|
|
69 |
}
|
|
70 |
#endif
|