Better approximation for signature size

Relates to #98.
This commit is contained in:
Alessio Di Mauro
2016-10-05 16:36:49 +02:00
parent af78e18151
commit 127227fe4c
+9 -1
View File
@@ -1865,7 +1865,15 @@ CK_DEFINE_FUNCTION(CK_RV, C_Sign)(
if (pSignature == NULL_PTR) {
// Just return the size of the signature
*pulSignatureLen = op_info.op.sign.key_len / 8 * 2 + 32; // Approximate the size of the signature. Specs agree with this.
if (is_RSA_mechanism(op_info.mechanism.mechanism)) {
// RSA
*pulSignatureLen = (op_info.op.sign.key_len + 7) / 8;
}
else {
// ECDSA
*pulSignatureLen = ((op_info.op.sign.key_len + 7) / 8) * 2;
}
DBG("The size of the signature will be %lu", *pulSignatureLen);
DOUT;