MD5Stream.st
branchjv
changeset 18011 deb0c3355881
parent 17911 a99f15c5efa5
parent 14668 dae8d0efb155
child 18017 7fef9e17913f
--- a/MD5Stream.st	Thu Dec 20 11:48:59 2012 +0000
+++ b/MD5Stream.st	Sat Jan 19 01:30:00 2013 +0000
@@ -55,42 +55,42 @@
     This may be used as checksum or for generating cryptographic signatures.
 
     Note:
-        in August 2004, some researchers have found a way to generate full collisions for MD5. 
-        Therefore, for new applications, it may be wise to choose another hash function for security stuff. 
-        See a hash-collision example in the examples method.
+	in August 2004, some researchers have found a way to generate full collisions for MD5.
+	Therefore, for new applications, it may be wise to choose another hash function for security stuff.
+	See a hash-collision example in the examples method.
 
-        So, the MD5 algorithm has severe weaknesses, for example it is easy to compute two messages yielding 
-        the same hash (collision attack). 
-        The use of this algorithm is only justified for non-cryptographic application.
+	So, the MD5 algorithm has severe weaknesses, for example it is easy to compute two messages yielding
+	the same hash (collision attack).
+	The use of this algorithm is only justified for non-cryptographic application.
 
 
     performance: roughly
-                        80000 Kb/s on a 2Ghz Duo
-                        27200 Kb/s on a 1.2Ghz Athlon
-                        12600 Kb/s on a 400Mhz PIII
-                         9150 Kb/s on a 300Mhz Sparc.
-        performance is almost completely limited by the speed of the md5-routine, which is the reference
-        implementation in C from md5lib.
+			80000 Kb/s on a 2Ghz Duo
+			27200 Kb/s on a 1.2Ghz Athlon
+			12600 Kb/s on a 400Mhz PIII
+			 9150 Kb/s on a 300Mhz Sparc.
+	performance is almost completely limited by the speed of the md5-routine, which is the reference
+	implementation in C from md5lib.
 
     [author:]
-        Stefan Vogel
+	Stefan Vogel
 
     [see also:]
-        SHA1Stream
+	SHA1Stream
 
     [class variables:]
-        HashSize        size of returned hash value
-        ContextSize     (implementation) size of hash context
+	HashSize        size of returned hash value
+	ContextSize     (implementation) size of hash context
 
     [instance variables:]
-        hashContext     (implementation)
-                        internal buffer for computation of the hash value
+	hashContext     (implementation)
+			internal buffer for computation of the hash value
 "
 !
 
 examples
 "
-                                                                [exBegin]
+								[exBegin]
     Test Vectors (from FIPS PUB 180-1); results are:
 
     'abc'
@@ -101,25 +101,25 @@
 
     A million repetitions of 'a'
     -> #[77 7 D6 AE 4E 2 7C 70 EE A2 A9 35 C2 29 6F 21]
-                                                                [exEnd]
+								[exEnd]
 
-                                                                [exBegin]
-     Transcript showCR:(MD5Stream hashValueOf:'abc') hexPrintString 
-                                                                [exEnd]
+								[exBegin]
+     Transcript showCR:(MD5Stream hashValueOf:'abc') hexPrintString
+								[exEnd]
 
-                                                                [exBegin]
+								[exBegin]
      (MD5Stream hashValueOf:'abc')
-        printOn:Transcript base:16.
+	printOn:Transcript base:16.
      Transcript cr.
-                                                                [exEnd]
+								[exEnd]
 
-                                                                [exBegin]
+								[exBegin]
      (MD5Stream hashValueOfStream:('abc' readStream))
-            printOn:Transcript base:16.
+	    printOn:Transcript base:16.
      Transcript cr.
-                                                                [exEnd]
+								[exEnd]
 
-                                                                [exBegin]
+								[exBegin]
     |hashStream|
 
     hashStream := MD5Stream new.
@@ -127,9 +127,9 @@
     hashStream hashValue printOn:Transcript base:16. Transcript cr.
     hashStream nextPut:'dbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'.
     hashStream hashValue printOn:Transcript base:16. Transcript cr.
-                                                                [exEnd]
+								[exEnd]
 
-                                                                [exBegin]
+								[exBegin]
     |hashStream|
 
     hashStream := MD5Stream new.
@@ -138,33 +138,33 @@
     hashStream hashValue printOn:Transcript base:16. Transcript cr.
     hashStream nextPut:'dbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq' asByteArray.
     hashStream hashValue printOn:Transcript base:16. Transcript cr.
-                                                                [exEnd]
+								[exEnd]
 
-                                                                [exBegin]
+								[exBegin]
     |hashStream|
 
     hashStream := MD5Stream new.
     1000000 timesRepeat:[ hashStream nextPut:$a ].
     hashStream hashValue printOn:Transcript base:16. Transcript cr.
-                                                                [exEnd]
+								[exEnd]
 
-                                                                [exBegin]
+								[exBegin]
     |hashStream|
 
     hashStream := MD5Stream new.
     hashStream nextPut:'a'.
     hashStream hashValue printOn:Transcript base:16. Transcript cr.
-                                                                [exEnd]
+								[exEnd]
 
-                                                                [exBegin]
+								[exBegin]
     |hashStream|
 
     hashStream := MD5Stream new.
     hashStream nextPut:$a.
     hashStream hashValue printOn:Transcript base:16. Transcript cr.
-                                                                [exEnd]
+								[exEnd]
 
-                                                                [exBegin]
+								[exBegin]
     |hashStream|
 
     hashStream := MD5Stream new.
@@ -173,10 +173,10 @@
     hashStream reset.
     hashStream nextPut:'abc'.
     hashStream hashValue printOn:Transcript base:16. Transcript cr.
-                                                                [exEnd]
+								[exEnd]
 
-  a collision:  
-                                                                [exBegin]
+  a collision:
+								[exBegin]
     |hashStream|
 
     hashStream := MD5Stream new.
@@ -194,23 +194,23 @@
 d8823e3156348f5bae6dacd436c919c6 dd53e23487da03fd02396306d248cda0
 e99f33420f577ee8ce54b67080280d1e c69821bcb6a8839396f965ab6ff72a70').
     hashStream hashValue printOn:Transcript base:16. Transcript cr.
-                                                                [exEnd]
+								[exEnd]
 
   timing throughput:
-                                                                [exBegin]
+								[exBegin]
     |hashStream n t|
 
     hashStream := MD5Stream new.
     n := 1000000.
     t := Time millisecondsToRun:[
-            n timesRepeat:[
-                hashStream nextPutAll:'12345678901234567890123456789012345678901234567890'.
-            ].
-         ].
+	    n timesRepeat:[
+		hashStream nextPutAll:'12345678901234567890123456789012345678901234567890'.
+	    ].
+	 ].
     t := (t / 1000) asFloat.
     Transcript show:t; show:' seconds for '; show:(50*n/1024) asFloat; showCR:' Kb'.
     Transcript show:(n*50/1024 / t); showCR:' Kb/s'
-                                                                [exEnd]
+								[exEnd]
 "
 ! !
 
@@ -346,6 +346,7 @@
 
 	    nInstBytes = 0;
 	    extPtr = (char *)__externalBytesAddress(anObject);
+	    if (extPtr == (char *)0) goto bad;
 	    sz = __externalBytesSize(anObject);
 	    if (__isSmallInteger(sz)) {
 		objSize = __intVal(sz);
@@ -389,18 +390,11 @@
 !MD5Stream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/MD5Stream.st,v 1.20 2012/01/12 16:28:30 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/MD5Stream.st,v 1.22 2013-01-17 22:41:35 cg Exp $'
 !
 
 version_CVS
-    ^ 'Header: /cvs/stx/stx/libbasic/MD5Stream.st,v 1.20 2012/01/12 16:28:30 cg Exp '
-!
-
-version_SVN
-    ^ '$Id: MD5Stream.st 10761 2012-01-19 11:46:00Z vranyj1 $'
+    ^ '$Header: /cvs/stx/stx/libbasic/MD5Stream.st,v 1.22 2013-01-17 22:41:35 cg Exp $'
 ! !
 
 MD5Stream initialize!
-
-
-