diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-11-25 14:38:48 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-11-25 14:38:48 +0100 |
commit | 63854ee52ec8d24928c2346928a3dbea22ebd1fe (patch) | |
tree | 353e8104a758592004d59c1d3ecdcd0186a4fe8e /src/util/crypto_rsa.c | |
parent | fff38c7f0b1bee8302b4e5689c77412d28542398 (diff) | |
download | gnunet-63854ee52ec8d24928c2346928a3dbea22ebd1fe.tar.gz gnunet-63854ee52ec8d24928c2346928a3dbea22ebd1fe.zip |
add pk invariant check
Diffstat (limited to 'src/util/crypto_rsa.c')
-rw-r--r-- | src/util/crypto_rsa.c | 24 |
1 files changed, 24 insertions, 0 deletions
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, |