libdigest-md2-perl-2.03+dfsg.orig/0000755000175000017500000000000011405155337016200 5ustar gregoagregoalibdigest-md2-perl-2.03+dfsg.orig/typemap0000644000175000017500000000007607253575261017615 0ustar gregoagregoaMD2_CTX* T_MD2_CTX INPUT T_MD2_CTX $var = get_md2_ctx($arg) libdigest-md2-perl-2.03+dfsg.orig/Makefile.PL0000644000175000017500000000027607253575261020167 0ustar gregoagregoarequire 5.004; use ExtUtils::MakeMaker; WriteMakefile( 'NAME' => 'Digest::MD2', 'VERSION_FROM' => 'MD2.pm', 'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, ); libdigest-md2-perl-2.03+dfsg.orig/Changes0000644000175000017500000003032107740244554017501 0ustar gregoagregoa2003-10-06 Gisle Aas Release 2.03 The only reason for this release it to clean up my CPAN directory. There is no change in this release besides the version number. 2003-07-22 Gisle Aas Release 2.02 Sync up with Digest-MD5-2.26 - added clone method - $md2->addfile croak on read errors - safer patchlevel include - warn if functional interface used as methods 2002-12-27 Gisle Aas Release 2.01 Support UTF8 strings in newer versions of Perl. 2001-03-13 Gisle Aas Release 2.00 Broken out of the Digest-MD5-2.12 distribution and made into a separate dist. ------------------------------------------------------------------- Changes below from the Digest-MD5 dist. 2000-09-18 Gisle Aas Release 2.12 Avoid pointer cast warning for machines with bigger ints than pointers. Patch by Robin Barker . 2000-08-19 Gisle Aas Release 2.11 The fallback code introduced in 2.10 did only work for perl-5.6.0. It should now for for perl5.004 and 5.005 as well. Patch by Ville Skyttä . 2000-08-18 Gisle Aas Release 2.10 Digest::MD5 will now try to fallback to the pure perl implementation of Digest::Perl::MD5 if bootstrap fails. Added a bit internal paranoia about casting the IV in the Digest::MD5 object to the MD5_CTX* pointer. 1999-08-06 Gisle Aas Release 2.09 Documentation update. 1999-07-28 Gisle Aas Release 2.08 The addfile() methods could trigger a core dump when passed a filehandle that had failed to open. 1999-04-26 Gisle Aas Release 2.07 The Digest::SHA1 module failed on some 64-bit systems, because I assumed there was a correspondence between the U32 size and BYTEORDER. This version use 'unsigned long' as Uwe's original SHA module did. The module should now work better when liked statically with perl, because we now use a safer module-loaded test in Digest.pm. Assume we know the outcome of the alignment test on VMS. Patch by Chuck Lane 1999-03-26 Gisle Aas Release 2.06 Avoid LONG and BYTE types in SHA.xs as they was in conflict with similar definitions in . Patch by Marko Asplund to make the the alignment test program link successfully with sfio-perl. Fixed a typo in MD5.xs that might have affected 64-bit systems. Spotted by Nick Ing-Simmons 1999-03-15 Gisle Aas Release 2.05 Included Digest::SHA1 based on Uwe Hollerbach's SHA module. 1999-03-05 Gisle Aas Release 2.04 Avoid the -o option when compiling alignment test program for Win32 as suggested by Gurusamy Sarathy. DEC Compiler bug workaround. Contributed by D Roland Walker Having references to a local variable called "na" was not very safe either. Some older versions of Perl can apparently macroize this into something completely different. 1999-02-27 Gisle Aas Release 2.03 Patch from Christopher J. Madsen that should help getting the u32align test program to compile with Visual C++ 5 on Windows NT. Got rid of references to PL_na. 1999-01-31 Gisle Aas Release 2.02 Added a hints file as workaround for an IRIX compiler bug. Contributed by D Roland Walker . Note that the rfc2202 test can still fail on some DEC Alpha, because of a compiler bug that affects the perl 'x' operator. The Digest:: modules should work and be safe to install anyway. 1998-12-18 Gisle Aas Release 2.01 Some casts and tweaks to make picky compilers more happy. 1998-11-04 Gisle Aas Release 2.00. Taken out Digest::SHA1 as this module will be provided from Uwe Hollerbach later. Some tweaks to MD2.xs and MD5.xs since "na" disappeared in perl5.005_53 1998-10-30 Gisle Aas Release 1.99_60 The 1.99_59 release introduced compilation problems for big-endian systems with free U32 alignment. Bug reported, and fix suggested by Paul J. Schinder . 1998-10-28 Gisle Aas Release 1.99_59 Makefile.PL will run a test program to find out if U32 values can be aligned anywhere. This hopefully cures the core dumps reported on Solaris and other big endian systems. Thanks to Graham Barr for debugging this. 1998-10-28 Gisle Aas Release 1.99_58 Should be very close to a 2.00 release now. Need some success reports from people running on big-endian machines first I think. Added a Digest::MD2 implementation. Wrote Digest.pm documentation. This define the interface that all Digest:: modules should provide. Avoided some code duplication in MD5.xs Fixed typo, that prevented Digest::SHA1::sha1_base64() from working. 1998-10-27 Gisle Aas Release 1.99_57 Rewritten most of the MD5 C code to make it real fast (especially on little-endian machines without alignment restrictions for U32). Compared to MD5-1.7 we can process files 4 times as fast and we digest small stuff in memory 7 times faster. I came to these conclusions after these tests (gcc -O2, i586, Linux): First tested calculation of the digest of a 31 MB file, using perl -le 'print Digest::MD5->new->addfile(*STDIN)->hexdigest' and similar stuff: MD5-1.7: 21.06s Digest::MD5-1.99_57: 5.23s md5sum (GNU textutils): 4.90s As you can see, we do nearly as good as the md5sum program. I think the reason we don't beat md5sum is that perl always insist on loading extra modules like Config.pm, Carp.pm, strict.pm, vars.pm, AutoLoader.pm and DynaLoader.pm. When I simply wrapped the MD5.xs hasher code in a C program I managed to process the file in 4.68s. Then we calculated the digest of the same 6 byte sting, 20000 times: MD5-1.7: 11.81s Digest::MD5-1.99_57: 1.68s Digest::MD5 benefit from making this into a plain procedure call instead of a static method call. Other changes in this release are: Documentation update Internal MD5.xs cleanup. $md5->digest will automatically reset now. Digest::HMAC methods add() and addfile() did not return the corret object. Added Digest.pm loading module. I am not sure this is a good idea. Added Digest::SHA1 and Digest::HMAC_SHA1 module. The Digest::SHA1 module is just a wrapper around SHA.pm. I hope to get the author of SHA.pm to move his module to the Digest:: category. 1998-10-25 Gisle Aas Release 1.99_56 Fix memcpy_byteswap() function in MD5.xs. Must be careful with htovl() as it might evaluate its arguments more than once. 1998-10-25 Gisle Aas Release 1.99_55 Grahams HMAC_MD5.pm splitted into two modules. Digest::HMAC and Digest::HMAC_MD5. Also provide functional interface. Documentation is still lacking. Included RFC 2202 based test for HMAC-MD5. 1998-10-24 Gisle Aas Release 1.99_54 Included HMAC_MD5.pm, contributed by Graham Barr . I have a hard time to make up my mind :-) md5_bin() renamed back to md5(). Functions are not exported by default any more. Try to Encode/Decode with memcpy_byteswap for 32-bit big-endian machines. 1998-10-23 Gisle Aas Release 1.99_53 Renamed core module as Digest::MD5. Leave a MD5.pm stub for legacy code. The md5() function renamed as md5_bin(). The constructor, Digest::MD5->new, no longer takes any extra arguments. Added some new tests. Updated the documentation. $md5->b64digest implemented with same base64 encoder as md5_base64. 1998-10-23 Gisle Aas Release 1.99_52 Patch from Graham Barr which make it work for big-endian machines again. 1998-10-22 Gisle Aas Release 1.99_51 The MD5 class is now subclassable. The add() and addfile() methods now return $self. The reset() method is just an alias for new(). The constructor (MD5->new) now takes optional arguments which are automatically added. It means that we can now write: MD5->new($data)->hexdigest; New $md5->b64digest method. New functions that are exported on request: md5, md5_hex, md5_base64 Included RFC 1321 Barely started to update the documentation. 1998-10-22 Gisle Aas Release 1.99_50 Much better performance (more than twice as fast now). Mostly because we use Copy/Zero instead of the original MD5_memcpy and MD5_memset functions. The addfile() and hexdigest() methods are now XS implemented. All RSA functions now included in MD5.xs and made static. Use perl's Copy/Zero. Random cleanup, simplifications and reformatting. Merged things better with the perl configuration. Neil Winton's versions below: *** 96/06/20 Version 1.7 MD5 is now completely 64-bit clean (I hope). The basic MD5 code uses 32-bit quantities and requires a typedef UINT4 to be defined in global.h. Perl configuration data (the value of BYTEORDER) is used to determine if unsigned longs have 4 or 8 bytes. On 64-bit platforms (eg DEC Alpha) then it assumes that "unsigned int" will be a 32-bit type. If this is incorrect then adding -DUINT4_IS_LONG to the DEFINES line in Makefile.PL will override this. On some machines (at least Cray that I know of) there is no 32-bit integer type. In this case defining TRUNCATE_UINT4 (which is done automatically for a Cray) will ensure that 64-bit values are masked down to 32 bits. I have done my best to test this but without easy access to a true 64-bit machine I can not totally guarantee it (unless anyone wants to lend me a spare Cray :-) There is one remaining limitation for 64-bit enabled processors. The amount of data passed to any single call to the underlying MD5 routines is limited to (2^32 - 1) bytes -- that's 4 gigabytes. I'm sorry if that's a real problem for you ... And finally, a minor complilation warning (unsigned char * used with function having char * prototype) has also been eliminated. *** 96/04/09 Version 1.6 Re-generated module framework using h2xs to pick up the latest module conventions for versions etc. You can now say "use MD5 1.6;" and things should work correctly. MD5.pod has been integrated into MD5.pm and CHANGES renamed to Changes. There is a fairly comprehensive test.pl which can be invoked via "make test". There are no functional changes to the MD5 routines themselves. *** 96/03/14 Version 1.5.3 Fixed addfile method to accept type-glob references for the file-handle (eg \*STDOUT). This is more consistent with other routines and is now the recommended way of passing file-handles. The documentation now gives more examples as to how the routines might be used. *** 96/03/12 Version 1.5.2 Minor fixes from Christopher J Madsen to provide support for building on OS/2 (and to work arround a perl -w bug). Remove warning about possible difference between add('foo', 'bar') and add('foobar'). This is not true (it may have been true in the earliest version of the module but is no longer the case). *** 96/03/08 Version 1.5.1 Add CHANGES file to make it easier for people to figure out what has been going on. (Meant to do this as part of 1.5) *** 96/03/05 Version 1.5 Add hash() and hexhash() methods at the suggestion/request of Gary Howland before inclusion in a wider library of cryptography modules. *** 96/02/27 Version 1.4 Finally fixed the pesky Solaris dynamic loading bug. All kudos to Ken Pizzini ! *** 95/11/29 Version 1.3.1 Add explanations of current known problems. *** 95/06/02 Version 1.3 Fix problems with scope resolution in addfile() reported by Jean-Claude Giese . Basically ARGV is always implicitly in package main while other filehandles aren't. *** 95/05/23 Version 1.2.1 [Changes pre 1.2.1 not recorded] libdigest-md2-perl-2.03+dfsg.orig/t/0000755000175000017500000000000007740244577016457 5ustar gregoagregoalibdigest-md2-perl-2.03+dfsg.orig/t/md2.t0000644000175000017500000000220007253575261017314 0ustar gregoagregoaprint "1..7\n"; use strict; use Digest::MD2 qw(md2 md2_hex); my $testno = 0; # From RFC 1319 my $TESTS = <<'EOT'; MD2 ("") = 8350e5a3e24c153df2275c9f80692773 MD2 ("a") = 32ec01ec4a6dac72c0ab96fb34c0b5d1 MD2 ("abc") = da853b0d3f88d99b30283a69e6ded6bb MD2 ("message digest") = ab4f496bfb2a530b219ff33031fe06b0 MD2 ("abcdefghijklmnopqrstuvwxyz") = 4e8ddff3650292ab5a4108c3aa47940b MD2 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") = da33def2a42df13975352846c30338cd MD2 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") = d5976f79d83d3a0dc9806c3c66f3efd8 EOT for (split(/^/, $TESTS)) { die unless /^MD2\s*\(\"([^\"]*)\"\)\s*=\s*(.*)/; my $message = $1; my $hexdigest = $2; my $bindigest = pack("H*", $hexdigest); my $failed; $failed++ unless md2($message) eq $bindigest; $failed++ unless md2_hex($message) eq $hexdigest; # Test OO interface $failed++ unless Digest::MD2->new->add($message)->digest eq $bindigest; $failed++ unless Digest::MD2->new->add($message)->hexdigest eq $hexdigest; print "not " if $failed; print "ok ", ++$testno, "\n"; } libdigest-md2-perl-2.03+dfsg.orig/t/badfile.t0000644000175000017500000000051107707426102020214 0ustar gregoagregoaprint "1..2\n"; use Digest::MD2 (); $md5 = Digest::MD2->new; eval { use vars qw(*FOO); $md5->addfile(*FOO); }; print "not " unless $@ =~ /^Bad filehandle: FOO at/; print "ok 1\n"; open(BAR, "no-existing-file.$$"); eval { $md5->addfile(*BAR); }; print "not " unless $@ =~ /^No filehandle passed at/; print "ok 2\n"; libdigest-md2-perl-2.03+dfsg.orig/MD2.pm0000644000175000017500000000256607740244332017132 0ustar gregoagregoapackage Digest::MD2; use strict; use vars qw($VERSION @ISA @EXPORT_OK); $VERSION = '2.03'; # $Date: 2003/07/23 06:33:38 $ require Exporter; *import = \&Exporter::import; @EXPORT_OK = qw(md2 md2_hex md2_base64); require DynaLoader; @ISA=qw(DynaLoader); Digest::MD2->bootstrap($VERSION); *reset = \&new; 1; __END__ =head1 NAME Digest::MD2 - Perl interface to the MD2 Algorithm =head1 SYNOPSIS # Functional style use Digest::MD2 qw(md2 md2_hex md2_base64); $digest = md2($data); $digest = md2_hex($data); $digest = md2_base64($data); # OO style use Digest::MD2; $ctx = Digest::MD2->new; $ctx->add($data); $ctx->addfile(*FILE); $digest = $ctx->digest; $digest = $ctx->hexdigest; $digest = $ctx->b64digest; =head1 DESCRIPTION The C module allows you to use the RSA Data Security Inc. MD2 Message Digest algorithm from within Perl programs. The algorithm takes as input a message of arbitrary length and produces as output a 128-bit "fingerprint" or "message digest" of the input. The C programming interface is identical to the interface of C. =head1 SEE ALSO L =head1 COPYRIGHT This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Copyright 1998-2003 Gisle Aas. Copyright 1990-1992 RSA Data Security, Inc. =head1 AUTHOR Gisle Aas =cut libdigest-md2-perl-2.03+dfsg.orig/MD2.xs0000644000175000017500000002675607707426102017157 0ustar gregoagregoa/* $Id: MD2.xs,v 1.3 2003/07/23 06:33:38 gisle Exp $ */ /* * This library is free software; you can redistribute it and/or * modify it under the same terms as Perl itself. * * Copyright 1998-2003 Gisle Aas. * Copyright 1990-1992 RSA Data Security, Inc. * * This code is derived from the reference implementation in RFC 1231 * which comes with this message: * * Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All * rights reserved. * * License to copy and use this software is granted for * non-commercial Internet Privacy-Enhanced Mail provided that it is * identified as the "RSA Data Security, Inc. MD2 Message Digest * Algorithm" in all material mentioning or referencing this software * or this function. * * 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. */ #ifdef __cplusplus extern "C" { #endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #ifdef __cplusplus } #endif #ifndef PERL_VERSION # include # if !(defined(PERL_VERSION) || (SUBVERSION > 0 && defined(PATCHLEVEL))) # include # endif # define PERL_REVISION 5 # define PERL_VERSION PATCHLEVEL # define PERL_SUBVERSION SUBVERSION #endif #if PERL_VERSION <= 4 && !defined(PL_dowarn) #define PL_dowarn dowarn #endif #ifdef G_WARN_ON #define DOWARN (PL_dowarn & G_WARN_ON) #else #define DOWARN PL_dowarn #endif #ifdef SvPVbyte #if PERL_REVISION == 5 && PERL_VERSION < 7 /* SvPVbyte does not work in perl-5.6.1, borrowed version for 5.7.3 */ #undef SvPVbyte #define SvPVbyte(sv, lp) \ ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : my_sv_2pvbyte(aTHX_ sv, &lp)) static char * my_sv_2pvbyte(pTHX_ register SV *sv, STRLEN *lp) { sv_utf8_downgrade(sv,0); return SvPV(sv,*lp); } #endif #else #define SvPVbyte SvPV #endif typedef struct { unsigned char state[16]; /* state */ unsigned char checksum[16]; /* checksum */ unsigned int count; /* number of bytes, modulo 16 */ unsigned char buffer[16]; /* input buffer */ } MD2_CTX; /* Permutation of 0..255 constructed from the digits of pi. It gives a "random" nonlinear byte substitution operation. */ static U8 PI_SUBST[256] = { 41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, 19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, 76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, 138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251, 245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63, 148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50, 39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165, 181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210, 150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157, 112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27, 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15, 85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, 234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65, 129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123, 8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233, 203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228, 166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237, 31, 26, 219, 153, 141, 51, 159, 17, 131, 20 }; static U8 *PADDING[] = { (U8 *)"", (U8 *)"\001", (U8 *)"\002\002", (U8 *)"\003\003\003", (U8 *)"\004\004\004\004", (U8 *)"\005\005\005\005\005", (U8 *)"\006\006\006\006\006\006", (U8 *)"\007\007\007\007\007\007\007", (U8 *)"\010\010\010\010\010\010\010\010", (U8 *)"\011\011\011\011\011\011\011\011\011", (U8 *)"\012\012\012\012\012\012\012\012\012\012", (U8 *)"\013\013\013\013\013\013\013\013\013\013\013", (U8 *)"\014\014\014\014\014\014\014\014\014\014\014\014", (U8 *)"\015\015\015\015\015\015\015\015\015\015\015\015\015", (U8 *)"\016\016\016\016\016\016\016\016\016\016\016\016\016\016", (U8 *)"\017\017\017\017\017\017\017\017\017\017\017\017\017\017\017", (U8 *)"\020\020\020\020\020\020\020\020\020\020\020\020\020\020\020\020" }; static void MD2Init(MD2_CTX* context) { Zero(context, 1, MD2_CTX); context->count = 0; } static void MD2Transform (U8* state, U8* checksum, U8* block) { unsigned int i, j, t; U8 x[48]; /* Form encryption block from state, block, state ^ block. */ Copy(state, x, 16, char); Copy(block, x+16, 16, char); for (i = 0; i < 16; i++) x[i+32] = state[i] ^ block[i]; /* Encrypt block (18 rounds). */ t = 0; for (i = 0; i < 18; i++) { for (j = 0; j < 48; j++) t = x[j] ^= PI_SUBST[t]; t = (t + i) & 0xff; } Copy(x, state, 16, char); /* Save new state */ /* Update checksum. */ t = checksum[15]; for (i = 0; i < 16; i++) t = checksum[i] ^= PI_SUBST[block[i] ^ t]; Zero(x, 1, x); /* Zeroize sensitive information. */ } static void MD2Update (MD2_CTX* context, U8 *input, STRLEN inputLen) { unsigned int i, index, partLen; /* Update number of bytes mod 16 */ index = context->count; context->count = (index + inputLen) & 0xf; partLen = 16 - index; /* Transform as many times as possible. */ if (inputLen >= partLen) { Copy(input, context->buffer+index, partLen, char); MD2Transform (context->state, context->checksum, context->buffer); for (i = partLen; i + 15 < inputLen; i += 16) MD2Transform (context->state, context->checksum, &input[i]); index = 0; } else i = 0; /* Buffer remaining input */ Copy(input+i, context->buffer + index, inputLen-i, char); } static void MD2Final (U8* digest, MD2_CTX *context) { unsigned int index, padLen; /* Pad out to multiple of 16 */ index = context->count; padLen = 16 - index; MD2Update (context, PADDING[padLen], padLen); /* Extend with checksum */ MD2Update (context, context->checksum, 16); Copy(context->state, digest, 16, char); /* Store state in digest */ Zero(context, 1, MD2_CTX); /* Zeroize sensitive information. */ } /*----------------------------------------------------------------*/ #ifndef INT2PTR #define INT2PTR(any,d) (any)(d) #endif static MD2_CTX* get_md2_ctx(SV* sv) { if (sv_derived_from(sv, "Digest::MD2")) return INT2PTR(MD2_CTX*, SvIV(SvRV(sv))); croak("Not a reference to a Digest::MD2 object"); return (MD2_CTX*)0; /* some compilers insist on a return value */ } static char* hex_16(const unsigned char* from, char* to) { static char *hexdigits = "0123456789abcdef"; const unsigned char *end = from + 16; char *d = to; while (from < end) { *d++ = hexdigits[(*from >> 4)]; *d++ = hexdigits[(*from & 0x0F)]; from++; } *d = '\0'; return to; } static char* base64_16(const unsigned char* from, char* to) { static char* base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; const unsigned char *end = from + 16; unsigned char c1, c2, c3; char *d = to; while (1) { c1 = *from++; *d++ = base64[c1>>2]; if (from == end) { *d++ = base64[(c1 & 0x3) << 4]; break; } c2 = *from++; c3 = *from++; *d++ = base64[((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)]; *d++ = base64[((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6)]; *d++ = base64[c3 & 0x3F]; } *d = '\0'; return to; } /* Formats */ #define F_BIN 0 #define F_HEX 1 #define F_B64 2 static SV* make_mortal_sv(const unsigned char *src, int type) { STRLEN len; char result[33]; char *ret; switch (type) { case F_BIN: ret = (char*)src; len = 16; break; case F_HEX: ret = hex_16(src, result); len = 32; break; case F_B64: ret = base64_16(src, result); len = 22; break; default: croak("Bad convertion type (%d)", type); break; } return sv_2mortal(newSVpv(ret,len)); } /********************************************************************/ typedef PerlIO* InputStream; MODULE = Digest::MD2 PACKAGE = Digest::MD2 PROTOTYPES: DISABLE void new(xclass) SV* xclass PREINIT: MD2_CTX* context; PPCODE: if (!SvROK(xclass)) { STRLEN my_na; char *sclass = SvPV(xclass, my_na); New(55, context, 1, MD2_CTX); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), sclass, (void*)context); SvREADONLY_on(SvRV(ST(0))); } else { context = get_md2_ctx(xclass); } MD2Init(context); XSRETURN(1); void clone(self) SV* self PREINIT: MD2_CTX* cont = get_md2_ctx(self); char *myname = sv_reftype(SvRV(self),TRUE); MD2_CTX* context; PPCODE: STRLEN my_na; New(55, context, 1, MD2_CTX); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), myname , (void*)context); SvREADONLY_on(SvRV(ST(0))); memcpy(context,cont,sizeof(MD2_CTX)); XSRETURN(1); void DESTROY(context) MD2_CTX* context CODE: Safefree(context); void add(self, ...) SV* self PREINIT: MD2_CTX* context = get_md2_ctx(self); int i; unsigned char *data; STRLEN len; PPCODE: for (i = 1; i < items; i++) { data = (unsigned char *)(SvPVbyte(ST(i), len)); MD2Update(context, data, len); } XSRETURN(1); /* self */ void addfile(self, fh) SV* self InputStream fh PREINIT: MD2_CTX* context = get_md2_ctx(self); unsigned char buffer[4096]; int n; CODE: if (fh) { /* Process blocks until EOF */ while ( (n = PerlIO_read(fh, buffer, sizeof(buffer))) > 0) { MD2Update(context, buffer, n); } if (PerlIO_error(fh)) { croak("Reading from filehandle failed"); } } else { croak("No filehandle passed"); } XSRETURN(1); /* self */ void digest(context) MD2_CTX* context ALIAS: Digest::MD2::digest = F_BIN Digest::MD2::hexdigest = F_HEX Digest::MD2::b64digest = F_B64 PREINIT: unsigned char digeststr[16]; PPCODE: MD2Final(digeststr, context); MD2Init(context); /* In case it is reused */ ST(0) = make_mortal_sv(digeststr, ix); XSRETURN(1); void md2(...) ALIAS: Digest::MD2::md2 = F_BIN Digest::MD2::md2_hex = F_HEX Digest::MD2::md2_base64 = F_B64 PREINIT: MD2_CTX ctx; int i; unsigned char *data; STRLEN len; unsigned char digeststr[16]; PPCODE: MD2Init(&ctx); if (DOWARN) { char *msg = 0; if (items == 1) { if (SvROK(ST(0))) { SV* sv = SvRV(ST(0)); if (SvOBJECT(sv) && strEQ(HvNAME(SvSTASH(sv)), "Digest::MD2")) msg = "probably called as method"; else msg = "called with reference argument"; } } else if (items > 1) { data = (unsigned char *)SvPVbyte(ST(0), len); if (len == 11 && memEQ("Digest::MD2", data, 11)) { msg = "probably called as class method"; } } if (msg) { char *f = (ix == F_BIN) ? "md2" : (ix == F_HEX) ? "md2_hex" : "md2_base64"; warn("&Digest::MD2::%s function %s", f, msg); } } for (i = 0; i < items; i++) { data = (unsigned char *)(SvPVbyte(ST(i), len)); MD2Update(&ctx, data, len); } MD2Final(digeststr, &ctx); ST(0) = make_mortal_sv(digeststr, ix); XSRETURN(1); libdigest-md2-perl-2.03+dfsg.orig/README0000644000175000017500000000117307707426102017063 0ustar gregoagregoaThe Digest::MD2 module allows you to use the RSA Data Security Inc. MD2 Message Digest algorithm from within Perl programs. The algorithm takes as input a message of arbitrary length and produces as output a 128-bit "fingerprint" or "message digest" of the input. The Digest::MD2 programming interface is identical to the interface of Digest::MD5. MD2 is described in RFC 1115. You will need Perl version 5.004 or better to install this module. Copyright 1998-2003 Gisle Aas. Copyright 1990-1992 RSA Data Security, Inc. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. libdigest-md2-perl-2.03+dfsg.orig/MANIFEST0000644000175000017500000000011611405155337017327 0ustar gregoagregoaChanges MANIFEST MD2.pm MD2.xs Makefile.PL README t/badfile.t t/md2.t typemap