1 /* Declarations of functions and data types used for SHA1 sum
3 Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation, Inc.
4 Copyright (C) 2006 Michael Vrable
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
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.
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. */
26 typedef uint32_t md5_uint32;
28 /* Structure to save state of computation between the single steps. */
39 char buffer[128] __attribute__ ((__aligned__ (__alignof__ (md5_uint32))));
43 /* Initialize structure containing state of computation. */
44 extern void sha1_init_ctx (struct sha1_ctx *ctx);
46 /* Starting with the result of former calls of this function (or the
47 initialization function update the context for the next LEN bytes
49 It is necessary that LEN is a multiple of 64!!! */
50 extern void sha1_process_block (const void *buffer, size_t len,
51 struct sha1_ctx *ctx);
53 /* Starting with the result of former calls of this function (or the
54 initialization function update the context for the next LEN bytes
56 It is NOT required that LEN is a multiple of 64. */
57 extern void sha1_process_bytes (const void *buffer, size_t len,
58 struct sha1_ctx *ctx);
60 /* Process the remaining bytes in the buffer and put result from CTX
61 in first 20 bytes following RESBUF. The result is always in little
62 endian byte order, so that a byte-wise output yields to the wanted
63 ASCII representation of the message digest.
65 IMPORTANT: On some systems it is required that RESBUF be correctly
66 aligned for a 32 bits value. */
67 extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
70 /* Put result from CTX in first 20 bytes following RESBUF. The result is
71 always in little endian byte order, so that a byte-wise output yields
72 to the wanted ASCII representation of the message digest.
74 IMPORTANT: On some systems it is required that RESBUF is correctly
75 aligned for a 32 bits value. */
76 extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf);
78 /* An object-oriented wrapper around checksumming functionality. */
82 char resbuf[20] __attribute__ ((__aligned__ (__alignof__ (md5_uint32))));
88 void process(void *data, size_t len);
89 const uint8_t *checksum();
90 size_t checksum_size() const { return 20; }