1 /* Declaration of functions and data types used for SHA1 sum computing
3 Copyright (C) 2008 Red Hat, Inc.
4 This file is part of Red Hat elfutils.
5 Written by Ulrich Drepper <drepper@redhat.com>, 2008.
7 Red Hat elfutils is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by the
9 Free Software Foundation; version 2 of the License.
11 Red Hat elfutils is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with Red Hat elfutils; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
20 Red Hat elfutils is an included package of the Open Invention Network.
21 An included package of the Open Invention Network is a package for which
22 Open Invention Network licensees cross-license their patents. No patent
23 license is granted, either expressly or impliedly, by designation as an
24 included package. Should you wish to participate in the Open Invention
25 Network licensing program, please visit www.openinventionnetwork.com
26 <http://www.openinventionnetwork.com>. */
35 #define SHA1_DIGEST_SIZE 20
36 #define SHA1_BLOCK_SIZE 64
38 typedef uint32_t sha1_uint32;
39 typedef uintptr_t sha1_uintptr;
41 /* Structure to save state of computation between the single steps. */
52 char buffer[128] __attribute__ ((__aligned__ (__alignof__ (sha1_uint32))));
55 /* Initialize structure containing state of computation. */
56 extern void sha1_init_ctx (struct sha1_ctx *ctx);
58 /* Starting with the result of former calls of this function (or the
59 initialization function update the context for the next LEN bytes
61 It is necessary that LEN is a multiple of 64!!! */
62 extern void sha1_process_block (const void *buffer, size_t len,
63 struct sha1_ctx *ctx);
65 /* Starting with the result of former calls of this function (or the
66 initialization function update the context for the next LEN bytes
68 It is NOT required that LEN is a multiple of 64. */
69 extern void sha1_process_bytes (const void *buffer, size_t len,
70 struct sha1_ctx *ctx);
72 /* Process the remaining bytes in the buffer and put result from CTX
73 in first 20 bytes following RESBUF. The result is always in little
74 endian byte order, so that a byte-wise output yields to the wanted
75 ASCII representation of the message digest.
77 IMPORTANT: On some systems it is required that RESBUF is correctly
78 aligned for a 32 bits value. */
79 extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
82 /* Put result from CTX in first 20 bytes following RESBUF. The result is
83 always in little endian byte order, so that a byte-wise output yields
84 to the wanted ASCII representation of the message digest.
86 IMPORTANT: On some systems it is required that RESBUF is correctly
87 aligned for a 32 bits value. */
88 extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf);