internal unsafe CryptographicAttributeObjectCollection ReadAttributes(CRYPT_ATTRIBUTES attributes) { var collection = new CryptographicAttributeObjectCollection(); var attributeSize = Marshal.SizeOf <CRYPT_ATTRIBUTE>(); var blobSize = Marshal.SizeOf <CRYPTOAPI_BLOB>(); for (var i = 0; i < attributes.cAttr; i++) { var structure = Marshal.PtrToStructure <CRYPT_ATTRIBUTE>(attributes.rgAttr + (i * attributeSize)); var asnValues = new AsnEncodedDataCollection(); for (var j = 0; j < structure.cValue; j++) { var blob = Marshal.PtrToStructure <CRYPTOAPI_BLOB>(structure.rgValue + j * blobSize); asnValues.Add(new AsnEncodedData(structure.pszObjId, ReadBlob(blob))); } collection.Add(new CryptographicAttributeObject(new Oid(structure.pszObjId), asnValues)); } return(collection); }
private static unsafe CryptographicAttributeObjectCollection ToCryptographicAttributeObjectCollection(CRYPT_ATTRIBUTES* pCryptAttributes) { CryptographicAttributeObjectCollection collection = new CryptographicAttributeObjectCollection(); for (int i = 0; i < pCryptAttributes->cAttr; i++) { CRYPT_ATTRIBUTE* pCryptAttribute = &(pCryptAttributes->rgAttr[i]); AddCryptAttribute(collection, pCryptAttribute); } return collection; }