Search in sources :

Example 1 with XMSSMTKeyParams

use of org.bouncycastle.pqc.asn1.XMSSMTKeyParams in project jmulticard by ctt-gob-es.

the class SubjectPublicKeyInfoFactory method createSubjectPublicKeyInfo.

/**
 * Create a SubjectPublicKeyInfo public key.
 *
 * @param publicKey the key to be encoded into the info object.
 * @return a SubjectPublicKeyInfo representing the key.
 * @throws java.io.IOException on an error encoding the key
 */
public static SubjectPublicKeyInfo createSubjectPublicKeyInfo(AsymmetricKeyParameter publicKey) throws IOException {
    if (publicKey instanceof QTESLAPublicKeyParameters) {
        QTESLAPublicKeyParameters keyParams = (QTESLAPublicKeyParameters) publicKey;
        AlgorithmIdentifier algorithmIdentifier = Utils.qTeslaLookupAlgID(keyParams.getSecurityCategory());
        return new SubjectPublicKeyInfo(algorithmIdentifier, keyParams.getPublicData());
    } else if (publicKey instanceof SPHINCSPublicKeyParameters) {
        SPHINCSPublicKeyParameters params = (SPHINCSPublicKeyParameters) publicKey;
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.sphincs256, new SPHINCS256KeyParams(Utils.sphincs256LookupTreeAlgID(params.getTreeDigest())));
        return new SubjectPublicKeyInfo(algorithmIdentifier, params.getKeyData());
    } else if (publicKey instanceof NHPublicKeyParameters) {
        NHPublicKeyParameters params = (NHPublicKeyParameters) publicKey;
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.newHope);
        return new SubjectPublicKeyInfo(algorithmIdentifier, params.getPubData());
    } else if (publicKey instanceof LMSPublicKeyParameters) {
        LMSPublicKeyParameters params = (LMSPublicKeyParameters) publicKey;
        byte[] encoding = Composer.compose().u32str(1).bytes(params).build();
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_alg_hss_lms_hashsig);
        return new SubjectPublicKeyInfo(algorithmIdentifier, new DEROctetString(encoding));
    } else if (publicKey instanceof HSSPublicKeyParameters) {
        HSSPublicKeyParameters params = (HSSPublicKeyParameters) publicKey;
        byte[] encoding = Composer.compose().u32str(params.getL()).bytes(params.getLMSPublicKey()).build();
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_alg_hss_lms_hashsig);
        return new SubjectPublicKeyInfo(algorithmIdentifier, new DEROctetString(encoding));
    } else if (publicKey instanceof SPHINCSPlusPublicKeyParameters) {
        SPHINCSPlusPublicKeyParameters params = (SPHINCSPlusPublicKeyParameters) publicKey;
        byte[] encoding = params.getEncoded();
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(Utils.sphincsPlusOidLookup(params.getParameters()));
        return new SubjectPublicKeyInfo(algorithmIdentifier, new DEROctetString(encoding));
    } else if (publicKey instanceof CMCEPublicKeyParameters) {
        CMCEPublicKeyParameters params = (CMCEPublicKeyParameters) publicKey;
        byte[] encoding = params.getEncoded();
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(Utils.mcElieceOidLookup(params.getParameters()));
        // https://datatracker.ietf.org/doc/draft-uni-qsckeys/
        return new SubjectPublicKeyInfo(algorithmIdentifier, new CMCEPublicKey(encoding));
    } else if (publicKey instanceof XMSSPublicKeyParameters) {
        XMSSPublicKeyParameters keyParams = (XMSSPublicKeyParameters) publicKey;
        byte[] publicSeed = keyParams.getPublicSeed();
        byte[] root = keyParams.getRoot();
        byte[] keyEnc = keyParams.getEncoded();
        if (keyEnc.length > publicSeed.length + root.length) {
            AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(IsaraObjectIdentifiers.id_alg_xmss);
            return new SubjectPublicKeyInfo(algorithmIdentifier, new DEROctetString(keyEnc));
        } else {
            AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.xmss, new XMSSKeyParams(keyParams.getParameters().getHeight(), Utils.xmssLookupTreeAlgID(keyParams.getTreeDigest())));
            return new SubjectPublicKeyInfo(algorithmIdentifier, new XMSSPublicKey(publicSeed, root));
        }
    } else if (publicKey instanceof XMSSMTPublicKeyParameters) {
        XMSSMTPublicKeyParameters keyParams = (XMSSMTPublicKeyParameters) publicKey;
        byte[] publicSeed = keyParams.getPublicSeed();
        byte[] root = keyParams.getRoot();
        byte[] keyEnc = keyParams.getEncoded();
        if (keyEnc.length > publicSeed.length + root.length) {
            AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(IsaraObjectIdentifiers.id_alg_xmssmt);
            return new SubjectPublicKeyInfo(algorithmIdentifier, new DEROctetString(keyEnc));
        } else {
            AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.xmss_mt, new XMSSMTKeyParams(keyParams.getParameters().getHeight(), keyParams.getParameters().getLayers(), Utils.xmssLookupTreeAlgID(keyParams.getTreeDigest())));
            return new SubjectPublicKeyInfo(algorithmIdentifier, new XMSSMTPublicKey(keyParams.getPublicSeed(), keyParams.getRoot()));
        }
    } else if (publicKey instanceof McElieceCCA2PublicKeyParameters) {
        McElieceCCA2PublicKeyParameters pub = (McElieceCCA2PublicKeyParameters) publicKey;
        McElieceCCA2PublicKey mcEliecePub = new McElieceCCA2PublicKey(pub.getN(), pub.getT(), pub.getG(), Utils.getAlgorithmIdentifier(pub.getDigest()));
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.mcElieceCca2);
        return new SubjectPublicKeyInfo(algorithmIdentifier, mcEliecePub);
    } else if (publicKey instanceof FrodoPublicKeyParameters) {
        FrodoPublicKeyParameters params = (FrodoPublicKeyParameters) publicKey;
        byte[] encoding = params.getEncoded();
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(Utils.frodoOidLookup(params.getParameters()));
        return new SubjectPublicKeyInfo(algorithmIdentifier, (new DEROctetString(encoding)));
    } else if (publicKey instanceof SABERPublicKeyParameters) {
        SABERPublicKeyParameters params = (SABERPublicKeyParameters) publicKey;
        byte[] encoding = params.getEncoded();
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(Utils.saberOidLookup(params.getParameters()));
        // https://datatracker.ietf.org/doc/draft-uni-qsckeys/
        return new SubjectPublicKeyInfo(algorithmIdentifier, new DERSequence(new DEROctetString(encoding)));
    } else {
        throw new IOException("key parameters not recognized");
    }
}
Also used : CMCEPublicKeyParameters(org.bouncycastle.pqc.crypto.cmce.CMCEPublicKeyParameters) SABERPublicKeyParameters(org.bouncycastle.pqc.crypto.saber.SABERPublicKeyParameters) XMSSKeyParams(org.bouncycastle.pqc.asn1.XMSSKeyParams) CMCEPublicKey(org.bouncycastle.pqc.asn1.CMCEPublicKey) LMSPublicKeyParameters(org.bouncycastle.pqc.crypto.lms.LMSPublicKeyParameters) McElieceCCA2PublicKeyParameters(org.bouncycastle.pqc.crypto.mceliece.McElieceCCA2PublicKeyParameters) SubjectPublicKeyInfo(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo) DEROctetString(org.bouncycastle.asn1.DEROctetString) AlgorithmIdentifier(org.bouncycastle.asn1.x509.AlgorithmIdentifier) XMSSMTPublicKey(org.bouncycastle.pqc.asn1.XMSSMTPublicKey) DERSequence(org.bouncycastle.asn1.DERSequence) SPHINCSPublicKeyParameters(org.bouncycastle.pqc.crypto.sphincs.SPHINCSPublicKeyParameters) HSSPublicKeyParameters(org.bouncycastle.pqc.crypto.lms.HSSPublicKeyParameters) QTESLAPublicKeyParameters(org.bouncycastle.pqc.crypto.qtesla.QTESLAPublicKeyParameters) IOException(java.io.IOException) McElieceCCA2PublicKey(org.bouncycastle.pqc.asn1.McElieceCCA2PublicKey) SPHINCS256KeyParams(org.bouncycastle.pqc.asn1.SPHINCS256KeyParams) XMSSMTKeyParams(org.bouncycastle.pqc.asn1.XMSSMTKeyParams) FrodoPublicKeyParameters(org.bouncycastle.pqc.crypto.frodo.FrodoPublicKeyParameters) XMSSPublicKeyParameters(org.bouncycastle.pqc.crypto.xmss.XMSSPublicKeyParameters) XMSSMTPublicKeyParameters(org.bouncycastle.pqc.crypto.xmss.XMSSMTPublicKeyParameters) SPHINCSPlusPublicKeyParameters(org.bouncycastle.pqc.crypto.sphincsplus.SPHINCSPlusPublicKeyParameters) NHPublicKeyParameters(org.bouncycastle.pqc.crypto.newhope.NHPublicKeyParameters) XMSSPublicKey(org.bouncycastle.pqc.asn1.XMSSPublicKey)

Example 2 with XMSSMTKeyParams

use of org.bouncycastle.pqc.asn1.XMSSMTKeyParams in project LinLong-Java by zhenwei1108.

the class PrivateKeyInfoFactory method createPrivateKeyInfo.

/**
 * Create a PrivateKeyInfo representation of a private key with attributes.
 *
 * @param privateKey the key to be encoded into the info object.
 * @param attributes the set of attributes to be included.
 * @return the appropriate PrivateKeyInfo
 * @throws IOException on an error encoding the key
 */
public static PrivateKeyInfo createPrivateKeyInfo(AsymmetricKeyParameter privateKey, ASN1Set attributes) throws IOException {
    if (privateKey instanceof QTESLAPrivateKeyParameters) {
        QTESLAPrivateKeyParameters keyParams = (QTESLAPrivateKeyParameters) privateKey;
        AlgorithmIdentifier algorithmIdentifier = Utils.qTeslaLookupAlgID(keyParams.getSecurityCategory());
        return new PrivateKeyInfo(algorithmIdentifier, new DEROctetString(keyParams.getSecret()), attributes);
    } else if (privateKey instanceof SPHINCSPrivateKeyParameters) {
        SPHINCSPrivateKeyParameters params = (SPHINCSPrivateKeyParameters) privateKey;
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.sphincs256, new SPHINCS256KeyParams(Utils.sphincs256LookupTreeAlgID(params.getTreeDigest())));
        return new PrivateKeyInfo(algorithmIdentifier, new DEROctetString(params.getKeyData()));
    } else if (privateKey instanceof NHPrivateKeyParameters) {
        NHPrivateKeyParameters params = (NHPrivateKeyParameters) privateKey;
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.newHope);
        short[] privateKeyData = params.getSecData();
        byte[] octets = new byte[privateKeyData.length * 2];
        for (int i = 0; i != privateKeyData.length; i++) {
            Pack.shortToLittleEndian(privateKeyData[i], octets, i * 2);
        }
        return new PrivateKeyInfo(algorithmIdentifier, new DEROctetString(octets));
    } else if (privateKey instanceof LMSPrivateKeyParameters) {
        LMSPrivateKeyParameters params = (LMSPrivateKeyParameters) privateKey;
        byte[] encoding = Composer.compose().u32str(1).bytes(params).build();
        byte[] pubEncoding = Composer.compose().u32str(1).bytes(params.getPublicKey()).build();
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_alg_hss_lms_hashsig);
        return new PrivateKeyInfo(algorithmIdentifier, new DEROctetString(encoding), attributes, pubEncoding);
    } else if (privateKey instanceof HSSPrivateKeyParameters) {
        HSSPrivateKeyParameters params = (HSSPrivateKeyParameters) privateKey;
        byte[] encoding = Composer.compose().u32str(params.getL()).bytes(params).build();
        byte[] pubEncoding = Composer.compose().u32str(params.getL()).bytes(params.getPublicKey().getLMSPublicKey()).build();
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_alg_hss_lms_hashsig);
        return new PrivateKeyInfo(algorithmIdentifier, new DEROctetString(encoding), attributes, pubEncoding);
    } else if (privateKey instanceof XMSSPrivateKeyParameters) {
        XMSSPrivateKeyParameters keyParams = (XMSSPrivateKeyParameters) privateKey;
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.xmss, new XMSSKeyParams(keyParams.getParameters().getHeight(), Utils.xmssLookupTreeAlgID(keyParams.getTreeDigest())));
        return new PrivateKeyInfo(algorithmIdentifier, xmssCreateKeyStructure(keyParams), attributes);
    } else if (privateKey instanceof XMSSMTPrivateKeyParameters) {
        XMSSMTPrivateKeyParameters keyParams = (XMSSMTPrivateKeyParameters) privateKey;
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.xmss_mt, new XMSSMTKeyParams(keyParams.getParameters().getHeight(), keyParams.getParameters().getLayers(), Utils.xmssLookupTreeAlgID(keyParams.getTreeDigest())));
        return new PrivateKeyInfo(algorithmIdentifier, xmssmtCreateKeyStructure(keyParams), attributes);
    } else if (privateKey instanceof McElieceCCA2PrivateKeyParameters) {
        McElieceCCA2PrivateKeyParameters priv = (McElieceCCA2PrivateKeyParameters) privateKey;
        McElieceCCA2PrivateKey mcEliecePriv = new McElieceCCA2PrivateKey(priv.getN(), priv.getK(), priv.getField(), priv.getGoppaPoly(), priv.getP(), Utils.getAlgorithmIdentifier(priv.getDigest()));
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.mcElieceCca2);
        return new PrivateKeyInfo(algorithmIdentifier, mcEliecePriv);
    } else {
        throw new IOException("key parameters not recognized");
    }
}
Also used : XMSSKeyParams(com.github.zhenwei.core.pqc.asn1.XMSSKeyParams) McElieceCCA2PrivateKeyParameters(com.github.zhenwei.core.pqc.crypto.mceliece.McElieceCCA2PrivateKeyParameters) QTESLAPrivateKeyParameters(com.github.zhenwei.core.pqc.crypto.qtesla.QTESLAPrivateKeyParameters) NHPrivateKeyParameters(com.github.zhenwei.core.pqc.crypto.newhope.NHPrivateKeyParameters) McElieceCCA2PrivateKey(com.github.zhenwei.core.pqc.asn1.McElieceCCA2PrivateKey) SPHINCSPrivateKeyParameters(com.github.zhenwei.core.pqc.crypto.sphincs.SPHINCSPrivateKeyParameters) HSSPrivateKeyParameters(com.github.zhenwei.core.pqc.crypto.lms.HSSPrivateKeyParameters) IOException(java.io.IOException) DEROctetString(com.github.zhenwei.core.asn1.DEROctetString) AlgorithmIdentifier(com.github.zhenwei.core.asn1.x509.AlgorithmIdentifier) SPHINCS256KeyParams(com.github.zhenwei.core.pqc.asn1.SPHINCS256KeyParams) LMSPrivateKeyParameters(com.github.zhenwei.core.pqc.crypto.lms.LMSPrivateKeyParameters) XMSSPrivateKeyParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSPrivateKeyParameters) XMSSMTKeyParams(com.github.zhenwei.core.pqc.asn1.XMSSMTKeyParams) PrivateKeyInfo(com.github.zhenwei.core.asn1.pkcs.PrivateKeyInfo) XMSSMTPrivateKeyParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSMTPrivateKeyParameters)

Example 3 with XMSSMTKeyParams

use of org.bouncycastle.pqc.asn1.XMSSMTKeyParams in project LinLong-Java by zhenwei1108.

the class SubjectPublicKeyInfoFactory method createSubjectPublicKeyInfo.

/**
 * Create a SubjectPublicKeyInfo public key.
 *
 * @param publicKey the key to be encoded into the info object.
 * @return a SubjectPublicKeyInfo representing the key.
 * @throws IOException on an error encoding the key
 */
public static SubjectPublicKeyInfo createSubjectPublicKeyInfo(AsymmetricKeyParameter publicKey) throws IOException {
    if (publicKey instanceof QTESLAPublicKeyParameters) {
        QTESLAPublicKeyParameters keyParams = (QTESLAPublicKeyParameters) publicKey;
        AlgorithmIdentifier algorithmIdentifier = Utils.qTeslaLookupAlgID(keyParams.getSecurityCategory());
        return new SubjectPublicKeyInfo(algorithmIdentifier, keyParams.getPublicData());
    } else if (publicKey instanceof SPHINCSPublicKeyParameters) {
        SPHINCSPublicKeyParameters params = (SPHINCSPublicKeyParameters) publicKey;
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.sphincs256, new SPHINCS256KeyParams(Utils.sphincs256LookupTreeAlgID(params.getTreeDigest())));
        return new SubjectPublicKeyInfo(algorithmIdentifier, params.getKeyData());
    } else if (publicKey instanceof NHPublicKeyParameters) {
        NHPublicKeyParameters params = (NHPublicKeyParameters) publicKey;
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.newHope);
        return new SubjectPublicKeyInfo(algorithmIdentifier, params.getPubData());
    } else if (publicKey instanceof LMSPublicKeyParameters) {
        LMSPublicKeyParameters params = (LMSPublicKeyParameters) publicKey;
        byte[] encoding = Composer.compose().u32str(1).bytes(params).build();
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_alg_hss_lms_hashsig);
        return new SubjectPublicKeyInfo(algorithmIdentifier, new DEROctetString(encoding));
    } else if (publicKey instanceof HSSPublicKeyParameters) {
        HSSPublicKeyParameters params = (HSSPublicKeyParameters) publicKey;
        byte[] encoding = Composer.compose().u32str(params.getL()).bytes(params.getLMSPublicKey()).build();
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_alg_hss_lms_hashsig);
        return new SubjectPublicKeyInfo(algorithmIdentifier, new DEROctetString(encoding));
    } else if (publicKey instanceof XMSSPublicKeyParameters) {
        XMSSPublicKeyParameters keyParams = (XMSSPublicKeyParameters) publicKey;
        byte[] publicSeed = keyParams.getPublicSeed();
        byte[] root = keyParams.getRoot();
        byte[] keyEnc = keyParams.getEncoded();
        if (keyEnc.length > publicSeed.length + root.length) {
            AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(IsaraObjectIdentifiers.id_alg_xmss);
            return new SubjectPublicKeyInfo(algorithmIdentifier, new DEROctetString(keyEnc));
        } else {
            AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.xmss, new XMSSKeyParams(keyParams.getParameters().getHeight(), Utils.xmssLookupTreeAlgID(keyParams.getTreeDigest())));
            return new SubjectPublicKeyInfo(algorithmIdentifier, new XMSSPublicKey(publicSeed, root));
        }
    } else if (publicKey instanceof XMSSMTPublicKeyParameters) {
        XMSSMTPublicKeyParameters keyParams = (XMSSMTPublicKeyParameters) publicKey;
        byte[] publicSeed = keyParams.getPublicSeed();
        byte[] root = keyParams.getRoot();
        byte[] keyEnc = keyParams.getEncoded();
        if (keyEnc.length > publicSeed.length + root.length) {
            AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(IsaraObjectIdentifiers.id_alg_xmssmt);
            return new SubjectPublicKeyInfo(algorithmIdentifier, new DEROctetString(keyEnc));
        } else {
            AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.xmss_mt, new XMSSMTKeyParams(keyParams.getParameters().getHeight(), keyParams.getParameters().getLayers(), Utils.xmssLookupTreeAlgID(keyParams.getTreeDigest())));
            return new SubjectPublicKeyInfo(algorithmIdentifier, new XMSSMTPublicKey(keyParams.getPublicSeed(), keyParams.getRoot()));
        }
    } else if (publicKey instanceof McElieceCCA2PublicKeyParameters) {
        McElieceCCA2PublicKeyParameters pub = (McElieceCCA2PublicKeyParameters) publicKey;
        McElieceCCA2PublicKey mcEliecePub = new McElieceCCA2PublicKey(pub.getN(), pub.getT(), pub.getG(), Utils.getAlgorithmIdentifier(pub.getDigest()));
        AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.mcElieceCca2);
        return new SubjectPublicKeyInfo(algorithmIdentifier, mcEliecePub);
    } else {
        throw new IOException("key parameters not recognized");
    }
}
Also used : XMSSKeyParams(com.github.zhenwei.core.pqc.asn1.XMSSKeyParams) QTESLAPublicKeyParameters(com.github.zhenwei.core.pqc.crypto.qtesla.QTESLAPublicKeyParameters) LMSPublicKeyParameters(com.github.zhenwei.core.pqc.crypto.lms.LMSPublicKeyParameters) McElieceCCA2PublicKeyParameters(com.github.zhenwei.core.pqc.crypto.mceliece.McElieceCCA2PublicKeyParameters) IOException(java.io.IOException) SubjectPublicKeyInfo(com.github.zhenwei.core.asn1.x509.SubjectPublicKeyInfo) DEROctetString(com.github.zhenwei.core.asn1.DEROctetString) AlgorithmIdentifier(com.github.zhenwei.core.asn1.x509.AlgorithmIdentifier) McElieceCCA2PublicKey(com.github.zhenwei.core.pqc.asn1.McElieceCCA2PublicKey) SPHINCS256KeyParams(com.github.zhenwei.core.pqc.asn1.SPHINCS256KeyParams) XMSSMTPublicKey(com.github.zhenwei.core.pqc.asn1.XMSSMTPublicKey) XMSSMTKeyParams(com.github.zhenwei.core.pqc.asn1.XMSSMTKeyParams) XMSSPublicKeyParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSPublicKeyParameters) SPHINCSPublicKeyParameters(com.github.zhenwei.core.pqc.crypto.sphincs.SPHINCSPublicKeyParameters) XMSSMTPublicKeyParameters(com.github.zhenwei.core.pqc.crypto.xmss.XMSSMTPublicKeyParameters) HSSPublicKeyParameters(com.github.zhenwei.core.pqc.crypto.lms.HSSPublicKeyParameters) NHPublicKeyParameters(com.github.zhenwei.core.pqc.crypto.newhope.NHPublicKeyParameters) XMSSPublicKey(com.github.zhenwei.core.pqc.asn1.XMSSPublicKey)

Example 4 with XMSSMTKeyParams

use of org.bouncycastle.pqc.asn1.XMSSMTKeyParams in project LinLong-Java by zhenwei1108.

the class BCXMSSMTPrivateKey method init.

private void init(PrivateKeyInfo keyInfo) throws IOException {
    this.attributes = keyInfo.getAttributes();
    XMSSMTKeyParams keyParams = XMSSMTKeyParams.getInstance(keyInfo.getPrivateKeyAlgorithm().getParameters());
    this.treeDigest = keyParams.getTreeDigest().getAlgorithm();
    this.keyParams = (XMSSMTPrivateKeyParameters) PrivateKeyFactory.createKey(keyInfo);
}
Also used : XMSSMTKeyParams(com.github.zhenwei.core.pqc.asn1.XMSSMTKeyParams)

Example 5 with XMSSMTKeyParams

use of org.bouncycastle.pqc.asn1.XMSSMTKeyParams in project jmulticard by ctt-gob-es.

the class BCXMSSMTPrivateKey method init.

private void init(PrivateKeyInfo keyInfo) throws IOException {
    this.attributes = keyInfo.getAttributes();
    XMSSMTKeyParams keyParams = XMSSMTKeyParams.getInstance(keyInfo.getPrivateKeyAlgorithm().getParameters());
    this.treeDigest = keyParams.getTreeDigest().getAlgorithm();
    this.keyParams = (XMSSMTPrivateKeyParameters) PrivateKeyFactory.createKey(keyInfo);
}
Also used : XMSSMTKeyParams(org.bouncycastle.pqc.asn1.XMSSMTKeyParams)

Aggregations

XMSSMTKeyParams (com.github.zhenwei.core.pqc.asn1.XMSSMTKeyParams)4 IOException (java.io.IOException)4 AlgorithmIdentifier (com.github.zhenwei.core.asn1.x509.AlgorithmIdentifier)3 XMSSKeyParams (com.github.zhenwei.core.pqc.asn1.XMSSKeyParams)3 DEROctetString (com.github.zhenwei.core.asn1.DEROctetString)2 McElieceCCA2PrivateKey (com.github.zhenwei.core.pqc.asn1.McElieceCCA2PrivateKey)2 SPHINCS256KeyParams (com.github.zhenwei.core.pqc.asn1.SPHINCS256KeyParams)2 McElieceCCA2PrivateKeyParameters (com.github.zhenwei.core.pqc.crypto.mceliece.McElieceCCA2PrivateKeyParameters)2 NHPrivateKeyParameters (com.github.zhenwei.core.pqc.crypto.newhope.NHPrivateKeyParameters)2 QTESLAPrivateKeyParameters (com.github.zhenwei.core.pqc.crypto.qtesla.QTESLAPrivateKeyParameters)2 SPHINCSPrivateKeyParameters (com.github.zhenwei.core.pqc.crypto.sphincs.SPHINCSPrivateKeyParameters)2 XMSSPrivateKeyParameters (com.github.zhenwei.core.pqc.crypto.xmss.XMSSPrivateKeyParameters)2 XMSSMTKeyParams (org.bouncycastle.pqc.asn1.XMSSMTKeyParams)2 ASN1BitString (com.github.zhenwei.core.asn1.ASN1BitString)1 ASN1ObjectIdentifier (com.github.zhenwei.core.asn1.ASN1ObjectIdentifier)1 ASN1OctetString (com.github.zhenwei.core.asn1.ASN1OctetString)1 PrivateKeyInfo (com.github.zhenwei.core.asn1.pkcs.PrivateKeyInfo)1 SubjectPublicKeyInfo (com.github.zhenwei.core.asn1.x509.SubjectPublicKeyInfo)1 McElieceCCA2PublicKey (com.github.zhenwei.core.pqc.asn1.McElieceCCA2PublicKey)1 XMSSMTPrivateKey (com.github.zhenwei.core.pqc.asn1.XMSSMTPrivateKey)1