I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Unverified Commit 0826b1e2 authored by zzz's avatar zzz
Browse files

Crypto: Throw checked exception

for unimplemented ElG import, so CertUtil.loadPrivateKey() will
continue processing and then
fail with the correct exception and error message on bad input.
Pull constant KeySpec out of loop.
parent 5d3c29fb
No related branches found
No related tags found
No related merge requests found
......@@ -349,9 +349,9 @@ public final class CertUtil {
throw new CertificateEncodingException("bad base64 cert");
PrivateKey rv = null;
// try all the types
KeySpec ks = new PKCS8EncodedKeySpec(data);
for (SigAlgo algo : EnumSet.allOf(SigAlgo.class)) {
try {
KeySpec ks = new PKCS8EncodedKeySpec(data);
String alg = algo.getName();
KeyFactory kf = KeyFactory.getInstance(alg);
rv = kf.generatePrivate(ks);
......
......@@ -4,6 +4,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.math.BigInteger;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import javax.crypto.interfaces.DHPrivateKey;
......@@ -65,9 +66,9 @@ public class ElGamalPrivateKeyImpl
}
public ElGamalPrivateKeyImpl(
PKCS8EncodedKeySpec spec)
PKCS8EncodedKeySpec spec) throws InvalidKeySpecException
{
throw new UnsupportedOperationException("todo");
throw new InvalidKeySpecException("todo");
//this.x = spec.getX();
//this.elSpec = new ElGamalParameterSpec(spec.getP(), spec.getG());
}
......
......@@ -4,6 +4,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.math.BigInteger;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
import javax.crypto.interfaces.DHPublicKey;
......@@ -60,9 +61,9 @@ public class ElGamalPublicKeyImpl
}
public ElGamalPublicKeyImpl(
X509EncodedKeySpec spec)
X509EncodedKeySpec spec) throws InvalidKeySpecException
{
throw new UnsupportedOperationException("todo");
throw new InvalidKeySpecException("todo");
//this.y = y;
//this.elSpec = elSpec;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment