public override void Decode (Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength) { int llen = implicitLength; // decode CHOICE Asn1Tag tag = new Asn1Tag(); buffer.Mark(); int len = buffer.DecodeTagAndLength(tag); if (tag.Equals(Asn1Tag.Universal, Asn1Tag.PRIM, 5)) { buffer.Reset(); NULLParams null_ = new NULLParams(); SetElement(_NULL_, null_); Element.Decode(buffer, true, len); } else if (tag.Equals(Asn1Tag.Universal, Asn1Tag.CONS, 16)) { buffer.Reset(); GostR3410_2012_PublicKeyParameters params_ = new GostR3410_2012_PublicKeyParameters(); SetElement(_PARAMS_, params_); Element.Decode(buffer, true, len); } else { throw new Exception("Asn1InvalidChoiceOptionException (buffer, tag)"); } }
public static void TestEquals() { Asn1Tag integer = new Asn1Tag(TagClass.Universal, 2); Asn1Tag integerAgain = new Asn1Tag(TagClass.Universal, 2); Asn1Tag context2 = new Asn1Tag(TagClass.ContextSpecific, 2); Asn1Tag constructedContext2 = new Asn1Tag(TagClass.ContextSpecific, 2, true); Asn1Tag application2 = new Asn1Tag(TagClass.Application, 2); Assert.False(integer.Equals(null)); Assert.False(integer.Equals(0x02)); Assert.False(integer.Equals(context2)); Assert.False(context2.Equals(constructedContext2)); Assert.False(context2.Equals(application2)); Assert.Equal(integer, integerAgain); Assert.True(integer == integerAgain); Assert.True(integer != context2); Assert.False(integer == context2); Assert.False(context2 == constructedContext2); Assert.False(context2 == application2); Assert.NotEqual(integer.GetHashCode(), context2.GetHashCode()); Assert.NotEqual(context2.GetHashCode(), constructedContext2.GetHashCode()); Assert.NotEqual(context2.GetHashCode(), application2.GetHashCode()); Assert.Equal(integer.GetHashCode(), integerAgain.GetHashCode()); }
public override void Decode(Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength) { var tag = new Asn1Tag(); buffer.Mark(); var num = buffer.DecodeTagAndLength(tag); if (tag.Equals(0, 0, NullTypeCode)) { buffer.Reset(); var element = new NullParams(); SetElement(Null, element); Element.Decode(buffer, true, num); } else { if (!tag.Equals(0, 0x20, SequenceTypeCode)) { throw ExceptionUtility.CryptographicException(Resources.Asn1InvalidChoiceOptionTagException, tag, buffer.ByteCount); } buffer.Reset(); var parameters = new GostR341094PublicKeyParameters(); SetElement(Params, parameters); Element.Decode(buffer, true, num); } }
public override void Decode(Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength) { var tag = new Asn1Tag(); buffer.Mark(); var num = buffer.DecodeTagAndLength(tag); if (tag.Equals(0, 0, NullTypeCode)) { buffer.Reset(); SetElement(Null, new NullParams()); Element.Decode(buffer, true, num); } else { if (!tag.Equals(0, TagForm, TagIdCode)) { throw ExceptionUtility.CryptographicException(Resources.Asn1InvalidChoiceOptionTagException, tag, buffer.ByteCount); } buffer.Reset(); SetElement(Params, CreateParams()); Element.Decode(buffer, true, num); } }
public override void Decode (Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength) { int llen = (explicitTagging) ? MatchTag(buffer, Asn1Tag.Sequence) : implicitLength; Init(); // decode SEQUENCE Asn1BerDecodeContext context = new Asn1BerDecodeContext(buffer, llen); IntHolder elemLen = new IntHolder(); // decode encryptionParamSet if (context.MatchElemTag(Asn1Tag.Universal, Asn1Tag.PRIM, 6, elemLen, false)) { encryptionParamSet = new Gost28147_89_ParamSet(); encryptionParamSet.Decode(buffer, true, elemLen.Value); } else { throw new Exception("Asn1MissingRequiredException"); } // decode extElem1 if (!context.Expired()) { Asn1Tag _tag = buffer.PeekTag(); if (_tag.Equals(Asn1Tag.Universal, Asn1Tag.PRIM, 6)) { throw new Exception("Asn1SeqOrderException"); } else { extElem1 = new Asn1OpenExt(); while (!context.Expired()) { extElem1.DecodeComponent(buffer); } } } else { extElem1 = null; } }