use of org.bouncycastle.jcajce.spec.EdDSAParameterSpec in project hotmoka by Hotmoka.
the class ED25519 method mkKeyPairGenerator.
@Override
protected KeyPairGenerator mkKeyPairGenerator(SecureRandom random) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException {
var keyPairGenerator = KeyPairGenerator.getInstance("Ed25519", "BC");
keyPairGenerator.initialize(new EdDSAParameterSpec(EdDSAParameterSpec.Ed25519), random);
return keyPairGenerator;
}
use of org.bouncycastle.jcajce.spec.EdDSAParameterSpec in project jans by JanssenProject.
the class AuthCryptoProvider method generateKeySignature.
private JSONObject generateKeySignature(Algorithm algorithm, Long expirationTime, int keyLength) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, OperatorCreationException, CertificateException, KeyStoreException, IOException {
SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.fromString(algorithm.getParamName());
if (signatureAlgorithm == null) {
algorithm = Algorithm.ES384;
signatureAlgorithm = SignatureAlgorithm.ES384;
}
KeyPairGenerator keyGen = null;
final AlgorithmFamily algorithmFamily = algorithm.getFamily();
switch(algorithmFamily) {
case RSA:
{
keyGen = KeyPairGenerator.getInstance(algorithmFamily.toString(), "BC");
keyGen.initialize(keyLength, new SecureRandom());
break;
}
case EC:
{
ECGenParameterSpec eccgen = new ECGenParameterSpec(signatureAlgorithm.getCurve().getAlias());
keyGen = KeyPairGenerator.getInstance(algorithmFamily.toString(), "BC");
keyGen.initialize(eccgen, new SecureRandom());
break;
}
case ED:
{
EdDSAParameterSpec edSpec = new EdDSAParameterSpec(signatureAlgorithm.getCurve().getAlias());
keyGen = KeyPairGenerator.getInstance(signatureAlgorithm.getName(), "BC");
keyGen.initialize(edSpec, new SecureRandom());
break;
}
default:
{
throw new IllegalStateException("The provided signature algorithm parameter is not supported: algorithmFamily = " + algorithmFamily);
}
}
return getJson(algorithm, keyGen, signatureAlgorithm.getAlgorithm(), expirationTime);
}
use of org.bouncycastle.jcajce.spec.EdDSAParameterSpec in project hotmoka by Hotmoka.
the class ED25519DET method mkKeyPairGenerator.
@Override
protected KeyPairGenerator mkKeyPairGenerator(SecureRandom random) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException {
var keyPairGenerator = KeyPairGenerator.getInstance("Ed25519", "BC");
keyPairGenerator.initialize(new EdDSAParameterSpec(EdDSAParameterSpec.Ed25519), random);
return keyPairGenerator;
}
Aggregations