diff --git a/core/java/src/net/i2p/crypto/DSAEngine.java b/core/java/src/net/i2p/crypto/DSAEngine.java index a7e18e1f7d..d3055f8b27 100644 --- a/core/java/src/net/i2p/crypto/DSAEngine.java +++ b/core/java/src/net/i2p/crypto/DSAEngine.java @@ -42,6 +42,7 @@ import java.security.interfaces.ECKey; import java.security.interfaces.RSAKey; import net.i2p.I2PAppContext; +import net.i2p.crypto.eddsa.EdDSAKey; import net.i2p.data.Hash; import net.i2p.data.Signature; import net.i2p.data.SigningPrivateKey; @@ -549,7 +550,11 @@ public class DSAEngine { throw new IllegalArgumentException("type mismatch hash=" + hash.getClass() + " key=" + type); String algo = getRawAlgo(type); - java.security.Signature jsig = java.security.Signature.getInstance(algo); + java.security.Signature jsig; + if (type.getBaseAlgorithm() == SigAlgo.EdDSA) + jsig = new net.i2p.crypto.eddsa.EdDSAEngine(); // Ignore algo, EdDSAKey includes a hash specification. + else + jsig = java.security.Signature.getInstance(algo); jsig.initVerify(pubKey); jsig.update(hash.getData()); boolean rv = jsig.verify(SigUtil.toJavaSig(signature)); @@ -623,7 +628,11 @@ public class DSAEngine { if (type.getHashLen() != hashlen) throw new IllegalArgumentException("type mismatch hash=" + hash.getClass() + " key=" + type); - java.security.Signature jsig = java.security.Signature.getInstance(algo); + java.security.Signature jsig; + if (type.getBaseAlgorithm() == SigAlgo.EdDSA) + jsig = new net.i2p.crypto.eddsa.EdDSAEngine(); // Ignore algo, EdDSAKey includes a hash specification. + else + jsig = java.security.Signature.getInstance(algo); jsig.initSign(privKey, _context.random()); jsig.update(hash.getData()); return SigUtil.fromJavaSig(jsig.sign(), type); @@ -650,6 +659,8 @@ public class DSAEngine { return "NONEwithDSA"; case EC: return "NONEwithECDSA"; + case EdDSA: + return "NONEwithEdDSA"; case RSA: return "NONEwithRSA"; default: @@ -663,6 +674,8 @@ public class DSAEngine { return "NONEwithDSA"; if (key instanceof ECKey) return "NONEwithECDSA"; + if (key instanceof EdDSAKey) + return "NONEwithEdDSA"; if (key instanceof RSAKey) return "NONEwithRSA"; throw new IllegalArgumentException();