directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: rev 57020 - incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/crypto
Date Tue, 09 Nov 2004 12:22:28 GMT
Author: erodriguez
Date: Tue Nov  9 04:22:26 2004
New Revision: 57020

Modified:
   incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/crypto/GlobalSequenceNumber.java
Log:
Removed dependency global sequence number had on confounder.

Modified: incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/crypto/GlobalSequenceNumber.java
==============================================================================
--- incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/crypto/GlobalSequenceNumber.java
(original)
+++ incubator/directory/kerberos/trunk/kerberos/src/java/org/apache/kerberos/crypto/GlobalSequenceNumber.java
Tue Nov  9 04:22:26 2004
@@ -16,28 +16,47 @@
  */
 package org.apache.kerberos.crypto;
 
-public class GlobalSequenceNumber implements SequenceNumber {
+import java.security.SecureRandom;
 
-	private int _sequenceNumber = Confounder.intValue();
+public class GlobalSequenceNumber implements SequenceNumber
+{
+    private static final SecureRandom random = new SecureRandom();
 
-	public GlobalSequenceNumber(int start) {
-		_sequenceNumber = start;
+	private int sequenceNumber = randomInt();
+
+	public GlobalSequenceNumber(int start)
+    {
+		sequenceNumber = start;
 	}
 	
-	public synchronized void init() {
-		_sequenceNumber = Confounder.intValue();
+	public synchronized void init()
+    {
+		sequenceNumber = randomInt();
 	}
 	
-	public synchronized int current() {
-		return _sequenceNumber;
+	public synchronized int current()
+    {
+		return sequenceNumber;
 	}
 
-	public synchronized int next() {
-		return _sequenceNumber + 1;
+	public synchronized int next()
+    {
+		return sequenceNumber + 1;
 	}
 	
-	public synchronized void step() {
-		_sequenceNumber++;
+	public synchronized void step()
+    {
+		sequenceNumber++;
+	}
+
+	private int randomInt()
+    {
+        byte[] data = new byte[4];
+        random.nextBytes(data);
+		int result = 0;
+		for (int i = 0; i < 4; i++)
+			result += data[i] * (16 ^ i);
+		return result;
 	}
 }
 

Mime
View raw message