Add crypto_pk_check_key_public_exponent function

This commit is contained in:
Robert Ransom 2011-04-28 12:13:03 -07:00 committed by Nick Mathewson
parent 7571e9f1cb
commit d2629f78a0
2 changed files with 13 additions and 0 deletions

View file

@ -656,6 +656,18 @@ crypto_pk_key_is_private(const crypto_pk_env_t *key)
return PRIVATE_KEY_OK(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 /** Compare the public-key components of a and b. Return -1 if a\<b, 0
* if a==b, and 1 if a\>b. * if a==b, and 1 if a\>b.
*/ */

View 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_dup_key(crypto_pk_env_t *orig);
crypto_pk_env_t *crypto_pk_copy_full(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_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, int crypto_pk_public_encrypt(crypto_pk_env_t *env, char *to, size_t tolen,
const char *from, size_t fromlen, int padding); const char *from, size_t fromlen, int padding);