13 #ifndef TOR_CRYPTO_RSA_H
14 #define TOR_CRYPTO_RSA_H
24 #define PK_BYTES (1024/8)
27 #define PK_PKCS1_OAEP_PADDING 60002
30 #define PKCS1_OAEP_PADDING_OVERHEAD 42
34 #define FINGERPRINT_LEN 49
37 #define TOR_RSA_EXPONENT 65537
45 #define crypto_pk_free(pk) FREE_AND_NULL(crypto_pk_t, crypto_pk_free_, (pk))
47 int crypto_get_rsa_padding(
int padding);
51 #define crypto_pk_generate_key(env) \
52 crypto_pk_generate_key_with_bits((env), (PK_BYTES*8))
57 char **dest,
size_t *len);
59 char **dest,
size_t *len);
61 const char *src,
size_t len);
63 const char *s, ssize_t len);
65 const char *src, ssize_t len);
80 const char *from,
size_t fromlen,
81 int padding,
int force);
84 const char *from,
size_t fromlen,
85 int padding,
int warnOnFailure);
87 const char *from,
size_t fromlen,
int padding);
89 const char *from,
size_t fromlen,
90 int padding,
int warnOnFailure);
92 char *to,
size_t tolen,
93 const char *from,
size_t fromlen));
95 const char *from,
size_t fromlen);
99 char *dest,
size_t dest_len);
107 const char *data,
size_t datalen,
const char *sig,
size_t siglen));
109 const char *from,
size_t fromlen);
116 #ifdef ENABLE_OPENSSL
121 struct rsa_st *crypto_pk_get_openssl_rsa_(
crypto_pk_t *env);
122 crypto_pk_t *crypto_new_pk_from_openssl_rsa_(
struct rsa_st *rsa);
123 MOCK_DECL(
struct evp_pkey_st *, crypto_pk_get_openssl_evp_pkey_,(
128 struct SECKEYPublicKeyStr;
129 struct SECKEYPrivateKeyStr;
130 crypto_pk_t *crypto_pk_new_from_nss_pubkey(
struct SECKEYPublicKeyStr *pub);
131 const struct SECKEYPublicKeyStr *crypto_pk_get_nss_pubkey(
133 const struct SECKEYPrivateKeyStr *crypto_pk_get_nss_privkey(
140 #ifdef TOR_UNIT_TESTS
143 STATIC int secitem_uint_cmp(
const struct SECItemStr *a,
144 const struct SECItemStr *b);
Headers for crypto_digest.c.
crypto_pk_t * crypto_pk_dup_key(crypto_pk_t *orig)
int crypto_pk_get_fingerprint(crypto_pk_t *pk, char *fp_out, int add_space)
void crypto_pk_assign_private(crypto_pk_t *dest, const crypto_pk_t *src)
int crypto_pk_obsolete_public_hybrid_encrypt(crypto_pk_t *env, char *to, size_t tolen, const char *from, size_t fromlen, int padding, int force)
crypto_pk_t * crypto_pk_asn1_decode_private(const char *str, size_t len, int max_bits)
int crypto_pk_cmp_keys(const crypto_pk_t *a, const crypto_pk_t *b)
int crypto_pk_generate_key_with_bits(crypto_pk_t *env, int bits)
size_t crypto_pk_keysize(const crypto_pk_t *env)
crypto_pk_t * crypto_pk_new(void)
int crypto_pk_eq_keys(const crypto_pk_t *a, const crypto_pk_t *b)
int crypto_pk_obsolete_private_hybrid_decrypt(crypto_pk_t *env, char *to, size_t tolen, const char *from, size_t fromlen, int padding, int warnOnFailure)
int crypto_pk_write_public_key_to_string(crypto_pk_t *env, char **dest, size_t *len)
int crypto_pk_read_private_key_from_string(crypto_pk_t *env, const char *s, ssize_t len)
int crypto_pk_private_sign(const crypto_pk_t *env, char *to, size_t tolen, const char *from, size_t fromlen)
int crypto_pk_write_private_key_to_filename(crypto_pk_t *env, const char *fname)
int crypto_pk_is_valid_private_key(const crypto_pk_t *env)
int crypto_pk_get_common_digests(crypto_pk_t *pk, common_digests_t *digests_out)
crypto_pk_t * crypto_pk_asn1_decode(const char *str, size_t len)
int crypto_pk_private_decrypt(crypto_pk_t *env, char *to, size_t tolen, const char *from, size_t fromlen, int padding, int warnOnFailure)
int crypto_pk_read_private_key1024_from_string(crypto_pk_t *env, const char *src, ssize_t len)
int crypto_pk_base64_encode_private(const crypto_pk_t *pk, char **priv_out)
int crypto_pk_asn1_encode(const crypto_pk_t *pk, char *dest, size_t dest_len)
int crypto_pk_get_hashed_fingerprint(crypto_pk_t *pk, char *fp_out)
int crypto_pk_get_digest(const crypto_pk_t *pk, char *digest_out)
int crypto_pk_public_encrypt(crypto_pk_t *env, char *to, size_t tolen, const char *from, size_t fromlen, int padding)
void crypto_pk_assign_public(crypto_pk_t *dest, const crypto_pk_t *src)
crypto_pk_t * crypto_pk_base64_decode_private(const char *str, size_t len)
int crypto_get_rsa_padding_overhead(int padding)
int crypto_pk_num_bits(crypto_pk_t *env)
void crypto_add_spaces_to_fp(char *out, size_t outlen, const char *in)
int crypto_pk_private_sign_digest(crypto_pk_t *env, char *to, size_t tolen, const char *from, size_t fromlen)
int crypto_pk_key_is_private(const crypto_pk_t *key)
int crypto_pk_asn1_encode_private(const crypto_pk_t *pk, char *dest, size_t dest_len)
int crypto_pk_public_checksig_digest(crypto_pk_t *env, const char *data, size_t datalen, const char *sig, size_t siglen)
crypto_pk_t * crypto_pk_copy_full(crypto_pk_t *orig)
int crypto_pk_read_private_key_from_filename(crypto_pk_t *env, const char *keyfile)
int crypto_pk_public_checksig(const crypto_pk_t *env, char *to, size_t tolen, const char *from, size_t fromlen)
int crypto_pk_public_exponent_ok(const crypto_pk_t *env)
int crypto_pk_read_public_key_from_string(crypto_pk_t *env, const char *src, size_t len)
int crypto_pk_write_private_key_to_string(crypto_pk_t *env, char **dest, size_t *len)
void crypto_pk_free_(crypto_pk_t *env)
Macros to implement mocking and selective exposure for the test code.
#define MOCK_DECL(rv, funcname, arglist)
Integer definitions used throughout Tor.