public override void PerformTest() { DerApplicationSpecific app = (DerApplicationSpecific) Asn1Object.FromByteArray(longTagged); app = (DerApplicationSpecific)Asn1Object.FromByteArray(app.GetContents()); Asn1InputStream aIn = new Asn1InputStream(app.GetContents()); Asn1TaggedObject tagged = (Asn1TaggedObject)aIn.ReadObject(); if (tagged.TagNo != 32) { Fail("unexpected tag value found - not 32"); } tagged = (Asn1TaggedObject)Asn1Object.FromByteArray(tagged.GetEncoded()); if (tagged.TagNo != 32) { Fail("unexpected tag value found on recode - not 32"); } tagged = (Asn1TaggedObject)aIn.ReadObject(); if (tagged.TagNo != 33) { Fail("unexpected tag value found - not 33"); } tagged = (Asn1TaggedObject)Asn1Object.FromByteArray(tagged.GetEncoded()); if (tagged.TagNo != 33) { Fail("unexpected tag value found on recode - not 33"); } aIn = new Asn1InputStream(longAppSpecificTag); app = (DerApplicationSpecific)aIn.ReadObject(); if (app.ApplicationTag != 97) { Fail("incorrect tag number read"); } app = (DerApplicationSpecific)Asn1Object.FromByteArray(app.GetEncoded()); if (app.ApplicationTag != 97) { Fail("incorrect tag number read on recode"); } SecureRandom sr = new SecureRandom(); for (int i = 0; i < 100; ++i) { int testTag = (sr.NextInt() & int.MaxValue) >> sr.Next(26); app = new DerApplicationSpecific(testTag, new byte[] { 1 }); app = (DerApplicationSpecific)Asn1Object.FromByteArray(app.GetEncoded()); if (app.ApplicationTag != testTag) { Fail("incorrect tag number read on recode (random test value: " + testTag + ")"); } } }