コード例 #1
0
        public override void Decode(Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength)
        {
            var elemLength = explicitTagging ? MatchTag(buffer, Asn1Tag.Sequence) : implicitLength;

            Init();

            var context = new Asn1BerDecodeContext(buffer, elemLength);
            var parsedLen = new IntHolder();

            if (!context.MatchElemTag(0, 0, 6, parsedLen, false))
            {
                throw ExceptionUtility.CryptographicException(Resources.Asn1MissingRequiredException, buffer.ByteCount);
            }

            Algorithm = new Asn1ObjectIdentifier();
            Algorithm.Decode(buffer, true, parsedLen.Value);

            if (!context.Expired())
            {
                Parameters = new Asn1OpenType();
                Parameters.Decode(buffer, true, 0);
            }

            CheckTc(true);
        }
コード例 #2
0
 public virtual void Encode(Asn1Type type, bool explicitTagging)
 {
     type.Encode(this, explicitTagging);
 }
コード例 #3
0
 public virtual void Encode(Asn1Type type, bool explicitTagging)
 {
     type.Encode(this, explicitTagging);
 }
コード例 #4
0
 public override void Encode(Asn1Type type, bool explicitTagging)
 {
     type.Encode(this, explicitTagging);
 }
コード例 #5
0
		public AlgorithmId(Asn1ObjectIdentifier id, Asn1Type type)
		{
			Id = id;
			Type = type;
		}
コード例 #6
0
 public override void Encode(Asn1Type type, bool explicitTagging)
 {
     type.Encode(this, explicitTagging);
 }
コード例 #7
0
		public virtual void SetElement(int choiceId, Asn1Type element)
		{
			_choiceId = choiceId;

			Element = element;
		}
コード例 #8
0
        public virtual void SetElement(int choiceId, Asn1Type element)
        {
            _choiceId = choiceId;

            Element = element;
        }
コード例 #9
0
        private void CheckTc(bool decode)
        {
            AlgorithmId algorithmId = null;

            foreach (var alg in PkiConstants.SupportedAlgorithms)
            {
                if (alg.Id.Equals(Algorithm))
                {
                    algorithmId = alg;
                    break;
                }
            }

            if ((algorithmId != null) && ((decode && (Parameters != null)) && (algorithmId.Type != null)))
            {
                try
                {
                    var buffer = new Asn1BerDecodeBuffer(((Asn1OpenType)Parameters).Value);
                    Parameters = (Asn1Type)Activator.CreateInstance(algorithmId.Type.GetType());
                    Parameters.Decode(buffer, true, 0);
                    buffer.InvokeEndElement("parameters", -1);
                }
                catch (Exception exception)
                {
                    Asn1Util.WriteStackTrace(exception, Console.Error);
                    throw ExceptionUtility.CryptographicException(Resources.Asn1TableConstraint);
                }
            }
        }
コード例 #10
0
 public AlgorithmIdentifier(Asn1ObjectIdentifier algorithm, Asn1OpenType parameters)
 {
     Algorithm = algorithm;
     Parameters = parameters;
 }
コード例 #11
0
 private void Init()
 {
     Algorithm = null;
     Parameters = null;
 }