public ObjectHandle CopyObject(ObjectHandle objectHandle, List<ObjectAttribute> attributes)
{
if (this._disposed)
throw new ObjectDisposedException(this.GetType().FullName);
if (objectHandle == null)
throw new ArgumentNullException("objectHandle");
ulong objectId = CK.CK_INVALID_HANDLE;
CK_ATTRIBUTE[] template = null;
ulong templateLength = 0;
if (attributes != null)
{
templateLength = Convert.ToUInt64(attributes.Count);
template = new CK_ATTRIBUTE[templateLength];
for (int i = 0; i < Convert.ToInt32(templateLength); i++)
template[i] = attributes[i].CkAttribute;
}
CKR rv = _p11.C_CopyObject(_sessionId, objectHandle.ObjectId, template, templateLength, ref objectId);
if (rv != CKR.CKR_OK)
throw new Pkcs11Exception("C_CopyObject", rv);
return new ObjectHandle(objectId);
}