private static byte[] EncodePSD2QcStatmentExtension(PSD2Roles roles, PSD2CertificateType certType, byte retentionPeriod, string ncaName, string ncaId)
        {
            var rolesSeq = new List <byte[]>();

            if (roles.HasFlag(PSD2Roles.PSP_AS))
            {
                rolesSeq.Add(Asn1Encoder.Sequence(Asn1Encoder.ObjectIdentifier(OID_PSP_AS), Asn1Encoder.Utf8String(PSD2Roles.PSP_AS.ToString())));
            }
            if (roles.HasFlag(PSD2Roles.PSP_PI))
            {
                rolesSeq.Add(Asn1Encoder.Sequence(Asn1Encoder.ObjectIdentifier(OID_PSP_PI), Asn1Encoder.Utf8String(PSD2Roles.PSP_PI.ToString())));
            }
            if (roles.HasFlag(PSD2Roles.PSP_AI))
            {
                rolesSeq.Add(Asn1Encoder.Sequence(Asn1Encoder.ObjectIdentifier(OID_PSP_AI), Asn1Encoder.Utf8String(PSD2Roles.PSP_AI.ToString())));
            }
            if (roles.HasFlag(PSD2Roles.PSP_IC))
            {
                rolesSeq.Add(Asn1Encoder.Sequence(Asn1Encoder.ObjectIdentifier(OID_PSP_IC), Asn1Encoder.Utf8String(PSD2Roles.PSP_IC.ToString())));
            }

            return(Asn1Encoder.Sequence(
                       Asn1Encoder.Sequence(
                           Asn1Encoder.ObjectIdentifier(OID_QcsCompliance) //  this certificate is issued as a Qualified Certificate
                           ),
                       Asn1Encoder.Sequence(
                           Asn1Encoder.ObjectIdentifier(OID_QcRetentionPeriod), // number of years after the validity period the certificate will be stored in the issuer's archive
                           Asn1Encoder.IntegerBigEndian(new[] { retentionPeriod })
                           ),
                       Asn1Encoder.Sequence(
                           Asn1Encoder.ObjectIdentifier(OID_QcsQcSSCD) // CAs claiming to issue certificates where the private key related to the certified public key resides in a Secure Signature Creation Device(SSCD)
                           ),
                       Asn1Encoder.Sequence(
                           Asn1Encoder.ObjectIdentifier(OID_QcType),
                           Asn1Encoder.Sequence(
                               Asn1Encoder.ObjectIdentifier(certType == PSD2CertificateType.QWAC ? OID_QWAC_web : OID_QSealC_eseal)
                               )
                           ),
                       Asn1Encoder.Sequence(
                           Asn1Encoder.ObjectIdentifier(OID_PSD2qcStatement),
                           Asn1Encoder.Sequence(
                               Asn1Encoder.Sequence(rolesSeq.ToArray()),
                               Asn1Encoder.Utf8String(ncaName),
                               Asn1Encoder.Utf8String(ncaId)
                               )
                           )
                       ));
        }
 public X509QcStatmentExtension(PSD2Roles roles, PSD2CertificateType certificateType, byte retentionPeriod, string ncaName, string ncaId, bool critical = false) :
     base(OID_qcStatements, EncodePSD2QcStatmentExtension(roles, certificateType, retentionPeriod, ncaName, ncaId), critical)
 {
 }