]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add crypto_pk_check_key_public_exponent function
authorRobert Ransom <rransom.8774@gmail.com>
Thu, 28 Apr 2011 19:13:03 +0000 (12:13 -0700)
committerNick Mathewson <nickm@torproject.org>
Mon, 16 May 2011 18:07:34 +0000 (14:07 -0400)
src/common/crypto.c
src/common/crypto.h

index f3268fe183b22664e893b95191b12617ee2329be..6761fd71f348c123cc07d4a32a6c4079968a13a0 100644 (file)
@@ -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.
  */
index 576c03dc30fda2f91d6715a8d65c1444dbca773e..0fcd067ae11b7f32cd0e84e448d2ce436257c810 100644 (file)
@@ -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);