classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch: SHA1PRNG fix


From: Anthony Green
Subject: Patch: SHA1PRNG fix
Date: Tue, 10 Jul 2001 20:03:47 -0700

I believe that these two array copies have source and destination
operands mixed up.  This random number generator produces a never
ending streamn of zeros otherwise.

Ok to commit?

AG


2001-07-09  Anthony Green  <address@hidden>

        * gnu/java/security/provider/SHA1PRNG.java (engineNextBytes): Fix
        order of memory copies.

Index: gnu/java/security/provider/SHA1PRNG.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/security/provider/SHA1PRNG.java,v
retrieving revision 1.1
diff -u -p -r1.1 SHA1PRNG.java
--- SHA1PRNG.java       2000/06/28 11:24:05     1.1
+++ SHA1PRNG.java       2001/07/11 02:58:22
@@ -76,7 +76,7 @@ public class SHA1PRNG implements Seriali
   {
 
     if( bytes.length < (20 - datapos) ) {
-      System.arraycopy( bytes, 0, data, datapos, bytes.length);
+      System.arraycopy( data, datapos, bytes, 0, bytes.length);
       datapos += bytes.length;
       return;
     }
@@ -85,7 +85,7 @@ public class SHA1PRNG implements Seriali
     byte digestdata[];
     while( bpos < blen ) {
       i = 20 - datapos;
-      System.arraycopy( bytes, bpos, data, datapos, i);
+      System.arraycopy( data, datapos, bytes, bpos, i);
       bpos += i;
       datapos += i;
       if( datapos >= 20) {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]