*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Sun, 27 Jan 2013 14:55:22 +0100
changeset 14723 8657c48a4c03
parent 14722 f481fa77115d
child 14724 03fbc7b1d07e
child 18017 7fef9e17913f
*** empty log message ***
MD5Stream.st
SHA1Stream.st
--- a/MD5Stream.st	Sun Jan 27 02:16:31 2013 +0100
+++ b/MD5Stream.st	Sun Jan 27 14:55:22 2013 +0100
@@ -55,37 +55,37 @@
     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
-        SHA256Stream SHA512Stream (in libcrypt) 
+	SHA1Stream
+	SHA256Stream SHA512Stream (in libcrypt)
 
     [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
 "
 !
 
@@ -268,12 +268,10 @@
    "reset the stream in order to compute a new hash value"
 
 %{
-   if (__isNonNilObject(__INST(hashContext)) &&
-       __qClass(__INST(hashContext)) == @global(ByteArray) &&
+   if (__isByteArray(__INST(hashContext)) &&
        __byteArraySize(__INST(hashContext)) == sizeof(MD5_CTX)
    ) {
-	MD5_CTX *ctx =
-	    (MD5_CTX *)__ByteArrayInstPtr(__INST(hashContext))->ba_element;
+	MD5_CTX *ctx = (MD5_CTX *)__ByteArrayInstPtr(__INST(hashContext))->ba_element;
 
 	MD5Init(ctx);
 	RETURN(self);
@@ -298,15 +296,12 @@
     digest := ByteArray new:HashSize.
 
 %{
-    if (__isNonNilObject(__INST(hashContext)) &&
-	__qClass(__INST(hashContext)) == @global(ByteArray) &&
+    if (__isByteArray(__INST(hashContext)) &&
 	__byteArraySize(__INST(hashContext)) == sizeof(MD5_CTX) &&
-	__isNonNilObject(digest) &&
-	__qClass(digest) == @global(ByteArray) &&
+	__isByteArray(digest) &&
 	__byteArraySize(digest) == 16
     ) {
-	MD5_CTX *ctx =
-	    (MD5_CTX *)__ByteArrayInstPtr(__INST(hashContext))->ba_element;
+	MD5_CTX *ctx = (MD5_CTX *)__ByteArrayInstPtr(__INST(hashContext))->ba_element;
 	MD5_CTX copyContext;
 
 	memcpy(&copyContext, ctx, sizeof(copyContext));
@@ -327,17 +322,16 @@
      or an externalBytes object (with known size)"
 
 %{
-    int len, offs;
-    int objSize, nInstVars, nInstBytes;
+    INT len, offs;
+    INT objSize;
+    int nInstVars, nInstBytes;
     char *extPtr;
 
-    if (__isNonNilObject(__INST(hashContext))
-       &&__qClass(__INST(hashContext)) == @global(ByteArray)
+    if (__isByteArray(__INST(hashContext))
        &&__byteArraySize(__INST(hashContext)) == sizeof(MD5_CTX)
        && __bothSmallInteger(count, start)
     ) {
-	MD5_CTX *ctx =
-	    (MD5_CTX *)__ByteArrayInstPtr(__INST(hashContext))->ba_element;
+	MD5_CTX *ctx = (MD5_CTX *)__ByteArrayInstPtr(__INST(hashContext))->ba_element;
 
 	len = __intVal(count);
 	offs = __intVal(start) - 1;
@@ -391,11 +385,11 @@
 !MD5Stream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/MD5Stream.st,v 1.23 2013-01-25 16:11:58 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/MD5Stream.st,v 1.24 2013-01-27 13:55:22 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/MD5Stream.st,v 1.23 2013-01-25 16:11:58 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/MD5Stream.st,v 1.24 2013-01-27 13:55:22 cg Exp $'
 ! !
 
 
--- a/SHA1Stream.st	Sun Jan 27 02:16:31 2013 +0100
+++ b/SHA1Stream.st	Sun Jan 27 14:55:22 2013 +0100
@@ -308,28 +308,28 @@
     This may be used as checksum or for generating cryptographic signatures.
 
     Notice (2005):
-        Be aware that SHA-1 is considered broken and may not be appropriate in some applications.
-        Especially it should no longer be used for security stuff.
+	Be aware that SHA-1 is considered broken and may not be appropriate in some applications.
+	Especially it should no longer be used for security stuff.
 
     performance: roughly
-           47400 Kb/s on a 2Ghz Duo
-            9580 Kb/s on a 400Mhz PIII
-            3970 Kb/s on a 300Mhz Sparc
+	   47400 Kb/s on a 2Ghz Duo
+	    9580 Kb/s on a 400Mhz PIII
+	    3970 Kb/s on a 300Mhz Sparc
 
     [author:]
-        Stefan Vogel
+	Stefan Vogel
 
     [see also:]
-        MD5Stream 
-        SHA256Stream SHA512Stream (in libcrypt) 
+	MD5Stream
+	SHA256Stream SHA512Stream (in libcrypt)
 
     [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
 "
 !
 
@@ -493,6 +493,7 @@
     ) {
 	SHA1_CTX *ctx = (SHA1_CTX *)__ByteArrayInstPtr(__INST(hashContext))->ba_element;
 	SHA1_CTX copyContext;
+
 	memcpy(&copyContext, ctx, sizeof(copyContext));
 	SHA1Final(__ByteArrayInstPtr(digest)->ba_element, &copyContext);
 	RETURN(digest);
@@ -518,7 +519,6 @@
     INT objSize;
     int nInstVars, nInstBytes;
     char *extPtr;
-    OBJ oClass;
 
    if (__isByteArray(__INST(hashContext))
        && __byteArraySize(__INST(hashContext)) == sizeof(SHA1_CTX)
@@ -529,8 +529,7 @@
 	len = __intVal(count);
 	offs = __intVal(start) - 1;
 
-	oClass = __Class(anObject);
-	if (oClass == ExternalBytes) {
+	if (__isExternalBytesLike(anObject)) {
 	    OBJ sz;
 
 	    nInstBytes = 0;
@@ -543,6 +542,9 @@
 		objSize = 0; /* unknown */
 	    }
 	} else {
+	    OBJ oClass;
+
+	    oClass = __Class(anObject);
 	    switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
 		case BYTEARRAY:
 		case WORDARRAY:
@@ -576,11 +578,11 @@
 !SHA1Stream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/SHA1Stream.st,v 1.32 2013-01-25 16:11:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/SHA1Stream.st,v 1.33 2013-01-27 13:55:22 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/SHA1Stream.st,v 1.32 2013-01-25 16:11:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/SHA1Stream.st,v 1.33 2013-01-27 13:55:22 cg Exp $'
 ! !