ext/Digest/MD5/README Digest::MD5 extension Readme
ext/Digest/MD5/t/align.t See if Digest::MD5 extension works
ext/Digest/MD5/t/badfile.t See if Digest::MD5 extension works
+ext/Digest/MD5/t/bits.t See if Digest::MD5 extension works
ext/Digest/MD5/t/clone.t See if Digest::MD5 extension works
ext/Digest/MD5/t/files.t See if Digest::MD5 extension works
ext/Digest/MD5/t/md5-aaa.t See if Digest::MD5 extension works
+2003-11-28 Gisle Aas <gisle@ActiveState.com>
+
+ Release 2.31
+
+ Inherit add_bits() from Digest::base if available.
+
+
+
2003-10-09 Gisle Aas <gisle@ActiveState.com>
Release 2.30
use strict;
use vars qw($VERSION @ISA @EXPORT_OK);
-$VERSION = '2.30'; # $Date: 2003/10/09 09:26:59 $
+$VERSION = '2.31'; # $Date: 2003/11/28 13:06:19 $
require Exporter;
*import = \&Exporter::import;
@ISA=qw(DynaLoader);
eval {
+ require Digest::base;
+ push(@ISA, 'Digest::base');
+};
+if ($@) {
+ my $err = $@;
+ *add_bits = sub { die $err };
+}
+
+
+eval {
Digest::MD5->bootstrap($VERSION);
};
if ($@) {
In most cases you want to make sure that the $io_handle is in
C<binmode> before you pass it as argument to the addfile() method.
+=item $md5->add_bits($data, $nbits)
+
+=item $md5->add_bits($bitstring)
+
+Since the MD5 algorithm is byte oriented you might only add bits as
+multiples of 8, so you probably want to just use add() instead. The
+add_bits() method is provided for compatibility with other digest
+implementations. See L<Digest> for description arguments to
+add_bits().
+
=item $md5->digest
Return the binary digest for the message. The returned string will be
-require 5.004;
+#!perl -w
+
+BEGIN { require 5.004 }
use strict;
use Config qw(%Config);
use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'Digest::MD5',
'VERSION_FROM' => 'MD5.pm',
- MAN3PODS => {}, # Pods will be built by installman.
+ 'PREREQ_PM' => { 'File::Spec' => 0,
+ 'Digest::base' => '1.00',
+ },
@extra,
'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
);
sub free_u32_alignment
{
- return 0 if $Config{d_u32align};
- return 1 if $Config{'byteorder'} eq '1234' || $Config{'byteorder'} eq '4321';
+ $|=1;
+ print "Testing alignment requirements for U32... ";
+ return 1 if $^O eq 'VMS';
+ return 1 if $^O eq 'MSWin32';
+
+ open(ALIGN_TEST, ">u32align.c") or die "$!";
+ print ALIGN_TEST <<'EOT'; close(ALIGN_TEST);
+/*--------------------------------------------------------------*/
+/* This program allocates a buffer of U8 (char) and then tries */
+/* to access it through a U32 pointer at every offset. The */
+/* program is expected to die with a bus error/seg fault for */
+/* machines that do not support unaligned integer read/write */
+/*--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include "EXTERN.h"
+#include "perl.h"
+
+#ifdef printf
+ #undef printf
+#endif
+
+int main(int argc, char** argv, char** env)
+{
+#if BYTEORDER == 0x1234 || BYTEORDER == 0x4321
+ U8 buf[] = "\0\0\0\1\0\0\0\0";
+ U32 *up;
+ int i;
+
+ if (sizeof(U32) != 4) {
+ printf("sizeof(U32) is not 4, but %d\n", sizeof(U32));
+ exit(1);
+ }
+
+ fflush(stdout);
+
+ for (i = 0; i < 4; i++) {
+ up = (U32*)(buf + i);
+ if (! ((*up == 1 << (8*i)) || /* big-endian */
+ (*up == 1 << (8*(3-i))) /* little-endian */
+ )
+ )
+ {
+ printf("read failed (%x)\n", *up);
+ exit(2);
+ }
+ }
+
+ /* write test */
+ for (i = 0; i < 4; i++) {
+ up = (U32*)(buf + i);
+ *up = 0xBeef;
+ if (*up != 0xBeef) {
+ printf("write failed (%x)\n", *up);
+ exit(3);
+ }
+ }
+
+ printf("no restrictions\n");
+ exit(0);
+#else
+ printf("unusual byteorder, playing safe\n");
+ exit(1);
+#endif
+ return 0;
+}
+/*--------------------------------------------------------------*/
+EOT
+
+ my $cc_cmd = "$Config{cc} $Config{ccflags} -I$Config{archlibexp}/CORE";
+ my $exe = "u32align$Config{exe_ext}";
+ $cc_cmd .= " -o $exe";
+ my $rc;
+ $rc = system("$cc_cmd $Config{ldflags} u32align.c $Config{libs}");
+ if ($rc) {
+ print "Can't compile test program. Will ensure alignment to play safe.\n\n";
+ unlink("u32align.c", $exe, "u32align$Config{obj_ext}");
+ return 0;
+ }
+
+ $rc = system("./$exe");
+ unlink("u32align.c", $exe, "u32align$Config{obj_ext}");
+
+ return 1 unless $rc;
+
+ if ($rc > 0x80) {
+ $rc >>= 8;
+ print "Test program exit status was $rc\n";
+ } else {
+ if ($rc & 0x80) {
+ $rc &= ~0x80;
+ print "Core dump deleted\n";
+ unlink("core");
+ }
+ print "signal $rc\n";
+ }
return 0;
}
-# Digest::MD5 2.07 and older used to trigger a core dump when
-# passed an illegal file handle that failed to open.
-
-print "1..3\n";
+print "1..2\n";
use Digest::MD5 ();
-use Config;
$md5 = Digest::MD5->new;
};
print "not " unless $@ =~ /^No filehandle passed at/;
print "ok 2\n";
-
-open(BAR, ">no-existing-file.$$") || die;
-eval {
- $md5->addfile(*BAR);
-};
-# Some stdio implementations don't find reading from
-# write-only filehandle to be a problem. Therefore we
-# cannot expect this to fail reliably with stdio.
-my $stdio = !exists $Config{useperlio} ||
- !defined $Config{useperlio} ||
- (exists $ENV{PERLIO} && $ENV{PERLIO} eq 'stdio') ||
- defined $Config{usefaststdio};
-print "not " unless $@ =~ /^Reading from filehandle failed at/ || $stdio;
-print "ok 3\n";
-
-close(BAR);
-unlink("no-existing-file.$$");
--- /dev/null
+#!perl -w
+
+use Test qw(plan ok);
+plan tests => 2;
+
+use Digest::MD5;
+
+my $md5 = Digest::MD5->new;
+
+if ($Digest::base::VERSION) {
+ $md5->add_bits("01111111");
+ ok($md5->hexdigest, "83acb6e67e50e31db6ed341dd2de1595");
+ eval {
+ $md5->add_bits("0111");
+ };
+ ok($@ =~ /must be multiple of 8/);
+}
+else {
+ print "# No Digest::base\n";
+ eval {
+ $md5->add_bits("foo");
+ };
+ ok($@ =~ /^Can\'t locate Digest\/base\.pm in \@INC/);
+ ok(1); # dummy
+}
+
my $EXPECT;
if (ord "A" == 193) { # EBCDIC
$EXPECT = <<EOT;
-e1d7df564fad76d2f0ed628c648d5833 Changes
+8f87b430c5e308f6cb3c01b6820f2f0c Changes
0565ec21b15c0f23f4c51fb327c8926d README
-4d48606863dbc7fd131c2e7b5eefc8c5 MD5.pm
+1d676ae6942cd3abbdc912c79e4bbb1f MD5.pm
45e5e6785b47fb922f33b4a74c29a148 MD5.xs
276da0aa4e9a08b7fe09430c9c5690aa rfc1321.txt
EOT
} elsif ("\n" eq "\015") { # MacOS
$EXPECT = <<EOT;
-c780484c87b64e32bd55c6be58b623b4 Changes
+28b11667b3a84a233cbdaf92ebb57578 Changes
6c950a0211a5a28f023bb482037698cd README
-546c4e62999c9888d7d46732a21c9dff MD5.pm
+be02581437f3d15bdc2d67551575bf60 MD5.pm
ca3f8cb317c5d088ed9f97204c6b8cda MD5.xs
754b9db19f79dbc4992f7166eb0f37ce rfc1321.txt
EOT
} else {
# This is the output of: 'md5sum Changes README MD5.pm MD5.xs rfc1321.txt'
$EXPECT = <<EOT;
-2bdd59aa1e816cd8df05968e70f75cf1 Changes
+a6a640087a028adbfa3fb3570e4104e6 Changes
6c950a0211a5a28f023bb482037698cd README
-546c4e62999c9888d7d46732a21c9dff MD5.pm
+be02581437f3d15bdc2d67551575bf60 MD5.pm
ca3f8cb317c5d088ed9f97204c6b8cda MD5.xs
754b9db19f79dbc4992f7166eb0f37ce rfc1321.txt
EOT