/// <summary>
		/// Constructor for creating extensions of existing OIDs.
		/// </summary>
		/// <param name="oid">base OID</param>
		/// <param name="values">added ints</param>
		public ASN1ObjectIdentifier(ASN1ObjectIdentifier oid, params int[] values) 
		{
			this.Init();
			this.Values = new int[values.Length+oid.Values.Length];
			oid.Values.CopyTo(this.Values, 0);
			values.CopyTo(this.Values, oid.Values.Length);
		}
Esempio n. 2
0
		public string GetDescription(ASN1ObjectIdentifier oid) 
		{
			string retString = (hashTable[oid.ToString()] as string);
			if (retString == null) retString=oid.ToString();

			return retString;
		}
		public InformationObject GetInformationObject(ASN1ObjectIdentifier oid) 
		{
			foreach (InformationObject iob in Elements) 
			{
				if (iob.uniqueId==oid) return iob;
			}

			throw 
				new mASN1.UnrecognizedObjectIdentifierException("unrecognized OID:"+oid+"(not in IOSet)");
		}
//		public InformationObject GetInformationObjectFromUID(UniqueObject uid) 
//		{
//			foreach (InformationObject iob in this.Elements) 
//			{
//				/* As soon as InformationObject is found - return */
//                if (uid.id == iob.uniqueId) return iob;
//			}
//
//			/* none found */
//			return null;
//		}

		public InformationObject GetInformationObjectFromUID(ASN1ObjectIdentifier uoid)
		{
			foreach (InformationObject iob in this.Elements)
			{
				if((uoid as ASN1ObjectIdentifier)==iob.uniqueId)
				{
					return iob;
				}
			}

			return null;
		}
		public override void RegisterComponents()
		{
			this.algorithm  = NextComponent() as ASN1ObjectIdentifier;
			this.parameters = NextComponent(); // notice the missing cast...
			// since the type cannot be resolved at compile-time this ASN1Object 
			// member has no cast.
		}
		public override void RegisterComponents()
		{
			this.type                 = NextComponent() as ASN1ObjectIdentifier;
			this.value                = NextComponent(); // as WHAT?
		    this.valuesWithContext    = NextComponent() as ValuesWithContext;

			/// povezi!!! 
			this.unique_TypeInfo.uoid = this.type;
		}
		/// <summary>
		/// Koji je UNIQUE?
		/// </summary>
		public void Assign(ASN1ObjectIdentifier _id, ASN1Type _type) 
		{
			this.id   = _id;
			this.type = _type;
			this.uniqueId = this.id;
		}
		public TypeIdentifier(ASN1ObjectIdentifier _id, ASN1Type _type) 
		{
			this.Assign(_id, _type);
		}
		public void Remove(ASN1ObjectIdentifier oid)
		{
			
		}
		public void Add(ASN1ObjectIdentifier oid, ASN1Type type)
		{
			TypeIdentifier ti = new TypeIdentifier(oid, type);
			this.Add(ti);
		}
Esempio n. 11
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");
		}
Esempio n. 12
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()));






			
		}
		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...");
		}