summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/sha1.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lib/sha1.h')
-rw-r--r--apps/plugins/lib/sha1.h116
1 files changed, 116 insertions, 0 deletions
diff --git a/apps/plugins/lib/sha1.h b/apps/plugins/lib/sha1.h
new file mode 100644
index 0000000000..6358d046d3
--- /dev/null
+++ b/apps/plugins/lib/sha1.h
@@ -0,0 +1,116 @@
1/* Taken from gnulib (http://savannah.gnu.org/projects/gnulib/) */
2/* Declarations of functions and data types used for SHA1 sum
3 library functions.
4 Copyright (C) 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
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 Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19
20#ifndef SHA1_H
21#define SHA1_H 1
22
23#include "plugin.h"
24
25/* Structure to save state of computation between the single steps. */
26struct sha1_ctx
27{
28 uint32_t A;
29 uint32_t B;
30 uint32_t C;
31 uint32_t D;
32 uint32_t E;
33
34 uint32_t total[2];
35 uint32_t buflen;
36 uint32_t buffer[32];
37};
38
39
40/* Initialize structure containing state of computation. */
41void sha1_init_ctx (struct sha1_ctx *ctx);
42
43/* Starting with the result of former calls of this function (or the
44 initialization function update the context for the next LEN bytes
45 starting at BUFFER.
46 It is necessary that LEN is a multiple of 64!!! */
47void sha1_process_block (const void *buffer, size_t len,
48 struct sha1_ctx *ctx);
49
50/* Starting with the result of former calls of this function (or the
51 initialization function update the context for the next LEN bytes
52 starting at BUFFER.
53 It is NOT required that LEN is a multiple of 64. */
54void sha1_process_bytes (const void *buffer, size_t len,
55 struct sha1_ctx *ctx);
56
57/* Process the remaining bytes in the buffer and put result from CTX
58 in first 20 bytes following RESBUF. The result is always in little
59 endian byte order, so that a byte-wise output yields to the wanted
60 ASCII representation of the message digest.
61
62 IMPORTANT: On some systems it is required that RESBUF be correctly
63 aligned for a 32 bits value. */
64void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
65
66
67/* Put result from CTX in first 20 bytes following RESBUF. The result is
68 always in little endian byte order, so that a byte-wise output yields
69 to the wanted ASCII representation of the message digest.
70
71 IMPORTANT: On some systems it is required that RESBUF is correctly
72 aligned for a 32 bits value. */
73void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf);
74
75/* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The
76 result is always in little endian byte order, so that a byte-wise
77 output yields to the wanted ASCII representation of the message
78 digest. */
79void *sha1_buffer (const char *buffer, size_t len, void *resblock);
80
81#endif
82
83
84/* hmac.h -- hashed message authentication codes
85 Copyright (C) 2005 Free Software Foundation, Inc.
86
87 This program is free software; you can redistribute it and/or modify
88 it under the terms of the GNU General Public License as published by
89 the Free Software Foundation; either version 2, or (at your option)
90 any later version.
91
92 This program is distributed in the hope that it will be useful,
93 but WITHOUT ANY WARRANTY; without even the implied warranty of
94 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
95 GNU General Public License for more details.
96
97 You should have received a copy of the GNU General Public License
98 along with this program; if not, write to the Free Software Foundation,
99 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
100
101/* Written by Simon Josefsson. */
102
103#ifndef HMAC_H
104#define HMAC_H 1
105
106#include <stddef.h>
107
108/* Compute Hashed Message Authentication Code with SHA-1, over BUFFER
109 data of BUFLEN bytes using the KEY of KEYLEN bytes, writing the
110 output to pre-allocated 20 byte minimum RESBUF buffer. Return 0 on
111 success. */
112int
113hmac_sha1 (const void *key, size_t keylen,
114 const void *in, size_t inlen, void *resbuf);
115
116#endif /* HMAC_H */