Example #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)));
        }
Example #2
0
 public static void CheckPrintableSubstring(string candidate, int offset, int length, bool expected)
 {
     Assert.Equal(expected, DerEncoder.IsValidPrintableString(candidate.ToCharArray(), offset, length));
 }
Example #3
0
 public static void CheckPrintableString(string candidate, bool expected)
 {
     Assert.Equal(expected, DerEncoder.IsValidPrintableString(candidate.ToCharArray()));
 }