Example #1
0
		public void Constructor_DateTime_Now () 
		{
			Pkcs9SigningTime st = new Pkcs9SigningTime (DateTime.UtcNow);
			Assert.AreEqual (signingTimeName, st.Oid.FriendlyName, "Oid.FriendlyName");
			Assert.AreEqual (signingTimeOid, st.Oid.Value, "Oid.Value");
			Assert.AreEqual (15, st.RawData.Length, "RawData.Length");
			Assert.AreEqual (BitConverter.ToString (st.RawData).ToLower ().Replace ("-", " "), st.Format (true), "Format(true)");
			Assert.AreEqual (BitConverter.ToString (st.RawData).ToLower ().Replace ("-", " "), st.Format (false), "Format(false)");
		}
Example #2
0
		public void Constructor_Bytes () 
		{
			byte[] date = new byte [15] { 0x17, 0x0D, 0x30, 0x34, 0x30, 0x36, 0x33, 0x30, 0x30, 0x34, 0x30, 0x30, 0x30, 0x30, 0x5A };
			Pkcs9SigningTime st = new Pkcs9SigningTime (date);
			Assert.AreEqual (signingTimeName, st.Oid.FriendlyName, "Oid.FriendlyName");
			Assert.AreEqual (signingTimeOid, st.Oid.Value, "Oid.Value");
			Assert.AreEqual (15, st.RawData.Length, "RawData.Length");
			Assert.AreEqual ("17-0D-30-34-30-36-33-30-30-34-30-30-30-30-5A", BitConverter.ToString (st.RawData), "RawData");
			Assert.AreEqual (mono10release, st.SigningTime, "st.SigningTime");
			Assert.AreEqual ("17 0d 30 34 30 36 33 30 30 34 30 30 30 30 5a", st.Format (true), "Format(true)");
			Assert.AreEqual ("17 0d 30 34 30 36 33 30 30 34 30 30 30 30 5a", st.Format (false), "Format(false)");
		}
Example #3
0
		public void Constructor_DateTime_Before2050 ()
		{
			DateTime dt = new DateTime (2049, 12, 31, 11, 59, 59);
			// up to 2050 encoding should stay with UTCTIME (0x17), i.e. 2 digits years
			Pkcs9SigningTime st = new Pkcs9SigningTime (dt);
			Assert.AreEqual (signingTimeName, st.Oid.FriendlyName, "Oid.FriendlyName");
			Assert.AreEqual (signingTimeOid, st.Oid.Value, "Oid.Value");
			Assert.AreEqual (15, st.RawData.Length, "RawData.Length");
			Assert.AreEqual ("17-0D-34-39-31-32-33-31-31-31-35-39-35-39-5A", BitConverter.ToString (st.RawData));
			Assert.AreEqual (dt, st.SigningTime, "st.SigningTime");
			Assert.AreEqual ("17 0d 34 39 31 32 33 31 31 31 35 39 35 39 5a", st.Format (true), "Format(true)");
			Assert.AreEqual ("17 0d 34 39 31 32 33 31 31 31 35 39 35 39 5a", st.Format (false), "Format(false)");
		}
Example #4
0
		public void Constructor_DateTime ()
		{
			Pkcs9SigningTime st = new Pkcs9SigningTime (mono10release);
			Assert.AreEqual (signingTimeName, st.Oid.FriendlyName, "Oid.FriendlyName");
			Assert.AreEqual (signingTimeOid, st.Oid.Value, "Oid.Value");
			Assert.AreEqual (15, st.RawData.Length, "RawData.Length");
			Assert.AreEqual ("17-0D-30-34-30-36-33-30-30-34-30-30-30-30-5A", BitConverter.ToString (st.RawData), "RawData");
			Assert.AreEqual (mono10release, st.SigningTime, "st.SigningTime");
			Assert.AreEqual ("17 0d 30 34 30 36 33 30 30 34 30 30 30 30 5a", st.Format (true), "Format(true)");
			Assert.AreEqual ("17 0d 30 34 30 36 33 30 30 34 30 30 30 30 5a", st.Format (false), "Format(false)");
		}
Example #5
0
		public void Constructor_DateTime_After1950 ()
		{
			DateTime dt = new DateTime (1950, 01, 01, 00, 00, 00);
			// UTCTIME (0x17), i.e. 2 digits years, limited to 1950-2050
			Pkcs9SigningTime st = new Pkcs9SigningTime (dt);
			Assert.AreEqual (signingTimeName, st.Oid.FriendlyName, "Oid.FriendlyName");
			Assert.AreEqual (signingTimeOid, st.Oid.Value, "Oid.Value");
			Assert.AreEqual (15, st.RawData.Length, "RawData.Length");
			Assert.AreEqual ("17-0D-35-30-30-31-30-31-30-30-30-30-30-30-5A", BitConverter.ToString (st.RawData));
			Assert.AreEqual (dt, st.SigningTime, "st.SigningTime");
			Assert.AreEqual ("17 0d 35 30 30 31 30 31 30 30 30 30 30 30 5a", st.Format (true), "Format(true)");
			Assert.AreEqual ("17 0d 35 30 30 31 30 31 30 30 30 30 30 30 5a", st.Format (false), "Format(false)");
		}