summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/md5/md5.h
diff options
context:
space:
mode:
authorjsing <>2025-01-19 07:51:41 +0000
committerjsing <>2025-01-19 07:51:41 +0000
commita2f6e4db5ee489ac3600ec5518e9914d017f85de (patch)
treeec020deb0d1f679179eab8c5f4643191d4e623cc /src/lib/libcrypto/md5/md5.h
parent34423391bcc52ecedccc906e3945ef585e383920 (diff)
downloadopenbsd-a2f6e4db5ee489ac3600ec5518e9914d017f85de.tar.gz
openbsd-a2f6e4db5ee489ac3600ec5518e9914d017f85de.tar.bz2
openbsd-a2f6e4db5ee489ac3600ec5518e9914d017f85de.zip
Improve bit counter handling in MD5.
Like most hashes, MD5 needs to keep count of the number of bits in the message being processed. However, rather than using a 64 bit counter this is implemented using two 32 bit values (which is exposed in the public API). Even with this hurdle, we can still use 64 bit math and let the compiler figure out how to best handle the situation (hopefully avoiding compiler warnings on 16 bit platforms in the process!). On amd64 this code now requires two instructions, instead of the previous five. While here remove a comment that is excessively visible and no longer completely accurate (and if you're going to redefine types like MD5_WORD you kinda need to know what you're doing). ok tb@ (who's going to miss the dear diary style comments)
Diffstat (limited to 'src/lib/libcrypto/md5/md5.h')
-rw-r--r--src/lib/libcrypto/md5/md5.h13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/lib/libcrypto/md5/md5.h b/src/lib/libcrypto/md5/md5.h
index a3529f486d..99e71783b9 100644
--- a/src/lib/libcrypto/md5/md5.h
+++ b/src/lib/libcrypto/md5/md5.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: md5.h,v 1.23 2024/06/01 07:44:11 tb Exp $ */ 1/* $OpenBSD: md5.h,v 1.24 2025/01/19 07:51:41 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -60,12 +60,13 @@
60 60
61#ifndef HEADER_MD5_H 61#ifndef HEADER_MD5_H
62#define HEADER_MD5_H 62#define HEADER_MD5_H
63
64#include <openssl/opensslconf.h>
65
63#if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__OpenBSD__) 66#if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__OpenBSD__)
64#define __bounded__(x, y, z) 67#define __bounded__(x, y, z)
65#endif 68#endif
66 69
67#include <openssl/opensslconf.h>
68
69#ifdef __cplusplus 70#ifdef __cplusplus
70extern "C" { 71extern "C" {
71#endif 72#endif
@@ -74,12 +75,6 @@ extern "C" {
74#error MD5 is disabled. 75#error MD5 is disabled.
75#endif 76#endif
76 77
77/*
78 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
79 * ! MD5_LONG has to be at least 32 bits wide. !
80 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
81 */
82
83#define MD5_LONG unsigned int 78#define MD5_LONG unsigned int
84 79
85#define MD5_CBLOCK 64 80#define MD5_CBLOCK 64