[gnome-keyring/gnome-2-26] Fixed problem with RSA key sizes that were not a multiple of 8.
- From: Stefan Walter <stefw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-keyring/gnome-2-26] Fixed problem with RSA key sizes that were not a multiple of 8.
- Date: Fri, 26 Jun 2009 16:14:02 +0000 (UTC)
commit bea17154da4c84f54064489e8ea875b74c7a6256
Author: Stef Walter <stef memberwebs com>
Date: Fri Jun 26 16:11:49 2009 +0000
Fixed problem with RSA key sizes that were not a multiple of 8.
This was a problem in the PKCS#1 padding functions, which calculated
the padding length incorrectly. All instances of this have been
searched out and fixed. Should fix bug #576700 at least with the
key that Robert Ancell posted.
pkcs11/gck/gck-crypto.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/pkcs11/gck/gck-crypto.c b/pkcs11/gck/gck-crypto.c
index c42625d..294b0f1 100644
--- a/pkcs11/gck/gck-crypto.c
+++ b/pkcs11/gck/gck-crypto.c
@@ -199,12 +199,15 @@ unpad_rsa_pkcs1 (guchar bt, guint n_modulus, const guchar* padded,
gsize n_padded, gsize *n_raw)
{
const guchar *at;
+ guint check;
guchar *raw;
+ check = (n_modulus + 7) / 8;
+
/* The absolute minimum size including padding */
- g_return_val_if_fail (n_modulus / 8 >= 3 + 8, NULL);
+ g_return_val_if_fail (check >= 3 + 8, NULL);
- if (n_padded != n_modulus / 8)
+ if (n_padded != check)
return NULL;
/* Check the header */
@@ -899,7 +902,7 @@ gck_crypto_rsa_pad_raw (guint n_modulus, const guchar* raw,
* padding data
*/
- total = n_modulus / 8;
+ total = (n_modulus + 7) / 8;
n_pad = total - n_raw;
if (n_pad < 0) /* minumum padding */
return NULL;
@@ -924,7 +927,7 @@ gck_crypto_rsa_pad_one (guint n_modulus, const guchar* raw,
* type padding data
*/
- total = n_modulus / 8;
+ total = (n_modulus + 7) / 8;
n_pad = total - 3 - n_raw;
if (n_pad < 8) /* minumum padding */
return NULL;
@@ -950,7 +953,7 @@ gck_crypto_rsa_pad_two (guint n_modulus, const guchar* raw,
* type padding data
*/
- total = n_modulus / 8;
+ total = (n_modulus + 7) / 8;
n_pad = total - 3 - n_raw;
if (n_pad < 8) /* minumum padding */
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]