コード例 #1
0
        public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging)
        {
            if (Value.Length < 1)
            {
                throw ExceptionUtility.CryptographicException(Resources.Asn1InvalidObjectIdException);
            }

            var len = 0;

            for (var i = Value.Length - 1; i >= 0; i--)
            {
                len += buffer.EncodeIdentifier(Value[i]);
            }

            if (explicitTagging)
            {
                len += buffer.EncodeTagAndLength(Tag, len);
            }

            return len;
        }
コード例 #2
0
ファイル: Asn1RelativeOid.cs プロジェクト: kunitdmi/corefx
        public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging)
        {
            if (Value.Length < 1)
            {
                throw new Exception("Asn1InvalidObjectIdException");
            }

            var len = 0;

            for (var i = Value.Length - 1; i >= 0; i--)
            {
                len += buffer.EncodeIdentifier(Value[i]);
            }

            if (explicitTagging)
            {
                len += buffer.EncodeTagAndLength(Tag, len);
            }

            return(len);
        }
コード例 #3
0
        public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging)
        {
            if (((Value.Length < 2) || (Value[0] > 2)) || ((Value[0] != 2) && (Value[1] > 0x27)))
            {
                throw ExceptionUtility.CryptographicException(Resources.Asn1InvalidObjectIdException);
            }

            var len = 0;

            for (var i = Value.Length - 1; i >= 1; i--)
            {
                len += buffer.EncodeIdentifier((i == 1) ? ((Value[0] * 40) + Value[1]) : Value[i]);
            }

            if (explicitTagging)
            {
                len += buffer.EncodeTagAndLength(Tag, len);
            }

            return len;
        }