Net.Pkcs11Interop.HighLevelAPI81.Session.Verify C# (CSharp) Method

Verify() public method

Verifies a signature of data, where the signature is an appendix to the data
public Verify ( Mechanism mechanism, ObjectHandle keyHandle, byte data, byte signature, bool &isValid ) : void
mechanism Mechanism Verification mechanism;
keyHandle ObjectHandle Verification key
data byte Data that was signed
signature byte Signature
isValid bool Flag indicating whether signature is valid
return void
        public void Verify(Mechanism mechanism, ObjectHandle keyHandle, byte[] data, byte[] signature, out bool isValid)
        {
            if (this._disposed)
                throw new ObjectDisposedException(this.GetType().FullName);

            if (mechanism == null)
                throw new ArgumentNullException("mechanism");
            
            if (keyHandle == null)
                throw new ArgumentNullException("keyHandle");
            
            if (data == null)
                throw new ArgumentNullException("data");

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

            CK_MECHANISM ckMechanism = mechanism.CkMechanism;

            CKR rv = _p11.C_VerifyInit(_sessionId, ref ckMechanism, keyHandle.ObjectId);
            if (rv != CKR.CKR_OK)
                throw new Pkcs11Exception("C_VerifyInit", rv);

            rv = _p11.C_Verify(_sessionId, data, Convert.ToUInt64(data.Length), signature, Convert.ToUInt64(signature.Length));
            if (rv == CKR.CKR_OK)
                isValid = true;
            else if (rv == CKR.CKR_SIGNATURE_INVALID)
                isValid = false;
            else 
                throw new Pkcs11Exception("C_Verify", rv);
        }

Same methods

Session::Verify ( Mechanism mechanism, ObjectHandle keyHandle, Stream inputStream, byte signature, bool &isValid ) : void
Session::Verify ( Mechanism mechanism, ObjectHandle keyHandle, Stream inputStream, byte signature, bool &isValid, int bufferLength ) : void