diff options
-rw-r--r-- | src/include/gnunet_crypto_lib.h | 9 | ||||
-rw-r--r-- | src/util/crypto_rsa.c | 24 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 0eb2ea8cd..edb4bb230 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -2216,6 +2216,15 @@ GNUNET_CRYPTO_rsa_public_key_hash (const struct GNUNET_CRYPTO_RsaPublicKey *key, | |||
2216 | 2216 | ||
2217 | 2217 | ||
2218 | /** | 2218 | /** |
2219 | * Check if @a key is well-formed. | ||
2220 | * | ||
2221 | * @return true if @a key is well-formed. | ||
2222 | */ | ||
2223 | bool | ||
2224 | GNUNET_CRYPTO_rsa_public_key_check ( | ||
2225 | const struct GNUNET_CRYPTO_RsaPublicKey *key); | ||
2226 | |||
2227 | /** | ||
2219 | * Obtain the length of the RSA key in bits. | 2228 | * Obtain the length of the RSA key in bits. |
2220 | * | 2229 | * |
2221 | * @param key the public key to introspect | 2230 | * @param key the public key to introspect |
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index f017d1f10..43e6eedac 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c | |||
@@ -296,6 +296,30 @@ struct GNUNET_CRYPTO_RsaPublicKeyHeaderP | |||
296 | GNUNET_NETWORK_STRUCT_END | 296 | GNUNET_NETWORK_STRUCT_END |
297 | 297 | ||
298 | 298 | ||
299 | bool | ||
300 | GNUNET_CRYPTO_rsa_public_key_check ( | ||
301 | const struct GNUNET_CRYPTO_RsaPublicKey *key) | ||
302 | { | ||
303 | gcry_mpi_t ne[2]; | ||
304 | int ret; | ||
305 | |||
306 | ret = key_from_sexp (ne, | ||
307 | key->sexp, | ||
308 | "public-key", | ||
309 | "ne"); | ||
310 | if (0 != ret) | ||
311 | ret = key_from_sexp (ne, | ||
312 | key->sexp, | ||
313 | "rsa", | ||
314 | "ne"); | ||
315 | if (0 != ret) | ||
316 | return false; | ||
317 | gcry_mpi_release (ne[0]); | ||
318 | gcry_mpi_release (ne[1]); | ||
319 | return true; | ||
320 | } | ||
321 | |||
322 | |||
299 | size_t | 323 | size_t |
300 | GNUNET_CRYPTO_rsa_public_key_encode ( | 324 | GNUNET_CRYPTO_rsa_public_key_encode ( |
301 | const struct GNUNET_CRYPTO_RsaPublicKey *key, | 325 | const struct GNUNET_CRYPTO_RsaPublicKey *key, |