summaryrefslogtreecommitdiff
path: root/gnu/javax/crypto/key/dh/GnuDHPrivateKey.java
diff options
context:
space:
mode:
authorRaif S. Naffah <raif@swiftdsl.com.au>2006-06-28 11:16:52 +0000
committerRaif S. Naffah <raif@swiftdsl.com.au>2006-06-28 11:16:52 +0000
commit5fcf70a20c4889826eeb0d3b6b7a935f85197000 (patch)
tree4ebbb77eeab58c41e4d70cf490e02b0f89a8b09f /gnu/javax/crypto/key/dh/GnuDHPrivateKey.java
parent5b665794bbdf633aab08c683643e3f776bb54a5c (diff)
downloadclasspath-5fcf70a20c4889826eeb0d3b6b7a935f85197000.tar.gz
2006-06-28 Raif S. Naffah <raif@swiftdsl.com.au>
* gnu/javax/crypto/key/dh/GnuDHPublicKey.java (str): New field. (toString): New method. * gnu/javax/crypto/key/dh/GnuDHPrivateKey.java (str): New field. (toString): New method. * gnu/javax/crypto/key/dh/GnuDHKey.java (str): New field. (toString): New method. * gnu/javax/crypto/key/dh/DHKeyPairPKCS8Codec.java (encodePrivateKey): Handle case when Q is null. (decodePrivateKey): Likewise. * gnu/javax/crypto/key/dh/DHKeyPairX509Codec.java (encodePublicKey): Likewise. (decodePublicKey): Likewise. * gnu/javax/crypto/jce/GnuCrypto.java (run): Added AlgorithmParameters aliases for all block ciphers. * gnu/javax/crypto/jce/DiffieHellmanImpl.java (result): Changed to byte[]. (engineDoPhase): Compute fully the shared secret. (checkState): New method. (reset): Likewise. (engineGenerateSecret()): Reset key-agreement before returning. (engineGenerateSecret(byte[],int)): Check for short-buffer. Reset key-agreement before returning. (engineGenerateSecret(String)): Reset key-agreement before returning. (engineInit(Key,SecureRandom)): Call reset() before returning. * gnu/javax/crypto/jce/params/BlockCipherParameters.java (log): New field. (engineInit): Replace printing to System.out with conditional logging. * gnu/javax/crypto/jce/cipher/CipherAdapter.java (engineInitHandler): When the key-size is not specified, attempt best effort to find a suitable value among those advertised by the cipher before setting it to the length of provided key material.
Diffstat (limited to 'gnu/javax/crypto/key/dh/GnuDHPrivateKey.java')
-rw-r--r--gnu/javax/crypto/key/dh/GnuDHPrivateKey.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/gnu/javax/crypto/key/dh/GnuDHPrivateKey.java b/gnu/javax/crypto/key/dh/GnuDHPrivateKey.java
index 70b684b77..f60343c54 100644
--- a/gnu/javax/crypto/key/dh/GnuDHPrivateKey.java
+++ b/gnu/javax/crypto/key/dh/GnuDHPrivateKey.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package gnu.javax.crypto.key.dh;
+import gnu.classpath.SystemProperties;
+import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.key.IKeyPairCodec;
@@ -63,6 +65,8 @@ public class GnuDHPrivateKey extends GnuDHKey implements DHPrivateKey
/** The private exponent. */
private final BigInteger x;
+ /** String representation of this key. Cached for speed. */
+ private transient String str;
// Constructor(s)
// -------------------------------------------------------------------------
@@ -193,4 +197,18 @@ public class GnuDHPrivateKey extends GnuDHKey implements DHPrivateKey
DHPrivateKey that = (DHPrivateKey) obj;
return super.equals(that) && x.equals(that.getX());
}
+ public String toString()
+ {
+ if (str == null)
+ {
+ String ls = SystemProperties.getProperty("line.separator");
+ str = new StringBuilder(this.getClass().getName()).append("(")
+ .append(super.toString()).append(",").append(ls)
+ .append("x=0x").append(Configuration.DEBUG ? x.toString(16)
+ : "**...*").append(ls)
+ .append(")")
+ .toString();
+ }
+ return str;
+ }
}