// 
// Decompiled by Procyon v0.6.0
// 

package org.bouncycastle.pqc.crypto.util;

import org.bouncycastle.pqc.crypto.xmss.XMSSMTPublicKeyParameters;
import org.bouncycastle.pqc.crypto.xmss.XMSSMTParameters;
import org.bouncycastle.pqc.asn1.XMSSMTKeyParams;
import org.bouncycastle.util.Pack;
import org.bouncycastle.pqc.crypto.xmss.XMSSPublicKeyParameters;
import org.bouncycastle.pqc.crypto.xmss.XMSSParameters;
import org.bouncycastle.pqc.asn1.XMSSPublicKey;
import org.bouncycastle.pqc.asn1.XMSSKeyParams;
import org.bouncycastle.pqc.crypto.snova.SnovaPublicKeyParameters;
import org.bouncycastle.pqc.crypto.sphincsplus.SPHINCSPlusPublicKeyParameters;
import org.bouncycastle.pqc.crypto.sphincs.SPHINCSPublicKeyParameters;
import org.bouncycastle.pqc.asn1.SPHINCS256KeyParams;
import org.bouncycastle.pqc.crypto.ntruprime.SNTRUPrimePublicKeyParameters;
import org.bouncycastle.pqc.crypto.slhdsa.SLHDSAPublicKeyParameters;
import org.bouncycastle.pqc.crypto.saber.SABERPublicKeyParameters;
import org.bouncycastle.pqc.crypto.rainbow.RainbowPublicKeyParameters;
import org.bouncycastle.pqc.crypto.picnic.PicnicPublicKeyParameters;
import org.bouncycastle.pqc.crypto.ntru.NTRUPublicKeyParameters;
import org.bouncycastle.pqc.crypto.ntruprime.NTRULPRimePublicKeyParameters;
import org.bouncycastle.pqc.crypto.newhope.NHPublicKeyParameters;
import org.bouncycastle.pqc.crypto.mayo.MayoPublicKeyParameters;
import org.bouncycastle.pqc.crypto.mlkem.MLKEMParameters;
import org.bouncycastle.pqc.crypto.mlkem.MLKEMPublicKeyParameters;
import org.bouncycastle.pqc.crypto.mldsa.MLDSAPublicKeyParameters;
import org.bouncycastle.pqc.crypto.mldsa.MLDSAParameters;
import org.bouncycastle.pqc.crypto.lms.HSSPublicKeyParameters;
import org.bouncycastle.pqc.crypto.lms.LMSKeyParameters;
import org.bouncycastle.pqc.crypto.hqc.HQCPublicKeyParameters;
import org.bouncycastle.pqc.crypto.frodo.FrodoPublicKeyParameters;
import org.bouncycastle.pqc.crypto.falcon.FalconPublicKeyParameters;
import org.bouncycastle.util.Arrays;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.pqc.crypto.crystals.dilithium.DilithiumPublicKeyParameters;
import org.bouncycastle.asn1.ASN1BitString;
import org.bouncycastle.pqc.crypto.crystals.dilithium.DilithiumParameters;
import org.bouncycastle.pqc.crypto.cmce.CMCEPublicKeyParameters;
import org.bouncycastle.pqc.asn1.CMCEPublicKey;
import org.bouncycastle.pqc.crypto.bike.BIKEPublicKeyParameters;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.bc.BCObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.internal.asn1.isara.IsaraObjectIdentifiers;
import org.bouncycastle.pqc.asn1.PQCObjectIdentifiers;
import java.util.HashMap;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.ASN1InputStream;
import java.io.InputStream;
import java.io.IOException;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
import java.util.Map;

public class PublicKeyFactory
{
    private static Map converters;
    
    public static AsymmetricKeyParameter createKey(final byte[] array) throws IOException {
        if (array == null) {
            throw new IllegalArgumentException("keyInfoData array null");
        }
        if (array.length == 0) {
            throw new IllegalArgumentException("keyInfoData array empty");
        }
        return createKey(SubjectPublicKeyInfo.getInstance(ASN1Primitive.fromByteArray(array)));
    }
    
    public static AsymmetricKeyParameter createKey(final InputStream inputStream) throws IOException {
        return createKey(SubjectPublicKeyInfo.getInstance(new ASN1InputStream(inputStream).readObject()));
    }
    
    public static AsymmetricKeyParameter createKey(final SubjectPublicKeyInfo subjectPublicKeyInfo) throws IOException {
        if (subjectPublicKeyInfo == null) {
            throw new IllegalArgumentException("keyInfo argument null");
        }
        return createKey(subjectPublicKeyInfo, null);
    }
    
    public static AsymmetricKeyParameter createKey(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
        if (subjectPublicKeyInfo == null) {
            throw new IllegalArgumentException("keyInfo argument null");
        }
        final AlgorithmIdentifier algorithm = subjectPublicKeyInfo.getAlgorithm();
        final SubjectPublicKeyInfoConverter subjectPublicKeyInfoConverter = PublicKeyFactory.converters.get(algorithm.getAlgorithm());
        if (subjectPublicKeyInfoConverter != null) {
            return subjectPublicKeyInfoConverter.getPublicKeyParameters(subjectPublicKeyInfo, o);
        }
        throw new IOException("algorithm identifier in public key not recognised: " + algorithm.getAlgorithm());
    }
    
    static {
        (PublicKeyFactory.converters = new HashMap()).put(PQCObjectIdentifiers.sphincs256, new SPHINCSConverter());
        PublicKeyFactory.converters.put(PQCObjectIdentifiers.newHope, new NHConverter());
        PublicKeyFactory.converters.put(PQCObjectIdentifiers.xmss, new XMSSConverter());
        PublicKeyFactory.converters.put(PQCObjectIdentifiers.xmss_mt, new XMSSMTConverter());
        PublicKeyFactory.converters.put(IsaraObjectIdentifiers.id_alg_xmss, new XMSSConverter());
        PublicKeyFactory.converters.put(IsaraObjectIdentifiers.id_alg_xmssmt, new XMSSMTConverter());
        PublicKeyFactory.converters.put(PKCSObjectIdentifiers.id_alg_hss_lms_hashsig, new LMSConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_sha2_128s_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_sha2_128f_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_shake_128s_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_shake_128f_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_haraka_128s_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_haraka_128f_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_sha2_192s_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_sha2_192f_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_shake_192s_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_shake_192f_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_haraka_192s_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_haraka_192f_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_sha2_256s_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_sha2_256f_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_shake_256s_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_shake_256f_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_haraka_256s_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_haraka_256f_r3, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_haraka_128s_r3_simple, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_haraka_128f_r3_simple, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_haraka_192s_r3_simple, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_haraka_192f_r3_simple, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_haraka_256s_r3_simple, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_haraka_256f_r3_simple, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_sha2_128s, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_sha2_128f, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_shake_128s, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_shake_128f, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_sha2_192s, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_sha2_192f, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_shake_192s, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_shake_192f, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_sha2_256s, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_sha2_256f, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_shake_256s, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sphincsPlus_shake_256f, new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(new ASN1ObjectIdentifier("1.3.9999.6.4.10"), new SPHINCSPlusConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.mceliece348864_r3, new CMCEConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.mceliece348864f_r3, new CMCEConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.mceliece460896_r3, new CMCEConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.mceliece460896f_r3, new CMCEConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.mceliece6688128_r3, new CMCEConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.mceliece6688128f_r3, new CMCEConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.mceliece6960119_r3, new CMCEConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.mceliece6960119f_r3, new CMCEConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.mceliece8192128_r3, new CMCEConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.mceliece8192128f_r3, new CMCEConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.frodokem640aes, new FrodoConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.frodokem640shake, new FrodoConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.frodokem976aes, new FrodoConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.frodokem976shake, new FrodoConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.frodokem1344aes, new FrodoConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.frodokem1344shake, new FrodoConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.lightsaberkem128r3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.saberkem128r3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.firesaberkem128r3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.lightsaberkem192r3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.saberkem192r3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.firesaberkem192r3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.lightsaberkem256r3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.saberkem256r3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.firesaberkem256r3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.ulightsaberkemr3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.usaberkemr3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.ufiresaberkemr3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.lightsaberkem90sr3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.saberkem90sr3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.firesaberkem90sr3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.ulightsaberkem90sr3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.usaberkem90sr3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.ufiresaberkem90sr3, new SABERConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.picnicl1fs, new PicnicConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.picnicl1ur, new PicnicConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.picnicl3fs, new PicnicConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.picnicl3ur, new PicnicConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.picnicl5fs, new PicnicConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.picnicl5ur, new PicnicConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.picnic3l1, new PicnicConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.picnic3l3, new PicnicConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.picnic3l5, new PicnicConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.picnicl1full, new PicnicConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.picnicl3full, new PicnicConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.picnicl5full, new PicnicConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.ntruhps2048509, new NtruConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.ntruhps2048677, new NtruConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.ntruhps4096821, new NtruConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.ntruhps40961229, new NtruConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.ntruhrss701, new NtruConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.ntruhrss1373, new NtruConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.falcon_512, new FalconConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.falcon_1024, new FalconConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.old_falcon_512, new FalconConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.old_falcon_1024, new FalconConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_alg_ml_kem_512, new MLKEMConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_alg_ml_kem_768, new MLKEMConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_alg_ml_kem_1024, new MLKEMConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.kyber512_aes, new MLKEMConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.kyber768_aes, new MLKEMConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.kyber1024_aes, new MLKEMConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.ntrulpr653, new NTRULPrimeConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.ntrulpr761, new NTRULPrimeConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.ntrulpr857, new NTRULPrimeConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.ntrulpr953, new NTRULPrimeConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.ntrulpr1013, new NTRULPrimeConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.ntrulpr1277, new NTRULPrimeConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sntrup653, new SNTRUPrimeConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sntrup761, new SNTRUPrimeConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sntrup857, new SNTRUPrimeConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sntrup953, new SNTRUPrimeConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sntrup1013, new SNTRUPrimeConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.sntrup1277, new SNTRUPrimeConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_ml_dsa_44, new MLDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_ml_dsa_65, new MLDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_ml_dsa_87, new MLDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_hash_ml_dsa_44_with_sha512, new MLDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_hash_ml_dsa_65_with_sha512, new MLDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_hash_ml_dsa_87_with_sha512, new MLDSAConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.dilithium2, new DilithiumConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.dilithium3, new DilithiumConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.dilithium5, new DilithiumConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.dilithium2_aes, new DilithiumConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.dilithium3_aes, new DilithiumConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.dilithium5_aes, new DilithiumConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.bike128, new BIKEConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.bike192, new BIKEConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.bike256, new BIKEConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.hqc128, new HQCConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.hqc192, new HQCConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.hqc256, new HQCConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.rainbow_III_classic, new RainbowConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.rainbow_III_circumzenithal, new RainbowConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.rainbow_III_compressed, new RainbowConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.rainbow_V_classic, new RainbowConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.rainbow_V_circumzenithal, new RainbowConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.rainbow_V_compressed, new RainbowConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_slh_dsa_sha2_128s, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_slh_dsa_sha2_128f, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_slh_dsa_sha2_192s, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_slh_dsa_sha2_192f, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_slh_dsa_sha2_256s, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_slh_dsa_sha2_256f, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_slh_dsa_shake_128s, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_slh_dsa_shake_128f, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_slh_dsa_shake_192s, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_slh_dsa_shake_192f, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_slh_dsa_shake_256s, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_slh_dsa_shake_256f, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_hash_slh_dsa_sha2_128s_with_sha256, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_hash_slh_dsa_sha2_128f_with_sha256, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_hash_slh_dsa_sha2_192s_with_sha512, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_hash_slh_dsa_sha2_192f_with_sha512, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_hash_slh_dsa_sha2_256s_with_sha512, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_hash_slh_dsa_sha2_256f_with_sha512, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_hash_slh_dsa_shake_128s_with_shake128, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_hash_slh_dsa_shake_128f_with_shake128, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_hash_slh_dsa_shake_192s_with_shake256, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_hash_slh_dsa_shake_192f_with_shake256, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_hash_slh_dsa_shake_256s_with_shake256, new SLHDSAConverter());
        PublicKeyFactory.converters.put(NISTObjectIdentifiers.id_hash_slh_dsa_shake_256f_with_shake256, new SLHDSAConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.mayo1, new MayoConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.mayo2, new MayoConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.mayo3, new MayoConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.mayo5, new MayoConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_24_5_4_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_24_5_4_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_24_5_4_shake_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_24_5_4_shake_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_24_5_5_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_24_5_5_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_24_5_5_shake_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_24_5_5_shake_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_25_8_3_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_25_8_3_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_25_8_3_shake_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_25_8_3_shake_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_29_6_5_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_29_6_5_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_29_6_5_shake_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_29_6_5_shake_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_37_8_4_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_37_8_4_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_37_8_4_shake_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_37_8_4_shake_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_37_17_2_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_37_17_2_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_37_17_2_shake_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_37_17_2_shake_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_49_11_3_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_49_11_3_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_49_11_3_shake_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_49_11_3_shake_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_56_25_2_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_56_25_2_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_56_25_2_shake_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_56_25_2_shake_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_60_10_4_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_60_10_4_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_60_10_4_shake_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_60_10_4_shake_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_66_15_3_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_66_15_3_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_66_15_3_shake_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_66_15_3_shake_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_75_33_2_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_75_33_2_ssk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_75_33_2_shake_esk, new SnovaConverter());
        PublicKeyFactory.converters.put(BCObjectIdentifiers.snova_75_33_2_shake_ssk, new SnovaConverter());
    }
    
    private static class BIKEConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            try {
                return new BIKEPublicKeyParameters(Utils.bikeParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), ASN1OctetString.getInstance(subjectPublicKeyInfo.parsePublicKey()).getOctets());
            }
            catch (final Exception ex) {
                return new BIKEPublicKeyParameters(Utils.bikeParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), subjectPublicKeyInfo.getPublicKeyData().getOctets());
            }
        }
    }
    
    private abstract static class SubjectPublicKeyInfoConverter
    {
        abstract AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo p0, final Object p1) throws IOException;
    }
    
    private static class CMCEConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            try {
                return new CMCEPublicKeyParameters(Utils.mcElieceParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), CMCEPublicKey.getInstance(subjectPublicKeyInfo.parsePublicKey()).getT());
            }
            catch (final Exception ex) {
                return new CMCEPublicKeyParameters(Utils.mcElieceParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), subjectPublicKeyInfo.getPublicKeyData().getOctets());
            }
        }
    }
    
    static class DilithiumConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            return getPublicKeyParams(Utils.dilithiumParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), subjectPublicKeyInfo.getPublicKeyData());
        }
        
        static DilithiumPublicKeyParameters getPublicKeyParams(final DilithiumParameters dilithiumParameters, final ASN1BitString asn1BitString) {
            try {
                final ASN1Primitive fromByteArray = ASN1Primitive.fromByteArray(asn1BitString.getOctets());
                if (fromByteArray instanceof ASN1Sequence) {
                    final ASN1Sequence instance = ASN1Sequence.getInstance(fromByteArray);
                    return new DilithiumPublicKeyParameters(dilithiumParameters, ASN1OctetString.getInstance(instance.getObjectAt(0)).getOctets(), ASN1OctetString.getInstance(instance.getObjectAt(1)).getOctets());
                }
                return new DilithiumPublicKeyParameters(dilithiumParameters, ASN1OctetString.getInstance(fromByteArray).getOctets());
            }
            catch (final Exception ex) {
                return new DilithiumPublicKeyParameters(dilithiumParameters, asn1BitString.getOctets());
            }
        }
    }
    
    private static class FalconConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            final byte[] octets = subjectPublicKeyInfo.getPublicKeyData().getOctets();
            return new FalconPublicKeyParameters(Utils.falconParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), Arrays.copyOfRange(octets, 1, octets.length));
        }
    }
    
    private static class FrodoConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            return new FrodoPublicKeyParameters(Utils.frodoParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), ASN1OctetString.getInstance(subjectPublicKeyInfo.parsePublicKey()).getOctets());
        }
    }
    
    private static class HQCConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            try {
                return new HQCPublicKeyParameters(Utils.hqcParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), ASN1OctetString.getInstance(subjectPublicKeyInfo.parsePublicKey()).getOctets());
            }
            catch (final Exception ex) {
                return new HQCPublicKeyParameters(Utils.hqcParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), subjectPublicKeyInfo.getPublicKeyData().getOctets());
            }
        }
    }
    
    private static class LMSConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            final byte[] octets = subjectPublicKeyInfo.getPublicKeyData().getOctets();
            final ASN1OctetString asn1OctetString = (ASN1OctetString)Utils.parseData(octets);
            if (asn1OctetString != null) {
                return this.getLmsKeyParameters(asn1OctetString.getOctets());
            }
            return this.getLmsKeyParameters(octets);
        }
        
        private LMSKeyParameters getLmsKeyParameters(final byte[] array) throws IOException {
            return HSSPublicKeyParameters.getInstance(array);
        }
    }
    
    static class MLDSAConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            return getPublicKeyParams(Utils.mldsaParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), subjectPublicKeyInfo.getPublicKeyData());
        }
        
        static MLDSAPublicKeyParameters getPublicKeyParams(final MLDSAParameters mldsaParameters, final ASN1BitString asn1BitString) {
            try {
                final ASN1Primitive fromByteArray = ASN1Primitive.fromByteArray(asn1BitString.getOctets());
                if (fromByteArray instanceof ASN1Sequence) {
                    final ASN1Sequence instance = ASN1Sequence.getInstance(fromByteArray);
                    return new MLDSAPublicKeyParameters(mldsaParameters, ASN1OctetString.getInstance(instance.getObjectAt(0)).getOctets(), ASN1OctetString.getInstance(instance.getObjectAt(1)).getOctets());
                }
                return new MLDSAPublicKeyParameters(mldsaParameters, ASN1OctetString.getInstance(fromByteArray).getOctets());
            }
            catch (final Exception ex) {
                return new MLDSAPublicKeyParameters(mldsaParameters, asn1BitString.getOctets());
            }
        }
    }
    
    static class MLKEMConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            return new MLKEMPublicKeyParameters(Utils.mlkemParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), subjectPublicKeyInfo.getPublicKeyData().getOctets());
        }
        
        static MLKEMPublicKeyParameters getPublicKeyParams(final MLKEMParameters mlkemParameters, final ASN1BitString asn1BitString) {
            try {
                final ASN1Primitive fromByteArray = ASN1Primitive.fromByteArray(asn1BitString.getOctets());
                if (fromByteArray instanceof ASN1Sequence) {
                    final ASN1Sequence instance = ASN1Sequence.getInstance(fromByteArray);
                    return new MLKEMPublicKeyParameters(mlkemParameters, ASN1OctetString.getInstance(instance.getObjectAt(0)).getOctets(), ASN1OctetString.getInstance(instance.getObjectAt(1)).getOctets());
                }
                return new MLKEMPublicKeyParameters(mlkemParameters, ASN1OctetString.getInstance(fromByteArray).getOctets());
            }
            catch (final Exception ex) {
                return new MLKEMPublicKeyParameters(mlkemParameters, asn1BitString.getOctets());
            }
        }
    }
    
    private static class MayoConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            return new MayoPublicKeyParameters(Utils.mayoParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), ASN1OctetString.getInstance(subjectPublicKeyInfo.parsePublicKey()).getOctets());
        }
    }
    
    private static class NHConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            return new NHPublicKeyParameters(subjectPublicKeyInfo.getPublicKeyData().getBytes());
        }
    }
    
    private static class NTRULPrimeConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            return new NTRULPRimePublicKeyParameters(Utils.ntrulprimeParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), ASN1OctetString.getInstance(subjectPublicKeyInfo.parsePublicKey()).getOctets());
        }
    }
    
    private static class NtruConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            final byte[] octets = subjectPublicKeyInfo.getPublicKeyData().getOctets();
            final ASN1OctetString octetData = Utils.parseOctetData(octets);
            if (octetData != null) {
                return this.getNtruPublicKeyParameters(subjectPublicKeyInfo, octetData.getOctets());
            }
            return this.getNtruPublicKeyParameters(subjectPublicKeyInfo, octets);
        }
        
        private NTRUPublicKeyParameters getNtruPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final byte[] array) {
            return new NTRUPublicKeyParameters(Utils.ntruParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), array);
        }
    }
    
    private static class PicnicConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            return new PicnicPublicKeyParameters(Utils.picnicParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), ASN1OctetString.getInstance(subjectPublicKeyInfo.parsePublicKey()).getOctets());
        }
    }
    
    private static class RainbowConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            return new RainbowPublicKeyParameters(Utils.rainbowParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), ASN1OctetString.getInstance(subjectPublicKeyInfo.parsePublicKey()).getOctets());
        }
    }
    
    private static class SABERConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            return new SABERPublicKeyParameters(Utils.saberParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), ASN1OctetString.getInstance(ASN1Sequence.getInstance(subjectPublicKeyInfo.parsePublicKey()).getObjectAt(0)).getOctets());
        }
    }
    
    private static class SLHDSAConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            try {
                final byte[] octets = ASN1OctetString.getInstance(subjectPublicKeyInfo.parsePublicKey()).getOctets();
                return new SLHDSAPublicKeyParameters(Utils.slhdsaParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), Arrays.copyOfRange(octets, 4, octets.length));
            }
            catch (final Exception ex) {
                return new SLHDSAPublicKeyParameters(Utils.slhdsaParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), subjectPublicKeyInfo.getPublicKeyData().getOctets());
            }
        }
    }
    
    private static class SNTRUPrimeConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            return new SNTRUPrimePublicKeyParameters(Utils.sntruprimeParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), ASN1OctetString.getInstance(subjectPublicKeyInfo.parsePublicKey()).getOctets());
        }
    }
    
    private static class SPHINCSConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            return new SPHINCSPublicKeyParameters(subjectPublicKeyInfo.getPublicKeyData().getBytes(), Utils.sphincs256LookupTreeAlgName(SPHINCS256KeyParams.getInstance(subjectPublicKeyInfo.getAlgorithm().getParameters())));
        }
    }
    
    private static class SPHINCSPlusConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            try {
                final byte[] octets = ASN1OctetString.getInstance(subjectPublicKeyInfo.parsePublicKey()).getOctets();
                return new SPHINCSPlusPublicKeyParameters(Utils.sphincsPlusParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), Arrays.copyOfRange(octets, 4, octets.length));
            }
            catch (final Exception ex) {
                return new SPHINCSPlusPublicKeyParameters(Utils.sphincsPlusParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), subjectPublicKeyInfo.getPublicKeyData().getOctets());
            }
        }
    }
    
    private static class SnovaConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            return new SnovaPublicKeyParameters(Utils.snovaParamsLookup(subjectPublicKeyInfo.getAlgorithm().getAlgorithm()), ASN1OctetString.getInstance(subjectPublicKeyInfo.parsePublicKey()).getOctets());
        }
    }
    
    private static class XMSSConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            final XMSSKeyParams instance = XMSSKeyParams.getInstance(subjectPublicKeyInfo.getAlgorithm().getParameters());
            if (instance != null) {
                final ASN1ObjectIdentifier algorithm = instance.getTreeDigest().getAlgorithm();
                final XMSSPublicKey instance2 = XMSSPublicKey.getInstance(subjectPublicKeyInfo.parsePublicKey());
                return new XMSSPublicKeyParameters.Builder(new XMSSParameters(instance.getHeight(), Utils.getDigest(algorithm))).withPublicSeed(instance2.getPublicSeed()).withRoot(instance2.getRoot()).build();
            }
            final byte[] octets = ASN1OctetString.getInstance(subjectPublicKeyInfo.parsePublicKey()).getOctets();
            return new XMSSPublicKeyParameters.Builder(XMSSParameters.lookupByOID(Pack.bigEndianToInt(octets, 0))).withPublicKey(octets).build();
        }
    }
    
    private static class XMSSMTConverter extends SubjectPublicKeyInfoConverter
    {
        @Override
        AsymmetricKeyParameter getPublicKeyParameters(final SubjectPublicKeyInfo subjectPublicKeyInfo, final Object o) throws IOException {
            final XMSSMTKeyParams instance = XMSSMTKeyParams.getInstance(subjectPublicKeyInfo.getAlgorithm().getParameters());
            if (instance != null) {
                final ASN1ObjectIdentifier algorithm = instance.getTreeDigest().getAlgorithm();
                final XMSSPublicKey instance2 = XMSSPublicKey.getInstance(subjectPublicKeyInfo.parsePublicKey());
                return new XMSSMTPublicKeyParameters.Builder(new XMSSMTParameters(instance.getHeight(), instance.getLayers(), Utils.getDigest(algorithm))).withPublicSeed(instance2.getPublicSeed()).withRoot(instance2.getRoot()).build();
            }
            final byte[] octets = ASN1OctetString.getInstance(subjectPublicKeyInfo.parsePublicKey()).getOctets();
            return new XMSSMTPublicKeyParameters.Builder(XMSSMTParameters.lookupByOID(Pack.bigEndianToInt(octets, 0))).withPublicKey(octets).build();
        }
    }
}
