public static bool is7BitEncodedString(ElementInfo info)
        {
            bool is7Bit     = false;
            int  stringType = CoderUtils.getStringTagForElement(info);

            is7Bit = (
                stringType == org.bn.coders.UniversalTags.PrintableString ||
                stringType == org.bn.coders.UniversalTags.VisibleString
                );
            return(is7Bit);
        }
Exemple #2
0
        public override DecodedObject <object> decodeString(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
        {
            if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Primitive, CoderUtils.getStringTagForElement(elementInfo), elementInfo))
            {
                return(null);
            }
            DecodedObject <int> len = decodeLength(stream);

            CoderUtils.checkConstraints(len.Value, elementInfo);
            byte[] byteBuf = new byte[len.Value];
            stream.Read(byteBuf, 0, byteBuf.Length);
            string result = CoderUtils.bufferToASN1String(byteBuf, elementInfo);

            return(new DecodedObject <object>(result, len.Value + len.Size));
        }
Exemple #3
0
        public override int encodeString(object obj, Stream stream, ElementInfo elementInfo)
        {
            int resultSize = 0, sizeOfString = 0;

            byte[] buffer = CoderUtils.ASN1StringToBuffer(obj, elementInfo);
            sizeOfString = buffer.Length;
            CoderUtils.checkConstraints(sizeOfString, elementInfo);

            stream.Write(buffer, 0, buffer.Length);

            resultSize += sizeOfString;
            resultSize += encodeLength(sizeOfString, stream);
            resultSize += encodeTag(BERCoderUtils.getTagValueForElement(elementInfo, TagClasses.Universal, ElementType.Primitive, CoderUtils.getStringTagForElement(elementInfo)), stream);
            return(resultSize);
        }