Search in sources :

Example 1 with SPHINCS256KeyGenerationParameters

use of org.bouncycastle.pqc.crypto.sphincs.SPHINCS256KeyGenerationParameters in project jmulticard by ctt-gob-es.

the class Sphincs256KeyPairGeneratorSpi method initialize.

public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException {
    if (!(params instanceof SPHINCS256KeyGenParameterSpec)) {
        throw new InvalidAlgorithmParameterException("parameter object not a SPHINCS256KeyGenParameterSpec");
    }
    SPHINCS256KeyGenParameterSpec sphincsParams = (SPHINCS256KeyGenParameterSpec) params;
    if (sphincsParams.getTreeDigest().equals(SPHINCS256KeyGenParameterSpec.SHA512_256)) {
        treeDigest = NISTObjectIdentifiers.id_sha512_256;
        param = new SPHINCS256KeyGenerationParameters(random, new SHA512tDigest(256));
    } else if (sphincsParams.getTreeDigest().equals(SPHINCS256KeyGenParameterSpec.SHA3_256)) {
        treeDigest = NISTObjectIdentifiers.id_sha3_256;
        param = new SPHINCS256KeyGenerationParameters(random, new SHA3Digest(256));
    }
    engine.init(param);
    initialised = true;
}
Also used : SHA512tDigest(org.bouncycastle.crypto.digests.SHA512tDigest) SHA3Digest(org.bouncycastle.crypto.digests.SHA3Digest) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) SPHINCS256KeyGenParameterSpec(org.bouncycastle.pqc.jcajce.spec.SPHINCS256KeyGenParameterSpec) SPHINCS256KeyGenerationParameters(org.bouncycastle.pqc.crypto.sphincs.SPHINCS256KeyGenerationParameters)

Example 2 with SPHINCS256KeyGenerationParameters

use of org.bouncycastle.pqc.crypto.sphincs.SPHINCS256KeyGenerationParameters in project jmulticard by ctt-gob-es.

the class Sphincs256KeyPairGeneratorSpi method generateKeyPair.

public KeyPair generateKeyPair() {
    if (!initialised) {
        param = new SPHINCS256KeyGenerationParameters(random, new SHA512tDigest(256));
        engine.init(param);
        initialised = true;
    }
    AsymmetricCipherKeyPair pair = engine.generateKeyPair();
    SPHINCSPublicKeyParameters pub = (SPHINCSPublicKeyParameters) pair.getPublic();
    SPHINCSPrivateKeyParameters priv = (SPHINCSPrivateKeyParameters) pair.getPrivate();
    return new KeyPair(new BCSphincs256PublicKey(treeDigest, pub), new BCSphincs256PrivateKey(treeDigest, priv));
}
Also used : SHA512tDigest(org.bouncycastle.crypto.digests.SHA512tDigest) KeyPair(java.security.KeyPair) AsymmetricCipherKeyPair(org.bouncycastle.crypto.AsymmetricCipherKeyPair) SPHINCS256KeyGenerationParameters(org.bouncycastle.pqc.crypto.sphincs.SPHINCS256KeyGenerationParameters) SPHINCSPrivateKeyParameters(org.bouncycastle.pqc.crypto.sphincs.SPHINCSPrivateKeyParameters) SPHINCSPublicKeyParameters(org.bouncycastle.pqc.crypto.sphincs.SPHINCSPublicKeyParameters) AsymmetricCipherKeyPair(org.bouncycastle.crypto.AsymmetricCipherKeyPair)

Aggregations

SHA512tDigest (org.bouncycastle.crypto.digests.SHA512tDigest)2 SPHINCS256KeyGenerationParameters (org.bouncycastle.pqc.crypto.sphincs.SPHINCS256KeyGenerationParameters)2 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1 KeyPair (java.security.KeyPair)1 AsymmetricCipherKeyPair (org.bouncycastle.crypto.AsymmetricCipherKeyPair)1 SHA3Digest (org.bouncycastle.crypto.digests.SHA3Digest)1 SPHINCSPrivateKeyParameters (org.bouncycastle.pqc.crypto.sphincs.SPHINCSPrivateKeyParameters)1 SPHINCSPublicKeyParameters (org.bouncycastle.pqc.crypto.sphincs.SPHINCSPublicKeyParameters)1 SPHINCS256KeyGenParameterSpec (org.bouncycastle.pqc.jcajce.spec.SPHINCS256KeyGenParameterSpec)1