Use a constant for "65537"

This commit is contained in:
Nick Mathewson 2018-07-19 09:23:30 -04:00
parent 824009cde5
commit 0812f1cbc2
2 changed files with 6 additions and 3 deletions

View File

@ -33,6 +33,9 @@
* including terminating NUL. */ * including terminating NUL. */
#define FINGERPRINT_LEN 49 #define FINGERPRINT_LEN 49
/** Value of 'e' to use in our public keys */
#define TOR_RSA_EXPONENT 65537
/** A public key, or a public/private key-pair. */ /** A public key, or a public/private key-pair. */
typedef struct crypto_pk_t crypto_pk_t; typedef struct crypto_pk_t crypto_pk_t;

View File

@ -158,7 +158,7 @@ crypto_pk_generate_key_with_bits,(crypto_pk_t *env, int bits))
RSA *r = NULL; RSA *r = NULL;
if (!e) if (!e)
goto done; goto done;
if (! BN_set_word(e, 65537)) if (! BN_set_word(e, TOR_RSA_EXPONENT))
goto done; goto done;
r = RSA_new(); r = RSA_new();
if (!r) if (!r)
@ -408,7 +408,7 @@ crypto_pk_check_key(crypto_pk_t *env)
} }
/** Return true iff <b>env</b> contains a public key whose public exponent /** Return true iff <b>env</b> contains a public key whose public exponent
* equals 65537. * equals TOR_RSA_EXPONENT.
*/ */
int int
crypto_pk_public_exponent_ok(crypto_pk_t *env) crypto_pk_public_exponent_ok(crypto_pk_t *env)
@ -424,7 +424,7 @@ crypto_pk_public_exponent_ok(crypto_pk_t *env)
#else #else
e = env->key->e; e = env->key->e;
#endif /* defined(OPENSSL_1_1_API) */ #endif /* defined(OPENSSL_1_1_API) */
return BN_is_word(e, 65537); return BN_is_word(e, TOR_RSA_EXPONENT);
} }
/** Compare the public-key components of a and b. Return less than 0 /** Compare the public-key components of a and b. Return less than 0