public byte[] SignRecover(Mechanism mechanism, ObjectHandle keyHandle, byte[] data)
{
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");
CK_MECHANISM ckMechanism = mechanism.CkMechanism;
CKR rv = _p11.C_SignRecoverInit(_sessionId, ref ckMechanism, keyHandle.ObjectId);
if (rv != CKR.CKR_OK)
throw new Pkcs11Exception("C_SignRecoverInit", rv);
ulong signatureLen = 0;
rv = _p11.C_SignRecover(_sessionId, data, Convert.ToUInt64(data.Length), null, ref signatureLen);
if (rv != CKR.CKR_OK)
throw new Pkcs11Exception("C_SignRecover", rv);
byte[] signature = new byte[signatureLen];
rv = _p11.C_SignRecover(_sessionId, data, Convert.ToUInt64(data.Length), signature, ref signatureLen);
if (rv != CKR.CKR_OK)
throw new Pkcs11Exception("C_SignRecover", rv);
if (signature.Length != Convert.ToInt32(signatureLen))
Array.Resize(ref signature, Convert.ToInt32(signatureLen));
return signature;
}