private static byte[] GetPublicX(Asn1Object header)
        {
            var seq1 = header as Asn1Sequence;

            if (seq1 != null && seq1.Count > 0)
            {
                var seq2 = seq1[0] as Asn1Sequence;
                if (seq2 != null)
                {
                    byte[] key = null;
                    if (seq2.Count == 5 || seq2.Count == 6)
                    {
                        key = Asn1Utils.ExtractOctets(seq2[seq2.Count - 1]);
                    }
                    else if (seq2.Count == 7)
                    {
                        key = Asn1Utils.ExtractOctets(seq2[5]);
                    }
                    if (key != null && key.Length == 8)
                    {
                        return(key);
                    }
                }
            }

            throw new CryptographicException("Ошибка в данных header.key.");
        }
        public byte[] GetRawCertificate()
        {
            var header = Asn1Object.FromByteArray(Header);
            var seq1   = header as Asn1Sequence;

            if (seq1 != null && seq1.Count > 0)
            {
                var seq2 = seq1[0] as Asn1Sequence;
                if (seq2 != null && seq2.Count >= 6)
                {
                    return(Asn1Utils.ExtractOctets(seq2[4]));
                }
            }

            throw new CryptographicException("Контейнер не содержит сертификата.");
        }
        private static DerObjectIdentifier GetAlgorithmId(Asn1Object header)
        {
            DerObjectIdentifier algId;

            try {
                algId = Asn1Utils.Goto(header, "0/2/1/1/0") as DerObjectIdentifier;
            } catch (Asn1Exception e) {
                throw new CryptographicException("Ошибка в данных header.key.", e);
            }

            if (algId != null)
            {
                return(algId);
            }

            throw new CryptographicException("Ошибка в данных header.key.");
        }