Sync with trunk revision 64099.
[reactos.git] / include / reactos / libs / gnutls / nettle / sha1.h
1 /* sha1.h
2 *
3 * The sha1 hash function.
4 */
5
6 /* nettle, low-level cryptographics library
7 *
8 * Copyright (C) 2001, 2012 Niels Möller
9 *
10 * The nettle library is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or (at your
13 * option) any later version.
14 *
15 * The nettle library is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with the nettle library; see the file COPYING.LIB. If not, write to
22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 * MA 02111-1301, USA.
24 */
25
26 #ifndef NETTLE_SHA1_H_INCLUDED
27 #define NETTLE_SHA1_H_INCLUDED
28
29 #include "nettle-types.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /* Name mangling */
36 #define sha1_init nettle_sha1_init
37 #define sha1_update nettle_sha1_update
38 #define sha1_digest nettle_sha1_digest
39
40 /* SHA1 */
41
42 #define SHA1_DIGEST_SIZE 20
43 #define SHA1_DATA_SIZE 64
44
45 /* Digest is kept internally as 5 32-bit words. */
46 #define _SHA1_DIGEST_LENGTH 5
47
48 struct sha1_ctx {
49 uint32_t state[_SHA1_DIGEST_LENGTH]; /* State variables */
50 uint32_t count_low, count_high; /* 64-bit block count */
51 uint8_t block[SHA1_DATA_SIZE]; /* SHA1 data buffer */
52 unsigned int index; /* index into buffer */
53 };
54
55 void
56 sha1_init(struct sha1_ctx *ctx);
57
58 void
59 sha1_update(struct sha1_ctx *ctx,
60 unsigned length, const uint8_t * data);
61
62 void
63 sha1_digest(struct sha1_ctx *ctx,
64 unsigned length, uint8_t * digest);
65
66 /* Internal compression function. STATE points to 5 uint32_t words,
67 and DATA points to 64 bytes of input data, possibly unaligned. */
68 void
69 _nettle_sha1_compress(uint32_t * state, const uint8_t * data);
70
71 #ifdef __cplusplus
72 }
73 #endif
74 #endif /* NETTLE_SHA1_H_INCLUDED */