use of net.i2p.crypto.eddsa.EdDSAEngine in project i2p.i2p by i2p.
the class DSAEngine method altSign.
/**
* Generic sign any type.
*
* @throws GeneralSecurityException if algorithm unvailable or on other errors
* @since 0.9.9 added off/len 0.9.12
*/
private Signature altSign(byte[] data, int offset, int len, SigningPrivateKey privateKey) throws GeneralSecurityException {
SigType type = privateKey.getType();
if (type == SigType.DSA_SHA1)
return altSignSHA1(data, offset, len, privateKey);
PrivateKey privKey = SigUtil.toJavaKey(privateKey);
byte[] sigbytes;
if (type.getBaseAlgorithm() == SigAlgo.EdDSA) {
// take advantage of one-shot mode
EdDSAEngine jsig = new EdDSAEngine(type.getDigestInstance());
jsig.initSign(privKey);
sigbytes = jsig.signOneShot(data, offset, len);
} else {
java.security.Signature jsig = java.security.Signature.getInstance(type.getAlgorithmName());
jsig.initSign(privKey, _context.random());
jsig.update(data, offset, len);
sigbytes = jsig.sign();
}
return SigUtil.fromJavaSig(sigbytes, type);
}
Aggregations