diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/log.c | 5 | ||||
-rw-r--r-- | src/common/tortls.c | 35 | ||||
-rw-r--r-- | src/common/tortls.h | 7 | ||||
-rw-r--r-- | src/common/util.c | 15 |
4 files changed, 15 insertions, 47 deletions
diff --git a/src/common/log.c b/src/common/log.c index 72dff4ae59..178c10a082 100644 --- a/src/common/log.c +++ b/src/common/log.c @@ -457,8 +457,9 @@ close_log(logfile_t *victim) } } -/** Add a log handler to send all messages of severity <b>loglevel</b> - * or higher to <b>stream</b>. DOCDOC.*/ +/** Add a log handler named <b>name</b> to send all messages of severity + * between <b>loglevelMin</b> and <b>loglevelMax</b> (inclusive) to + * <b>stream</b>. */ static void add_stream_log_impl(int loglevelMin, int loglevelMax, const char *name, FILE *stream) diff --git a/src/common/tortls.c b/src/common/tortls.c index b2369c7c47..9b282b2cb7 100644 --- a/src/common/tortls.c +++ b/src/common/tortls.c @@ -1304,38 +1304,3 @@ tor_tls_used_v1_handshake(tor_tls_t *tls) return 1; } -#if SSL3_RANDOM_SIZE != TOR_TLS_RANDOM_LEN -#error "The TOR_TLS_RANDOM_LEN macro is defined incorrectly. That's a bug." -#endif - -/** DOCDOC */ -int -tor_tls_get_random_values(tor_tls_t *tls, char *client_random_out, - char *server_random_out) -{ - tor_assert(tls && tls->ssl); - if (!tls->ssl->s3) - return -1; - memcpy(client_random_out, tls->ssl->s3->client_random, SSL3_RANDOM_SIZE); - memcpy(server_random_out, tls->ssl->s3->server_random, SSL3_RANDOM_SIZE); - return 0; -} - -/** DOCDOC */ -int -tor_tls_hmac_with_master_secret(tor_tls_t *tls, char *hmac_out, - const char *data, size_t data_len) -{ - SSL_SESSION *s; - tor_assert(tls && tls->ssl); - if (!(s = SSL_get_session(tls->ssl))) - return -1; - if (s->master_key_length < 0) - return -1; - crypto_hmac_sha1(hmac_out, - (const char*)s->master_key, - (size_t)s->master_key_length, - data, data_len); - return 0; -} - diff --git a/src/common/tortls.h b/src/common/tortls.h index 8584eb18ee..a7ef9a775e 100644 --- a/src/common/tortls.h +++ b/src/common/tortls.h @@ -43,9 +43,6 @@ typedef struct tor_tls_t tor_tls_t; case TOR_TLS_ERROR_NO_ROUTE: \ case TOR_TLS_ERROR_TIMEOUT -/**DOCDOC*/ -#define TOR_TLS_RANDOM_LEN 32 - #define TOR_TLS_IS_ERROR(rv) ((rv) < TOR_TLS_CLOSE) const char *tor_tls_err_to_string(int err); @@ -79,10 +76,6 @@ void tor_tls_get_n_raw_bytes(tor_tls_t *tls, size_t *n_read, size_t *n_written); int tor_tls_used_v1_handshake(tor_tls_t *tls); -int tor_tls_get_random_values(tor_tls_t *tls, char *client_random_out, - char *server_random_out); -int tor_tls_hmac_with_master_secret(tor_tls_t *tls, char *hmac_out, - const char *data, size_t data_len); /* Log and abort if there are unhandled TLS errors in OpenSSL's error stack. */ diff --git a/src/common/util.c b/src/common/util.c index 21ac808786..2169fbbb6c 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1298,7 +1298,10 @@ parse_http_time(const char *date, struct tm *tm) return 0; } -/** DOCDOC */ +/** Given an <b>interval</b> in seconds, try to write it to the + * <b>out_len</b>-byte buffer in <b>out</b> in a human-readable form. + * Return 0 on success, -1 on failure. + */ int format_time_interval(char *out, size_t out_len, long interval) { @@ -1932,13 +1935,19 @@ read_file_to_str(const char *filename, int flags, struct stat *stat_out) #define TOR_ISODIGIT(c) ('0' <= (c) && (c) <= '7') -/* DOCDOC */ +/* Given a c-style double-quoted escaped string in <b>s</b>, extract and + * decode its contents into a newly allocated string. On success, assign this + * string to *<b>result</b>, assign its length to <b>size_out</b> (if + * provided), and return a pointer to the position in <b>s</b> immediately + * after the string. On failure, return NULL. + */ static const char * unescape_string(const char *s, char **result, size_t *size_out) { const char *cp; char *out; - tor_assert(s[0] == '\"'); + if (s[0] != '\"') + return NULL; cp = s+1; while (1) { switch (*cp) { |