CopyFrom() public method

public CopyFrom ( System asnEncodedData ) : void
asnEncodedData System
return void
Exemplo n.º 1
0
 public static void Pkcs9AttributeCopyFromAsnNotAPkcs9Attribute()
 {
     // Pkcs9AttributeObject.CopyFrom(AsnEncodedData) refuses to accept any AsnEncodedData that isn't a Pkcs9AttributeObject-derived class. 
     Pkcs9AttributeObject p = new Pkcs9AttributeObject();
     byte[] rawData = "041e4d00790020004400650073006300720069007000740069006f006e000000".HexToByteArray();
     AsnEncodedData a = new AsnEncodedData(Oids.DocumentName, rawData);
     Assert.Throws<ArgumentException>(() => p.CopyFrom(a));
 }
        internal static AsnEncodedDataCollection GetAsnEncodedDataCollection(System.Security.Cryptography.CAPI.CRYPT_ATTRIBUTE cryptAttribute)
        {
            AsnEncodedDataCollection datas = new AsnEncodedDataCollection();
            Oid    oid  = new Oid(cryptAttribute.pszObjId);
            string name = oid.Value;

            for (uint i = 0; i < cryptAttribute.cValue; i++)
            {
                IntPtr pBlob = new IntPtr(((long)cryptAttribute.rgValue) + (i * Marshal.SizeOf(typeof(System.Security.Cryptography.CAPI.CRYPTOAPI_BLOB))));
                Pkcs9AttributeObject asnEncodedData = new Pkcs9AttributeObject(oid, System.Security.Cryptography.CAPI.BlobToByteArray(pBlob));
                Pkcs9AttributeObject obj3           = CryptoConfig.CreateFromName(name) as Pkcs9AttributeObject;
                if (obj3 != null)
                {
                    obj3.CopyFrom(asnEncodedData);
                    asnEncodedData = obj3;
                }
                datas.Add(asnEncodedData);
            }
            return(datas);
        }
Exemplo n.º 3
0
		public void CopyFrom_Self ()
		{
			Pkcs9AttributeObject a = new Pkcs9AttributeObject ("1.2.3.4", new byte[2] { 0x05, 0x00 } );
			a.CopyFrom (new AsnEncodedData (a.Oid, a.RawData));
		}
Exemplo n.º 4
0
		public void CopyFrom_SigningTime_OidRaw ()
		{
			Pkcs9SigningTime st = new Pkcs9SigningTime (DateTime.UtcNow);
			Pkcs9AttributeObject a = new Pkcs9AttributeObject ();
			a.CopyFrom (new AsnEncodedData (st.Oid, st.RawData));
		}
Exemplo n.º 5
0
 public static void Pkcs9AttributeCopyFromNullAsn()
 {
     Pkcs9AttributeObject p = new Pkcs9AttributeObject();
     Assert.Throws<ArgumentNullException>(() => p.CopyFrom(null));
 }