Mercurial > dovecot > core-2.2
annotate src/lib/sha1.h @ 23007:36e01285b5b8
lib: buffer - Improve header comment for buffer_insert() and buffer_delete().
author | Stephan Bosch <stephan.bosch@dovecot.fi> |
---|---|
date | Mon, 18 Mar 2019 00:52:37 +0100 |
parents | f0e431db73d8 |
children |
rev | line source |
---|---|
2370 | 1 /* $FreeBSD: src/sys/crypto/sha1.h,v 1.8 2002/03/20 05:13:50 alfred Exp $ */ |
2 /* $KAME: sha1.h,v 1.5 2000/03/27 04:36:23 sumikawa Exp $ */ | |
3 | |
4 /* | |
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | |
6 * All rights reserved. | |
7 * | |
8 * Redistribution and use in source and binary forms, with or without | |
9 * modification, are permitted provided that the following conditions | |
10 * are met: | |
11 * 1. Redistributions of source code must retain the above copyright | |
12 * notice, this list of conditions and the following disclaimer. | |
13 * 2. Redistributions in binary form must reproduce the above copyright | |
14 * notice, this list of conditions and the following disclaimer in the | |
15 * documentation and/or other materials provided with the distribution. | |
16 * 3. Neither the name of the project nor the names of its contributors | |
17 * may be used to endorse or promote products derived from this software | |
18 * without specific prior written permission. | |
19 * | |
20 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND | |
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE | |
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
30 * SUCH DAMAGE. | |
31 */ | |
32 /* | |
33 * FIPS pub 180-1: Secure Hash Algorithm (SHA-1) | |
34 * based on: http://csrc.nist.gov/fips/fip180-1.txt | |
35 * implemented by Jun-ichiro itojun Itoh <itojun@itojun.org> | |
36 */ | |
37 | |
6410
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
4778
diff
changeset
|
38 #ifndef SHA1_H |
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
4778
diff
changeset
|
39 #define SHA1_H |
2370 | 40 |
12307
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
41 #include "hash-method.h" |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
42 |
4667
4cd8792b5fcb
Let's be nice and work with older libmysqlclient libraries.
Timo Sirainen <tss@iki.fi>
parents:
2628
diff
changeset
|
43 /* libmysqlclient really should try to keep its internal stuff internal so |
4cd8792b5fcb
Let's be nice and work with older libmysqlclient libraries.
Timo Sirainen <tss@iki.fi>
parents:
2628
diff
changeset
|
44 they won't conflict with the actual programs that are trying to use it. |
4cd8792b5fcb
Let's be nice and work with older libmysqlclient libraries.
Timo Sirainen <tss@iki.fi>
parents:
2628
diff
changeset
|
45 This particular instance has been fixed in 4.1.18 and 5.0.19, but there |
4cd8792b5fcb
Let's be nice and work with older libmysqlclient libraries.
Timo Sirainen <tss@iki.fi>
parents:
2628
diff
changeset
|
46 are others. */ |
4778
055deed128b7
Make it possible to take address of sha1_result() function.
Timo Sirainen <tss@iki.fi>
parents:
4667
diff
changeset
|
47 #define sha1_result sha1_result_libmysqlclient_craps_all_over |
4667
4cd8792b5fcb
Let's be nice and work with older libmysqlclient libraries.
Timo Sirainen <tss@iki.fi>
parents:
2628
diff
changeset
|
48 |
2370 | 49 struct sha1_ctxt { |
50 union { | |
2385
161a9e818ad6
Changed to use standard uint* types rather than u_int*. Also removed
Timo Sirainen <tss@iki.fi>
parents:
2370
diff
changeset
|
51 uint8_t b8[20]; |
161a9e818ad6
Changed to use standard uint* types rather than u_int*. Also removed
Timo Sirainen <tss@iki.fi>
parents:
2370
diff
changeset
|
52 uint32_t b32[5]; |
2370 | 53 } h; |
54 union { | |
2385
161a9e818ad6
Changed to use standard uint* types rather than u_int*. Also removed
Timo Sirainen <tss@iki.fi>
parents:
2370
diff
changeset
|
55 uint8_t b8[8]; |
161a9e818ad6
Changed to use standard uint* types rather than u_int*. Also removed
Timo Sirainen <tss@iki.fi>
parents:
2370
diff
changeset
|
56 uint64_t b64[1]; |
2370 | 57 } c; |
58 union { | |
2385
161a9e818ad6
Changed to use standard uint* types rather than u_int*. Also removed
Timo Sirainen <tss@iki.fi>
parents:
2370
diff
changeset
|
59 uint8_t b8[64]; |
161a9e818ad6
Changed to use standard uint* types rather than u_int*. Also removed
Timo Sirainen <tss@iki.fi>
parents:
2370
diff
changeset
|
60 uint32_t b32[16]; |
2370 | 61 } m; |
2386 | 62 uint8_t count; |
2370 | 63 }; |
64 | |
65 extern void sha1_init(struct sha1_ctxt *); | |
66 extern void sha1_pad(struct sha1_ctxt *); | |
2628
59059ea978b2
Change src from unsigned char* toi void* so callers don't have to do
Timo Sirainen <tss@iki.fi>
parents:
2386
diff
changeset
|
67 extern void sha1_loop(struct sha1_ctxt *, const void *, size_t); |
2370 | 68 extern void sha1_result(struct sha1_ctxt *, void *); |
69 | |
70 | |
71 /* compatibilty with other SHA1 source codes */ | |
72 typedef struct sha1_ctxt SHA1_CTX; | |
73 #define SHA1Init(x) sha1_init((x)) | |
74 #define SHA1Update(x, y, z) sha1_loop((x), (y), (z)) | |
75 #define SHA1Final(x, y) sha1_result((y), (x)) | |
76 | |
77 #define SHA1_RESULTLEN (160/8) | |
78 | |
20536
f0e431db73d8
lib: Potential compiling fix.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
20328
diff
changeset
|
79 extern void sha1_get_digest(const void *data, size_t size, |
f0e431db73d8
lib: Potential compiling fix.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
20328
diff
changeset
|
80 unsigned char result[STATIC_ARRAY SHA1_RESULTLEN]); |
2370 | 81 |
12307
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
82 extern const struct hash_method hash_method_sha1; |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
83 |
6410
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
4778
diff
changeset
|
84 #endif |