Пример #1
0
		public void Assign(ASN1Object ob)
		{
			/// mozda ne bi bilo lose da se
			/// prije provjeri da li ovaj tip uopce smije
			/// biti u ovoj CHOICE strukturi... 
			/// 
			/// laters.
			
			this.chosen = ob;
			

			/// ??? 
			///  \/
			
			/// Ovo prespajanje treba napraviti tako da se moze 
			/// testirati MatchType... inace ovaj objekt ostaje 
			/// sa Tag == 0.
			//this.Tag = ob.Tag;

			/*
			 *  this.aTag = new MultiASN1TAG(ob.aTag)
			 * 
			 */
			
		}
Пример #2
0
		public virtual void Assign(ASN1Object ulazASN1) 
		{
			this.underObject = ulazASN1;
			
			///This one is usually a no-op, unless overriden.
			this.RegisterComponents();
		}
		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;
		}
Пример #5
0
		public virtual bool CheckType(ASN1Object obo) 
		{
			return true; /* OOOPS */
		}
Пример #6
0
		public static void DumpDERToFile(ASN1Object ob, String filename) 
		{
			try 
			{
				FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write);
				
				BERWriter br = new BERWriter(fs);
				br.Write(ob.asDER().GetBERCode());
				
				fs.Close();
				br.Close();
			}
			catch
			{
				Console.WriteLine("Failed at writing Data BER to file.");
			}
		}
Пример #7
0
		public static void DumpHEX(ASN1Object ob) 
		{
			DumpHEX(ob.asDER());
		}
Пример #8
0
		public virtual void Add(ASN1Object obo) 
		{
			if (this.CheckType(obo))
			{
				this.Elements.Add(obo);
			}
			else 
			{
				throw new Exception("Wrong type for this SEQUENCE OF");
			}
		}
Пример #9
0
		/// <summary>
		/// Must rename this to CheckTag... an introspection any deeper
		/// than this is pointless..
		/// </summary>
		/// <param name="obo"></param>
		/// <returns></returns>
		public virtual bool CheckType(ASN1Object obo) 
		{
			//return ASN1Type.MatchType(obo, _type);
			return true;
		}
Пример #10
0
		protected virtual void DoComponentAssign(int j, ASN1Object ulaz)
		{
			this.Components[j] = ulaz;
		}
Пример #11
0
		protected void RegType(ASN1Type tip, ASN1Object defaultValue)
		{
			this.ComponentTypes[typeCounter] = ASN1ComponentTypeInfo.Make(tip, defaultValue);
			typeCounter++;
		}
Пример #12
0
		/// <summary>
		/// MUST CHANGE, MOVE OR WHATEVER....
		///    usage - u ASN1Sequence..
		///    
		///    <para>Returns true if ASN1Object ob and ASN1Type tip match.</para>
		/// </summary>
		/// <param name="ob"></param>
		/// <param name="tip"></param>
		/// <returns></returns>
		public static bool MatchType(ASN1Object ob, ASN1Type tip) 
		{
			if ((tip == null)||(ob==null)) 
			{
				/// Ovo je zbog SET OF.
				/// Nadam se da necu platiti penale za ovo. :-(
				return true;
			}
			if (tip.SkipMatch) 
			{
				return true;
			}
			else if (tip.Tags != null) 
			{
				return (tip.Tags.Contains(ob.Tag));
			}
			else return (ob.Tag == tip.Tag);
		}
Пример #13
0
		private void DecodeByTagNumber(int tagNum, BEREncoding ulazBER) 
		{
			/// BAAAD!!!
			foreach (ASN1Type tip in this.Alternatives) 
			{
				if (tagNum == tip.Tag) 
				{
					this.chosen = tip.CreateInstance(ulazBER);
					this.Tag = tagNum;
					return;
				}
			}

			throw new Exception("Unrecognized alternative in CHOICE!");
		}