示例#1
0
        /// <summary>
        ///   Write the provided string using the specified encoding type using the specified
        ///   tag corresponding to the encoding type.
        /// </summary>
        /// <param name="tag">The tag to write.</param>
        /// <param name="encodingType">
        ///   The <see cref="UniversalTagNumber"/> corresponding to the encoding to use.
        /// </param>
        /// <param name="str">The string to write.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        ///   <paramref name="encodingType"/> is not a restricted character string encoding type --OR--
        ///   <paramref name="encodingType"/> is a restricted character string encoding type that is not
        ///   currently supported by this method
        /// </exception>
        /// <exception cref="ArgumentException">
        ///   <paramref name="tag"/>.<see cref="Asn1Tag.TagClass"/> is
        ///   <see cref="TagClass.Universal"/>, but
        ///   <paramref name="tag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for
        ///   the method
        /// </exception>
        /// <exception cref="ObjectDisposedException">The writer has been Disposed.</exception>
        public void WriteCharacterString(Asn1Tag tag, UniversalTagNumber encodingType, ReadOnlySpan <char> str)
        {
            CheckUniversalTag(tag, encodingType);

            Text.Encoding encoding = AsnCharacterStringEncodings.GetEncoding(encodingType);
            WriteCharacterStringCore(tag, encoding, str);
        }
示例#2
0
 /// <summary>
 ///   Reads the next value as character string with the specified tag and
 ///   encoding type, copying the decoded value into a provided destination buffer.
 /// </summary>
 /// <param name="expectedTag">The tag to check for before reading.</param>
 /// <param name="encodingType">
 ///   A <see cref="UniversalTagNumber"/> corresponding to the value type to process.
 /// </param>
 /// <param name="destination">The buffer in which to write.</param>
 /// <param name="charsWritten">
 ///   On success, receives the number of chars written to <paramref name="destination"/>.
 /// </param>
 /// <returns>
 ///   <c>true</c> and advances the reader if <paramref name="destination"/> had sufficient
 ///   length to receive the value, otherwise
 ///   <c>false</c> and the reader does not advance.
 /// </returns>
 /// <exception cref="ArgumentOutOfRangeException">
 ///   <paramref name="encodingType"/> is not a known character string type.
 /// </exception>
 /// <exception cref="CryptographicException">
 ///   the next value does not have the correct tag --OR--
 ///   the length encoding is not valid under the current encoding rules --OR--
 ///   the contents are not valid under the current encoding rules --OR--
 ///   the string did not successfully decode
 /// </exception>
 /// <exception cref="ArgumentException">
 ///   <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is
 ///   <see cref="TagClass.Universal"/>, but
 ///   <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not the same as
 ///   <paramref name="encodingType"/>.
 /// </exception>
 /// <seealso cref="TryReadPrimitiveCharacterStringBytes(Asn1Tag,UniversalTagNumber,out ReadOnlyMemory{byte})"/>
 /// <seealso cref="TryCopyCharacterStringBytes(Asn1Tag,UniversalTagNumber,Span{byte},out int)"/>
 /// <seealso cref="ReadCharacterString(Asn1Tag,UniversalTagNumber)"/>
 public bool TryCopyCharacterString(
     Asn1Tag expectedTag,
     UniversalTagNumber encodingType,
     Span <char> destination,
     out int charsWritten)
 {
     Text.Encoding encoding = AsnCharacterStringEncodings.GetEncoding(encodingType);
     return(TryCopyCharacterString(expectedTag, encodingType, encoding, destination, out charsWritten));
 }
示例#3
0
 /// <summary>
 ///   Reads the next value as character string with the specified tag and
 ///   encoding type, returning the decoded value as a <see cref="string"/>.
 /// </summary>
 /// <param name="expectedTag">The tag to check for before reading.</param>
 /// <param name="encodingType">
 ///   A <see cref="UniversalTagNumber"/> corresponding to the value type to process.
 /// </param>
 /// <returns>
 ///   the decoded value as a <see cref="string"/>.
 /// </returns>
 /// <exception cref="ArgumentOutOfRangeException">
 ///   <paramref name="encodingType"/> is not a known character string type.
 /// </exception>
 /// <exception cref="CryptographicException">
 ///   the next value does not have the correct tag --OR--
 ///   the length encoding is not valid under the current encoding rules --OR--
 ///   the contents are not valid under the current encoding rules --OR--
 ///   the string did not successfully decode
 /// </exception>
 /// <exception cref="ArgumentException">
 ///   <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is
 ///   <see cref="TagClass.Universal"/>, but
 ///   <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not the same as
 ///   <paramref name="encodingType"/>.
 /// </exception>
 /// <seealso cref="TryReadPrimitiveCharacterStringBytes(Asn1Tag,UniversalTagNumber,out ReadOnlyMemory{byte})"/>
 /// <seealso cref="TryCopyCharacterStringBytes(Asn1Tag,UniversalTagNumber,Span{byte},out int)"/>
 /// <seealso cref="TryCopyCharacterString(Asn1Tag,UniversalTagNumber,Span{char},out int)"/>
 public string ReadCharacterString(Asn1Tag expectedTag, UniversalTagNumber encodingType)
 {
     Text.Encoding encoding = AsnCharacterStringEncodings.GetEncoding(encodingType);
     return(ReadCharacterString(expectedTag, encodingType, encoding));
 }
示例#4
0
        /// <summary>
        ///   Write the provided string using the specified encoding type using the UNIVERSAL
        ///   tag corresponding to the encoding type.
        /// </summary>
        /// <param name="encodingType">
        ///   The <see cref="UniversalTagNumber"/> corresponding to the encoding to use.
        /// </param>
        /// <param name="str">The string to write.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        ///   <paramref name="encodingType"/> is not a restricted character string encoding type --OR--
        ///   <paramref name="encodingType"/> is a restricted character string encoding type that is not
        ///   currently supported by this method
        /// </exception>
        /// <exception cref="ObjectDisposedException">The writer has been Disposed.</exception>
        /// <seealso cref="WriteCharacterString(Asn1Tag,UniversalTagNumber,ReadOnlySpan{char})"/>
        public void WriteCharacterString(UniversalTagNumber encodingType, ReadOnlySpan <char> str)
        {
            Text.Encoding encoding = AsnCharacterStringEncodings.GetEncoding(encodingType);

            WriteCharacterStringCore(new Asn1Tag(encodingType), encoding, str);
        }