]> git.ipfire.org Git - thirdparty/glibc.git/blame - locale/programs/md5.h
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / locale / programs / md5.h
CommitLineData
b13927da
UD
1/* Declaration of functions and data types used for MD5 sum computing
2 library functions.
dff8da6b 3 Copyright (C) 1995-2024 Free Software Foundation, Inc.
68dbb3a6
UD
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
68dbb3a6
UD
10
11 The GNU C Library 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 GNU
41bdb6e2 14 Lesser General Public License for more details.
68dbb3a6 15
41bdb6e2 16 You should have received a copy of the GNU Lesser General Public
59ba27a6 17 License along with the GNU C Library; if not, see
5a82c748 18 <https://www.gnu.org/licenses/>. */
68dbb3a6
UD
19
20#ifndef _MD5_H
21#define _MD5_H 1
22
d91c4c2e
RM
23#define MD5_DIGEST_SIZE 16
24#define MD5_BLOCK_SIZE 64
25
68dbb3a6
UD
26/* The following contortions are an attempt to use the C preprocessor
27 to determine an unsigned integral type that is 32 bits wide. An
28 alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
29 doing that would require that the configure script compile and *run*
30 the resulting executable. Locally running cross-compiled executables
31 is usually not possible. */
32
e6e3c666 33#include <stdint.h>
35d30630
UD
34typedef uint32_t md5_uint32;
35typedef uintptr_t md5_uintptr;
68dbb3a6 36
68dbb3a6
UD
37/* Structure to save state of computation between the single steps. */
38struct md5_ctx
39{
40 md5_uint32 A;
41 md5_uint32 B;
42 md5_uint32 C;
43 md5_uint32 D;
44
45 md5_uint32 total[2];
46 md5_uint32 buflen;
7dc6bd90
UD
47 union
48 {
49 char buffer[128];
50 md5_uint32 buffer32[32];
51 };
68dbb3a6
UD
52};
53
54/*
55 * The following three functions are build up the low level used in
56 * the functions `md5_stream' and `md5_buffer'.
57 */
58
59/* Initialize structure containing state of computation.
60 (RFC 1321, 3.3: Step 3) */
79937577 61extern void __md5_init_ctx (struct md5_ctx *ctx) __THROW;
68dbb3a6
UD
62
63/* Starting with the result of former calls of this function (or the
64 initialization function update the context for the next LEN bytes
65 starting at BUFFER.
66 It is necessary that LEN is a multiple of 64!!! */
79937577
UD
67extern void __md5_process_block (const void *buffer, size_t len,
68 struct md5_ctx *ctx) __THROW;
68dbb3a6
UD
69
70/* Starting with the result of former calls of this function (or the
71 initialization function update the context for the next LEN bytes
72 starting at BUFFER.
73 It is NOT required that LEN is a multiple of 64. */
79937577
UD
74extern void __md5_process_bytes (const void *buffer, size_t len,
75 struct md5_ctx *ctx) __THROW;
68dbb3a6
UD
76
77/* Process the remaining bytes in the buffer and put result from CTX
78 in first 16 bytes following RESBUF. The result is always in little
79 endian byte order, so that a byte-wise output yields to the wanted
80 ASCII representation of the message digest.
81
82 IMPORTANT: On some systems it is required that RESBUF is correctly
83 aligned for a 32 bits value. */
79937577 84extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW;
68dbb3a6
UD
85
86
87/* Put result from CTX in first 16 bytes following RESBUF. The result is
88 always in little endian byte order, so that a byte-wise output yields
89 to the wanted ASCII representation of the message digest.
90
91 IMPORTANT: On some systems it is required that RESBUF is correctly
92 aligned for a 32 bits value. */
79937577 93extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW;
68dbb3a6 94
68dbb3a6
UD
95/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
96 result is always in little endian byte order, so that a byte-wise
97 output yields to the wanted ASCII representation of the message
98 digest. */
79937577
UD
99extern void *__md5_buffer (const char *buffer, size_t len,
100 void *resblock) __THROW;
68dbb3a6 101
36775c3b 102#endif /* md5.h */