Add() public method

public Add ( System asnEncodedData ) : int
asnEncodedData System
return int
		public void ConstructorOidCollection () 
		{
			Oid o = new Oid (defaultOid);
			AsnEncodedDataCollection coll = new AsnEncodedDataCollection ();
			CryptographicAttributeObject ca = new CryptographicAttributeObject (o, coll);
			Assert.AreEqual (defaultName, ca.Oid.FriendlyName, "Oid.FriendlyName");
			Assert.AreEqual (defaultOid, ca.Oid.Value, "Oid.Value");
			Assert.AreEqual (0, ca.Values.Count, "Values - 0");
			coll.Add (new AsnEncodedData (new byte [0]));
			Assert.AreEqual (1, ca.Values.Count, "Values - 1");
		}
        public static void CryptographicAttributeObjectMismatch()
        {
            Oid oid = new Oid(Oids.DocumentDescription);
            Oid wrongOid = new Oid(Oids.DocumentName);

            AsnEncodedDataCollection col = new AsnEncodedDataCollection();
            col.Add(new AsnEncodedData(oid, new byte[3]));

            object ignore;
            Assert.Throws<InvalidOperationException>(() => ignore = new CryptographicAttributeObject(wrongOid, col));
        }
 internal static AsnEncodedDataCollection GetAsnEncodedDataCollection(System.Security.Cryptography.CAPI.CRYPT_ATTRIBUTE_TYPE_VALUE cryptAttribute)
 {
     AsnEncodedDataCollection datas = new AsnEncodedDataCollection();
     datas.Add(new Pkcs9AttributeObject(new Oid(cryptAttribute.pszObjId), System.Security.Cryptography.CAPI.BlobToByteArray(cryptAttribute.Value)));
     return datas;
 }
 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;
 }
Example #5
0
 internal static AsnEncodedDataCollection GetAsnEncodedDataCollection (CAPI.CRYPT_ATTRIBUTE_TYPE_VALUE cryptAttribute) {
     AsnEncodedDataCollection list = new AsnEncodedDataCollection();
     list.Add(new Pkcs9AttributeObject(new Oid(cryptAttribute.pszObjId), CAPI.BlobToByteArray(cryptAttribute.Value)));
     return list;
 }
Example #6
0
        internal static AsnEncodedDataCollection GetAsnEncodedDataCollection (CAPI.CRYPT_ATTRIBUTE cryptAttribute) {
            AsnEncodedDataCollection list = new AsnEncodedDataCollection();
            Oid oid = new Oid(cryptAttribute.pszObjId);
            string szOid = oid.Value;

            for (uint index = 0; index < cryptAttribute.cValue; index++) {
                checked {
                    IntPtr pAttributeBlob = new IntPtr((long)cryptAttribute.rgValue + (index * Marshal.SizeOf(typeof(CAPI.CRYPTOAPI_BLOB))));
                    Pkcs9AttributeObject attribute = new Pkcs9AttributeObject(oid, CAPI.BlobToByteArray(pAttributeBlob));
                    Pkcs9AttributeObject customAttribute = CryptoConfig.CreateFromName(szOid) as Pkcs9AttributeObject;
                    if (customAttribute != null) {
                        customAttribute.CopyFrom(attribute);
                        attribute = customAttribute;
                    }
                    list.Add(attribute);
                }
            }
            return list;
        }