Search in sources :

Example 1 with EdDSAParameterSpec

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;
}
Also used : EdDSAParameterSpec(org.bouncycastle.jcajce.spec.EdDSAParameterSpec)

Example 2 with EdDSAParameterSpec

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);
}
Also used : EdDSAParameterSpec(org.bouncycastle.jcajce.spec.EdDSAParameterSpec) ECGenParameterSpec(java.security.spec.ECGenParameterSpec) SecureRandom(java.security.SecureRandom) SignatureAlgorithm(io.jans.as.model.crypto.signature.SignatureAlgorithm) KeyPairGenerator(java.security.KeyPairGenerator) AlgorithmFamily(io.jans.as.model.crypto.signature.AlgorithmFamily)

Example 3 with EdDSAParameterSpec

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;
}
Also used : EdDSAParameterSpec(org.bouncycastle.jcajce.spec.EdDSAParameterSpec)

Aggregations

EdDSAParameterSpec (org.bouncycastle.jcajce.spec.EdDSAParameterSpec)3 AlgorithmFamily (io.jans.as.model.crypto.signature.AlgorithmFamily)1 SignatureAlgorithm (io.jans.as.model.crypto.signature.SignatureAlgorithm)1 KeyPairGenerator (java.security.KeyPairGenerator)1 SecureRandom (java.security.SecureRandom)1 ECGenParameterSpec (java.security.spec.ECGenParameterSpec)1