CopyFrom() публичный Метод

public CopyFrom ( System asnEncodedData ) : void
asnEncodedData System
Результат void
Пример #1
0
		public void CopyFrom ()
		{
			/* byte[] data = ASN1Convert.FromOid ("1.2.840.113549.1.7.1").GetBytes (); */
			byte[] data = { 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01 };
			AsnEncodedData aed = new AsnEncodedData (data);
			Pkcs9ContentType ct = new Pkcs9ContentType ();
			ct.CopyFrom (aed);
		}
		public void CopyFrom ()
		{
			/* byte[] data = ASN1Convert.FromOid ("1.2.840.113549.1.7.1").GetBytes (); */
			byte[] data = { 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01 };
			AsnEncodedData aed = new AsnEncodedData (data);
			Pkcs9ContentType ct = new Pkcs9ContentType ();
			ct.CopyFrom (aed);
			Assert.AreEqual ("1.2.840.113549.1.7.1", ct.ContentType.Value, "ContentType");
			Assert.IsNull (ct.Oid, "Oid");
			Assert.AreEqual (data, ct.RawData, "RawData");
		}
Пример #3
0
		public void CopyFrom_BadData ()
		{
			/* Note: this is the full structure (but only the OID part is required)
			ASN1 set = new ASN1 (0x30);
			set.Add (ASN1Convert.FromOid ("1.2.840.113549.1.7.1"));
			ASN1 p9 = new ASN1 (0x30);
			p9.Add (ASN1Convert.FromOid ("1.2.840.113549.1.9.3"));
			p9.Add (set);
			byte[] data = p9.GetBytes ();*/
			byte[] data = { 0x30, 0x18, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x03, 0x30, 0x0B, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01 };
			AsnEncodedData aed = new AsnEncodedData (data);
			Pkcs9ContentType ct = new Pkcs9ContentType ();
			ct.CopyFrom (aed);
		}
Пример #4
0
 private static Pkcs9ContentType CreatePkcs9ContentType(byte[] rawData)
 {
     Pkcs9ContentType pkcs9ContentType = new Pkcs9ContentType();
     Pkcs9AttributeObject pkcs9AttributeObject = new Pkcs9AttributeObject(pkcs9ContentType.Oid, rawData);
     pkcs9ContentType.CopyFrom(pkcs9AttributeObject);
     return pkcs9ContentType;
 }
Пример #5
0
        public static void ContentTypeFromCookedData()
        {
            string contentType = "1.3.8473.23.4773.23";
            byte[] encodedContentType = "06072bc21917a52517".HexToByteArray();
            Pkcs9ContentType p = new Pkcs9ContentType();
            Pkcs9AttributeObject pkcs9AttributeObject = new Pkcs9AttributeObject(p.Oid, encodedContentType);
            p.CopyFrom(pkcs9AttributeObject);

            string cookedData = p.ContentType.Value;
            Assert.Equal(contentType, cookedData);
            string oid = p.Oid.Value;
            Assert.Equal(s_OidContentType, oid);
        }