* Re: MD5 implementation
1996-01-11 5:00 ` Michael Spratte
@ 1996-01-11 5:00 ` Nick Maclaren
1996-01-12 5:00 ` Michael Gsandtner
1996-01-12 5:00 ` Donn Cave
2 siblings, 0 replies; 7+ messages in thread
From: Nick Maclaren @ 1996-01-11 5:00 UTC (permalink / raw)
In article <4d3usa$gfm@nntpd2.cxo.dec.com>,
Michael Spratte <spratte@odette.cxo.dec.com> wrote:
>
>In article <30F4CCAF.41C6@adv.magwien.gv.at>, Michael Gsandtner <gsa@adv.magwien.gv.at> writes:
>|>Where can I get a MD5 (rfc1321) encryption implementation for a
>|>64 Bit alpha running DEC/OSF1 ?
>|>The reference implementation included in the RFC works fine only
>|>on 32 Bit machines.
>
>I've had no problem with the RFC1321 code running on Digital UNIX. All
>I did was modify global.h:
>
>/* UINT4 defines a four byte word */
>#if defined(__osf__) && defined(__alpha)
>typedef unsigned int UINT4;
>#else
>typedef unsigned long int UINT4;
>#endif
>
>With this modification, the code works identically on ULTRIX, OpenVMS,
>Digital UNIX, and Windows NT.
I am sorry to say that I think that this is a revolting solution!
It isn't difficult to do the job properly (i.e. without any #ifs
that depend on any particular system). For such code, see
/pub/software/programs/checksum/... on cus.cam.ac.uk.
Yes, that code has #ifs that fix up SunOS (no EXIT_SUCCESS etc.)
and has alternate code for POSIX/UNIX systems (to allow its use in
a pipe). But otherwise it works without #ifs under OS/2, MVS and
many UNICES (including DEC OSF/1).
If it doesn't, please tell me and I shall regard it as a bug.
Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email: nmm1@cam.ac.uk
Tel.: +44 1223 334761 Fax: +44 1223 334679
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: MD5 implementation
1996-01-11 5:00 ` Michael Spratte
1996-01-11 5:00 ` Nick Maclaren
@ 1996-01-12 5:00 ` Michael Gsandtner
1996-01-12 5:00 ` Donn Cave
2 siblings, 0 replies; 7+ messages in thread
From: Michael Gsandtner @ 1996-01-12 5:00 UTC (permalink / raw)
> I've had no problem with the RFC1321 code running on Digital UNIX. All
> I did was modify global.h:
>
> /* UINT4 defines a four byte word */
> #if defined(__osf__) && defined(__alpha)
> typedef unsigned int UINT4;
> #else
> typedef unsigned long int UINT4;
> #endif
>
Well, that's a very little but very fundamental change !
I refuse saying RFC1321 code has no problems on Digital UNIX.
However, this changed version works great on a alpha too.
Thanks --Michi
--
Michael Gsandtner, MA14 ADV, Magistrat Wien, �sterreich
Rathausstr. 1
A-1082 Wien
Austria (NOT where the kangaroos are !), Europe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: MD5 implementation
1996-01-11 5:00 ` Michael Spratte
1996-01-11 5:00 ` Nick Maclaren
1996-01-12 5:00 ` Michael Gsandtner
@ 1996-01-12 5:00 ` Donn Cave
2 siblings, 0 replies; 7+ messages in thread
From: Donn Cave @ 1996-01-12 5:00 UTC (permalink / raw)
In article <4d3usa$gfm@nntpd2.cxo.dec.com>, spratte@odette.cxo.dec.com
(Michael Spratte) wrote:
...
| I've had no problem with the RFC1321 code running on Digital UNIX. All
| I did was modify global.h:
|
| /* UINT4 defines a four byte word */
| #if defined(__osf__) && defined(__alpha)
| typedef unsigned int UINT4;
| #else
| typedef unsigned long int UINT4;
| #endif
|
| With this modification, the code works identically on ULTRIX, OpenVMS,
| Digital UNIX, and Windows NT.
That's about the same as what I proposed to the author of Python*, and
it turns out there was already a slightly more elegant solution based on
the symbols LONG_BIT and WORD_BIT, in sys/limits.h. These symbols
evidently are intended to expose the size in bits of "long int" and "int"
respectively. So the following works not only on the Alpha, but also on
64-bit MIPS hardware etc., as long as there's a sys/limits.h and it has these
symbols, which is true at least on several UNIX platforms.
#include <sys/limits.h>
#if WORD_BIT == 32
typedef unsigned int UINT4;
#else
# if LONG_BIT == 32
typedef unsigned long int UINT4;
# else
what have we here
# endif
#endif
Donn Cave, University Computing Services, University of Washington
donn@u.washington.edu
* Python is an interpreted language; it incorporates this code in its MD5
support module. Direct your browser to http://www.python.org.
^ permalink raw reply [flat|nested] 7+ messages in thread