[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35824 - gnunet/src/util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35824 - gnunet/src/util |
Date: |
Wed, 27 May 2015 09:42:45 +0200 |
Author: harsha
Date: 2015-05-27 09:42:45 +0200 (Wed, 27 May 2015)
New Revision: 35824
Modified:
gnunet/src/util/crypto_rsa.c
gnunet/src/util/test_crypto_rsa.c
Log:
validate the parsed RSA private key
Modified: gnunet/src/util/crypto_rsa.c
===================================================================
--- gnunet/src/util/crypto_rsa.c 2015-05-26 15:24:57 UTC (rev 35823)
+++ gnunet/src/util/crypto_rsa.c 2015-05-27 07:42:45 UTC (rev 35824)
@@ -222,7 +222,6 @@
size_t len)
{
struct GNUNET_CRYPTO_rsa_PrivateKey *key;
-
key = GNUNET_new (struct GNUNET_CRYPTO_rsa_PrivateKey);
if (0 !=
gcry_sexp_new (&key->sexp,
@@ -230,11 +229,18 @@
len,
0))
{
- GNUNET_break_op (0);
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Decoded private key is not valid\n");
GNUNET_free (key);
return NULL;
}
- /* FIXME: verify that this is an RSA private key */
+ if (0 != gcry_pk_testkey (key->sexp))
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Decoded private key is not valid\n");
+ GNUNET_CRYPTO_rsa_private_key_free (key);
+ return NULL;
+ }
return key;
}
Modified: gnunet/src/util/test_crypto_rsa.c
===================================================================
--- gnunet/src/util/test_crypto_rsa.c 2015-05-26 15:24:57 UTC (rev 35823)
+++ gnunet/src/util/test_crypto_rsa.c 2015-05-27 07:42:45 UTC (rev 35824)
@@ -54,6 +54,15 @@
char *enc;
enc = NULL;
size = GNUNET_CRYPTO_rsa_private_key_encode (priv, &enc);
+ /* Decoding */
+ GNUNET_CRYPTO_rsa_private_key_free (priv);
+ priv = NULL;
+ priv = GNUNET_CRYPTO_rsa_private_key_decode (enc, size);
+ GNUNET_assert (NULL != priv);
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
+ enc, size);
+ GNUNET_assert (NULL == GNUNET_CRYPTO_rsa_private_key_decode (enc, size));
+ (void) fprintf (stderr, "The above warning is expected.\n");
GNUNET_free (enc);
/* try ordinary sig first */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35824 - gnunet/src/util,
gnunet <=