Search in sources :

Example 1 with XMSSMTKeyGenerationParameters

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

the class XMSSMTKeyPairGeneratorSpi method generateKeyPair.

public KeyPair generateKeyPair() {
    if (!initialised) {
        param = new XMSSMTKeyGenerationParameters(new XMSSMTParameters(10, 20, new SHA512Digest()), random);
        engine.init(param);
        initialised = true;
    }
    AsymmetricCipherKeyPair pair = engine.generateKeyPair();
    XMSSMTPublicKeyParameters pub = (XMSSMTPublicKeyParameters) pair.getPublic();
    XMSSMTPrivateKeyParameters priv = (XMSSMTPrivateKeyParameters) pair.getPrivate();
    return new KeyPair(new BCXMSSMTPublicKey(treeDigest, pub), new BCXMSSMTPrivateKey(treeDigest, priv));
}
Also used : SHA512Digest(com.github.zhenwei.core.crypto.digests.SHA512Digest) KeyPair(java.security.KeyPair) AsymmetricCipherKeyPair(com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair) XMSSMTKeyGenerationParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSMTKeyGenerationParameters) XMSSMTPublicKeyParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSMTPublicKeyParameters) XMSSMTParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSMTParameters) AsymmetricCipherKeyPair(com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair) XMSSMTPrivateKeyParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSMTPrivateKeyParameters)

Example 2 with XMSSMTKeyGenerationParameters

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

the class XMSSMTKeyPairGeneratorSpi method initialize.

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

Aggregations

SHA512Digest (com.github.zhenwei.core.crypto.digests.SHA512Digest)2 XMSSMTKeyGenerationParameters (com.github.zhenwei.core.pqc.crypto.xmss.XMSSMTKeyGenerationParameters)2 XMSSMTParameters (com.github.zhenwei.core.pqc.crypto.xmss.XMSSMTParameters)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 XMSSMTPrivateKeyParameters (com.github.zhenwei.core.pqc.crypto.xmss.XMSSMTPrivateKeyParameters)1 XMSSMTPublicKeyParameters (com.github.zhenwei.core.pqc.crypto.xmss.XMSSMTPublicKeyParameters)1 XMSSMTParameterSpec (com.github.zhenwei.provider.jcajce.spec.XMSSMTParameterSpec)1 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1 KeyPair (java.security.KeyPair)1