[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: add pk invariant check
From: |
gnunet |
Subject: |
[gnunet] branch master updated: add pk invariant check |
Date: |
Thu, 25 Nov 2021 14:49:33 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 63854ee52 add pk invariant check
63854ee52 is described below
commit 63854ee52ec8d24928c2346928a3dbea22ebd1fe
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Thu Nov 25 14:38:48 2021 +0100
add pk invariant check
---
src/include/gnunet_crypto_lib.h | 9 +++++++++
src/util/crypto_rsa.c | 24 ++++++++++++++++++++++++
2 files changed, 33 insertions(+)
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
@@ -2215,6 +2215,15 @@ GNUNET_CRYPTO_rsa_public_key_hash (const struct
GNUNET_CRYPTO_RsaPublicKey *key,
struct GNUNET_HashCode *hc);
+/**
+ * Check if @a key is well-formed.
+ *
+ * @return true if @a key is well-formed.
+ */
+bool
+GNUNET_CRYPTO_rsa_public_key_check (
+ const struct GNUNET_CRYPTO_RsaPublicKey *key);
+
/**
* Obtain the length of the RSA key in bits.
*
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
GNUNET_NETWORK_STRUCT_END
+bool
+GNUNET_CRYPTO_rsa_public_key_check (
+ const struct GNUNET_CRYPTO_RsaPublicKey *key)
+{
+ gcry_mpi_t ne[2];
+ int ret;
+
+ ret = key_from_sexp (ne,
+ key->sexp,
+ "public-key",
+ "ne");
+ if (0 != ret)
+ ret = key_from_sexp (ne,
+ key->sexp,
+ "rsa",
+ "ne");
+ if (0 != ret)
+ return false;
+ gcry_mpi_release (ne[0]);
+ gcry_mpi_release (ne[1]);
+ return true;
+}
+
+
size_t
GNUNET_CRYPTO_rsa_public_key_encode (
const struct GNUNET_CRYPTO_RsaPublicKey *key,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: add pk invariant check,
gnunet <=