From 4867251671aad340962f5db54a6dd5aace62513d Mon Sep 17 00:00:00 2001 From: okir Date: Mon, 20 Jan 2003 09:52:05 +0000 Subject: [PATCH] - fix sc_pkcs11_signature_size to return modulus size in bytes, not bits (Stef) git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@869 c6295689-39f2-0310-b995-f0e70906c6a9 --- src/pkcs11/mechanism.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pkcs11/mechanism.c b/src/pkcs11/mechanism.c index ff7e5325..c4916d38 100644 --- a/src/pkcs11/mechanism.c +++ b/src/pkcs11/mechanism.c @@ -389,9 +389,16 @@ sc_pkcs11_signature_size(sc_pkcs11_operation_t *operation, CK_ULONG_PTR pLength) { struct sc_pkcs11_object *key; CK_ATTRIBUTE attr = { CKA_MODULUS_BITS, pLength, sizeof(*pLength) }; + CK_RV rc; key = ((struct signature_data *) operation->priv_data)->key; - return key->ops->get_attribute(operation->session, key, &attr); + rv = key->ops->get_attribute(operation->session, key, &attr); + + /* convert bits to bytes */ + if (rv == CKR_OK) + *pLength = (*pLength + 7) / 8; + + return rv; } static void