Esempio n. 1
0
		public void Test_SET_OF()
		{
			test_SET_OF tSET_OF = new test_SET_OF();
			tSET_OF.Add(SimpleSamples.funnyOID);
		 


			test_SET_OF_type t_type = new test_SET_OF_type();
			test_SET_OF t1 = t_type.CreateInstance(tSET_OF.asBER()) as test_SET_OF;


			BERWriter.DumpHEX(t1);
			BERWriter.DumpHEX(tSET_OF);
			
			
			
			Console.WriteLine("\nTest invalid element insertion:");
			/// ovo bi trebalo baciti Exception
			try
			{
				tSET_OF.Add(SimpleSamples.funnyOID);
			}
			catch(mASN1Exception e)
			{
				Console.WriteLine(".. was expecting SET struct to complain about already existing element");
				Console.WriteLine("Exception: "+e.Message);
			}
			finally
			{
				Console.WriteLine("This was \"SET OF\" Exception testing");
			}
			

			
			
			Console.WriteLine("\nTest DER-sorting:");
			ASN1ObjectIdentifier oid1=new ASN1ObjectIdentifier(), 
				oid2=new ASN1ObjectIdentifier(), 
				oid3=new ASN1ObjectIdentifier();
			oid1.Assign(1, 2, 0);
			oid2.Assign(1, 2, 1);
			oid3.Assign(1, 2, 2);

			tSET_OF.Add(oid1, oid3, oid2);
			Console.WriteLine(tSET_OF.ToBERString());
			Console.WriteLine(tSET_OF.ToDERString());

			// These shouldn't be equal, because DER is BER-sorted.
			Assert.IsFalse(BERComparer.Equals(tSET_OF.asBER(), tSET_OF.asDER()));






			
		}
Esempio n. 2
0
		public void Test_OBJECT_IDENTIFIER()
		{
			ASN1ObjectIdentifier oid = SimpleSamples.funnyOID;

			BERWriter.DumpHEX(oid);
			Console.WriteLine(oid.ToString());

			ASN1ObjectIdentifier oid1 = new ASN1ObjectIdentifier();

			oid1.Assign(1, 2, 3, 4, 5, 6, 7);
			BERWriter.DumpHEX(oid1);
			Console.WriteLine(oid1.ToString());

			Assert.AreEqual(oid, oid1);

			BEREncoding ber = oid.asDER();
			ASN1ObjectIdentifier_type oid_t = new ASN1ObjectIdentifier_type();

			ASN1ObjectIdentifier oid2 = oid_t.CreateInstance(ber) as ASN1ObjectIdentifier;

			BERWriter.DumpHEX(oid2);





			Console.WriteLine("Unfinished business");
		}
		public void Test_INFORMATION_OBJECT_SET ()
		{
			ASN1InformationObjectSet iob_set1 = new ASN1InformationObjectSet();
				
			TypeIdentifier ti1 = new TypeIdentifier();
			ti1.Assign(SimpleSamples.funnyOID, ASN1Null.asn1type);

			TypeIdentifier ti2 = new TypeIdentifier();
			ti2.Assign(new ASN1ObjectIdentifier(1, 2, 3), new ASN1Boolean_type());

			iob_set1.Add(ti1);
			
			ASN1ObjectIdentifier unique = new ASN1ObjectIdentifier();
			unique.Assign(1, 2, 3, 4);


			Console.WriteLine("To be cont...");
		}