Search in sources :

Example 1 with XMSSKeyGenerationParameters

use of com.github.zhenwei.core.pqc.crypto.xmss.XMSSKeyGenerationParameters in project LinLong-Java by zhenwei1108.

the class XMSSKeyPairGeneratorSpi method generateKeyPair.

public KeyPair generateKeyPair() {
    if (!initialised) {
        param = new XMSSKeyGenerationParameters(new XMSSParameters(10, new SHA512Digest()), random);
        engine.init(param);
        initialised = true;
    }
    AsymmetricCipherKeyPair pair = engine.generateKeyPair();
    XMSSPublicKeyParameters pub = (XMSSPublicKeyParameters) pair.getPublic();
    XMSSPrivateKeyParameters priv = (XMSSPrivateKeyParameters) pair.getPrivate();
    return new KeyPair(new BCXMSSPublicKey(treeDigest, pub), new BCXMSSPrivateKey(treeDigest, priv));
}
Also used : SHA512Digest(com.github.zhenwei.core.crypto.digests.SHA512Digest) XMSSParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSParameters) KeyPair(java.security.KeyPair) AsymmetricCipherKeyPair(com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair) XMSSPrivateKeyParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSPrivateKeyParameters) XMSSKeyGenerationParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSKeyGenerationParameters) XMSSPublicKeyParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSPublicKeyParameters) AsymmetricCipherKeyPair(com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair)

Example 2 with XMSSKeyGenerationParameters

use of com.github.zhenwei.core.pqc.crypto.xmss.XMSSKeyGenerationParameters in project LinLong-Java by zhenwei1108.

the class XMSSKeyPairGeneratorSpi method initialize.

public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException {
    if (!(params instanceof XMSSParameterSpec)) {
        throw new InvalidAlgorithmParameterException("parameter object not a XMSSParameterSpec");
    }
    XMSSParameterSpec xmssParams = (XMSSParameterSpec) params;
    if (xmssParams.getTreeDigest().equals(XMSSParameterSpec.SHA256)) {
        treeDigest = NISTObjectIdentifiers.id_sha256;
        param = new XMSSKeyGenerationParameters(new XMSSParameters(xmssParams.getHeight(), new SHA256Digest()), random);
    } else if (xmssParams.getTreeDigest().equals(XMSSParameterSpec.SHA512)) {
        treeDigest = NISTObjectIdentifiers.id_sha512;
        param = new XMSSKeyGenerationParameters(new XMSSParameters(xmssParams.getHeight(), new SHA512Digest()), random);
    } else if (xmssParams.getTreeDigest().equals(XMSSParameterSpec.SHAKE128)) {
        treeDigest = NISTObjectIdentifiers.id_shake128;
        param = new XMSSKeyGenerationParameters(new XMSSParameters(xmssParams.getHeight(), new SHAKEDigest(128)), random);
    } else if (xmssParams.getTreeDigest().equals(XMSSParameterSpec.SHAKE256)) {
        treeDigest = NISTObjectIdentifiers.id_shake256;
        param = new XMSSKeyGenerationParameters(new XMSSParameters(xmssParams.getHeight(), new SHAKEDigest(256)), random);
    }
    engine.init(param);
    initialised = true;
}
Also used : SHA512Digest(com.github.zhenwei.core.crypto.digests.SHA512Digest) XMSSParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSParameters) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) SHA256Digest(com.github.zhenwei.core.crypto.digests.SHA256Digest) XMSSKeyGenerationParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSKeyGenerationParameters) XMSSParameterSpec(com.github.zhenwei.provider.jcajce.spec.XMSSParameterSpec) SHAKEDigest(com.github.zhenwei.core.crypto.digests.SHAKEDigest)

Aggregations

SHA512Digest (com.github.zhenwei.core.crypto.digests.SHA512Digest)2 XMSSKeyGenerationParameters (com.github.zhenwei.core.pqc.crypto.xmss.XMSSKeyGenerationParameters)2 XMSSParameters (com.github.zhenwei.core.pqc.crypto.xmss.XMSSParameters)2 AsymmetricCipherKeyPair (com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair)1 SHA256Digest (com.github.zhenwei.core.crypto.digests.SHA256Digest)1 SHAKEDigest (com.github.zhenwei.core.crypto.digests.SHAKEDigest)1 XMSSPrivateKeyParameters (com.github.zhenwei.core.pqc.crypto.xmss.XMSSPrivateKeyParameters)1 XMSSPublicKeyParameters (com.github.zhenwei.core.pqc.crypto.xmss.XMSSPublicKeyParameters)1 XMSSParameterSpec (com.github.zhenwei.provider.jcajce.spec.XMSSParameterSpec)1 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1 KeyPair (java.security.KeyPair)1