h/fmt_compile.h \
h/fmt_scan.h \
h/icalendar.h \
- h/md5.h \
h/mf.h \
h/mh.h \
h/mhcachesbr.h \
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 \
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
---------
+++ /dev/null
-/* 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 <inttypes.h>
-
-/* 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 *);
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 */
*/
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.
#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"
.RB [ \-contentid " | " \-nocontentid ]
.RB [ \-verbose " | " \-noverbose ]
.RB [ \-disposition " | " \-nodisposition ]
-.RB [ \-check " | " \-nocheck ]
.RB [ \-headerencoding
.I encoding-algorithm
.RB " | " \-autoheaderencoding ]
/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
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
.IR policy ]
.RB [ \-wcache
.IR policy ]
-.RB [ \-check " | " \-nocheck ]
.RB [ \-changecur " | " \-nochangecur ]
.RB [ \-verbose " | " \-noverbose ]
.RB [ \-disposition " | " \-nodisposition ]
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
.IR policy ]
.RB [ \-wcache
.IR policy ]
-.RB [ \-check " | " \-nocheck ]
.PP
.HP 5
.B mhn
.IR policy ]
.RB [ \-wcache
.IR policy ]
-.RB [ \-check " | " \-nocheck ]
.ad
.SH DESCRIPTION
The
.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
.IR policy ]
.RB [ \-wcache
.IR policy ]
-.RB [ \-check " | " \-nocheck ]
.RB [ \-verbose " | " \-noverbose ]
.ad
.SH DESCRIPTION
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
*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;
#include "h/mh.h"
#include "error.h"
#include "h/mime.h"
-#include "h/md5.h"
#include <inttypes.h>
static const char nib2b64[0x40+1] =
* 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;
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);
}
}
*len = charstring_bytes (decoded_c);
charstring_free (decoded_c);
- if (digest) {
- MD5Final (digest, &mdContext);
- }
-
return OK;
}
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. */
+++ /dev/null
-/* 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);
-}
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
Content-Type: text/plain
EOF
-#
-# Check an md5'd attachment
-#
-
-cat > "$draft" <<EOF
-To: Mr Test <mrtest@example.com>
-cc:
-Fcc: +outbox
-Subject: Test of digested part
-
-#text/plain; name="textplain" [ - ] ${srcdir}/test/mhbuild/textplain
-
-EOF
-
-mhbuild -check "$draft"
-
-cat > "$expected" <<EOF
-To: Mr Test <mrtest@example.com>
-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"
#
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.
'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"
*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");
#include "sbr/print_help.h"
#include "sbr/error.h"
#include <fcntl.h>
-#include "h/md5.h"
#include "h/mts.h"
#include "h/tws.h"
#include "h/mime.h"
#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) \
continue;
case CHECKSW:
- checksw++;
- continue;
case NCHECKSW:
- checksw = 0;
+ /* Currently a NOP */
continue;
case HEADSW:
#include "sbr/path.h"
#include "sbr/error.h"
#include <fcntl.h>
-#include "h/md5.h"
#include "h/mts.h"
#include "h/tws.h"
#include "h/fmt_scan.h"
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 **);
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:
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.
}
-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
#include "sbr/trimcpy.h"
#include "sbr/error.h"
#include <fcntl.h>
-#include "h/md5.h"
#include "h/mts.h"
#include "h/tws.h"
#include "h/mime.h"
#include "sbr/error.h"
#include <fcntl.h>
#include "h/signals.h"
-#include "h/md5.h"
#include "h/mts.h"
#include "h/tws.h"
#include "h/mime.h"
#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) \
continue;
case CHECKSW:
- checksw++;
- continue;
case NCHECKSW:
- checksw = 0;
+ /* Currently a NOP */
continue;
case HEADSW:
#include "sbr/error.h"
#include <fcntl.h>
#include "h/signals.h"
-#include "h/md5.h"
#include "h/mts.h"
#include "h/tws.h"
#include "h/fmt_scan.h"
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) \
continue;
case CHECKSW:
- checksw++;
- continue;
case NCHECKSW:
- checksw = 0;
+ /* Currently a NOP */
continue;
case HEADSW:
#include "sbr/error.h"
#include <fcntl.h>
#include "h/utils.h"
-#include "h/md5.h"
#include "h/mts.h"
#include "h/tws.h"
#include "h/mime.h"
#include "sbr/arglist.h"
#include "sbr/error.h"
#include <fcntl.h>
-#include "h/md5.h"
#include "h/mts.h"
#include "h/tws.h"
#include "h/mime.h"
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
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 **);
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);
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);
/* 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;
{
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);
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;
CE ce = &ct->c_cefile;
/* sbeck -- handle suffixes */
CI ci;
- MD5_CTX mdContext;
if (ce->ce_fp) {
fseek (ce->ce_fp, 0L, SEEK_SET);
own_ct_fp = true;
}
- if ((digested = ct->c_digested))
- MD5Init (&mdContext);
-
quoted = 0;
fseek (ct->c_fp, ct->c_begin, SEEK_SET);
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;
/* 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;
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:
}
-/*
- * 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. */
#include "sbr/error.h"
#include <fcntl.h>
#include "h/signals.h"
-#include "h/md5.h"
#include "h/mts.h"
#include "h/tws.h"
#include "h/fmt_scan.h"
continue;
case CHECKSW:
- checksw++;
- continue;
case NCHECKSW:
- checksw = 0;
+ /* Currently a NOP */
continue;
case CONCATSW:
#include "sbr/error.h"
#include <fcntl.h>
#include "h/signals.h"
-#include "h/md5.h"
#include "h/mts.h"
#include "h/tws.h"
#include "h/mime.h"
#include "sbr/error.h"
#include <fcntl.h>
#include "h/signals.h"
-#include "h/md5.h"
#include "h/mts.h"
#include "h/tws.h"
#include "h/mime.h"
#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 */ \
continue;
case CHECKSW:
- checksw++;
- continue;
case NCHECKSW:
- checksw = 0;
+ /* Currently a NOP */
continue;
case PARTSW:
#include "sbr/path.h"
#include "sbr/error.h"
#include <fcntl.h>
-#include "h/md5.h"
#include "h/mts.h"
#include "h/tws.h"
#include "h/fmt_scan.h"
*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");
#include "sbr/arglist.h"
#include "sbr/error.h"
#include <fcntl.h>
-#include "h/md5.h"
#include "h/mts.h"
#include "h/tws.h"
#include "h/mime.h"