Squid Web Cache master
Loading...
Searching...
No Matches
md5.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2026 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#ifndef SQUID_INCLUDE_MD5_H
10#define SQUID_INCLUDE_MD5_H
11
12#if HAVE_NETTLE_MD5_H
13#include <nettle/md5.h>
14
15#if HAVE_NETTLE_VERSION_H
16#include <nettle/version.h>
17#endif
18
19typedef struct md5_ctx SquidMD5_CTX;
20
21#define SquidMD5Init(c) md5_init((c))
22#define SquidMD5Update(c,b,l) md5_update((c), (l), (const uint8_t *)(b))
23
24#if NETTLE_VERSION_MAJOR >= 4
25#define SquidMD5Final(d,c) md5_digest((c), (uint8_t *)(d))
26#else
27#define SquidMD5Final(d,c) md5_digest((c), MD5_DIGEST_SIZE, (uint8_t *)(d))
28#endif
29
30#define SQUID_MD5_DIGEST_LENGTH MD5_DIGEST_SIZE
31
32#else
33/*
34 * This is the header file for the MD5 message-digest algorithm.
35 * The algorithm is due to Ron Rivest. This code was
36 * written by Colin Plumb in 1993, no copyright is claimed.
37 * This code is in the public domain; do with it what you wish.
38 *
39 * Equivalent code is available from RSA Data Security, Inc.
40 * This code has been tested against that, and is equivalent,
41 * except that you don't need to include two pages of legalese
42 * with every copy.
43 *
44 * To compute the message digest of a chunk of bytes, declare an
45 * MD5Context structure, pass it to MD5Init, call MD5Update as
46 * needed on buffers full of bytes, and then call MD5Final, which
47 * will fill a supplied 16-byte array with the digest.
48 *
49 * Changed so as no longer to depend on Colin Plumb's `usual.h'
50 * header definitions; now uses stuff from dpkg's config.h
51 * - Ian Jackson <ian@chiark.greenend.org.uk>.
52 * Still in the public domain.
53 *
54 * Changed MD5Update to take a void * for easier use and some other
55 * minor cleanup. - Henrik Nordstrom <henrik@henriknordstrom.net>.
56 * Still in the public domain.
57 *
58 * Prefixed all symbols with "Squid" so they don't collide with
59 * other libraries. Duane Wessels <wessels@squid-cache.org>.
60 * Still in the public domain.
61 *
62 */
63
64typedef struct SquidMD5Context {
65 uint32_t buf[4];
66 uint32_t bytes[2];
67 uint32_t in[16];
69
70SQUIDCEXTERN void SquidMD5Init(struct SquidMD5Context *context);
71SQUIDCEXTERN void SquidMD5Update(struct SquidMD5Context *context, const void *buf, unsigned len);
72SQUIDCEXTERN void SquidMD5Final(uint8_t digest[16], struct SquidMD5Context *context);
73SQUIDCEXTERN void SquidMD5Transform(uint32_t buf[4], uint32_t const in[16]);
74
75#define SQUID_MD5_DIGEST_LENGTH 16
76
77#endif /* HAVE_NETTLE_MD5_H */
78
79#endif /* SQUID_INCLUDE_MD5_H */
80
SQUIDCEXTERN void SquidMD5Init(struct SquidMD5Context *context)
Definition md5.cc:73
SQUIDCEXTERN void SquidMD5Update(struct SquidMD5Context *context, const void *buf, unsigned len)
Definition md5.cc:89
SQUIDCEXTERN void SquidMD5Transform(uint32_t buf[4], uint32_t const in[16])
Definition md5.cc:181
SQUIDCEXTERN void SquidMD5Final(uint8_t digest[16], struct SquidMD5Context *context)
struct SquidMD5Context SquidMD5_CTX
#define SQUIDCEXTERN
Definition squid.h:21
uint32_t bytes[2]
Definition md5.h:66
uint32_t buf[4]
Definition md5.h:65
uint32_t in[16]
Definition md5.h:67