[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/release-0.2.2] Add crypto_pk_check_key_public_exponent function



commit d2629f78a000486f8f994ba0ab75ceeaee67fc55
Author: Robert Ransom <rransom.8774@xxxxxxxxx>
Date:   Thu Apr 28 12:13:03 2011 -0700

    Add crypto_pk_check_key_public_exponent function
---
 src/common/crypto.c |   12 ++++++++++++
 src/common/crypto.h |    1 +
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/common/crypto.c b/src/common/crypto.c
index f3268fe..6761fd7 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -656,6 +656,18 @@ crypto_pk_key_is_private(const crypto_pk_env_t *key)
   return PRIVATE_KEY_OK(key);
 }
 
+/** Return true iff <b>env</b> contains a public key whose public exponent
+ * equals 65537.
+ */
+int
+crypto_pk_check_key_public_exponent(crypto_pk_env_t *env)
+{
+  tor_assert(env);
+  tor_assert(env->key);
+
+  return BN_is_word(env->key->e, 65537);
+}
+
 /** Compare the public-key components of a and b.  Return -1 if a\<b, 0
  * if a==b, and 1 if a\>b.
  */
diff --git a/src/common/crypto.h b/src/common/crypto.h
index 576c03d..0fcd067 100644
--- a/src/common/crypto.h
+++ b/src/common/crypto.h
@@ -92,6 +92,7 @@ size_t crypto_pk_keysize(crypto_pk_env_t *env);
 crypto_pk_env_t *crypto_pk_dup_key(crypto_pk_env_t *orig);
 crypto_pk_env_t *crypto_pk_copy_full(crypto_pk_env_t *orig);
 int crypto_pk_key_is_private(const crypto_pk_env_t *key);
+int crypto_pk_check_key_public_exponent(crypto_pk_env_t *env);
 
 int crypto_pk_public_encrypt(crypto_pk_env_t *env, char *to, size_t tolen,
                              const char *from, size_t fromlen, int padding);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits