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 Constructor_Empty () { Pkcs9ContentType ct = new Pkcs9ContentType (); Assert.AreEqual ("1.2.840.113549.1.9.3", ct.Oid.Value, "Oid.Value"); Assert.AreEqual ("Content Type", ct.Oid.FriendlyName, "Oid.FriendlyName"); Assert.IsNull (ct.RawData, "RawData"); Assert.IsNull (ct.ContentType, "ContentType"); Assert.AreEqual (String.Empty, ct.Format (true), "Format(true)"); Assert.AreEqual (String.Empty, ct.Format (false), "Format(false)"); }
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"); }
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); }
private static Pkcs9ContentType CreatePkcs9ContentType(byte[] rawData) { Pkcs9ContentType pkcs9ContentType = new Pkcs9ContentType(); Pkcs9AttributeObject pkcs9AttributeObject = new Pkcs9AttributeObject(pkcs9ContentType.Oid, rawData); pkcs9ContentType.CopyFrom(pkcs9AttributeObject); return pkcs9ContentType; }
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); }
public static void ContentTypeNullary() { Pkcs9ContentType p = new Pkcs9ContentType(); Assert.Null(p.RawData); Assert.Null(p.ContentType); string oid = p.Oid.Value; Assert.Equal(s_OidContentType, oid); }