Net.Pkcs11Interop.HighLevelAPI40.Session.CopyObject C# (CSharp) Метод

CopyObject() публичный Метод

Copies an object, creating a new object for the copy
public CopyObject ( ObjectHandle objectHandle, List attributes ) : ObjectHandle
objectHandle ObjectHandle Handle of object to be copied
attributes List New values for any attributes of the object that can ordinarily be modified
Результат ObjectHandle
        public ObjectHandle CopyObject(ObjectHandle objectHandle, List<ObjectAttribute> attributes)
        {
            if (this._disposed)
                throw new ObjectDisposedException(this.GetType().FullName);

            if (objectHandle == null)
                throw new ArgumentNullException("objectHandle");

            uint objectId = CK.CK_INVALID_HANDLE;

            CK_ATTRIBUTE[] template = null;
            uint templateLength = 0;

            if (attributes != null)
            {
                templateLength = Convert.ToUInt32(attributes.Count);
                template = new CK_ATTRIBUTE[templateLength];
                for (int i = 0; i < 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);
        }