From 69784f97df8510329937bba19f523812edccc9ad Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niels=20M=C3=B6ller?= Date: Sat, 24 Aug 2024 20:33:10 +0200 Subject: [PATCH] Delete md5-compat functions --- Makefile.in | 5 ++-- md5-compat.c | 56 ----------------------------------- md5-compat.h | 58 ------------------------------------- nettle.texinfo | 16 ---------- testsuite/Makefile.in | 2 +- testsuite/md5-compat-test.c | 52 --------------------------------- 6 files changed, 3 insertions(+), 186 deletions(-) delete mode 100644 md5-compat.c delete mode 100644 md5-compat.h delete mode 100644 testsuite/md5-compat-test.c diff --git a/Makefile.in b/Makefile.in index 71ad761e..e428d696 100644 --- a/Makefile.in +++ b/Makefile.in @@ -130,7 +130,7 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c aes-decrypt-table.c \ hmac-streebog-meta.c hmac-sm3-meta.c \ knuth-lfib.c hkdf.c \ md2.c md2-meta.c md4.c md4-meta.c \ - md5.c md5-compat.c md5-meta.c \ + md5.c md5-meta.c \ memeql-sec.c memxor.c memxor3.c \ nettle-lookup-hash.c \ nettle-meta-aeads.c nettle-meta-armors.c \ @@ -239,8 +239,7 @@ HEADERS = aes.h arcfour.h arctwo.h asn1.h blowfish.h balloon.h \ knuth-lfib.h hkdf.h \ macros.h \ cmac.h siv-cmac.h siv-gcm.h \ - md2.h md4.h \ - md5.h md5-compat.h \ + md2.h md4.h md5.h \ memops.h memxor.h \ nettle-meta.h nettle-types.h \ ocb.h pbkdf2.h \ diff --git a/md5-compat.c b/md5-compat.c deleted file mode 100644 index d0d6176a..00000000 --- a/md5-compat.c +++ /dev/null @@ -1,56 +0,0 @@ -/* md5-compat.c - - The md5 hash function, RFC 1321-style interface. - - Copyright (C) 2001 Niels Möller - - This file is part of GNU Nettle. - - GNU Nettle is free software: you can redistribute it and/or - modify it under the terms of either: - - * the GNU Lesser General Public License as published by the Free - Software Foundation; either version 3 of the License, or (at your - option) any later version. - - or - - * the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - or both in parallel, as here. - - GNU Nettle is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received copies of the GNU General Public License and - the GNU Lesser General Public License along with this program. If - not, see http://www.gnu.org/licenses/. -*/ - -#if HAVE_CONFIG_H -# include "config.h" -#endif - -#include "md5-compat.h" - -void -MD5Init(MD5_CTX *ctx) -{ - md5_init(ctx); -} - -void -MD5Update(MD5_CTX *ctx, const unsigned char *data, unsigned int length) -{ - md5_update(ctx, length, data); -} - -void -MD5Final(unsigned char *out, MD5_CTX *ctx) -{ - md5_digest(ctx, MD5_DIGEST_SIZE, out); -} diff --git a/md5-compat.h b/md5-compat.h deleted file mode 100644 index fd309821..00000000 --- a/md5-compat.h +++ /dev/null @@ -1,58 +0,0 @@ -/* md5-compat.h - - The md5 hash function, RFC 1321-style interface. - - Copyright (C) 2001 Niels Möller - - This file is part of GNU Nettle. - - GNU Nettle is free software: you can redistribute it and/or - modify it under the terms of either: - - * the GNU Lesser General Public License as published by the Free - Software Foundation; either version 3 of the License, or (at your - option) any later version. - - or - - * the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - or both in parallel, as here. - - GNU Nettle is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received copies of the GNU General Public License and - the GNU Lesser General Public License along with this program. If - not, see http://www.gnu.org/licenses/. -*/ - -#ifndef NETTLE_MD5_COMPAT_H_INCLUDED -#define NETTLE_MD5_COMPAT_H_INCLUDED - -#include "md5.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Name mangling */ -#define MD5Init nettle_MD5Init -#define MD5Update nettle_MD5Update -#define MD5Final nettle_MD5Final - -typedef struct md5_ctx MD5_CTX; - -void MD5Init(MD5_CTX *ctx); -void MD5Update(MD5_CTX *ctx, const unsigned char *data, unsigned int length); -void MD5Final(unsigned char *out, MD5_CTX *ctx); - -#ifdef __cplusplus -} -#endif - -#endif /* NETTLE_MD5_COMPAT_H_INCLUDED */ diff --git a/nettle.texinfo b/nettle.texinfo index 484480ca..70b01ab3 100644 --- a/nettle.texinfo +++ b/nettle.texinfo @@ -83,7 +83,6 @@ Reference * Randomness:: * ASCII encoding:: * Miscellaneous functions:: -* Compatibility functions:: Hash functions @@ -356,7 +355,6 @@ This chapter describes all the Nettle functions, grouped by family. * Randomness:: * ASCII encoding:: * Miscellaneous functions:: -* Compatibility functions:: @end menu @node Hash functions @@ -6597,20 +6595,6 @@ These functions are declared in @file{}. For compatibility with earlier versions of Nettle, @code{memxor} and @code{memxor3} are also declared in @file{}. -@node Compatibility functions -@section Compatibility functions - -For convenience, Nettle includes alternative interfaces to some -algorithms, for compatibility with some other popular crypto toolkits. -These are not fully documented here; refer to the source or to the -documentation for the original implementation. - -MD5 is defined in [RFC 1321], which includes a reference implementation. -Nettle defines a compatible interface to MD5 in -@file{}. This file defines the typedef -@code{MD5_CTX}, and declares the functions @code{MD5Init}, @code{MD5Update} and -@code{MD5Final}. - @node Nettle soup @chapter Traditional Nettle Soup For the serious nettle hacker, here is a recipe for nettle soup. 4 servings. diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in index 0699fa0d..92e8559f 100644 --- a/testsuite/Makefile.in +++ b/testsuite/Makefile.in @@ -16,7 +16,7 @@ TS_NETTLE_SOURCES = aes-test.c aes-keywrap-test.c arcfour-test.c arctwo-test.c \ camellia-test.c chacha-test.c \ cnd-memcpy-test.c \ des-test.c des3-test.c \ - md2-test.c md4-test.c md5-test.c md5-compat-test.c \ + md2-test.c md4-test.c md5-test.c \ memeql-test.c memxor-test.c gosthash94-test.c \ ripemd160-test.c hkdf-test.c \ salsa20-test.c \ diff --git a/testsuite/md5-compat-test.c b/testsuite/md5-compat-test.c deleted file mode 100644 index e2234009..00000000 --- a/testsuite/md5-compat-test.c +++ /dev/null @@ -1,52 +0,0 @@ -#include "testutils.h" -#include "md5-compat.h" - -void -test_main(void) -{ - MD5_CTX ctx; - unsigned char digest[MD5_DIGEST_SIZE]; - - MD5Init(&ctx); - MD5Final(digest, &ctx); - ASSERT(MEMEQ(MD5_DIGEST_SIZE, digest, - H("D41D8CD98F00B204 E9800998ECF8427E"))); - - MD5Init(&ctx); - MD5Update(&ctx, US("a"), 1); - MD5Final(digest, &ctx); - ASSERT(MEMEQ(MD5_DIGEST_SIZE, digest, - H("0CC175B9C0F1B6A8 31C399E269772661"))); - - MD5Init(&ctx); - MD5Update(&ctx, US("abc"), 3); - MD5Final(digest, &ctx); - ASSERT(MEMEQ(MD5_DIGEST_SIZE, digest, - H("900150983cd24fb0 D6963F7D28E17F72"))); - - MD5Init(&ctx); - MD5Update(&ctx, US("message digest"), 14); - MD5Final(digest, &ctx); - ASSERT(MEMEQ(MD5_DIGEST_SIZE, digest, - H("F96B697D7CB7938D 525A2F31AAF161D0"))); - - MD5Init(&ctx); - MD5Update(&ctx, US("abcdefghijklmnopqrstuvwxyz"), 26); - MD5Final(digest, &ctx); - ASSERT(MEMEQ(MD5_DIGEST_SIZE, digest, - H("C3FCD3D76192E400 7DFB496CCA67E13B"))); - - MD5Init(&ctx); - MD5Update(&ctx, US("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"), 62); - MD5Final(digest, &ctx); - ASSERT(MEMEQ(MD5_DIGEST_SIZE, digest, - H("D174AB98D277D9F5 A5611C2C9F419D9F"))); - - MD5Init(&ctx); - MD5Update(&ctx, US("1234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890"), - 80); - MD5Final(digest, &ctx); - ASSERT(MEMEQ(MD5_DIGEST_SIZE, digest, - H("57EDF4A22BE3C955 AC49DA2E2107B67A"))); -} -- 2.47.2