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); }
public virtual void Encode(Asn1Type type, bool explicitTagging) { type.Encode(this, explicitTagging); }
public override void Encode(Asn1Type type, bool explicitTagging) { type.Encode(this, explicitTagging); }
public AlgorithmId(Asn1ObjectIdentifier id, Asn1Type type) { Id = id; Type = type; }
public virtual void SetElement(int choiceId, Asn1Type element) { _choiceId = choiceId; Element = element; }
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); } } }
public AlgorithmIdentifier(Asn1ObjectIdentifier algorithm, Asn1OpenType parameters) { Algorithm = algorithm; Parameters = parameters; }
private void Init() { Algorithm = null; Parameters = null; }