[NEW] Automatize release procedure.

Add md5 binary and source.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@592 f5eea248-9336-0410-98b8-ebc06183d4e3
remotes/x64
Don Ho 2009-12-19 12:42:57 +00:00
parent 56a236af40
commit 00e79d39c8
14 changed files with 3348 additions and 3 deletions

Binary file not shown.

View File

@ -0,0 +1,77 @@
PROGRAM = md5
CC = gcc
CFLAGS = -O3 -Wall
RELFILES = Makefile index.html main.c md5.c md5.exe \
md5.png md5s.png md5.h \
md5.vcproj md5.sln \
rfc1321.html rfc1321.txt
all: $(PROGRAM)
md5: md5.o main.o
$(CC) -o md5 md5.o main.o
zip:
rm -f md5.zip
zip md5.zip $(RELFILES)
tar:
rm -f md5.tar.gz md5.tar
tar cfv md5.tar $(RELFILES)
gzip md5.tar
lint:
lint main.c md5.c
# The silly stuff with "tr" is to allow directly cutting and
# pasting the test cases from RFC 1321.
check: $(PROGRAM)
./md5 -d"" -otest.out
./md5 -d"a" >>test.out
./md5 -d"abc" >>test.out
./md5 -d"message digest" >>test.out
./md5 -d"abcdefghijklmnopqrstuvwxyz" >>test.out
./md5 -d"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" >>test.out
./md5 -d"12345678901234567890123456789012345678901234567890123456789012345678901234567890" >>test.out
@echo "d41d8cd98f00b204e9800998ecf8427e" | tr [a-f] [A-F] >expected.out
@echo "0cc175b9c0f1b6a831c399e269772661" | tr [a-f] [A-F] >>expected.out
@echo "900150983cd24fb0d6963f7d28e17f72" | tr [a-f] [A-F] >>expected.out
@echo "f96b697d7cb7938d525a2f31aaf161d0" | tr [a-f] [A-F] >>expected.out
@echo "c3fcd3d76192e4007dfb496cca67e13b" | tr [a-f] [A-F] >>expected.out
@echo "d174ab98d277d9f5a5611c2c9f419d9f" | tr [a-f] [A-F] >>expected.out
@echo "57edf4a22be3c955ac49da2e2107b67a" | tr [a-f] [A-F] >>expected.out
@diff test.out expected.out ; if test $$? -ne 0 ; then \
echo '** md5: Verification test failed. **' ; else \
echo 'All tests passed.' ; fi
# Test the Win32 version running under "Wine" (which,
# obviously, must be installed).
wcheck: $(PROGRAM)
wine ./md5.exe -d"" -owtest.out
wine ./md5.exe -d"a" >>wtest.out
wine ./md5.exe -d"abc" >>wtest.out
wine ./md5.exe -d"message digest" >>wtest.out
wine ./md5.exe -d"abcdefghijklmnopqrstuvwxyz" >>wtest.out
wine ./md5.exe -d"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" >>wtest.out
wine ./md5.exe -d"12345678901234567890123456789012345678901234567890123456789012345678901234567890" >>wtest.out
@echo "d41d8cd98f00b204e9800998ecf8427e" | tr [a-f] [A-F] >expected.out
@echo "0cc175b9c0f1b6a831c399e269772661" | tr [a-f] [A-F] >>expected.out
@echo "900150983cd24fb0d6963f7d28e17f72" | tr [a-f] [A-F] >>expected.out
@echo "f96b697d7cb7938d525a2f31aaf161d0" | tr [a-f] [A-F] >>expected.out
@echo "c3fcd3d76192e4007dfb496cca67e13b" | tr [a-f] [A-F] >>expected.out
@echo "d174ab98d277d9f5a5611c2c9f419d9f" | tr [a-f] [A-F] >>expected.out
@echo "57edf4a22be3c955ac49da2e2107b67a" | tr [a-f] [A-F] >>expected.out
@diff -b wtest.out expected.out ; if test $$? -ne 0 ; then \
echo '** md5: Verification test failed. **' ; else \
echo 'All tests passed.' ; fi
clean:
rm -f $(PROGRAM) *.bak *.o *.out core
md5.o: md5.c md5.h
main.o: main.c md5.h

View File

@ -0,0 +1,242 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>MD5: Command Line Message Digest Utility</title>
<meta name="author" content="John Walker" />
<meta name="description" content="MD5: Command Line Message Digest Utility" />
<meta name="keywords" content="md5, message, digest, signature, command, line, utility" />
<meta name="robots" content="index" />
<link rel="stylesheet" href="/documents/styles/standard_screen.css" type="text/css" />
<style type="text/css">
dd {
text-align: justify;
}
dt {
margin-top: 1ex;
}
</style>
</head>
<body class="standard">
<center>
<h1><img src="md5.png" width="208" height="109" alt="MD5" /></h1>
<h2>
Command Line Message Digest Utility
</h2>
</center>
<hr />
<p class="j">
This page describes <b>md5</b>, a command line utility usable on
either Unix or MS-DOS/Windows, which generates and verifies
message digests (digital signatures) using the MD5 algorithm.
This program can be useful when developing shell scripts or Perl
programs for software installation, file comparison, and
detection of file corruption and tampering.
</p>
<h3>NAME</h3>
<b>md5</b> - generate / check MD5 message digest
<h3>SYNOPSIS</h3>
<b>md5</b> [ <b>-c</b><i>signature</i> ]
[ <b>-l</b> ] [ <b>-n</b> ]
[ <b>-u</b> ] [ <b>-v</b> ]
[ <b>-d</b><i>input_text</i> | <em>infile</em>&hellip; ]
<h3>DESCRIPTION</h3>
<p class="j">
A <em>message digest</em> is a compact digital signature for an
arbitrarily long stream of binary data. An ideal message digest
algorithm would never generate the same signature for two
different sets of input, but achieving such theoretical
perfection would require a message digest as long as the input
file. Practical message digest algorithms compromise in favour
of a digital signature of modest size created with an algorithm
designed to make preparation of input text with a given
signature computationally infeasible. Message digest algorithms
have much in common with techniques used in encryption, but to a
different end; verification that data have not been altered
since the signature was published.
</p>
<p class="j">
Many older programs requiring digital signatures employed 16 or
32 bit <em>cyclical redundancy codes</em> (CRC) originally
developed to verify correct transmission in data communication
protocols, but these short codes, while adequate to detect the
kind of transmission errors for which they were intended, are
insufficiently secure for applications such as electronic
commerce and verification of security related software
distributions.
</p>
<p class="j">
The most commonly used present-day message digest algorithm is
the 128 bit MD5 algorithm, developed by Ron Rivest of the
<a href="http://web.mit.edu/" target="_blank">MIT</a>
<a href="http://www.lcs.mit.edu/" target="_blank">Laboratory for Computer Science</a> and
<a href="http://www.rsa.com/" target="_blank">RSA Data Security,
Inc.</a> The algorithm, with a reference implementation, was
published as Internet <a href="rfc1321.html">RFC 1321</a> in April 1992, and was
placed into the public domain at that time. Message
digest algorithms such as MD5 are not deemed
&ldquo;encryption technology&rdquo; and are not subject to the
export controls some governments impose on
other data security products. (Obviously, the
responsibility for obeying the laws in the jurisdiction
in which you reside is entirely your own, but many
common Web and Mail utilities use MD5, and I am unaware
of any restrictions on their distribution and use.)
</p>
<p class="j">
The MD5 algorithm has been implemented in numerous
computer languages including C,
<a href="http://www.perl.org/" target="_blank">Perl</a>, and
<a href="http://java.sun.com/" target="_blank">Java</a>; if you're
writing a program in such a language, track down a suitable
subroutine and incorporate it into your program. The
program described on this page is a <em>command line</em>
implementation of MD5, intended for use in shell scripts
and Perl programs (it is much faster than computing
an MD5 signature directly in Perl). This <b>md5</b>
program was originally developed as part of a suite of tools
intended to monitor large collections of files (for example,
the contents of a Web site) to detect corruption of
files and inadvertent (or perhaps malicious) changes. That
task is now best accomplished with more comprehensive
packages such as
<a href="http://www.tripwire.com/" target="_blank">Tripwire</a>,
but the command line <b>md5</b> component continues to prove useful
for verifying correct delivery and installation of software packages,
comparing the contents of two different systems, and checking for
changes in specific files.
</p>
<h3>OPTIONS</h3>
<dl>
<dt><b>-c</b><i>signature</i></dt> <dd>Computes the signature of the
specified <em>infile</em> or the string supplied by the <b>-d</b>
option and compares it against the specified <i>signature</i>.
If the two signatures match, the exit status will be zero,
otherwise the exit status will be 1. No signature is written;
only the exit
status is set. The signature to be checked must be specified
as 32 hexadecimal digits.</dd>
<dt><b>-d</b><i>input_text</i></dt> <dd>A signature is computed for the
given <i>input_text</i> (which must be quoted if it contains white space
characters) instead of input from <i>infile</i> or standard
input. If input is specified with the <b>-d</b> option, no
<i>infile</i> should be specified.</dd>
<dt><b>-l</b></dt> <dd>Use lower case letters for hexadecimal
digits &ldquo;a&rdquo; through &ldquo;f&rdquo;. By default, upper case letters are
used. Note that the <i>signature</i> argument to the
<b>-c</b> option may use upper or lower case hexadecimal
digits (or a mix) regardless of the setting of this option.</dd>
<dt><b>-n</b></dt> <dd>Suppress printing the file name (or
&ldquo;<tt>-</tt>&rdquo; for standard input) after the hexadecimal
signature.</dd>
<dt><b>-o</b><i>fname</i></dt> <dd>Write output to <i>fname</i>.
If <i>fname</i> is &ldquo;<tt>-</tt>&rdquo;, output is written
to standard output, which is the default is no
<b>-o</b> option is specified.</dd>
<dt><b>-u</b></dt> <dd>Print how-to-call information.</dd>
<dt><b>-v</b></dt> <dd>Print version information.</dd>
</dl>
<h3>FILES</h3>
<p class="j">
If no <em>infile</em> or <b>-d</b> option is specified or
<em>infile</em> is a single &ldquo;<tt>-</tt>&rdquo;, <b>md5</b>
reads from standard input. A single &ldquo;<tt>-</tt>&rdquo; on
the command line causes all subsequent arguments to be treated as
file names even if they begin with &ldquo;<tt>-</tt>&rdquo;. If
no <b>-o</b> option is specified or the <em>fname</em> is a
single &ldquo;<tt>-</tt>&rdquo;, output is sent to standard
output. Input and output are processed strictly serially;
consequently <b>md5</b> may be used in pipelines.
</p>
<h3>BUGS</h3>
<p class="j">
The mechanism used to set standard input to binary mode may be
specific to Microsoft C; if you rebuild the DOS/Windows version
of the program from source using another compiler, be sure to verify
binary files work properly when read via redirection or a pipe.
</p>
<p class="j">
This program has not been tested on a machine on which <tt>int</tt>
and/or <tt>long</tt> are longer than 32 bits.
</p>
<h2><img src="/images/icons/file.png" alt="" align="middle" width="40" height="40" />
Download <a href="md5.zip">md5.zip</a> (Zipped)
or <a href="md5.tar.gz">md5.tar.gz</a> (tar/gzip)</h2>
<p class="j">
The program is provided as either <a href="md5.zip">md5.zip</a>, a
<a href="http://www.info-zip.org/" target="_blank">Zipped</a> archive, or
<a href="md5.tar.gz">md5.tar.gz</a>, a <tt>gzip</tt>ped
<tt>tar</tt> archive. The two archive formats have identical
contents; both include a
ready-to-run Win32 command-line executable program, <code>md5.exe</code>
(compiled using Microsoft Visual C++ .NET),
and source code along with a
<code>Makefile</code> to build the program under Unix.
</p>
<h3>SEE ALSO</h3>
<b>sum</b>(1)
<h3>EXIT STATUS</h3>
<p class="j">
<b>md5</b> returns status 0 if processing was
completed without errors, 1 if the <b>-c</b> option was
specified and the given signature does not match that of the input,
and 2 if processing could not be performed at
all due, for example, to a nonexistent input file.
</p>
<h3>COPYING</h3>
<blockquote>
<p class="j">
This software is in the public domain. Permission to use, copy,
modify, and distribute this software and its documentation for
any purpose and without fee is hereby granted, without any
conditions or restrictions. This software is provided &ldquo;as is&rdquo;
without express or implied warranty.
</p>
</blockquote>
<h3>ACKNOWLEDGEMENTS</h3>
<p class="j">
The MD5 algorithm was developed by Ron Rivest. The public
domain C language implementation used in this program was
written by Colin Plumb in 1993.
</p>
<h3><a href="/">Fourmilab home page</a></h3>
<hr />
<address>
<a href="/">by John Walker</a><br />
January 14th, 2008
</address>
</body>
</html>

View File

@ -0,0 +1,275 @@
/*
Calculate or Check MD5 Signature of File or Command Line Argument
by John Walker
http://www.fourmilab.ch/
This program is in the public domain.
*/
#define VERSION "2.2 (2008-01-14)"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#ifdef _WIN32
#include <fcntl.h>
#include <io.h>
#endif
#include "md5.h"
#define FALSE 0
#define TRUE 1
#define EOS '\0'
/* Main program */
int main(argc, argv)
int argc; char *argv[];
{
int i, j, opt, cdata = FALSE, docheck = FALSE, showfile = TRUE, f = 0;
unsigned int bp;
char *cp, *clabel, *ifname, *hexfmt = "%02X";
FILE *in = stdin, *out = stdout;
unsigned char buffer[16384], signature[16], csig[16];
struct MD5Context md5c;
/* Build parameter quality control. Verify machine
properties were properly set in md5.h and refuse
to run if they're not correct. */
#ifdef CHECK_HARDWARE_PROPERTIES
/* Verify unit32 is, in fact, a 32 bit data type. */
if (sizeof(uint32) != 4) {
fprintf(stderr, "** Configuration error. Setting for uint32 in file md5.h\n");
fprintf(stderr, " is incorrect. This must be a 32 bit data type, but it\n");
fprintf(stderr, " is configured as a %d bit data type.\n", sizeof(uint32) * 8);
return 2;
}
/* If HIGHFIRST is not defined, verify that this machine is,
in fact, a little-endian architecture. */
#ifndef HIGHFIRST
{ uint32 t = 0x12345678;
if (*((char *) &t) != 0x78) {
fprintf(stderr, "** Configuration error. Setting for HIGHFIRST in file md5.h\n");
fprintf(stderr, " is incorrect. This symbol has not been defined, yet this\n");
fprintf(stderr, " machine is a big-endian (most significant byte first in\n");
fprintf(stderr, " memory) architecture. Please modify md5.h so HIGHFIRST is\n");
fprintf(stderr, " defined when building for this machine.\n");
return 2;
}
}
#endif
#endif
/* Process command line options. */
for (i = 1; i < argc; i++) {
cp = argv[i];
if (*cp == '-') {
if (strlen(cp) == 1) {
i++;
break; /* - -- Mark end of options; balance are files */
}
opt = *(++cp);
if (islower(opt)) {
opt = toupper(opt);
}
switch (opt) {
case 'C': /* -Csignature -- Check signature, set return code */
docheck = TRUE;
if (strlen(cp + 1) != 32) {
docheck = FALSE;
}
memset(csig, 0, 16);
clabel = cp + 1;
for (j = 0; j < 16; j++) {
if (isxdigit((int) clabel[0]) && isxdigit((int) clabel[1]) &&
sscanf((cp + 1 + (j * 2)), hexfmt, &bp) == 1) {
csig[j] = (unsigned char) bp;
} else {
docheck = FALSE;
break;
}
clabel += 2;
}
if (!docheck) {
fprintf(stderr, "Error in signature specification. Must be 32 hex digits.\n");
return 2;
}
break;
case 'D': /* -Dtext -- Compute signature of given text */
MD5Init(&md5c);
MD5Update(&md5c, (unsigned char *) (cp + 1), strlen(cp + 1));
cdata = TRUE;
f++; /* Mark no infile argument needed */
break;
case 'L': /* -L -- Use lower case letters as hex digits */
hexfmt = "%02x";
break;
case 'N': /* -N -- Don't show file name after sum */
showfile = FALSE;
break;
case 'O': /* -Ofname -- Write output to fname (- = stdout) */
cp++;
if (strcmp(cp, "-") != 0) {
if (out != stdout) {
fprintf(stderr, "Redundant output file specification.\n");
return 2;
}
if ((out = fopen(cp, "w")) == NULL) {
fprintf(stderr, "Cannot open output file %s\n", cp);
return 2;
}
}
break;
case '?': /* -U, -? -H -- Print how to call information. */
case 'H':
case 'U':
printf("\nMD5 -- Calculate MD5 signature of file. Call");
printf("\n with md5 [ options ] [file ...]");
printf("\n");
printf("\n Options:");
printf("\n -csig Check against sig, set exit status 0 = OK");
printf("\n -dtext Compute signature of text argument");
printf("\n -l Use lower case letters for hexadecimal digits");
printf("\n -n Do not show file name after sum");
printf("\n -ofname Write output to fname (- = stdout)");
printf("\n -u Print this message");
printf("\n -v Print version information");
printf("\n");
printf("\nby John Walker -- http://www.fourmilab.ch/");
printf("\nVersion %s\n", VERSION);
printf("\nThis program is in the public domain.\n");
printf("\n");
#ifdef CHECK_HARDWARE_PROPERTIES
#ifdef HIGHFIRST
{ uint32 t = 0x12345678;
if (*((char *) &t) == 0x78) {
fprintf(stderr, "** Note. md5 is not optimally configured for use on this\n");
fprintf(stderr, " machine. This is a little-endian (least significant byte\n");
fprintf(stderr, " first in memory) architecture, yet md5 has been built with the\n");
fprintf(stderr, " symbol HIGHFIRST defined in md5.h, which includes code which\n");
fprintf(stderr, " supports both big- and little-endian machines. Modifying\n");
fprintf(stderr, " md5.h to undefine HIGHFIRST for this platform will make md5\n");
fprintf(stderr, " run faster on it.\n");
}
}
#endif
#endif
return 0;
case 'V': /* -V -- Print version number */
printf("%s\n", VERSION);
return 0;
}
} else {
break;
}
}
if (cdata && (i < argc)) {
fprintf(stderr, "Cannot specify both -d option and input file.\n");
return 2;
}
if ((i >= argc) && (f == 0)) {
f++;
}
for (; (f > 0) || (i < argc); i++) {
if ((!cdata) && (f > 0)) {
ifname = "-";
} else {
ifname = argv[i];
}
f = 0;
if (!cdata) {
int opened = FALSE;
/* If the data weren't supplied on the command line with
the "-d" option, read it now from the input file. */
if (strcmp(ifname, "-") != 0) {
if ((in = fopen(ifname, "rb")) == NULL) {
fprintf(stderr, "Cannot open input file %s\n", ifname);
return 2;
}
opened = TRUE;
} else {
in = stdin;
}
#ifdef _WIN32
/** Warning! On systems which distinguish text mode and
binary I/O (MS-DOS, Macintosh, etc.) the modes in the open
statement for "in" should have forced the input file into
binary mode. But what if we're reading from standard
input? Well, then we need to do a system-specific tweak
to make sure it's in binary mode. While we're at it,
let's set the mode to binary regardless of however fopen
set it.
The following code, conditional on _WIN32, sets binary
mode using the method prescribed by Microsoft Visual C 7.0
("Monkey C"); this may require modification if you're
using a different compiler or release of Monkey C. If
you're porting this code to a different system which
distinguishes text and binary files, you'll need to add
the equivalent call for that system. */
_setmode(_fileno(in), _O_BINARY);
#endif
MD5Init(&md5c);
while ((j = (int) fread(buffer, 1, sizeof buffer, in)) > 0) {
MD5Update(&md5c, buffer, (unsigned) j);
}
if (opened) {
fclose(in);
}
}
MD5Final(signature, &md5c);
if (docheck) {
docheck = 0;
for (j = 0; j < sizeof signature; j++) {
if (signature[j] != csig[j]) {
docheck = 1;
break;
}
}
if (i < (argc - 1)) {
fprintf(stderr, "Only one file may be tested with the -c option.\n");
return 2;
}
} else {
for (j = 0; j < sizeof signature; j++) {
fprintf(out, hexfmt, signature[j]);
}
if ((!cdata) && showfile) {
fprintf(out, " %s", (in == stdin) ? "-" : ifname);
}
fprintf(out, "\n");
}
}
return docheck;
}

View File

@ -0,0 +1,255 @@
/*
* This code implements the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
* written by Colin Plumb in 1993, no copyright is claimed.
* This code is in the public domain; do with it what you wish.
*
* Equivalent code is available from RSA Data Security, Inc.
* This code has been tested against that, and is equivalent,
* except that you don't need to include two pages of legalese
* with every copy.
*
* To compute the message digest of a chunk of bytes, declare an
* MD5Context structure, pass it to MD5Init, call MD5Update as
* needed on buffers full of bytes, and then call MD5Final, which
* will fill a supplied 16-byte array with the digest.
*/
/* Brutally hacked by John Walker back from ANSI C to K&R (no
prototypes) to maintain the tradition that Netfone will compile
with Sun's original "cc". */
#include <memory.h> /* for memcpy() */
#include "md5.h"
#ifndef HIGHFIRST
#define byteReverse(buf, len) /* Nothing */
#else
/*
* Note: this code is harmless on little-endian machines.
*/
void byteReverse(buf, longs)
unsigned char *buf; unsigned longs;
{
uint32 t;
do {
t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
((unsigned) buf[1] << 8 | buf[0]);
*(uint32 *) buf = t;
buf += 4;
} while (--longs);
}
#endif
/*
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
* initialization constants.
*/
void MD5Init(ctx)
struct MD5Context *ctx;
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
ctx->buf[2] = 0x98badcfe;
ctx->buf[3] = 0x10325476;
ctx->bits[0] = 0;
ctx->bits[1] = 0;
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void MD5Update(ctx, buf, len)
struct MD5Context *ctx; unsigned char *buf; unsigned len;
{
uint32 t;
/* Update bitcount */
t = ctx->bits[0];
if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
ctx->bits[1]++; /* Carry from low to high */
ctx->bits[1] += len >> 29;
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
/* Handle any leading odd-sized chunks */
if (t) {
unsigned char *p = (unsigned char *) ctx->in + t;
t = 64 - t;
if (len < t) {
memcpy(p, buf, len);
return;
}
memcpy(p, buf, t);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32 *) ctx->in);
buf += t;
len -= t;
}
/* Process data in 64-byte chunks */
while (len >= 64) {
memcpy(ctx->in, buf, 64);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32 *) ctx->in);
buf += 64;
len -= 64;
}
/* Handle any remaining bytes of data. */
memcpy(ctx->in, buf, len);
}
/*
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
void MD5Final(digest, ctx)
unsigned char digest[16]; struct MD5Context *ctx;
{
unsigned count;
unsigned char *p;
/* Compute number of bytes mod 64 */
count = (ctx->bits[0] >> 3) & 0x3F;
/* Set the first char of padding to 0x80. This is safe since there is
always at least one byte free */
p = ctx->in + count;
*p++ = 0x80;
/* Bytes of padding needed to make 64 bytes */
count = 64 - 1 - count;
/* Pad out to 56 mod 64 */
if (count < 8) {
/* Two lots of padding: Pad the first block to 64 bytes */
memset(p, 0, count);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32 *) ctx->in);
/* Now fill the next block with 56 bytes */
memset(ctx->in, 0, 56);
} else {
/* Pad block to 56 bytes */
memset(p, 0, count - 8);
}
byteReverse(ctx->in, 14);
/* Append length in bits and transform */
((uint32 *) ctx->in)[14] = ctx->bits[0];
((uint32 *) ctx->in)[15] = ctx->bits[1];
MD5Transform(ctx->buf, (uint32 *) ctx->in);
byteReverse((unsigned char *) ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
}
/* The four core functions - F1 is optimized somewhat */
/* #define F1(x, y, z) (x & y | ~x & z) */
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#define F2(x, y, z) F1(z, x, y)
#define F3(x, y, z) (x ^ y ^ z)
#define F4(x, y, z) (y ^ (x | ~z))
/* This is the central step in the MD5 algorithm. */
#define MD5STEP(f, w, x, y, z, data, s) \
( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
/*
* The core of the MD5 algorithm, this alters an existing MD5 hash to
* reflect the addition of 16 longwords of new data. MD5Update blocks
* the data and converts bytes into longwords for this routine.
*/
void MD5Transform(buf, in)
uint32 buf[4]; uint32 in[16];
{
register uint32 a, b, c, d;
a = buf[0];
b = buf[1];
c = buf[2];
d = buf[3];
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
buf[0] += a;
buf[1] += b;
buf[2] += c;
buf[3] += d;
}

View File

@ -0,0 +1,54 @@
#ifndef MD5_H
#define MD5_H
/* The following tests optimise behaviour on little-endian
machines, where there is no need to reverse the byte order
of 32 bit words in the MD5 computation. By default,
HIGHFIRST is defined, which indicates we're running on a
big-endian (most significant byte first) machine, on which
the byteReverse function in md5.c must be invoked. However,
byteReverse is coded in such a way that it is an identity
function when run on a little-endian machine, so calling it
on such a platform causes no harm apart from wasting time.
If the platform is known to be little-endian, we speed
things up by undefining HIGHFIRST, which defines
byteReverse as a null macro. Doing things in this manner
insures we work on new platforms regardless of their byte
order. */
#define HIGHFIRST
#ifdef __i386__
#undef HIGHFIRST
#endif
/* On machines where "long" is 64 bits, we need to declare
uint32 as something guaranteed to be 32 bits. */
#ifdef __alpha
typedef unsigned int uint32;
#else
typedef unsigned long uint32;
#endif
struct MD5Context {
uint32 buf[4];
uint32 bits[2];
unsigned char in[64];
};
extern void MD5Init();
extern void MD5Update();
extern void MD5Final();
extern void MD5Transform();
/*
* This is needed to make RSAREF happy on some MS-DOS compilers.
*/
typedef struct MD5Context MD5_CTX;
/* Define CHECK_HARDWARE_PROPERTIES to have main,c verify
byte order and uint32 settings. */
#define CHECK_HARDWARE_PROPERTIES
#endif /* !MD5_H */

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 7.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "md5", "md5.vcproj", "{08715914-9160-4A19-997E-237020B3433B}"
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug
ConfigName.1 = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{08715914-9160-4A19-997E-237020B3433B}.Debug.ActiveCfg = Debug|Win32
{08715914-9160-4A19-997E-237020B3433B}.Debug.Build.0 = Debug|Win32
{08715914-9160-4A19-997E-237020B3433B}.Release.ActiveCfg = Release|Win32
{08715914-9160-4A19-997E-237020B3433B}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,130 @@
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="md5"
ProjectGUID="{08715914-9160-4A19-997E-237020B3433B}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;__i386__"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/md5.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/md5.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
OmitFramePointers="TRUE"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;__i386__"
StringPooling="TRUE"
RuntimeLibrary="4"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/md5.exe"
LinkIncremental="1"
AdditionalLibraryDirectories=""
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
<File
RelativePath="main.c">
</File>
<File
RelativePath="md5.c">
</File>
<File
RelativePath="..\..\Program Files\Microsoft Visual Studio .NET\Vc7\lib\setargv.obj">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc">
<File
RelativePath="md5.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -18,9 +18,7 @@ rem Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
echo on echo on
del /F /Q .\build\npp.*.Installer.exe del /F /Q .\build\*.*
del /F /Q .\build\npp.bin.7z
del /F /Q .\build\npp.bin.zip
del /F /S /Q .\zipped.package.release\unicode\*.* del /F /S /Q .\zipped.package.release\unicode\*.*
copy /Y ..\bin\license.txt .\zipped.package.release\unicode\ copy /Y ..\bin\license.txt .\zipped.package.release\unicode\
@ -104,3 +102,24 @@ If ErrorLevel 1 PAUSE
If ErrorLevel 1 PAUSE If ErrorLevel 1 PAUSE
"C:\Program Files\NSIS\makensis.exe" nppSetup.nsi "C:\Program Files\NSIS\makensis.exe" nppSetup.nsi
@echo off
setlocal enableDelayedExpansion
cd .\build\
for %%a in (npp.*.Installer.exe) do (
rem echo a = %%a
set nppInstallerVar=%%a
set zipvar=!nppInstallerVar:Installer.exe=bin.zip!
set 7zvar=!nppInstallerVar:Installer.exe=bin.7z!
set md5var=!nppInstallerVar:Installer.exe=release.md5!
)
ren npp.bin.zip !zipvar!
ren npp.bin.7z !7zvar!
..\externalTools\md5.exe -o!md5var! !nppInstallerVar! !zipvar! !7zvar!
cd ..
endlocal