diff --git a/core/java/src/net/i2p/crypto/KeyGenerator.java b/core/java/src/net/i2p/crypto/KeyGenerator.java index fa85bd456ea142bc1ce75df2083426c2945d391a..710cddabb3da9b6e4836e753db5fce23f345687e 100644 --- a/core/java/src/net/i2p/crypto/KeyGenerator.java +++ b/core/java/src/net/i2p/crypto/KeyGenerator.java @@ -159,15 +159,16 @@ public final class KeyGenerator { BigInteger aalpha = CryptoConstants.elgg.modPow(a, CryptoConstants.elgp); SimpleDataStructure[] keys = new SimpleDataStructure[2]; - keys[0] = new PublicKey(); - keys[1] = new PrivateKey(); // bigInteger.toByteArray returns SIGNED integers, but since they'return positive, // signed two's complement is the same as unsigned try { - keys[0].setData(SigUtil.rectify(aalpha, PublicKey.KEYSIZE_BYTES)); - keys[1].setData(SigUtil.rectify(a, PrivateKey.KEYSIZE_BYTES)); + PublicKey pub = new PublicKey(SigUtil.rectify(aalpha, PublicKey.KEYSIZE_BYTES)); + keys[0] = pub; + keys[1] = new PrivateKey(EncType.ELGAMAL_2048, + SigUtil.rectify(a, PrivateKey.KEYSIZE_BYTES), + pub); } catch (InvalidKeyException ike) { throw new IllegalArgumentException(ike); } @@ -199,7 +200,7 @@ public final class KeyGenerator { byte[] bpub = new byte[32]; Curve25519.eval(bpub, 0, bpriv, null); pub = new PublicKey(type, bpub); - priv = new PrivateKey(type, bpriv); + priv = new PrivateKey(type, bpriv, pub); break; default: diff --git a/core/java/src/net/i2p/data/PrivateKey.java b/core/java/src/net/i2p/data/PrivateKey.java index e3a3b60f4172ccaf75849424602f20151f08fda5..41c544e17207cdf40d1bc0082725daa91ee37991 100644 --- a/core/java/src/net/i2p/data/PrivateKey.java +++ b/core/java/src/net/i2p/data/PrivateKey.java @@ -123,6 +123,7 @@ public class PrivateKey extends SimpleDataStructure implements Destroyable { Arrays.fill(data, (byte) 0); SimpleByteCache.release(data); } + _pubKey = null; } /**