32 #define BEGIN_END_OVERHEAD_LEN 64
35 signature = tor_malloc(keysize);
39 log_warn(
LD_BUG,
"Couldn't sign digest.");
44 buf_len = (siglen * 2) + BEGIN_END_OVERHEAD_LEN;
45 buf = tor_malloc(buf_len);
47 if (strlcpy(buf,
"-----BEGIN SIGNATURE-----\n", buf_len) >= buf_len)
52 BASE64_ENCODE_MULTILINE) < 0) {
53 log_warn(
LD_BUG,
"couldn't base64-encode signature");
57 if (strlcat(buf,
"-----END SIGNATURE-----\n", buf_len) >= buf_len)
64 log_warn(
LD_BUG,
"tried to exceed string length.");
82 size_t sig_len, s_len;
85 log_warn(
LD_BUG,
"No signature generated");
88 sig_len = strlen(sig);
90 if (sig_len + s_len + 1 > buf_len) {
91 log_warn(
LD_BUG,
"Not enough room for signature");
95 memcpy(buf+s_len, sig, sig_len+1);
int base64_encode(char *dest, size_t destlen, const char *src, size_t srclen, int flags)
size_t crypto_pk_keysize(const crypto_pk_t *env)
int crypto_pk_private_sign(const crypto_pk_t *env, char *to, size_t tolen, const char *from, size_t fromlen)
Master header file for Tor-specific functionality.
int router_append_dirobj_signature(char *buf, size_t buf_len, const char *digest, size_t digest_len, crypto_pk_t *private_key)
char * router_get_dirobj_signature(const char *digest, size_t digest_len, const crypto_pk_t *private_key)
Header file for signing.c.