Title: [828] trunk/jopenssl/src/java/org/jruby/ext/openssl: jopenssl cleanup: remove extraneous debug code; fix DH#params to use not-yet-deprecated RubyHash API.
Revision
828
Author
bill_dortch
Date
2007-12-09 18:38:16 -0500 (Sun, 09 Dec 2007)

Log Message

jopenssl cleanup: remove extraneous debug code; fix DH#params to use not-yet-deprecated RubyHash API.

Modified Paths

Diff

Modified: trunk/jopenssl/src/java/org/jruby/ext/openssl/BN.java (827 => 828)


--- trunk/jopenssl/src/java/org/jruby/ext/openssl/BN.java	2007-12-09 11:37:59 UTC (rev 827)
+++ trunk/jopenssl/src/java/org/jruby/ext/openssl/BN.java	2007-12-09 23:38:16 UTC (rev 828)
@@ -623,7 +623,6 @@
             if (safe) {
                 do {
                     q = new BigInteger(qbits, 2, secureRandom);
-                    //q = BigInteger.probablePrime(qbits, secureRandom);
                     p = q.shiftLeft(1).setBit(0);
                 } while (!(p.isProbablePrime(DEFAULT_CERTAINTY) && q.isProbablePrime(DEFAULT_CERTAINTY)));
             } else {
@@ -692,18 +691,15 @@
 
         byte[] buf;
         random.nextBytes(buf = new byte[bytes]);
-        // System.out.println("original bits = " + new BigInteger(1, buf).bitLength());
         if (top >= 0) {
             if (top == 0) {
                 buf[0] |= (1 << bit);
             } else {
-                if (bit == 0)
-                {
+                if (bit == 0) {
                     buf[0] = 1;
                     buf[1] |= 0x80;
                 }
-                else
-                {
+                else {
                     buf[0] |= (3 << (bit - 1));
                 }
             }
@@ -712,7 +708,6 @@
         if (bottom) {
             buf[bytes-1] |= 1;
         }
-        // System.out.println("modified bits = " + new BigInteger(1, buf).bitLength());
         
         // treating result as unsigned
         return new BigInteger(1, buf);

Modified: trunk/jopenssl/src/java/org/jruby/ext/openssl/PKeyDH.java (827 => 828)


--- trunk/jopenssl/src/java/org/jruby/ext/openssl/PKeyDH.java	2007-12-09 11:37:59 UTC (rev 827)
+++ trunk/jopenssl/src/java/org/jruby/ext/openssl/PKeyDH.java	2007-12-09 23:38:16 UTC (rev 828)
@@ -33,6 +33,7 @@
 import java.math.BigInteger;
 import java.security.SecureRandom;
 import java.security.spec.InvalidParameterSpecException;
+import java.util.HashMap;
 
 import javax.crypto.spec.DHParameterSpec;
 
@@ -338,15 +339,14 @@
             y = this.dh_pub_key;
         }
         Ruby runtime = getRuntime();
-        RubyHash params = RubyHash.newHash(runtime);
-
-        // FIXME: aset deprecated in JRuby 1.1, but no other backward-compatible option (?)
-        params.aset(runtime.newString("p"), BN.newBN(runtime, p));
-        params.aset(runtime.newString("g"), BN.newBN(runtime, g));
-        params.aset(runtime.newString("pub_key"), BN.newBN(runtime, x));
-        params.aset(runtime.newString("priv_key"), BN.newBN(runtime, y));
+        HashMap params = new HashMap();
         
-        return params;
+        params.put(runtime.newString("p"), BN.newBN(runtime, p));
+        params.put(runtime.newString("g"), BN.newBN(runtime, g));
+        params.put(runtime.newString("pub_key"), BN.newBN(runtime, x));
+        params.put(runtime.newString("priv_key"), BN.newBN(runtime, y));
+        
+        return RubyHash.newHash(runtime, params, runtime.getNil());
     }
     
     // don't need synchronized as value is volatile
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to