Beispiel #1
0
        public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging)
        {
            if (OidValue.Items.Length < 1)
            {
                throw ExceptionUtility.CryptographicException(Resources.Asn1InvalidObjectIdException);
            }

            var len = 0;

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

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

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

            var len = 0;

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

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

            return(len);
        }