Browse Source

* renamed md5test.pp to mdtest.pas
* extended mdtest.pas with rfc tests
* added md2 hash support to md5.pp

git-svn-id: trunk@5648 -

ivost 18 years ago
parent
commit
c8d60373b0

+ 1 - 1
.gitattributes

@@ -1403,7 +1403,7 @@ packages/base/hash/fpmake.inc svneol=native#text/plain
 packages/base/hash/fpmake.pp svneol=native#text/plain
 packages/base/hash/fpmake.pp svneol=native#text/plain
 packages/base/hash/md5.pp svneol=native#text/plain
 packages/base/hash/md5.pp svneol=native#text/plain
 packages/base/hash/md5.ref -text
 packages/base/hash/md5.ref -text
-packages/base/hash/md5test.pp svneol=native#text/plain
+packages/base/hash/mdtest.pas svneol=native#text/plain
 packages/base/hash/ntlm.pas svneol=native#text/plain
 packages/base/hash/ntlm.pas svneol=native#text/plain
 packages/base/hash/unixcrypt.pas -text
 packages/base/hash/unixcrypt.pas -text
 packages/base/hash/uuid.pas svneol=native#text/plain
 packages/base/hash/uuid.pas svneol=native#text/plain

+ 157 - 85
packages/base/hash/Makefile

@@ -1,8 +1,8 @@
 #
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2006/12/01]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2006/12/19]
 #
 #
 default: all
 default: all
-MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos sparc-linux sparc-netbsd sparc-solaris x86_64-linux x86_64-freebsd x86_64-win64 arm-linux arm-palmos arm-wince arm-gba powerpc64-linux
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded powerpc64-linux powerpc64-embedded
 BSDs = freebsd netbsd openbsd darwin
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx
 UNIXs = linux $(BSDs) solaris qnx
 LIMIT83fs = go32v2 os2 emx watcom
 LIMIT83fs = go32v2 os2 emx watcom
@@ -233,250 +233,298 @@ PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/ext
 override PACKAGE_NAME=hash
 override PACKAGE_NAME=hash
 override PACKAGE_VERSION=2.0.0
 override PACKAGE_VERSION=2.0.0
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_UNITS+=md5 crc ntlm  unixcrypt
+override TARGET_UNITS+=md5 crc ntlm uuid  unixcrypt
 endif
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
 ifeq ($(FULL_TARGET),i386-solaris)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netware)
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
 ifeq ($(FULL_TARGET),i386-darwin)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wince)
 ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
+endif
+ifeq ($(FULL_TARGET),i386-embedded)
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_UNITS+=md5 crc ntlm  unixcrypt
+override TARGET_UNITS+=md5 crc ntlm uuid  unixcrypt
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
+endif
+ifeq ($(FULL_TARGET),m68k-embedded)
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_UNITS+=md5 crc ntlm  unixcrypt
+override TARGET_UNITS+=md5 crc ntlm uuid  unixcrypt
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 ifeq ($(FULL_TARGET),powerpc-amiga)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
+endif
+ifeq ($(FULL_TARGET),powerpc-embedded)
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_UNITS+=md5 crc ntlm  unixcrypt
+override TARGET_UNITS+=md5 crc ntlm uuid  unixcrypt
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
+endif
+ifeq ($(FULL_TARGET),sparc-embedded)
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_UNITS+=md5 crc ntlm  unixcrypt
+override TARGET_UNITS+=md5 crc ntlm uuid  unixcrypt
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
+endif
+ifeq ($(FULL_TARGET),x86_64-embedded)
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_UNITS+=md5 crc ntlm  unixcrypt
+override TARGET_UNITS+=md5 crc ntlm uuid  unixcrypt
 endif
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 ifeq ($(FULL_TARGET),arm-palmos)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),arm-wince)
 ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),arm-gba)
 ifeq ($(FULL_TARGET),arm-gba)
-override TARGET_UNITS+=md5 crc ntlm
+override TARGET_UNITS+=md5 crc ntlm uuid
+endif
+ifeq ($(FULL_TARGET),arm-nds)
+override TARGET_UNITS+=md5 crc ntlm uuid
+endif
+ifeq ($(FULL_TARGET),arm-embedded)
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_UNITS+=md5 crc ntlm  unixcrypt
+override TARGET_UNITS+=md5 crc ntlm uuid  unixcrypt
+endif
+ifeq ($(FULL_TARGET),powerpc64-embedded)
+override TARGET_UNITS+=md5 crc ntlm uuid
 endif
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
 ifeq ($(FULL_TARGET),i386-solaris)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netware)
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
 ifeq ($(FULL_TARGET),i386-darwin)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wince)
 ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
+endif
+ifeq ($(FULL_TARGET),i386-embedded)
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
+endif
+ifeq ($(FULL_TARGET),m68k-embedded)
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 ifeq ($(FULL_TARGET),powerpc-amiga)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
+endif
+ifeq ($(FULL_TARGET),powerpc-embedded)
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
+endif
+ifeq ($(FULL_TARGET),sparc-embedded)
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
+endif
+ifeq ($(FULL_TARGET),x86_64-embedded)
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 ifeq ($(FULL_TARGET),arm-palmos)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),arm-wince)
 ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),arm-gba)
 ifeq ($(FULL_TARGET),arm-gba)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
+endif
+ifeq ($(FULL_TARGET),arm-nds)
+override TARGET_EXAMPLES+=mdtest
+endif
+ifeq ($(FULL_TARGET),arm-embedded)
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_EXAMPLES+=md5test
+override TARGET_EXAMPLES+=mdtest
+endif
+ifeq ($(FULL_TARGET),powerpc64-embedded)
+override TARGET_EXAMPLES+=mdtest
 endif
 endif
 override INSTALL_FPCPACKAGE=y
 override INSTALL_FPCPACKAGE=y
 ifdef REQUIRE_UNITSDIR
 ifdef REQUIRE_UNITSDIR
@@ -1274,6 +1322,9 @@ endif
 ifeq ($(FULL_TARGET),i386-wince)
 ifeq ($(FULL_TARGET),i386-wince)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
+ifeq ($(FULL_TARGET),i386-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
@@ -1295,6 +1346,9 @@ endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 ifeq ($(FULL_TARGET),m68k-palmos)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
+ifeq ($(FULL_TARGET),m68k-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 ifeq ($(FULL_TARGET),powerpc-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
@@ -1313,6 +1367,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 ifeq ($(FULL_TARGET),powerpc-morphos)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
+ifeq ($(FULL_TARGET),powerpc-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
@@ -1322,6 +1379,9 @@ endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 ifeq ($(FULL_TARGET),sparc-solaris)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
+ifeq ($(FULL_TARGET),sparc-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 ifeq ($(FULL_TARGET),x86_64-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
@@ -1331,6 +1391,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 ifeq ($(FULL_TARGET),x86_64-win64)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
+ifeq ($(FULL_TARGET),x86_64-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifeq ($(FULL_TARGET),arm-linux)
 ifeq ($(FULL_TARGET),arm-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
@@ -1343,9 +1406,18 @@ endif
 ifeq ($(FULL_TARGET),arm-gba)
 ifeq ($(FULL_TARGET),arm-gba)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
+ifeq ($(FULL_TARGET),arm-nds)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 ifeq ($(FULL_TARGET),powerpc64-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 endif
 endif
+ifeq ($(FULL_TARGET),powerpc64-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifdef REQUIRE_PACKAGES_RTL
 ifdef REQUIRE_PACKAGES_RTL
 PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
 PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_RTL),)
 ifneq ($(PACKAGEDIR_RTL),)
@@ -1423,7 +1495,7 @@ ifeq ($(CPU_TARGET),powerpc)
 FPCCPUOPT:=-O1r
 FPCCPUOPT:=-O1r
 endif
 endif
 else
 else
-FPCCPUOPT:=-O1r
+FPCCPUOPT:=-O2
 endif
 endif
 override FPCOPT+=-Ur -Xs $(FPCCPUOPT) -n
 override FPCOPT+=-Ur -Xs $(FPCCPUOPT) -n
 override FPCOPTDEF+=RELEASE
 override FPCOPTDEF+=RELEASE

+ 2 - 2
packages/base/hash/Makefile.fpc

@@ -7,9 +7,9 @@ name=hash
 version=2.0.0
 version=2.0.0
 
 
 [target]
 [target]
-units=md5 crc ntlm
+units=md5 crc ntlm uuid
 units_linux=unixcrypt
 units_linux=unixcrypt
-examples=md5test
+examples=mdtest
 
 
 [install]
 [install]
 fpcpackage=y
 fpcpackage=y

+ 141 - 35
packages/base/hash/md5.pp

@@ -2,7 +2,9 @@
     This file is part of the Free Pascal packages.
     This file is part of the Free Pascal packages.
     Copyright (c) 1999-2006 by the Free Pascal development team
     Copyright (c) 1999-2006 by the Free Pascal development team
 
 
-    Implements a MD5 digest algorithm.
+    Implements a MD2 digest algorithm (RFC 1319)
+    Implements a MD4 digest algorithm (RFC 1320)
+    Implements a MD5 digest algorithm (RFC 1321)
 
 
     See the file COPYING.FPC, included in this distribution,
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
     for details about the copyright.
@@ -13,11 +15,6 @@
 
 
  **********************************************************************}
  **********************************************************************}
 
 
-{
-  Implements a MD4 digest algorithm (RFC 1320)
-  Implements a MD5 digest algorithm (RFC 1321)
-}
-
 unit md5;
 unit md5;
 
 
 {$mode objfpc}
 {$mode objfpc}
@@ -35,6 +32,7 @@ const
 
 
 type
 type
   TMDVersion = (
   TMDVersion = (
+    MD_VERSION_2,
     MD_VERSION_4,
     MD_VERSION_4,
     MD_VERSION_5
     MD_VERSION_5
   );
   );
@@ -44,10 +42,13 @@ type
 
 
   TMDContext = record
   TMDContext = record
     Version : TMDVersion;
     Version : TMDVersion;
+    Align   : PtrUInt;
     State   : array[0..3] of Cardinal;
     State   : array[0..3] of Cardinal;
-    Length  : PtrUInt;
     BufCnt  : PtrUInt;
     BufCnt  : PtrUInt;
     Buffer  : array[0..63] of Byte;
     Buffer  : array[0..63] of Byte;
+    case Integer of
+      0: (Length   : PtrUInt);
+      1: (Checksum : array[0..15] of Byte);
   end;
   end;
 
 
 
 
@@ -99,6 +100,68 @@ begin
 end;
 end;
 
 
 
 
+procedure MD2Transform(var Context: TMDContext; Buffer: Pointer);
+const
+  PI_SUBST: array[0..255] of Byte = (
+  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
+);
+var
+  i: Integer;
+  j: Integer;
+  t: Cardinal;
+  x: array[0..47] of Byte;
+begin
+  { Form encryption block from state, block, state ^ block }
+  Move(Context.State, x[0], 16);
+  Move(Buffer^, x[16], 16);
+  for i := 0 to 15 do
+    x[i+32] := PByte(@Context.State)[i] xor PByte(Buffer)[i];
+
+  { Encrypt block (18 rounds) }
+  t := 0;
+  for i := 0 to 17 do
+  begin
+    for j := 0 to 47 do
+    begin
+      x[j] := x[j] xor PI_SUBST[t];
+      t := x[j];
+    end;
+    t := (t + i) and $FF;
+  end;
+
+  { Save new state }
+  Move(x[0], Context.State, 16);
+
+  { Update checksum }
+  t := Context.Checksum[15];
+  for i := 0 to 15 do
+  begin
+    Context.Checksum[i] := Context.Checksum[i] xor PI_SUBST[PByte(Buffer)[i] xor t];
+    t := Context.Checksum[i];
+  end;
+
+  { Zeroize sensitive information. }
+  FillChar(x, Sizeof(x), 0);
+end;
+
+
 procedure MD4Transform(var Context: TMDContext; Buffer: Pointer);
 procedure MD4Transform(var Context: TMDContext; Buffer: Pointer);
 
 
   procedure R1(var a: Cardinal; b,c,d,x: Cardinal; s: Byte);
   procedure R1(var a: Cardinal; b,c,d,x: Cardinal; s: Byte);
@@ -225,29 +288,49 @@ end;
 
 
 procedure MDInit(var Context: TMDContext; const Version: TMDVersion);
 procedure MDInit(var Context: TMDContext; const Version: TMDVersion);
 begin
 begin
+  FillChar(Context, Sizeof(TMDContext), 0);
   Context.Version := Version;
   Context.Version := Version;
-  Context.State[0] := $67452301;
-  Context.State[1] := $efcdab89;
-  Context.State[2] := $98badcfe;
-  Context.State[3] := $10325476;
-  Context.Length := 0;
-  Context.BufCnt := 0;
+
+  case Version of
+
+    MD_VERSION_4, MD_VERSION_5:
+      begin
+        Context.Align := 64;
+        Context.State[0] := $67452301;
+        Context.State[1] := $efcdab89;
+        Context.State[2] := $98badcfe;
+        Context.State[3] := $10325476;
+        Context.Length := 0;
+        Context.BufCnt := 0;
+      end;
+
+    MD_VERSION_2:
+      begin
+        Context.Align := 16;
+      end;
+
+  end;
 end;
 end;
 
 
 
 
 procedure MDUpdate(var Context: TMDContext; var Buf; const BufLen: PtrUInt);
 procedure MDUpdate(var Context: TMDContext; var Buf; const BufLen: PtrUInt);
 var
 var
+  Align: PtrUInt;
   Src: Pointer;
   Src: Pointer;
   Num: PtrUInt;
   Num: PtrUInt;
 begin
 begin
+  if BufLen = 0 then
+    Exit;
+
+  Align := Context.Align;
   Src := @Buf;
   Src := @Buf;
   Num := 0;
   Num := 0;
 
 
   // 1. Transform existing data in buffer
   // 1. Transform existing data in buffer
   if Context.BufCnt > 0 then
   if Context.BufCnt > 0 then
   begin
   begin
-    // 1.1 Try to fill buffer to 64 bytes
-    Num := 64 - Context.BufCnt;
+    // 1.1 Try to fill buffer to "Align" bytes
+    Num := Align - Context.BufCnt;
     if Num > BufLen then
     if Num > BufLen then
       Num := BufLen;
       Num := BufLen;
 
 
@@ -255,10 +338,11 @@ begin
     Context.BufCnt := Context.BufCnt + Num;
     Context.BufCnt := Context.BufCnt + Num;
     Src := Pointer(PtrUInt(Src) + Num);
     Src := Pointer(PtrUInt(Src) + Num);
 
 
-    // 1.2 If buffer contains 64 bytes, transform it
-    if Context.BufCnt = 64 then
+    // 1.2 If buffer contains "Align" bytes, transform it
+    if Context.BufCnt = Align then
     begin
     begin
       case Context.Version of
       case Context.Version of
+        MD_VERSION_2: MD2Transform(Context, @Context.Buffer);
         MD_VERSION_4: MD4Transform(Context, @Context.Buffer);
         MD_VERSION_4: MD4Transform(Context, @Context.Buffer);
         MD_VERSION_5: MD5Transform(Context, @Context.Buffer);
         MD_VERSION_5: MD5Transform(Context, @Context.Buffer);
       end;
       end;
@@ -266,19 +350,20 @@ begin
     end;
     end;
   end;
   end;
 
 
-  // 2. Transform 64-Byte blocks of Buf
+  // 2. Transform "Align"-Byte blocks of Buf
   Num := BufLen - Num;
   Num := BufLen - Num;
-  while Num >= 64 do
+  while Num >= Align do
   begin
   begin
     case Context.Version of
     case Context.Version of
+      MD_VERSION_2: MD2Transform(Context, Src);
       MD_VERSION_4: MD4Transform(Context, Src);
       MD_VERSION_4: MD4Transform(Context, Src);
       MD_VERSION_5: MD5Transform(Context, Src);
       MD_VERSION_5: MD5Transform(Context, Src);
     end;
     end;
-    Src := Pointer(PtrUInt(Src) + 64);
-    Num := Num - 64;
+    Src := Pointer(PtrUInt(Src) + Align);
+    Num := Num - Align;
   end;
   end;
 
 
-  // 3. If there's a block smaller than 64 Bytes left, add it to buffer
+  // 3. If there's a block smaller than "Align" Bytes left, add it to buffer
   if Num > 0 then
   if Num > 0 then
   begin
   begin
     Context.BufCnt := Num;
     Context.BufCnt := Num;
@@ -289,26 +374,47 @@ end;
 
 
 procedure MDFinal(var Context: TMDContext; var Digest: TMDDigest);
 procedure MDFinal(var Context: TMDContext; var Digest: TMDDigest);
 const
 const
-  Padding: array[0..15] of Cardinal = ($80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+  PADDING_MD45: array[0..15] of Cardinal = ($80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
 var
 var
   Length: QWord;
   Length: QWord;
   Pads: Cardinal;
   Pads: Cardinal;
 begin
 begin
-  // 1. Compute length of the whole stream in bits
-  Length := 8 * (Context.Length + Context.BufCnt);
+  case Context.Version of
 
 
-  // 2. Append padding bits
-  Pads := (120 - Context.BufCnt) mod 64;
-  if Pads > 0 then
-    MDUpdate(Context, Padding, Pads) else
-    MDUpdate(Context, Padding, 56);
+    MD_VERSION_4, MD_VERSION_5:
+      begin
+        // 1. Compute length of the whole stream in bits
+        Length := 8 * (Context.Length + Context.BufCnt);
 
 
-  // 3. Append length of the stream
-  Invert(@Length, @Length, 8);
-  MDUpdate(Context, Length, 8);
+        // 2. Append padding bits
+        Pads := (120 - Context.BufCnt) mod 64;
+        if Pads > 0 then
+          MDUpdate(Context, PADDING_MD45, Pads) else
+          MDUpdate(Context, PADDING_MD45, 56);
+
+        // 3. Append length of the stream
+        Invert(@Length, @Length, 8);
+        MDUpdate(Context, Length, 8);
+
+        // 4. Invert state to digest
+        Invert(@Context.State, @Digest, 16);
+      end;
+
+    MD_VERSION_2:
+      begin
+        Pads := 16 - Context.BufCnt;
+        Length := Pads;
+        while Pads > 0 do
+        begin
+          MDUpdate(Context, Length, 1);
+          Dec(Pads);
+        end;
+        MDUpdate(Context, Context.Checksum, 16);
+        Move(Context.State, Digest, 16);
+      end;
+
+  end;
 
 
-  // 4. Invert state to digest
-  Invert(@Context.State, @Digest, 16);
   FillChar(Context, SizeOf(TMDContext), 0);
   FillChar(Context, SizeOf(TMDContext), 0);
 end;
 end;
 
 

+ 0 - 55
packages/base/hash/md5test.pp

@@ -1,55 +0,0 @@
-{
-    This file is part of the Free Pascal packages.
-    Copyright (c) 1999-2000 by the Free Pascal development team
-
-    Tests the MD5 program.
-
-    See the file COPYING.FPC, included in this distribution,
-    for details about the copyright.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- **********************************************************************}
-
-program md5test;
-
-{$h+}
-
-uses md5, ntlm;
-
-var
-  I: byte;
-
-const
-  Suite: array[1..7] of string = (
-    '',
-    'a',
-    'abc',
-    'message digest',
-    'abcdefghijklmnopqrstuvwxyz',
-    'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
-    '12345678901234567890123456789012345678901234567890123456789012345678901234567890'
-    );
-
-begin
-  Writeln('Executing RFC 1320 test suite ...');
-  for I := 1 to 7 do
-    Writeln('MD4 ("',Suite[i],'") = ',MDPrint(MDString(Suite[I], 4)));
-  Writeln();
-  Writeln('md4file (50)  : ',MDPrint(MDFile('md5test.pp',4,50)));
-  Writeln('md4file (def) : ',MDPrint(MDFile('md5test.pp',4)));
-  Writeln;
-
-  Writeln('Executing RFC 1321 test suite ...');
-  for I := 1 to 7 do
-    Writeln('MD5 ("',Suite[i],'") = ',MDPrint(MDString(Suite[I], 5)));
-  Writeln();
-  Writeln('md5file (50)  : ',MDPrint(MDFile('md5test.pp',5,50)));
-  Writeln('md5file (def) : ',MDPrint(MDFile('md5test.pp',5)));
-  Writeln;
-
-  Writeln('nt-password   : ',MDPrint(NTGenerate('foobar')));
-  Writeln('lm-password   : ',MDPrint(LMGenerate('foobar')));
-end.

+ 90 - 0
packages/base/hash/mdtest.pas

@@ -0,0 +1,90 @@
+{
+    This file is part of the Free Pascal packages.
+    Copyright (c) 1999-2000 by the Free Pascal development team
+
+    Tests the MD5 program.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+program mdtest;
+
+{$h+}
+
+uses
+  md5;
+
+const
+  Suite: array[1..7] of string = (
+    '',
+    'a',
+    'abc',
+    'message digest',
+    'abcdefghijklmnopqrstuvwxyz',
+    'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
+    '12345678901234567890123456789012345678901234567890123456789012345678901234567890'
+    );
+
+  Results: array[TMDVersion, Low(Suite)..High(Suite)] of string = (
+    // MD_VERSION_2
+    ('8350e5a3e24c153df2275c9f80692773',
+     '32ec01ec4a6dac72c0ab96fb34c0b5d1',
+     'da853b0d3f88d99b30283a69e6ded6bb',
+     'ab4f496bfb2a530b219ff33031fe06b0',
+     '4e8ddff3650292ab5a4108c3aa47940b',
+     'da33def2a42df13975352846c30338cd',
+     'd5976f79d83d3a0dc9806c3c66f3efd8'),
+
+    // MD_VERSION_4
+    ('31d6cfe0d16ae931b73c59d7e0c089c0',
+     'bde52cb31de33e46245e05fbdbd6fb24',
+     'a448017aaf21d8525fc10ae87aa6729d',
+     'd9130a8164549fe818874806e1c7014b',
+     'd79e1c308aa5bbcdeea8ed63df412da9',
+     '043f8582f241db351ce627e153e7f0e4',
+     'e33b4ddc9c38f2199c3e7b164fcc0536'),
+
+    // MD_VERSION_5
+    ('d41d8cd98f00b204e9800998ecf8427e',
+     '0cc175b9c0f1b6a831c399e269772661',
+     '900150983cd24fb0d6963f7d28e17f72',
+     'f96b697d7cb7938d525a2f31aaf161d0',
+     'c3fcd3d76192e4007dfb496cca67e13b',
+     'd174ab98d277d9f5a5611c2c9f419d9f',
+     '57edf4a22be3c955ac49da2e2107b67a')
+  );
+
+procedure performTest(const Ver: TMDVersion);
+var
+  I: Integer;
+  S: String;
+begin
+  for I := Low(Suite) to High(Suite) do
+  begin
+    S := LowerCase(MDPrint(MDString(Suite[I], Ver)));
+    if S = Results[Ver, I] then
+      Write('passed  ') else
+      Write('failed  ');
+    WriteLn('  "', Suite[I], '" = ', S);
+  end;
+end;
+
+begin
+  Writeln('Executing RFC 1319 test suite ...');
+  performTest(MD_VERSION_2);
+  Writeln;
+
+  Writeln('Executing RFC 1320 test suite ...');
+  performTest(MD_VERSION_4);
+  Writeln;
+
+  Writeln('Executing RFC 1321 test suite ...');
+  performTest(MD_VERSION_5);
+  Writeln;
+end.

+ 14 - 16
packages/base/hash/uuid.pas

@@ -185,9 +185,9 @@ begin
   (* put name space ID in network byte order so it hashes the same
   (* put name space ID in network byte order so it hashes the same
      no matter what endian machine we're on *)
      no matter what endian machine we're on *)
   net_nsid := nsid;
   net_nsid := nsid;
-//  net_nsid.time_low := htonl(net_nsid.time_low);
-//  net_nsid.time_mid := htons(net_nsid.time_mid);
-//  net_nsid.time_hi_and_version := htons(net_nsid.time_hi_and_version);
+  net_nsid.time_low := ntobe(net_nsid.time_low);
+  net_nsid.time_mid := ntobe(net_nsid.time_mid);
+  net_nsid.time_hi_and_version := ntobe(net_nsid.time_hi_and_version);
 
 
   MDInit(c, MD_VERSION_4);
   MDInit(c, MD_VERSION_4);
   MDUpdate(c, net_nsid, sizeof(net_nsid));
   MDUpdate(c, net_nsid, sizeof(net_nsid));
@@ -202,19 +202,17 @@ end;
 { uuid_create_sha1_from_name }
 { uuid_create_sha1_from_name }
 
 
 procedure uuid_create_sha1_from_name(var uuid: uuid_t; const nsid: uuid_t; const name: string);
 procedure uuid_create_sha1_from_name(var uuid: uuid_t; const nsid: uuid_t; const name: string);
-begin
-end;
-{var
+var
   net_nsid: uuid_t;
   net_nsid: uuid_t;
-  c: TMDContext;
-  hash: TMDDigest;
+{  c: TMDContext;
+  hash: TMDDigest;}
 begin
 begin
   (* put name space ID in network byte order so it hashes the same
   (* put name space ID in network byte order so it hashes the same
      no matter what endian machine we're on *)
      no matter what endian machine we're on *)
-//  net_nsid := nsid;
-//  net_nsid.time_low := htonl(net_nsid.time_low);
-//  net_nsid.time_mid := htons(net_nsid.time_mid);
-//  net_nsid.time_hi_and_version := htons(net_nsid.time_hi_and_version);
+  net_nsid := nsid;
+  net_nsid.time_low := ntobe(net_nsid.time_low);
+  net_nsid.time_mid := ntobe(net_nsid.time_mid);
+  net_nsid.time_hi_and_version := ntobe(net_nsid.time_hi_and_version);
 
 
   {SHAInit(c, SHA_VERSION_1);
   {SHAInit(c, SHA_VERSION_1);
   SHAUpdate(c, net_nsid, sizeof(net_nsid));
   SHAUpdate(c, net_nsid, sizeof(net_nsid));
@@ -223,7 +221,7 @@ begin
 
 
   (* the hash is in network byte order at this point *)
   (* the hash is in network byte order at this point *)
   format_uuid_v3or5(uuid, @hash, UUID_VERSION_5);
   format_uuid_v3or5(uuid, @hash, UUID_VERSION_5);
-end;}
+end;
 
 
 
 
 { uuid_compare }
 { uuid_compare }
@@ -283,9 +281,9 @@ procedure format_uuid_v3or5(var uuid: uuid_t; const hash: pointer; const v: inte
 begin
 begin
   (* convert UUID to local byte order *)
   (* convert UUID to local byte order *)
   move(hash^, uuid, sizeof(uuid));
   move(hash^, uuid, sizeof(uuid));
-//  uuid.time_low := ntohl(uuid.time_low);
-//  uuid.time_mid := ntohs(uuid.time_mid);
-//  uuid.time_hi_and_version := ntohs(uuid.time_hi_and_version);
+  uuid.time_low := beton(uuid.time_low);
+  uuid.time_mid := beton(uuid.time_mid);
+  uuid.time_hi_and_version := beton(uuid.time_hi_and_version);
 
 
   (* put in the variant and version bits *)
   (* put in the variant and version bits *)
   uuid.time_hi_and_version := uuid.time_hi_and_version and $0FFF;
   uuid.time_hi_and_version := uuid.time_hi_and_version and $0FFF;