mirror of
https://github.com/dlang/phobos.git
synced 2025-04-26 21:22:20 +03:00
Merge pull request #1800 from Geod24/remove-deprecated-modules
Remove deprecated crc32 and std.md5
This commit is contained in:
commit
67342afbc9
6 changed files with 7 additions and 578 deletions
81
crc32.d
81
crc32.d
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2001, 2002
|
||||
* Pavel "EvilOne" Minayev
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Author makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided
|
||||
* "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
// CRC-32 calculation
|
||||
module crc32;
|
||||
|
||||
pragma(msg, "The 'crc32' module has been scheduled for deprecation. Please use 'std.digest.crc' instead.");
|
||||
|
||||
private immutable uint[256] crc32_table =
|
||||
[
|
||||
0x00000000,0x77073096,0xee0e612c,0x990951ba,0x076dc419,0x706af48f,0xe963a535,
|
||||
0x9e6495a3,0x0edb8832,0x79dcb8a4,0xe0d5e91e,0x97d2d988,0x09b64c2b,0x7eb17cbd,
|
||||
0xe7b82d07,0x90bf1d91,0x1db71064,0x6ab020f2,0xf3b97148,0x84be41de,0x1adad47d,
|
||||
0x6ddde4eb,0xf4d4b551,0x83d385c7,0x136c9856,0x646ba8c0,0xfd62f97a,0x8a65c9ec,
|
||||
0x14015c4f,0x63066cd9,0xfa0f3d63,0x8d080df5,0x3b6e20c8,0x4c69105e,0xd56041e4,
|
||||
0xa2677172,0x3c03e4d1,0x4b04d447,0xd20d85fd,0xa50ab56b,0x35b5a8fa,0x42b2986c,
|
||||
0xdbbbc9d6,0xacbcf940,0x32d86ce3,0x45df5c75,0xdcd60dcf,0xabd13d59,0x26d930ac,
|
||||
0x51de003a,0xc8d75180,0xbfd06116,0x21b4f4b5,0x56b3c423,0xcfba9599,0xb8bda50f,
|
||||
0x2802b89e,0x5f058808,0xc60cd9b2,0xb10be924,0x2f6f7c87,0x58684c11,0xc1611dab,
|
||||
0xb6662d3d,0x76dc4190,0x01db7106,0x98d220bc,0xefd5102a,0x71b18589,0x06b6b51f,
|
||||
0x9fbfe4a5,0xe8b8d433,0x7807c9a2,0x0f00f934,0x9609a88e,0xe10e9818,0x7f6a0dbb,
|
||||
0x086d3d2d,0x91646c97,0xe6635c01,0x6b6b51f4,0x1c6c6162,0x856530d8,0xf262004e,
|
||||
0x6c0695ed,0x1b01a57b,0x8208f4c1,0xf50fc457,0x65b0d9c6,0x12b7e950,0x8bbeb8ea,
|
||||
0xfcb9887c,0x62dd1ddf,0x15da2d49,0x8cd37cf3,0xfbd44c65,0x4db26158,0x3ab551ce,
|
||||
0xa3bc0074,0xd4bb30e2,0x4adfa541,0x3dd895d7,0xa4d1c46d,0xd3d6f4fb,0x4369e96a,
|
||||
0x346ed9fc,0xad678846,0xda60b8d0,0x44042d73,0x33031de5,0xaa0a4c5f,0xdd0d7cc9,
|
||||
0x5005713c,0x270241aa,0xbe0b1010,0xc90c2086,0x5768b525,0x206f85b3,0xb966d409,
|
||||
0xce61e49f,0x5edef90e,0x29d9c998,0xb0d09822,0xc7d7a8b4,0x59b33d17,0x2eb40d81,
|
||||
0xb7bd5c3b,0xc0ba6cad,0xedb88320,0x9abfb3b6,0x03b6e20c,0x74b1d29a,0xead54739,
|
||||
0x9dd277af,0x04db2615,0x73dc1683,0xe3630b12,0x94643b84,0x0d6d6a3e,0x7a6a5aa8,
|
||||
0xe40ecf0b,0x9309ff9d,0x0a00ae27,0x7d079eb1,0xf00f9344,0x8708a3d2,0x1e01f268,
|
||||
0x6906c2fe,0xf762575d,0x806567cb,0x196c3671,0x6e6b06e7,0xfed41b76,0x89d32be0,
|
||||
0x10da7a5a,0x67dd4acc,0xf9b9df6f,0x8ebeeff9,0x17b7be43,0x60b08ed5,0xd6d6a3e8,
|
||||
0xa1d1937e,0x38d8c2c4,0x4fdff252,0xd1bb67f1,0xa6bc5767,0x3fb506dd,0x48b2364b,
|
||||
0xd80d2bda,0xaf0a1b4c,0x36034af6,0x41047a60,0xdf60efc3,0xa867df55,0x316e8eef,
|
||||
0x4669be79,0xcb61b38c,0xbc66831a,0x256fd2a0,0x5268e236,0xcc0c7795,0xbb0b4703,
|
||||
0x220216b9,0x5505262f,0xc5ba3bbe,0xb2bd0b28,0x2bb45a92,0x5cb36a04,0xc2d7ffa7,
|
||||
0xb5d0cf31,0x2cd99e8b,0x5bdeae1d,0x9b64c2b0,0xec63f226,0x756aa39c,0x026d930a,
|
||||
0x9c0906a9,0xeb0e363f,0x72076785,0x05005713,0x95bf4a82,0xe2b87a14,0x7bb12bae,
|
||||
0x0cb61b38,0x92d28e9b,0xe5d5be0d,0x7cdcefb7,0x0bdbdf21,0x86d3d2d4,0xf1d4e242,
|
||||
0x68ddb3f8,0x1fda836e,0x81be16cd,0xf6b9265b,0x6fb077e1,0x18b74777,0x88085ae6,
|
||||
0xff0f6a70,0x66063bca,0x11010b5c,0x8f659eff,0xf862ae69,0x616bffd3,0x166ccf45,
|
||||
0xa00ae278,0xd70dd2ee,0x4e048354,0x3903b3c2,0xa7672661,0xd06016f7,0x4969474d,
|
||||
0x3e6e77db,0xaed16a4a,0xd9d65adc,0x40df0b66,0x37d83bf0,0xa9bcae53,0xdebb9ec5,
|
||||
0x47b2cf7f,0x30b5ffe9,0xbdbdf21c,0xcabac28a,0x53b39330,0x24b4a3a6,0xbad03605,
|
||||
0xcdd70693,0x54de5729,0x23d967bf,0xb3667a2e,0xc4614ab8,0x5d681b02,0x2a6f2b94,
|
||||
0xb40bbe37,0xc30c8ea1,0x5a05df1b,0x2d02ef8d
|
||||
];
|
||||
|
||||
uint init_crc32()
|
||||
{
|
||||
return cast(uint)-1;
|
||||
}
|
||||
|
||||
uint update_crc32(ubyte val, uint crc)
|
||||
{
|
||||
return crc32_table[cast(ubyte) crc ^ val] ^ (crc >> 8);
|
||||
}
|
||||
|
||||
uint update_crc32(char val, uint crc)
|
||||
{
|
||||
return update_crc32(cast(ubyte) val, crc);
|
||||
}
|
||||
|
||||
uint strcrc32(char[] s)
|
||||
{
|
||||
uint crc = init_crc32();
|
||||
for (int i = 0; i < s.length; i++)
|
||||
crc = update_crc32(s[i], crc);
|
||||
return crc;
|
||||
}
|
|
@ -175,7 +175,7 @@ MAIN = $(ROOT)/emptymain.d
|
|||
STD_MODULES = $(addprefix std/, algorithm array ascii base64 bigint \
|
||||
bitmanip compiler complex concurrency container conv \
|
||||
cstream csv datetime demangle encoding exception \
|
||||
file format functional getopt json math mathspecial md5 \
|
||||
file format functional getopt json math mathspecial \
|
||||
metastrings mmfile numeric outbuffer parallelism path \
|
||||
process random range regex signals socket socketstream \
|
||||
stdint stdio stdiobase stream string syserror system traits \
|
||||
|
@ -209,7 +209,7 @@ EXTRA_MODULES += $(EXTRA_DOCUMENTABLES) $(addprefix \
|
|||
unicode_comp unicode_decomp unicode_grapheme unicode_norm)
|
||||
|
||||
# Aggregate all D modules relevant to this build
|
||||
D_MODULES = crc32 $(STD_MODULES) $(EXTRA_MODULES) $(STD_NET_MODULES) \
|
||||
D_MODULES = $(STD_MODULES) $(EXTRA_MODULES) $(STD_NET_MODULES) \
|
||||
$(STD_DIGEST_MODULES)
|
||||
# Add the .d suffix to the module names
|
||||
D_FILES = $(addsuffix .d,$(D_MODULES))
|
||||
|
@ -353,7 +353,6 @@ ifneq (,$(findstring $(OS),linux))
|
|||
endif
|
||||
mkdir -p $(INSTALL_DIR)/import/etc
|
||||
mkdir -p $(INSTALL_DIR)/import/std
|
||||
cp crc32.d $(INSTALL_DIR)/import/
|
||||
cp -r std/* $(INSTALL_DIR)/import/std/
|
||||
cp -r etc/* $(INSTALL_DIR)/import/etc/
|
||||
cp LICENSE_1_0.txt $(INSTALL_DIR)/phobos-LICENSE.txt
|
||||
|
|
476
std/md5.d
476
std/md5.d
|
@ -1,476 +0,0 @@
|
|||
// Written in the D programming language.
|
||||
|
||||
/* md5.d - RSA Data Security, Inc., MD5 message-digest algorithm
|
||||
* Derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $(RED Scheduled for deprecation. Please use std.digest.md instead.)
|
||||
*
|
||||
* Computes MD5 digests of arbitrary data. MD5 digests are 16 byte quantities that are like a checksum or crc, but are more robust.
|
||||
*
|
||||
* There are two ways to do this. The first does it all in one function call to
|
||||
* sum(). The second is for when the data is buffered.
|
||||
*
|
||||
* Bugs:
|
||||
* MD5 digests have been demonstrated to not be unique.
|
||||
*
|
||||
* Author:
|
||||
* The routines and algorithms are derived from the
|
||||
* $(I RSA Data Security, Inc. MD5 Message-Digest Algorithm).
|
||||
*
|
||||
* References:
|
||||
* $(LINK2 http://en.wikipedia.org/wiki/Md5, Wikipedia on MD5)
|
||||
*
|
||||
* Source: $(PHOBOSSRC std/_md5.d)
|
||||
*
|
||||
* Macros:
|
||||
* WIKI = Phobos/StdMd5
|
||||
*/
|
||||
|
||||
/++++++++++++++++++++++++++++++++
|
||||
Example:
|
||||
|
||||
--------------------
|
||||
// This code is derived from the
|
||||
// RSA Data Security, Inc. MD5 Message-Digest Algorithm.
|
||||
|
||||
import std.md5;
|
||||
import std.stdio;
|
||||
|
||||
void main(string[] args)
|
||||
{
|
||||
foreach (arg; args)
|
||||
mdFile(arg);
|
||||
}
|
||||
|
||||
/// Digests a file and prints the result.
|
||||
void mdFile(string filename)
|
||||
{
|
||||
ubyte[16] digest;
|
||||
|
||||
MD5_CTX context;
|
||||
context.start();
|
||||
foreach (buffer; File(filename).byChunk(64 * 1024))
|
||||
context.update(buffer);
|
||||
context.finish(digest);
|
||||
writefln("MD5 (%s) = %s", filename, digestToString(digest));
|
||||
}
|
||||
--------------------
|
||||
+/
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
module std.md5;
|
||||
|
||||
pragma(msg, "std.md5 is scheduled for deprecation. Please use "
|
||||
"std.digest.md instead");
|
||||
|
||||
//debug=md5; // uncomment to turn on debugging printf's
|
||||
|
||||
import std.ascii;
|
||||
import std.bitmanip;
|
||||
import std.string;
|
||||
import std.exception;
|
||||
debug(md5) import std.c.stdio : printf;
|
||||
|
||||
/***************************************
|
||||
* Computes MD5 digest of several arrays of data.
|
||||
*/
|
||||
|
||||
void sum(ref ubyte[16] digest, in void[][] data...)
|
||||
{
|
||||
MD5_CTX context;
|
||||
context.start();
|
||||
foreach (datum; data)
|
||||
{
|
||||
context.update(datum);
|
||||
}
|
||||
context.finish(digest);
|
||||
}
|
||||
|
||||
// /******************
|
||||
// * Prints a message digest in hexadecimal to stdout.
|
||||
// */
|
||||
// void printDigest(const ubyte digest[16])
|
||||
// {
|
||||
// foreach (ubyte u; digest)
|
||||
// printf("%02x", u);
|
||||
// }
|
||||
|
||||
/****************************************
|
||||
* Converts MD5 digest to a string.
|
||||
*/
|
||||
|
||||
string digestToString(in ubyte[16] digest)
|
||||
{
|
||||
auto result = new char[32];
|
||||
int i;
|
||||
|
||||
foreach (ubyte u; digest)
|
||||
{
|
||||
result[i] = std.ascii.hexDigits[u >> 4];
|
||||
result[i + 1] = std.ascii.hexDigits[u & 15];
|
||||
i += 2;
|
||||
}
|
||||
return assumeUnique(result);
|
||||
}
|
||||
|
||||
/**
|
||||
Gets the digest of all $(D data) items passed in.
|
||||
|
||||
Example:
|
||||
|
||||
----
|
||||
string a = "Mary has ", b = "a little lamb";
|
||||
int[] c = [ 1, 2, 3, 4, 5 ];
|
||||
string d = getDigestString(a, b, c);
|
||||
----
|
||||
*/
|
||||
string getDigestString(in void[][] data...)
|
||||
{
|
||||
MD5_CTX ctx;
|
||||
ctx.start();
|
||||
foreach (datum; data) {
|
||||
ctx.update(datum);
|
||||
}
|
||||
ubyte[16] digest;
|
||||
ctx.finish(digest);
|
||||
return digestToString(digest);
|
||||
}
|
||||
|
||||
version(unittest) import std.stdio;
|
||||
unittest
|
||||
{
|
||||
string a = "Mary has ", b = "a little lamb";
|
||||
int[] c = [ 1, 2, 3, 4, 5 ];
|
||||
string d = getDigestString(a, b, c);
|
||||
version(LittleEndian)
|
||||
assert(d == "F36625A66B2A8D9F47270C00C8BEFD2F", d);
|
||||
else
|
||||
assert(d == "2656D2008FF10DAE4B0783E6E0171655", d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds context of MD5 computation.
|
||||
*
|
||||
* Used when data to be digested is buffered.
|
||||
*/
|
||||
struct MD5_CTX
|
||||
{
|
||||
private import core.stdc.string : memcpy, memset;
|
||||
|
||||
uint[4] state = /* state (ABCD) */
|
||||
/* magic initialization constants */
|
||||
[0x67452301,0xefcdab89,0x98badcfe,0x10325476];
|
||||
|
||||
ulong count; /* number of bits, modulo 2^64 */
|
||||
ubyte[64] buffer; /* input buffer */
|
||||
|
||||
static ubyte[64] PADDING =
|
||||
[
|
||||
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.
|
||||
*/
|
||||
private static
|
||||
{
|
||||
uint F(uint x, uint y, uint z) { return (x & y) | (~x & z); }
|
||||
uint G(uint x, uint y, uint z) { return (x & z) | (y & ~z); }
|
||||
uint H(uint x, uint y, uint z) { return x ^ y ^ z; }
|
||||
uint I(uint x, uint y, uint z) { return y ^ (x | ~z); }
|
||||
}
|
||||
|
||||
/* ROTATE_LEFT rotates x left n bits.
|
||||
*/
|
||||
static uint ROTATE_LEFT(uint x, uint n)
|
||||
{
|
||||
// With recently added optimization to DMD (commit 32ea0206 at 07/28/11), this is translated to rol.
|
||||
// No assembler required.
|
||||
return (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.
|
||||
*/
|
||||
static void FF(ref uint a, uint b, uint c, uint d, uint x, uint s, uint ac)
|
||||
{
|
||||
a += F (b, c, d) + x + ac;
|
||||
a = ROTATE_LEFT (a, s);
|
||||
a += b;
|
||||
}
|
||||
|
||||
static void GG(ref uint a, uint b, uint c, uint d, uint x, uint s, uint ac)
|
||||
{
|
||||
a += G (b, c, d) + x + ac;
|
||||
a = ROTATE_LEFT (a, s);
|
||||
a += b;
|
||||
}
|
||||
|
||||
static void HH(ref uint a, uint b, uint c, uint d, uint x, uint s, uint ac)
|
||||
{
|
||||
a += H (b, c, d) + x + ac;
|
||||
a = ROTATE_LEFT (a, s);
|
||||
a += b;
|
||||
}
|
||||
|
||||
static void II(ref uint a, uint b, uint c, uint d, uint x, uint s, uint ac)
|
||||
{
|
||||
a += I (b, c, d) + x + ac;
|
||||
a = ROTATE_LEFT (a, s);
|
||||
a += b;
|
||||
}
|
||||
|
||||
/**
|
||||
* MD5 initialization. Begins an MD5 operation, writing a new context.
|
||||
*/
|
||||
void start()
|
||||
{
|
||||
this = MD5_CTX.init;
|
||||
}
|
||||
|
||||
/** MD5 block update operation. Continues an MD5 message-digest
|
||||
operation, processing another message block, and updating the
|
||||
context.
|
||||
*/
|
||||
void update(const void[] input)
|
||||
{
|
||||
uint i, index, partLen;
|
||||
auto inputLen = input.length;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
index = (cast(uint)count >> 3) & (64 - 1);
|
||||
|
||||
/* Update number of bits */
|
||||
count += inputLen * 8;
|
||||
|
||||
partLen = 64 - index;
|
||||
|
||||
/* Transform as many times as possible. */
|
||||
if (inputLen >= partLen)
|
||||
{
|
||||
core.stdc.string.memcpy(&buffer[index], input.ptr, partLen);
|
||||
transform (buffer.ptr);
|
||||
|
||||
for (i = partLen; i + 63 < inputLen; i += 64)
|
||||
transform ((cast(ubyte[])input)[i .. i + 64].ptr);
|
||||
|
||||
index = 0;
|
||||
}
|
||||
else
|
||||
i = 0;
|
||||
|
||||
/* Buffer remaining input */
|
||||
if (inputLen - i)
|
||||
core.stdc.string.memcpy(&buffer[index], &input[i], inputLen-i);
|
||||
}
|
||||
|
||||
/** MD5 finalization. Ends an MD5 message-digest operation, writing the
|
||||
* the message to digest and zeroing the context.
|
||||
*/
|
||||
void finish(ref ubyte[16] digest) /* message digest */
|
||||
{
|
||||
ubyte[8] bits = void;
|
||||
uint index, padLen;
|
||||
|
||||
/* Save number of bits */
|
||||
bits[0 .. 8] = nativeToLittleEndian(count)[];
|
||||
|
||||
/* Pad out to 56 mod 64. */
|
||||
index = (cast(uint)count >> 3) & (64 - 1);
|
||||
padLen = (index < 56) ? (56 - index) : (120 - index);
|
||||
update (PADDING[0 .. padLen]);
|
||||
|
||||
/* Append length (before padding) */
|
||||
update (bits);
|
||||
|
||||
/* Store state in digest */
|
||||
digest[0 .. 4] = nativeToLittleEndian(state[0])[];
|
||||
digest[4 .. 8] = nativeToLittleEndian(state[1])[];
|
||||
digest[8 .. 12] = nativeToLittleEndian(state[2])[];
|
||||
digest[12 .. 16] = nativeToLittleEndian(state[3])[];
|
||||
|
||||
/* Zeroize sensitive information. */
|
||||
core.stdc.string.memset (&this, 0, MD5_CTX.sizeof);
|
||||
}
|
||||
|
||||
/* MD5 basic transformation. Transforms state based on block.
|
||||
*/
|
||||
|
||||
/* Constants for MD5Transform routine. */
|
||||
enum
|
||||
{
|
||||
S11 = 7,
|
||||
S12 = 12,
|
||||
S13 = 17,
|
||||
S14 = 22,
|
||||
S21 = 5,
|
||||
S22 = 9,
|
||||
S23 = 14,
|
||||
S24 = 20,
|
||||
S31 = 4,
|
||||
S32 = 11,
|
||||
S33 = 16,
|
||||
S34 = 23,
|
||||
S41 = 6,
|
||||
S42 = 10,
|
||||
S43 = 15,
|
||||
S44 = 21,
|
||||
}
|
||||
|
||||
private void transform (const ubyte* /*[64]*/ block)
|
||||
{
|
||||
uint a = state[0],
|
||||
b = state[1],
|
||||
c = state[2],
|
||||
d = state[3];
|
||||
uint[16] x = void;
|
||||
|
||||
version(BigEndian)
|
||||
{
|
||||
for(size_t i = 0; i < 16; i++)
|
||||
{
|
||||
x[i] = littleEndianToNative!uint(*cast(ubyte[4]*)&block[i*4]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(cast(ubyte*)x.ptr)[0 .. 64] = block[0 .. 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. */
|
||||
x[] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
debug(md5) printf("std.md5.unittest\n");
|
||||
|
||||
ubyte[16] digest;
|
||||
|
||||
sum (digest, "");
|
||||
assert(digest == cast(ubyte[])x"d41d8cd98f00b204e9800998ecf8427e");
|
||||
|
||||
sum (digest, "a");
|
||||
assert(digest == cast(ubyte[])x"0cc175b9c0f1b6a831c399e269772661");
|
||||
|
||||
sum (digest, "abc");
|
||||
assert(digest == cast(ubyte[])x"900150983cd24fb0d6963f7d28e17f72");
|
||||
|
||||
sum (digest, "message digest");
|
||||
assert(digest == cast(ubyte[])x"f96b697d7cb7938d525a2f31aaf161d0");
|
||||
|
||||
sum (digest, "abcdefghijklmnopqrstuvwxyz");
|
||||
assert(digest == cast(ubyte[])x"c3fcd3d76192e4007dfb496cca67e13b");
|
||||
|
||||
sum (digest, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
|
||||
assert(digest == cast(ubyte[])x"d174ab98d277d9f5a5611c2c9f419d9f");
|
||||
|
||||
sum (digest,
|
||||
"1234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890");
|
||||
assert(digest == cast(ubyte[])x"57edf4a22be3c955ac49da2e2107b67a");
|
||||
|
||||
assert(digestToString(cast(ubyte[16])x"c3fcd3d76192e4007dfb496cca67e13b")
|
||||
== "C3FCD3D76192E4007DFB496CCA67E13B");
|
||||
}
|
|
@ -28,7 +28,6 @@ public import std.format;
|
|||
public import std.getopt;
|
||||
public import std.math;
|
||||
public import std.mathspecial;
|
||||
public import std.md5;
|
||||
public import std.metastrings;
|
||||
public import std.mmfile;
|
||||
public import std.outbuffer;
|
||||
|
@ -92,9 +91,6 @@ else
|
|||
std.zlib.adler32(0,null); // D.zlib
|
||||
auto t = task!cmp("foo", "bar"); // parallelism
|
||||
|
||||
ubyte[16] buf;
|
||||
std.md5.sum(buf,"");
|
||||
|
||||
creal c = 3.0 + 4.0i;
|
||||
c = sqrt(c);
|
||||
assert(c.re == 2);
|
||||
|
|
11
win32.mak
11
win32.mak
|
@ -114,7 +114,7 @@ SRC_STD_2a_HEAVY= std\array.d std\functional.d std\path.d std\outbuffer.d std\ut
|
|||
|
||||
SRC_STD_3= std\csv.d std\math.d std\complex.d std\numeric.d std\bigint.d \
|
||||
std\metastrings.d std\bitmanip.d std\typecons.d \
|
||||
std\uni.d std\base64.d std\md5.d std\ascii.d \
|
||||
std\uni.d std\base64.d std\ascii.d \
|
||||
std\demangle.d std\uri.d std\mmfile.d std\getopt.d
|
||||
|
||||
SRC_STD_3a= std\signals.d std\typetuple.d std\traits.d \
|
||||
|
@ -150,12 +150,12 @@ SRC_STD_ALL= $(SRC_STD_1_HEAVY) $(SRC_STD_2_HEAVY) $(SRC_STD_2a_HEAVY) \
|
|||
$(SRC_STD_3) $(SRC_STD_3a) $(SRC_STD_3b) $(SRC_STD_4) \
|
||||
$(SRC_STD_5_HEAVY) $(SRC_STD_6) $(SRC_STD_REST)
|
||||
|
||||
SRC= unittest.d crc32.d index.d
|
||||
SRC= unittest.d index.d
|
||||
|
||||
SRC_STD= std\zlib.d std\zip.d std\stdint.d std\container.d std\conv.d std\utf.d std\uri.d \
|
||||
std\math.d std\string.d std\path.d std\datetime.d \
|
||||
std\csv.d std\file.d std\compiler.d std\system.d \
|
||||
std\outbuffer.d std\md5.d std\base64.d \
|
||||
std\outbuffer.d std\base64.d \
|
||||
std\mmfile.d \
|
||||
std\syserror.d \
|
||||
std\random.d std\stream.d std\process.d \
|
||||
|
@ -308,7 +308,6 @@ DOCS= $(DOC)\object.html \
|
|||
$(DOC)\std_json.html \
|
||||
$(DOC)\std_math.html \
|
||||
$(DOC)\std_mathspecial.html \
|
||||
$(DOC)\std_md5.html \
|
||||
$(DOC)\std_metastrings.html \
|
||||
$(DOC)\std_mmfile.html \
|
||||
$(DOC)\std_numeric.html \
|
||||
|
@ -416,7 +415,6 @@ cov : $(SRC_TO_COMPILE) $(LIB)
|
|||
$(DMD) -cov=82 -unittest -main -run std\typecons.d
|
||||
$(DMD) -cov=44 -unittest -main -run std\uni.d
|
||||
$(DMD) -cov=91 -unittest -main -run std\base64.d
|
||||
$(DMD) -cov=99 -unittest -main -run std\md5.d
|
||||
$(DMD) -cov=100 -unittest -main -run std\ascii.d
|
||||
$(DMD) -cov=0 -unittest -main -run std\demangle.d
|
||||
$(DMD) -cov=57 -unittest -main -run std\uri.d
|
||||
|
@ -607,9 +605,6 @@ $(DOC)\std_math.html : $(STDDOC) std\math.d
|
|||
$(DOC)\std_mathspecial.html : $(STDDOC) std\mathspecial.d
|
||||
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_mathspecial.html $(STDDOC) std\mathspecial.d
|
||||
|
||||
$(DOC)\std_md5.html : $(STDDOC) std\md5.d
|
||||
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_md5.html $(STDDOC) std\md5.d
|
||||
|
||||
$(DOC)\std_metastrings.html : $(STDDOC) std\metastrings.d
|
||||
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_metastrings.html $(STDDOC) std\metastrings.d
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ SRC_STD_math=std\math.d
|
|||
SRC_STD_3= std\csv.d std\complex.d std\numeric.d std\bigint.d
|
||||
SRC_STD_3c= std\datetime.d std\metastrings.d std\bitmanip.d std\typecons.d
|
||||
|
||||
SRC_STD_3a= std\uni.d std\base64.d std\md5.d std\ascii.d \
|
||||
SRC_STD_3a= std\uni.d std\base64.d std\ascii.d \
|
||||
std\demangle.d std\uri.d std\mmfile.d std\getopt.d
|
||||
|
||||
SRC_STD_3b= std\signals.d std\typetuple.d std\traits.d \
|
||||
|
@ -174,7 +174,7 @@ SRC= unittest.d crc32.d index.d
|
|||
SRC_STD= std\zlib.d std\zip.d std\stdint.d std\container.d std\conv.d std\utf.d std\uri.d \
|
||||
std\math.d std\string.d std\path.d std\datetime.d \
|
||||
std\csv.d std\file.d std\compiler.d std\system.d \
|
||||
std\outbuffer.d std\md5.d std\base64.d \
|
||||
std\outbuffer.d std\base64.d \
|
||||
std\mmfile.d \
|
||||
std\syserror.d \
|
||||
std\random.d std\stream.d std\process.d \
|
||||
|
@ -327,7 +327,6 @@ DOCS= $(DOC)\object.html \
|
|||
$(DOC)\std_json.html \
|
||||
$(DOC)\std_math.html \
|
||||
$(DOC)\std_mathspecial.html \
|
||||
$(DOC)\std_md5.html \
|
||||
$(DOC)\std_metastrings.html \
|
||||
$(DOC)\std_mmfile.html \
|
||||
$(DOC)\std_numeric.html \
|
||||
|
@ -582,9 +581,6 @@ $(DOC)\std_math.html : $(STDDOC) std\math.d
|
|||
$(DOC)\std_mathspecial.html : $(STDDOC) std\mathspecial.d
|
||||
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_mathspecial.html $(STDDOC) std\mathspecial.d
|
||||
|
||||
$(DOC)\std_md5.html : $(STDDOC) std\md5.d
|
||||
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_md5.html $(STDDOC) std\md5.d
|
||||
|
||||
$(DOC)\std_metastrings.html : $(STDDOC) std\metastrings.d
|
||||
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_metastrings.html $(STDDOC) std\metastrings.d
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue