From: Ken Hornstein Date: Wed, 24 Apr 2019 14:25:18 +0000 (-0400) Subject: Removal of Content-MD5 support X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/43d9833bf1dcf38c7892a23951bf1d968028a15e?hp=c51d837b9bda943c5e0235b92ca3b98803185e17 Removal of Content-MD5 support The generation and verification of Content-MD5 headers is no longer done. FINALLY. --- diff --git a/Makefile.am b/Makefile.am index ed782681..cf106bb0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -339,7 +339,6 @@ noinst_HEADERS = \ h/fmt_compile.h \ h/fmt_scan.h \ h/icalendar.h \ - h/md5.h \ h/mf.h \ h/mh.h \ h/mhcachesbr.h \ @@ -1093,7 +1092,6 @@ sbr_libmh_a_SOURCES = \ sbr/m_popen.c \ sbr/m_rand.c \ sbr/makedir.c \ - sbr/md5.c \ sbr/message_id.c \ sbr/mf.c \ sbr/mime_type.c \ diff --git a/docs/pending-release-notes b/docs/pending-release-notes index e3b213c0..5438191d 100644 --- a/docs/pending-release-notes +++ b/docs/pending-release-notes @@ -17,6 +17,11 @@ OBSOLETE FEATURES DEPRECATED FEATURES ------------------- +- The generation and verification of Content-MD5 headers is no longer + performed. The -check and -nocheck switches to various nmh programs + that would control this functionality still exist, but are non-functional + and will be removed in the next release. + --------- BUG FIXES --------- diff --git a/h/md5.h b/h/md5.h deleted file mode 100644 index e1906046..00000000 --- a/h/md5.h +++ /dev/null @@ -1,49 +0,0 @@ -/* md5.h -- header file for md5 message digest - * taken from RFC-1321/Appendices A.1/A.2 - */ - -/* - * RSAREF types and constants - */ - -#include "nmh.h" -#include - -/* UINT4 defines a four byte word */ -typedef uint32_t UINT4; - -/* MD5.H - header file for MD5C.C - */ - -/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. - */ - -/* MD5 context. */ -typedef struct { - UINT4 state[4]; /* state (ABCD) */ - UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ - unsigned char buffer[64]; /* input buffer */ -} MD5_CTX; - -void MD5Init(MD5_CTX *); -void MD5Update(MD5_CTX *, unsigned char *, unsigned int); -void MD5Final(unsigned char [16], MD5_CTX *); diff --git a/h/mhparse.h b/h/mhparse.h index 96a37b0a..4052cc3c 100644 --- a/h/mhparse.h +++ b/h/mhparse.h @@ -139,10 +139,6 @@ struct Content { int c_encoding; /* internal flag for encoding type */ int c_reqencoding; /* Requested encoding (by mhbuild) */ - /* Content-MD5 info */ - int c_digested; /* have we seen this header before? */ - unsigned char c_digest[16]; /* decoded MD5 checksum */ - /* pointers to content-specific structures */ void *c_ctparams; /* content type specific data */ struct exbody *c_ctexbody; /* data for type message/external */ @@ -506,8 +502,6 @@ char *get_param(PM first, const char *name, char replace, int fetchonly); */ char *get_param_value(PM pm, char replace); -extern int checksw; /* Add Content-MD5 field */ - /* * mhstore * Put it here because it uses the CT typedef. diff --git a/h/mime.h b/h/mime.h index e389b284..a0022c18 100644 --- a/h/mime.h +++ b/h/mime.h @@ -9,7 +9,6 @@ #define ID_FIELD "Content-ID" #define DESCR_FIELD "Content-Description" #define DISPO_FIELD "Content-Disposition" -#define MD5_FIELD "Content-MD5" #define PSEUDOHEADER_PREFIX "Nmh-" #define ATTACH_FIELD PSEUDOHEADER_PREFIX "Attach" #define ATTACH_FIELD_ALT "Attach" diff --git a/man/mhbuild.man b/man/mhbuild.man index 8e872091..46a05074 100644 --- a/man/mhbuild.man +++ b/man/mhbuild.man @@ -20,7 +20,6 @@ mhbuild \- translate MIME composition drafts for nmh messages .RB [ \-contentid " | " \-nocontentid ] .RB [ \-verbose " | " \-noverbose ] .RB [ \-disposition " | " \-nodisposition ] -.RB [ \-check " | " \-nocheck ] .RB [ \-headerencoding .I encoding-algorithm .RB " | " \-autoheaderencoding ] @@ -728,17 +727,6 @@ This third part will be text/plain /home/foobar/lib/picture.gif .fi .RE -.SS "Integrity Check" -If -.B mhbuild -is given the -.B \-check -switch, then it will also associate an integrity check with each -\*(lqleaf\*(rq content. -This will add a Content-MD5 header field to the content, along with the md5 -sum of the unencoded contents, per RFC 1864. -This may be used by the receiver of the message to verify that the contents -of the message were not changed in transport. .SS "Transfer Encodings" After .B mhbuild @@ -748,15 +736,6 @@ It will check for 8-bit data, long lines, spaces at the end of lines, and clashes with multipart boundaries. It will then choose a transfer encoding appropriate for each content type. .PP -If an integrity check is being associated with each content by using -the -.B \-check -switch, then -.B mhbuild -will encode each content with -a transfer encoding, even if the content contains only 7-bit data. -This is to increase the likelihood that the content is not changed while in -transport. .SS "Invoking mhbuild" Typically, .B mhbuild diff --git a/man/mhlist.man b/man/mhlist.man index da1ce800..e352f047 100644 --- a/man/mhlist.man +++ b/man/mhlist.man @@ -30,7 +30,6 @@ mhlist \- list information about nmh MIME messages .IR policy ] .RB [ \-wcache .IR policy ] -.RB [ \-check " | " \-nocheck ] .RB [ \-changecur " | " \-nochangecur ] .RB [ \-verbose " | " \-noverbose ] .RB [ \-disposition " | " \-nodisposition ] @@ -200,15 +199,6 @@ but are also implemented in and .B mhstore to make common part numbering possible across all three programs. -.SS "Checking the Contents" -The -.B \-check -switch tells -.B mhlist -to check each content for an integrity checksum. If a content has -such a checksum (specified as a Content-MD5 header field), then -.B mhlist -will attempt to verify the integrity of the content. .SH FILES .fc ^ ~ .nf diff --git a/man/mhn.man b/man/mhn.man index ae12a6a0..beb0633e 100644 --- a/man/mhn.man +++ b/man/mhn.man @@ -35,7 +35,6 @@ mhn \- display/list/store/cache nmh MIME messages .IR policy ] .RB [ \-wcache .IR policy ] -.RB [ \-check " | " \-nocheck ] .PP .HP 5 .B mhn diff --git a/man/mhshow.man b/man/mhshow.man index 4cbbd191..c7fc1438 100644 --- a/man/mhshow.man +++ b/man/mhshow.man @@ -36,7 +36,6 @@ mhshow \- display nmh MIME messages .IR policy ] .RB [ \-wcache .IR policy ] -.RB [ \-check " | " \-nocheck ] .ad .SH DESCRIPTION The @@ -248,15 +247,6 @@ non-empty, then .B mhshow will remove each of the messages shown from each sequence named by the profile entry. -.SS "Checking the Contents" -The -.B \-check -switch tells -.B mhshow -to check each content for an integrity checksum. If a content has such -a checksum (specified as a Content-MD5 header field), then -.B mhshow -will attempt to verify the integrity of the content. .SS "Showing the Contents" The headers of each message are displayed with the .I mhlproc diff --git a/man/mhstore.man b/man/mhstore.man index cb10d62c..8347a627 100644 --- a/man/mhstore.man +++ b/man/mhstore.man @@ -33,7 +33,6 @@ mhstore \- store contents of nmh MIME messages into files .IR policy ] .RB [ \-wcache .IR policy ] -.RB [ \-check " | " \-nocheck ] .RB [ \-verbose " | " \-noverbose ] .ad .SH DESCRIPTION @@ -175,16 +174,6 @@ The switch will cancel any previous .B \-prefer switches. -.SS "Checking the Contents" -The -.B \-check -switch tells -.B mhstore -to check each content for an integrity checksum. -If a content has such a checksum (specified as a Content-MD5 header -field), then -.B mhstore -will attempt to verify the integrity of the content. .SS "Storing the Contents" .B mhstore will store the contents of the named messages in diff --git a/mts/smtp/smtp.c b/mts/smtp/smtp.c index 8270b343..ea7f7196 100644 --- a/mts/smtp/smtp.c +++ b/mts/smtp/smtp.c @@ -1048,7 +1048,7 @@ sm_sasl_callback(enum sasl_message_type mtype, unsigned const char *indata, *outdata = NULL; *outdatalen = 0; } else { - rc = decodeBase64(line + 4, outdata, &len, 0, NULL); + rc = decodeBase64(line + 4, outdata, &len, 0); if (rc != OK) { netsec_err(errstr, "Unable to decode base64 response"); return NOTOK; diff --git a/sbr/base64.c b/sbr/base64.c index ef3aa32a..8fb5357e 100644 --- a/sbr/base64.c +++ b/sbr/base64.c @@ -8,7 +8,6 @@ #include "h/mh.h" #include "error.h" #include "h/mime.h" -#include "h/md5.h" #include static const char nib2b64[0x40+1] = @@ -245,21 +244,16 @@ static const unsigned char b642nib[0x80] = { * len - number of decoded bytes * skip-crs - non-zero for text content, and for which CR's should be * skipped - * digest - for an MD5 digest, it can be null */ int decodeBase64 (const char *encoded, unsigned char **decoded, size_t *len, - int skip_crs, unsigned char *digest) + int skip_crs) { const char *cp = encoded; int bitno, skip; uint32_t bits; /* Size the decoded string very conservatively. */ charstring_t decoded_c = charstring_create (strlen (encoded)); - MD5_CTX mdContext; - - if (digest) - MD5Init (&mdContext); bitno = 18; bits = 0L; @@ -292,22 +286,16 @@ test_end: if (! skip_crs || b != '\r') { charstring_push_back (decoded_c, b); } - if (digest) - MD5Update (&mdContext, (unsigned char *) &b, 1); if (skip < 2) { b = (bits >> 8) & 0xff; if (! skip_crs || b != '\r') { charstring_push_back (decoded_c, b); } - if (digest) - MD5Update (&mdContext, (unsigned char *) &b, 1); if (skip < 1) { b = bits & 0xff; if (! skip_crs || b != '\r') { charstring_push_back (decoded_c, b); } - if (digest) - MD5Update (&mdContext, (unsigned char *) &b, 1); } } @@ -339,10 +327,6 @@ test_end: *len = charstring_bytes (decoded_c); charstring_free (decoded_c); - if (digest) { - MD5Final (digest, &mdContext); - } - return OK; } diff --git a/sbr/base64.h b/sbr/base64.h index c5981d05..aea3bdde 100644 --- a/sbr/base64.h +++ b/sbr/base64.h @@ -8,7 +8,7 @@ int writeBase64aux(FILE *, FILE *, int); int writeBase64(const unsigned char *, size_t, unsigned char *); int writeBase64raw(const unsigned char *, size_t, unsigned char *); -int decodeBase64(const char *, unsigned char **, size_t *, int, unsigned char *); +int decodeBase64(const char *, unsigned char **, size_t *, int); void hexify(const unsigned char *, size_t, char **); /* Includes trailing NUL. */ diff --git a/sbr/md5.c b/sbr/md5.c deleted file mode 100644 index 8dbc0b71..00000000 --- a/sbr/md5.c +++ /dev/null @@ -1,287 +0,0 @@ -/* md5.c -- md5 message digest algorithm - * taken from RFC-1321/Appendix A.3 - */ - -/* - * MD5C.C -- RSA Data Security, Inc., MD5 message-digest algorithm - */ - -/* - * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All - * rights reserved. - * - * License to copy and use this software is granted provided that it - * is identified as the "RSA Data Security, Inc. MD5 Message-Digest - * Algorithm" in all material mentioning or referencing this software - * or this function. - * - * License is also granted to make and use derivative works provided - * that such works are identified as "derived from the RSA Data - * Security, Inc. MD5 Message-Digest Algorithm" in all material - * mentioning or referencing the derived work. - * - * RSA Data Security, Inc. makes no representations concerning either - * the merchantability of this software or the suitability of this - * software for any particular purpose. It is provided "as is" - * without express or implied warranty of any kind. - * - * These notices must be retained in any copies of any part of this - * documentation and/or software. - */ - -#include "h/md5.h" - -/* Constants for MD5Transform routine. */ -#define S11 7 -#define S12 12 -#define S13 17 -#define S14 22 -#define S21 5 -#define S22 9 -#define S23 14 -#define S24 20 -#define S31 4 -#define S32 11 -#define S33 16 -#define S34 23 -#define S41 6 -#define S42 10 -#define S43 15 -#define S44 21 - -static void MD5Transform(UINT4 [4], unsigned char [64]); -static void Encode(unsigned char *, UINT4 *, unsigned int); -static void Decode(UINT4 *, unsigned char *, unsigned int); - -static unsigned char PADDING[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -/* F, G, H and I are basic MD5 functions. */ -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define I(x, y, z) ((y) ^ ((x) | (~z))) - -/* ROTATE_LEFT rotates x left n bits. */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. -Rotation is separate from addition to prevent recomputation. */ -#define FF(a, b, c, d, x, s, ac) \ - { \ - (a) += F((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT((a), (s)); \ - (a) += (b); \ - } -#define GG(a, b, c, d, x, s, ac) \ - { \ - (a) += G((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT((a), (s)); \ - (a) += (b); \ - } -#define HH(a, b, c, d, x, s, ac) \ - { \ - (a) += H((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT((a), (s)); \ - (a) += (b); \ - } -#define II(a, b, c, d, x, s, ac) \ - { \ - (a) += I((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT((a), (s)); \ - (a) += (b); \ - } - -/* MD5 initialization. Begins an MD5 operation, writing a new context. */ -void -MD5Init(MD5_CTX *context) -{ - context->count[0] = context->count[1] = 0; - /* Load magic initialization constants. */ - context->state[0] = 0x67452301; - context->state[1] = 0xefcdab89; - context->state[2] = 0x98badcfe; - context->state[3] = 0x10325476; -} - -/* MD5 block update operation. Continues an MD5 message-digest - * operation, processing another message block, and updating the - * context. */ -void -MD5Update(MD5_CTX *context, unsigned char *input, unsigned int inputLen) -{ - unsigned int i, index, partLen; - - /* Compute number of bytes mod 64 */ - index = (unsigned int)((context->count[0] >> 3) & 0x3F); - - /* Update number of bits */ - if ((context->count[0] += ((UINT4)inputLen << 3)) < ((UINT4)inputLen << 3)) - context->count[1]++; - context->count[1] += ((UINT4)inputLen >> 29); - - partLen = 64 - index; - - /* Transform as many times as possible. */ - if (inputLen >= partLen) { - memcpy(&context->buffer[index], input, partLen); - MD5Transform(context->state, context->buffer); - - for (i = partLen; i + 63 < inputLen; i += 64) - MD5Transform(context->state, &input[i]); - - index = 0; - } else - i = 0; - - /* Buffer remaining input */ - memcpy(&context->buffer[index], &input[i], inputLen - i); -} - -/* MD5 finalization. Ends an MD5 message-digest operation, writing the - * the message digest and zeroizing the context. */ -void -MD5Final(unsigned char digest[16], MD5_CTX *context) -{ - unsigned char bits[8]; - unsigned int index; - unsigned int padLen; - - /* Save number of bits */ - Encode(bits, context->count, 8); - - /* Pad out to 56 mod 64. */ - index = (unsigned int)((context->count[0] >> 3) & 0x3f); - padLen = (index < 56) ? (56 - index) : (120 - index); - MD5Update(context, PADDING, padLen); - - /* Append length (before padding) */ - MD5Update(context, bits, 8); - /* Store state in digest */ - Encode(digest, context->state, 16); - - /* Zeroize sensitive information. */ - memset(context, 0, sizeof(*context)); -} - -/* MD5 basic transformation. Transforms state based on block. */ -static void -MD5Transform(UINT4 state[4], unsigned char block[64]) -{ - UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; - - Decode(x, block, 64); - - /* Round 1 */ - FF(a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ - FF(d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ - FF(c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ - FF(b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ - FF(a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ - FF(d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ - FF(c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ - FF(b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ - FF(a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ - FF(d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ - FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ - FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ - FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ - FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ - FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ - FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ - - /* Round 2 */ - GG(a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ - GG(d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ - GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ - GG(b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ - GG(a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ - GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */ - GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ - GG(b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ - GG(a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ - GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ - GG(c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ - GG(b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ - GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ - GG(d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ - GG(c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ - GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ - - /* Round 3 */ - HH(a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ - HH(d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ - HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ - HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ - HH(a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ - HH(d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ - HH(c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ - HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ - HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ - HH(d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ - HH(c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ - HH(b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ - HH(a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ - HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ - HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ - HH(b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ - - /* Round 4 */ - II(a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ - II(d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ - II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ - II(b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ - II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ - II(d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ - II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ - II(b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ - II(a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ - II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ - II(c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ - II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ - II(a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ - II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ - II(c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ - II(b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ - - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - - /* Zeroize sensitive information. */ - memset(x, 0, sizeof(x)); -} - -/* Encodes input (UINT4) into output (unsigned char). Assumes len is a - * multiple of 4. */ -static void -Encode(unsigned char *output, UINT4 *input, unsigned int len) -{ - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) { - output[j] = (unsigned char)(input[i] & 0xff); - output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); - output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); - output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); - } -} - -/* Decodes input (unsigned char) into output (UINT4). Assumes len is a - * multiple of 4. */ -static void -Decode(UINT4 *output, unsigned char *input, unsigned int len) -{ - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((UINT4)input[j]) | - (((UINT4)input[j+1]) << 8) | - (((UINT4)input[j+2]) << 16) | - (((UINT4)input[j+3]) << 24); -} diff --git a/sbr/netsec.c b/sbr/netsec.c index 83d75631..5efc4129 100644 --- a/sbr/netsec.c +++ b/sbr/netsec.c @@ -323,7 +323,7 @@ netsec_b64_snoop_decoder(netsec_context *nsc, const char *string, size_t len, len -= offset; } - if (decodeBase64(string, &decoded, &decodedlen, 1, NULL) == OK) { + if (decodeBase64(string, &decoded, &decodedlen, 1) == OK) { /* * Some mechanisms produce large binary tokens, which aren't really * readable. So let's do a simple heuristic. If the token is greater diff --git a/test/mhbuild/test-attach b/test/mhbuild/test-attach index c97ec394..cebf6e92 100755 --- a/test/mhbuild/test-attach +++ b/test/mhbuild/test-attach @@ -148,36 +148,6 @@ MIME-Version: 1.0 Content-Type: text/plain EOF -# -# Check an md5'd attachment -# - -cat > "$draft" < -cc: -Fcc: +outbox -Subject: Test of digested part - -#text/plain; name="textplain" [ - ] ${srcdir}/test/mhbuild/textplain - -EOF - -mhbuild -check "$draft" - -cat > "$expected" < -cc: -Fcc: +outbox -Subject: Test of digested part -MIME-Version: 1.0 -Content-Type: text/plain; name="textplain"; charset="us-ascii" -Content-Description: - -Content-MD5: x3hNJn10cGowZv+ILUkycw== -Content-Transfer-Encoding: quoted-printable - -This is a text/plain part. -EOF - check "$draft" "$expected" # diff --git a/test/mhlist/test-mhlist b/test/mhlist/test-mhlist index 42d2f43f..ad459b73 100755 --- a/test/mhlist/test-mhlist +++ b/test/mhlist/test-mhlist @@ -169,28 +169,6 @@ run_test 'mhlist last -part 4 -noheader -norealsize -realsize' \ 1 multipart/related 180 4 text/plain 36' -start_test '-check' -run_test 'mhlist last -part 2 -noheader -check' \ -' 11 multipart/mixed 936 - 1 multipart/related 180 - 2 text/plain 36' - -start_test '-check with bad MD5 checksum' -sed 's/\(Content-MD5: \)kq+Hnc/\1BADBAD/' $msgfile > $MH_TEST_DIR/$$.tmp -mv -f $MH_TEST_DIR/$$.tmp $msgfile -run_test 'mhlist last -part 2 -noheader -check' \ -' 11 multipart/mixed 936 - 1 multipart/related 180 - 2 text/plain 36 -mhlist: content integrity suspect (digest mismatch) -- continuing - (content text/plain in message 11, part 2)' - -start_test '-nocheck, the default' -run_test 'mhlist last -part 2 -noheader -check -nocheck' \ -' 11 multipart/mixed 936 - 1 multipart/related 180 - 2 text/plain 36' - # # Set the cur sequence to 1 to test default behavior of changecur after # this test. diff --git a/test/mhstore/test-mhstore b/test/mhstore/test-mhstore index e8866189..b53b01f7 100755 --- a/test/mhstore/test-mhstore +++ b/test/mhstore/test-mhstore @@ -214,43 +214,11 @@ run_test 'mhstore last -part 1.1 -auto' \ 'storing message 11 part 1.1 as file test1.txt' check "$expected" test1.txt -# check -check -start_test '-check' +# check -outfile - with -file +start_test '-outfile - with -file' cat >"$expected" <<'EOF' This is the second text/plain part. EOF -run_test 'mhstore last -part 2 -check' \ - 'storing message 11 part 2 as file 11.2.txt' -check "$expected" 11.2.txt 'keep first' - -# check with -check on base64 encoded part -start_test 'with -check on base64 encoded part' -cat >"$expected2" <<'EOF' -This is the fourth text/plain part. -This test has multiple lines. -EOF -run_test 'mhstore last -part 4 -check' \ - 'storing message 11 part 4 as file 11.4.txt' -check "$expected2" 11.4.txt - -# check -check with bad MD5 checksum -start_test '-check with bad MD5 checksum' -sed 's/\(Content-MD5: \)kq+Hnc/\1BADBAD/' "$msgfile" >"$MH_TEST_DIR/$$.tmp" -mv -f "$MH_TEST_DIR/$$.tmp" "$msgfile" -run_test 'mhstore last -part 2 -check' \ -'storing message 11 part 2 as file 11.2.txt -mhstore: content integrity suspect (digest mismatch) -- continuing - (content text/plain in message 11, part 2)' -check "$expected" 11.2.txt 'keep first' - -# check -nocheck, the default -start_test '-nocheck, the default' -run_test 'mhstore last -part 2 -check -nocheck' \ - 'storing message 11 part 2 as file 11.2.txt' -check "$expected" 11.2.txt 'keep first' - -# check -outfile - with -file -start_test '-outfile - with -file' run_prog mhstore -noverbose -file `mhpath 11` -part 2 -outfile - >"$actual" 2>&1 check "$expected" "$actual" diff --git a/uip/imaptest.c b/uip/imaptest.c index 9009159f..8a73f08c 100644 --- a/uip/imaptest.c +++ b/uip/imaptest.c @@ -649,7 +649,7 @@ imap_sasl_callback(enum sasl_message_type mtype, unsigned const char *indata, *outdata = NULL; *outdatalen = 0; } else { - rc = decodeBase64(line + 2, outdata, &len, 0, NULL); + rc = decodeBase64(line + 2, outdata, &len, 0); *outdatalen = len; if (rc != OK) { netsec_err(errstr, "Unable to decode base64 response"); diff --git a/uip/mhbuild.c b/uip/mhbuild.c index 1ef84211..59ca2ec5 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -17,7 +17,6 @@ #include "sbr/print_help.h" #include "sbr/error.h" #include -#include "h/md5.h" #include "h/mts.h" #include "h/tws.h" #include "h/mime.h" @@ -33,8 +32,8 @@ #define MHBUILD_SWITCHES \ X("auto", 0, AUTOSW) \ X("noauto", 0, NAUTOSW) \ - X("check", 0, CHECKSW) \ - X("nocheck", 0, NCHECKSW) \ + X("check", -5, CHECKSW) \ + X("nocheck", -7, NCHECKSW) \ X("directives", 0, DIRECTIVES) \ X("nodirectives", 0, NDIRECTIVES) \ X("headers", 0, HEADSW) \ @@ -181,10 +180,8 @@ main (int argc, char **argv) continue; case CHECKSW: - checksw++; - continue; case NCHECKSW: - checksw = 0; + /* Currently a NOP */ continue; case HEADSW: diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index c7b969c7..cee0ee56 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -35,7 +35,6 @@ #include "sbr/path.h" #include "sbr/error.h" #include -#include "h/md5.h" #include "h/mts.h" #include "h/tws.h" #include "h/fmt_scan.h" @@ -95,7 +94,6 @@ static void set_id (CT, int); static int compose_content (CT, int); static int scan_content (CT, size_t); static int build_headers (CT, int); -static char *calculate_digest (CT, int); static int extract_headers (CT, char *, FILE **); @@ -1607,7 +1605,7 @@ scan_content (CT ct, size_t maxunencoded) if (ct->c_reqencoding != CE_UNKNOWN) ct->c_encoding = ct->c_reqencoding; else { - int wants_q_p = (containsnul || linelen || linespace || checksw); + int wants_q_p = (containsnul || linelen || linespace); switch (ct->c_type) { case CT_TEXT: @@ -1782,15 +1780,6 @@ skip_headers: if (ct->c_ctexbody) return OK; - /* - * output the Content-MD5 - */ - if (checksw) { - np = mh_xstrdup(MD5_FIELD); - vp = calculate_digest (ct, ct->c_encoding == CE_QUOTED); - add_header (ct, np, vp); - } - /* * output the Content-Transfer-Encoding * If using EAI and message body is 7-bit, force 8-bit C-T-E. @@ -1879,101 +1868,6 @@ skip_headers: } -static char nib2b64[0x40+1] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -static char * -calculate_digest (CT ct, int asciiP) -{ - int cc; - char *vp, *op; - unsigned char *dp; - unsigned char digest[16]; - unsigned char outbuf[25]; - MD5_CTX mdContext; - CE ce = &ct->c_cefile; - char *infilename = ce->ce_file ? ce->ce_file : ct->c_file; - FILE *in; - - /* open content */ - if ((in = fopen (infilename, "r")) == NULL) - adios (infilename, "unable to open for reading"); - - /* Initialize md5 context */ - MD5Init (&mdContext); - - /* calculate md5 message digest */ - if (asciiP) { - char *bufp = NULL; - size_t buflen; - ssize_t gotlen; - while ((gotlen = getline(&bufp, &buflen, in)) != -1) { - char c, *cp; - - cp = bufp + gotlen - 1; - if ((c = *cp) == '\n') - gotlen--; - - MD5Update (&mdContext, (unsigned char *) bufp, - (unsigned int) gotlen); - - if (c == '\n') - MD5Update (&mdContext, (unsigned char *) "\r\n", 2); - } - } else { - char buffer[BUFSIZ]; - while ((cc = fread (buffer, sizeof(*buffer), sizeof(buffer), in)) > 0) - MD5Update (&mdContext, (unsigned char *) buffer, (unsigned int) cc); - } - - /* md5 finalization. Write digest and zero md5 context */ - MD5Final (digest, &mdContext); - - /* close content */ - fclose (in); - - /* print debugging info */ - if (debugsw) { - unsigned char *ep; - - fprintf (stderr, "MD5 digest="); - for (ep = (dp = digest) + sizeof digest; - dp < ep; dp++) - fprintf (stderr, "%02x", *dp & 0xff); - fprintf (stderr, "\n"); - } - - /* encode the digest using base64 */ - for (dp = digest, op = (char *) outbuf, - cc = sizeof digest; - cc > 0; cc -= 3, op += 4) { - unsigned long bits; - char *bp; - - bits = (*dp++ & 0xff) << 16; - if (cc > 1) { - bits |= (*dp++ & 0xff) << 8; - if (cc > 2) - bits |= *dp++ & 0xff; - } - - for (bp = op + 4; bp > op; bits >>= 6) - *--bp = nib2b64[bits & 0x3f]; - if (cc < 3) { - *(op + 3) = '='; - if (cc < 2) - *(op + 2) = '='; - } - } - - /* null terminate string */ - outbuf[24] = '\0'; - - /* now make copy and return string */ - vp = concat (" ", outbuf, "\n", NULL); - return vp; -} - /* * Set things up for the content structure for file "filename" that * we want to attach diff --git a/uip/mhcachesbr.c b/uip/mhcachesbr.c index 942c3f01..498efe22 100644 --- a/uip/mhcachesbr.c +++ b/uip/mhcachesbr.c @@ -12,7 +12,6 @@ #include "sbr/trimcpy.h" #include "sbr/error.h" #include -#include "h/md5.h" #include "h/mts.h" #include "h/tws.h" #include "h/mime.h" diff --git a/uip/mhlist.c b/uip/mhlist.c index b3bba8ba..c5b2fe82 100644 --- a/uip/mhlist.c +++ b/uip/mhlist.c @@ -26,7 +26,6 @@ #include "sbr/error.h" #include #include "h/signals.h" -#include "h/md5.h" #include "h/mts.h" #include "h/tws.h" #include "h/mime.h" @@ -39,8 +38,8 @@ #include "mhfree.h" #define MHLIST_SWITCHES \ - X("check", 0, CHECKSW) \ - X("nocheck", 0, NCHECKSW) \ + X("check", -5, CHECKSW) \ + X("nocheck", -7, NCHECKSW) \ X("headers", 0, HEADSW) \ X("noheaders", 0, NHEADSW) \ X("realsize", 0, SIZESW) \ @@ -148,10 +147,8 @@ do_cache: continue; case CHECKSW: - checksw++; - continue; case NCHECKSW: - checksw = 0; + /* Currently a NOP */ continue; case HEADSW: diff --git a/uip/mhn.c b/uip/mhn.c index 6973a5de..7d2abb3f 100644 --- a/uip/mhn.c +++ b/uip/mhn.c @@ -27,7 +27,6 @@ #include "sbr/error.h" #include #include "h/signals.h" -#include "h/md5.h" #include "h/mts.h" #include "h/tws.h" #include "h/fmt_scan.h" @@ -46,8 +45,8 @@ X("noauto", 0, NAUTOSW) \ X("cache", 0, CACHESW) \ X("nocache", 0, NCACHESW) \ - X("check", 0, CHECKSW) \ - X("nocheck", 0, NCHECKSW) \ + X("check", -5, CHECKSW) \ + X("nocheck", -7, NCHECKSW) \ X("headers", 0, HEADSW) \ X("noheaders", 0, NHEADSW) \ X("list", 0, LISTSW) \ @@ -200,10 +199,8 @@ do_cache: continue; case CHECKSW: - checksw++; - continue; case NCHECKSW: - checksw = 0; + /* Currently a NOP */ continue; case HEADSW: diff --git a/uip/mhoutsbr.c b/uip/mhoutsbr.c index a69dadee..c69c7b40 100644 --- a/uip/mhoutsbr.c +++ b/uip/mhoutsbr.c @@ -11,7 +11,6 @@ #include "sbr/error.h" #include #include "h/utils.h" -#include "h/md5.h" #include "h/mts.h" #include "h/tws.h" #include "h/mime.h" diff --git a/uip/mhparse.c b/uip/mhparse.c index c1eec406..74ec577f 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -21,7 +21,6 @@ #include "sbr/arglist.h" #include "sbr/error.h" #include -#include "h/md5.h" #include "h/mts.h" #include "h/tws.h" #include "h/mime.h" @@ -39,8 +38,6 @@ extern int debugsw; -int checksw = 0; /* check Content-MD5 field */ - /* * These are for mhfixmsg to: * 1) Instruct parser not to detect invalid Content-Transfer-Encoding @@ -148,7 +145,6 @@ static int InitFTP (CT); static int openFTP (CT, char **); static int InitMail (CT); static int openMail (CT, char **); -static int readDigest (CT, char *); static int get_leftover_mp_content (CT, int); static int InitURL (CT); static int openURL (CT, char **); @@ -509,46 +505,6 @@ get_content (FILE *in, char *file, int toplevel) if (s2i->si_init && (*s2i->si_init) (ct) == NOTOK) goto out; } - else if (!strcasecmp (hp->name, MD5_FIELD)) { - /* Get Content-MD5 field */ - char *cp, *dp, *ep; - - if (!checksw) - goto next_header; - - if (ct->c_digested) { - inform("message %s has multiple %s: fields", - ct->c_file, MD5_FIELD); - goto next_header; - } - - ep = cp = mh_xstrdup(FENDNULL(hp->value)); /* get a copy */ - - while (isspace ((unsigned char) *cp)) - cp++; - for (dp = strchr(cp, '\n'); dp; dp = strchr(dp, '\n')) - *dp++ = ' '; - for (dp = cp + strlen (cp) - 1; dp >= cp; dp--) - if (!isspace ((unsigned char) *dp)) - break; - *++dp = '\0'; - if (debugsw) - fprintf (stderr, "%s: %s\n", MD5_FIELD, cp); - - if (*cp == '(' && - get_comment (ct->c_file, MD5_FIELD, &cp, NULL) == NOTOK) { - free (ep); - goto out; - } - - for (dp = cp; *dp && !isspace ((unsigned char) *dp); dp++) - continue; - *dp = '\0'; - - readDigest (ct, cp); - free (ep); - ct->c_digested++; - } else if (!strcasecmp (hp->name, ID_FIELD)) { /* Get Content-ID field */ ct->c_id = add (hp->value, ct->c_id); @@ -1768,7 +1724,6 @@ openBase64 (CT ct, char **file) CE ce = &ct->c_cefile; unsigned char *decoded; size_t decoded_len; - unsigned char digest[16]; if (ce->ce_fp) { fseek (ce->ce_fp, 0L, SEEK_SET); @@ -1852,8 +1807,8 @@ openBase64 (CT ct, char **file) /* decodeBase64() requires null-terminated input. */ *cp = '\0'; - if (decodeBase64 (buffer, &decoded, &decoded_len, ct->c_type == CT_TEXT, - ct->c_digested ? digest : NULL) != OK) + if (decodeBase64 (buffer, &decoded, &decoded_len, + ct->c_type == CT_TEXT) != OK) goto clean_up; { @@ -1867,18 +1822,6 @@ openBase64 (CT ct, char **file) content_error (ce->ce_file, ct, "error writing to"); goto clean_up; } - - if (ct->c_digested) { - if (memcmp(digest, ct->c_digest, - sizeof digest)) { - content_error (NULL, ct, - "content integrity suspect (digest mismatch) -- continuing"); - } else { - if (debugsw) { - fprintf (stderr, "content integrity confirmed\n"); - } - } - } } fseek (ct->c_fp, 0L, SEEK_SET); @@ -1944,7 +1887,7 @@ InitQuoted (CT ct) static int openQuoted (CT ct, char **file) { - int cc, digested, len, quoted; + int cc, len, quoted; bool own_ct_fp = false; char *cp, *ep; char *bufp = NULL; @@ -1954,7 +1897,6 @@ openQuoted (CT ct, char **file) CE ce = &ct->c_cefile; /* sbeck -- handle suffixes */ CI ci; - MD5_CTX mdContext; if (ce->ce_fp) { fseek (ce->ce_fp, 0L, SEEK_SET); @@ -2013,9 +1955,6 @@ openQuoted (CT ct, char **file) own_ct_fp = true; } - if ((digested = ct->c_digested)) - MD5Init (&mdContext); - quoted = 0; fseek (ct->c_fp, ct->c_begin, SEEK_SET); @@ -2048,8 +1987,6 @@ openQuoted (CT ct, char **file) mask <<= 4; mask |= hex2nib[((unsigned char) *cp) & 0x7f]; putc (mask, ce->ce_fp); - if (digested) - MD5Update (&mdContext, &mask, 1); if (ferror (ce->ce_fp)) { content_error (ce->ce_file, ct, "error writing to"); goto clean_up; @@ -2087,13 +2024,6 @@ openQuoted (CT ct, char **file) /* Just show the raw byte. */ putc (*cp, ce->ce_fp); - if (digested) { - if (*cp == '\n') { - MD5Update (&mdContext, (unsigned char *) "\r\n",2); - } else { - MD5Update (&mdContext, (unsigned char *) cp, 1); - } - } if (ferror (ce->ce_fp)) { content_error (ce->ce_file, ct, "error writing to"); goto clean_up; @@ -2113,18 +2043,6 @@ openQuoted (CT ct, char **file) goto clean_up; } - if (digested) { - unsigned char digest[16]; - - MD5Final (digest, &mdContext); - if (memcmp(digest, ct->c_digest, - sizeof digest)) - content_error (NULL, ct, - "content integrity suspect (digest mismatch) -- continuing"); - else if (debugsw) - fprintf (stderr, "content integrity confirmed\n"); - } - fseek (ce->ce_fp, 0L, SEEK_SET); ready_to_go: @@ -2910,46 +2828,6 @@ openURL (CT ct, char **file) } -/* - * Stores MD5 digest (in cp, from Content-MD5 header) in ct->c_digest. It - * has to be base64 decoded. - */ -static int -readDigest (CT ct, char *cp) -{ - unsigned char *digest; - - size_t len; - if (decodeBase64 (cp, &digest, &len, 0, NULL) == OK) { - const size_t maxlen = sizeof ct->c_digest; - - if (strlen ((char *) digest) <= maxlen) { - memcpy (ct->c_digest, digest, maxlen); - - if (debugsw) { - size_t i; - - fprintf (stderr, "MD5 digest="); - for (i = 0; i < maxlen; ++i) { - fprintf (stderr, "%02x", ct->c_digest[i] & 0xff); - } - fprintf (stderr, "\n"); - } - - return OK; - } - if (debugsw) { - fprintf (stderr, "invalid MD5 digest (got %d octets)\n", - (int) strlen ((char *) digest)); - } - - return NOTOK; - } - - return NOTOK; -} - - /* Multipart parts might have content before the first subpart and/or after the last subpart that hasn't been stored anywhere else, so do that. */ diff --git a/uip/mhshow.c b/uip/mhshow.c index 66d2366b..6009fdc5 100644 --- a/uip/mhshow.c +++ b/uip/mhshow.c @@ -28,7 +28,6 @@ #include "sbr/error.h" #include #include "h/signals.h" -#include "h/md5.h" #include "h/mts.h" #include "h/tws.h" #include "h/fmt_scan.h" @@ -160,10 +159,8 @@ do_cache: continue; case CHECKSW: - checksw++; - continue; case NCHECKSW: - checksw = 0; + /* Currently a NOP */ continue; case CONCATSW: diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index 17ef4d22..9cd67331 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -17,7 +17,6 @@ #include "sbr/error.h" #include #include "h/signals.h" -#include "h/md5.h" #include "h/mts.h" #include "h/tws.h" #include "h/mime.h" diff --git a/uip/mhstore.c b/uip/mhstore.c index 9cbdc69a..6ea99f30 100644 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@ -27,7 +27,6 @@ #include "sbr/error.h" #include #include "h/signals.h" -#include "h/md5.h" #include "h/mts.h" #include "h/tws.h" #include "h/mime.h" @@ -42,8 +41,8 @@ #define MHSTORE_SWITCHES \ X("auto", 0, AUTOSW) \ X("noauto", 0, NAUTOSW) \ - X("check", 0, CHECKSW) \ - X("nocheck", 0, NCHECKSW) \ + X("check", -5, CHECKSW) \ + X("nocheck", -7, NCHECKSW) \ X("verbose", 0, VERBSW) \ X("noverbose", 0, NVERBSW) \ X("file file", 0, FILESW) /* interface from show */ \ @@ -153,10 +152,8 @@ do_cache: continue; case CHECKSW: - checksw++; - continue; case NCHECKSW: - checksw = 0; + /* Currently a NOP */ continue; case PARTSW: diff --git a/uip/mhstoresbr.c b/uip/mhstoresbr.c index d9091a88..3f92e499 100644 --- a/uip/mhstoresbr.c +++ b/uip/mhstoresbr.c @@ -20,7 +20,6 @@ #include "sbr/path.h" #include "sbr/error.h" #include -#include "h/md5.h" #include "h/mts.h" #include "h/tws.h" #include "h/fmt_scan.h" diff --git a/uip/popsbr.c b/uip/popsbr.c index 237e80cc..d61ce767 100644 --- a/uip/popsbr.c +++ b/uip/popsbr.c @@ -454,7 +454,7 @@ pop_sasl_callback(enum sasl_message_type mtype, unsigned const char *indata, *outdata = NULL; *outdatalen = 0; } else { - rc = decodeBase64(line + 2, outdata, &len, 0, NULL); + rc = decodeBase64(line + 2, outdata, &len, 0); *outdatalen = len; if (rc != OK) { netsec_err(errstr, "Unable to decode base64 response"); diff --git a/uip/viamail.c b/uip/viamail.c index 7ec3808a..cd08e090 100644 --- a/uip/viamail.c +++ b/uip/viamail.c @@ -18,7 +18,6 @@ #include "sbr/arglist.h" #include "sbr/error.h" #include -#include "h/md5.h" #include "h/mts.h" #include "h/tws.h" #include "h/mime.h"