summaryrefslogtreecommitdiff
path: root/src/common/tortls.c
diff options
context:
space:
mode:
authorMarek Majkowski <marek@popcount.org>2013-06-10 20:30:57 +0100
committerNick Mathewson <nickm@torproject.org>2013-06-12 13:02:06 -0400
commit16d1dd134a995cf62cdbcf6c2d59da7ae09d601b (patch)
tree5ae484f315b6b5878d8cdb436881ca4e994317ca /src/common/tortls.c
parent616fd790ecacf933e6a624a14a8971d9ebf70d5c (diff)
downloadtor-16d1dd134a995cf62cdbcf6c2d59da7ae09d601b.tar.gz
tor-16d1dd134a995cf62cdbcf6c2d59da7ae09d601b.zip
Fix #9043 - simplyfy the code and use EVP_PKEY_cmp instead of pkey_eq / tor_tls_evp_pkey_eq
Diffstat (limited to 'src/common/tortls.c')
-rw-r--r--src/common/tortls.c25
1 files changed, 1 insertions, 24 deletions
diff --git a/src/common/tortls.c b/src/common/tortls.c
index c0e36034d2..6bd557b8c0 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -979,29 +979,6 @@ tor_tls_cert_get_key(tor_cert_t *cert)
return result;
}
-/** Return true iff <b>a</b> and <b>b</b> represent the same public key. */
-int
-tor_tls_evp_pkey_eq(EVP_PKEY *a, EVP_PKEY *b)
-{
- /* We'd like to do this, but openssl 0.9.7 doesn't have it:
- return EVP_PKEY_cmp(a,b) == 1;
- */
- unsigned char *a_enc = NULL, *b_enc = NULL;
- int a_len, b_len, result;
- a_len = i2d_PublicKey(a, &a_enc);
- b_len = i2d_PublicKey(b, &b_enc);
- if (a_len != b_len || a_len < 0) {
- result = 0;
- } else {
- result = tor_memeq(a_enc, b_enc, a_len);
- }
- if (a_enc)
- OPENSSL_free(a_enc);
- if (b_enc)
- OPENSSL_free(b_enc);
- return result;
-}
-
/** Return true iff the other side of <b>tls</b> has authenticated to us, and
* the key certified in <b>cert</b> is the same as the key they used to do it.
*/
@@ -1017,7 +994,7 @@ tor_tls_cert_matches_key(const tor_tls_t *tls, const tor_cert_t *cert)
link_key = X509_get_pubkey(peercert);
cert_key = X509_get_pubkey(cert->cert);
- result = link_key && cert_key && tor_tls_evp_pkey_eq(cert_key, link_key);
+ result = link_key && cert_key && EVP_PKEY_cmp(cert_key, link_key) == 1;
X509_free(peercert);
if (link_key)