summaryrefslogtreecommitdiff
path: root/openbsd-compat/sha1.h
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2015-08-19 14:23:51 +0100
committerColin Watson <cjwatson@debian.org>2015-08-19 16:48:11 +0100
commit0f0841b2d28b7463267d4d91577e72e3340a1d3a (patch)
treeba55fcd2b6e2cc22b30f5afb561dbb3da4c8b6c7 /openbsd-compat/sha1.h
parentf2a5f5dae656759efb0b76c3d94890b65c197a02 (diff)
parent8698446b972003b63dfe5dcbdb86acfe986afb85 (diff)
New upstream release (6.8p1).
Diffstat (limited to 'openbsd-compat/sha1.h')
-rw-r--r--openbsd-compat/sha1.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/openbsd-compat/sha1.h b/openbsd-compat/sha1.h
new file mode 100644
index 000000000..327d94cd5
--- /dev/null
+++ b/openbsd-compat/sha1.h
@@ -0,0 +1,58 @@
1/* $OpenBSD: sha1.h,v 1.24 2012/12/05 23:19:57 deraadt Exp $ */
2
3/*
4 * SHA-1 in C
5 * By Steve Reid <steve@edmweb.com>
6 * 100% Public Domain
7 */
8
9#ifndef _SHA1_H
10#define _SHA1_H
11
12#ifndef WITH_OPENSSL
13
14#define SHA1_BLOCK_LENGTH 64
15#define SHA1_DIGEST_LENGTH 20
16#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
17
18typedef struct {
19 u_int32_t state[5];
20 u_int64_t count;
21 u_int8_t buffer[SHA1_BLOCK_LENGTH];
22} SHA1_CTX;
23
24void SHA1Init(SHA1_CTX *);
25void SHA1Pad(SHA1_CTX *);
26void SHA1Transform(u_int32_t [5], const u_int8_t [SHA1_BLOCK_LENGTH])
27 __attribute__((__bounded__(__minbytes__,1,5)))
28 __attribute__((__bounded__(__minbytes__,2,SHA1_BLOCK_LENGTH)));
29void SHA1Update(SHA1_CTX *, const u_int8_t *, size_t)
30 __attribute__((__bounded__(__string__,2,3)));
31void SHA1Final(u_int8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *)
32 __attribute__((__bounded__(__minbytes__,1,SHA1_DIGEST_LENGTH)));
33char *SHA1End(SHA1_CTX *, char *)
34 __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
35char *SHA1File(const char *, char *)
36 __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
37char *SHA1FileChunk(const char *, char *, off_t, off_t)
38 __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH)));
39char *SHA1Data(const u_int8_t *, size_t, char *)
40 __attribute__((__bounded__(__string__,1,2)))
41 __attribute__((__bounded__(__minbytes__,3,SHA1_DIGEST_STRING_LENGTH)));
42
43#define HTONDIGEST(x) do { \
44 x[0] = htonl(x[0]); \
45 x[1] = htonl(x[1]); \
46 x[2] = htonl(x[2]); \
47 x[3] = htonl(x[3]); \
48 x[4] = htonl(x[4]); } while (0)
49
50#define NTOHDIGEST(x) do { \
51 x[0] = ntohl(x[0]); \
52 x[1] = ntohl(x[1]); \
53 x[2] = ntohl(x[2]); \
54 x[3] = ntohl(x[3]); \
55 x[4] = ntohl(x[4]); } while (0)
56
57#endif /* !WITH_OPENSSL */
58#endif /* _SHA1_H */