diff --git a/core/java/src/net/i2p/crypto/EncType.java b/core/java/src/net/i2p/crypto/EncType.java index 97b630855..9af047106 100644 --- a/core/java/src/net/i2p/crypto/EncType.java +++ b/core/java/src/net/i2p/crypto/EncType.java @@ -113,6 +113,9 @@ public enum EncType { private boolean x_isAvailable() { if (ELGAMAL_2048 == this) return true; + // EC types are placeholders for now + if (base == EncAlgo.EC) + return false; try { getParams(); } catch (InvalidParameterSpecException e) { diff --git a/core/java/src/net/i2p/crypto/KeyPair.java b/core/java/src/net/i2p/crypto/KeyPair.java index 8fe0131dd..9af4fc841 100644 --- a/core/java/src/net/i2p/crypto/KeyPair.java +++ b/core/java/src/net/i2p/crypto/KeyPair.java @@ -13,9 +13,15 @@ public class KeyPair { private final PublicKey pub; private final PrivateKey priv; + /** + * @param publicKey non-null, same EncType as privateKey + * @param privateKey non-null, same EncType as publicKey + */ public KeyPair(PublicKey publicKey, PrivateKey privateKey) { pub = publicKey; priv = privateKey; + if (pub.getType() != priv.getType()) + throw new IllegalArgumentException(); } public PublicKey getPublic() { diff --git a/core/java/src/net/i2p/data/PrivateKey.java b/core/java/src/net/i2p/data/PrivateKey.java index 054931a88..13872cb34 100644 --- a/core/java/src/net/i2p/data/PrivateKey.java +++ b/core/java/src/net/i2p/data/PrivateKey.java @@ -53,11 +53,10 @@ public class PrivateKey extends SimpleDataStructure { * @since 0.9.38 */ public PrivateKey(EncType type, byte data[]) { - super(); - _type = type; + this(type); if (data == null) throw new IllegalArgumentException("Data must be specified"); - _data = data; + setData(data); } /** constructs from base64 diff --git a/core/java/src/net/i2p/data/PublicKey.java b/core/java/src/net/i2p/data/PublicKey.java index cf2bae769..ea459c454 100644 --- a/core/java/src/net/i2p/data/PublicKey.java +++ b/core/java/src/net/i2p/data/PublicKey.java @@ -76,11 +76,10 @@ public class PublicKey extends SimpleDataStructure { * @since 0.9.38 */ public PublicKey(EncType type, byte data[]) { - super(); - _type = type; + this(type); if (data == null) throw new IllegalArgumentException("Data must be specified"); - _data = data; + setData(data); } /** constructs from base64