Esempio n. 1
0
        private static byte[][] ParseRdn(
            byte[][] encodedOid,
            char[] chars,
            int valueStart,
            int valueEnd,
            bool ia5String)
        {
            byte[][] encodedValue;

            int length = valueEnd - valueStart;

            if (ia5String)
            {
                // An email address with an invalid value will throw.
                encodedValue = DerEncoder.SegmentedEncodeIA5String(chars, valueStart, length);
            }
            else if (DerEncoder.IsValidPrintableString(chars, valueStart, length))
            {
                encodedValue = DerEncoder.SegmentedEncodePrintableString(chars, valueStart, length);
            }
            else
            {
                encodedValue = DerEncoder.SegmentedEncodeUtf8String(chars, valueStart, length);
            }

            return(DerEncoder.ConstructSegmentedSet(
                       DerEncoder.ConstructSegmentedSequence(
                           encodedOid,
                           encodedValue)));
        }
Esempio n. 2
0
        internal static byte[][] SegmentedEncodeAttributeSet(this IEnumerable <X501Attribute> attributes)
        {
            List <byte[][]> encodedAttributes = new List <byte[][]>();

            foreach (X501Attribute attribute in attributes)
            {
                encodedAttributes.Add(
                    DerEncoder.ConstructSegmentedSequence(
                        DerEncoder.SegmentedEncodeOid(attribute.Oid),
                        DerEncoder.ConstructSegmentedPresortedSet(
                            attribute.RawData.WrapAsSegmentedForSequence())));
            }

            return(DerEncoder.ConstructSegmentedSet(encodedAttributes.ToArray()));
        }