Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sha1.h
Go to the documentation of this file.
1 /* Declarations of functions and data types used for SHA1 sum
2  library functions.
3  Copyright (C) 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
4 
5  This program is free software; you can redistribute it and/or modify it
6  under the terms of the GNU General Public License as published by the
7  Free Software Foundation; either version 2, or (at your option) any
8  later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software Foundation,
17  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 
19 /* This file is taken from coreutils-6.2 (lib/sha1.h) and adapted for dibbler
20  * by Michal Kowalczuk <michal@kowalczuk.eu> */
21 
22 #ifndef SHA1_H
23 # define SHA1_H 1
24 
25 # include <stdio.h>
26 # include <stdint.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #define SHA1_BLOCKSIZE 64
33 #define SHA1_DIGESTSIZE 20
34 
35 /* Structure to save state of computation between the single steps. */
36 struct sha1_ctx
37 {
43 
47 };
48 
49 
50 /* Initialize structure containing state of computation. */
51 extern void sha1_init_ctx (struct sha1_ctx *ctx);
52 
53 /* Starting with the result of former calls of this function (or the
54  initialization function update the context for the next LEN bytes
55  starting at BUFFER.
56  It is necessary that LEN is a multiple of 64!!! */
57 extern void sha1_process_block (const void *buffer, size_t len,
58  struct sha1_ctx *ctx);
59 
60 /* Starting with the result of former calls of this function (or the
61  initialization function update the context for the next LEN bytes
62  starting at BUFFER.
63  It is NOT required that LEN is a multiple of 64. */
64 extern void sha1_process_bytes (const void *buffer, size_t len,
65  struct sha1_ctx *ctx);
66 
67 /* Process the remaining bytes in the buffer and put result from CTX
68  in first 20 bytes following RESBUF. The result is always in little
69  endian byte order, so that a byte-wise output yields to the wanted
70  ASCII representation of the message digest.
71 
72  IMPORTANT: On some systems it is required that RESBUF be correctly
73  aligned for a 32 bits value. */
74 extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
75 
76 
77 /* Put result from CTX in first 20 bytes following RESBUF. The result is
78  always in little endian byte order, so that a byte-wise output yields
79  to the wanted ASCII representation of the message digest.
80 
81  IMPORTANT: On some systems it is required that RESBUF is correctly
82  aligned for a 32 bits value. */
83 extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf);
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 #endif
90