[tor-commits] [tor/master] For testing: add a tor_x509_cert_dup().

nickm at torproject.org nickm at torproject.org
Thu Nov 3 13:18:59 UTC 2016


commit 67e66898d2b77940199fe23843e148ab836ff431
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Sep 9 14:43:09 2016 -0400

    For testing: add a tor_x509_cert_dup().
---
 src/common/tortls.c | 7 +++++++
 src/common/tortls.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/src/common/tortls.c b/src/common/tortls.c
index 33bd334..0315398 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -683,6 +683,13 @@ MOCK_IMPL(STATIC tor_x509_cert_t *,
   return cert;
 }
 
+/** Return a copy of <b>cert</b> */
+tor_x509_cert_t *
+tor_x509_cert_dup(const tor_x509_cert_t *cert)
+{
+  return tor_x509_cert_new(X509_dup(cert->cert));
+}
+
 /** Read a DER-encoded X509 cert, of length exactly <b>certificate_len</b>,
  * from a <b>certificate</b>.  Return a newly allocated tor_x509_cert_t on
  * success and NULL on failure. */
diff --git a/src/common/tortls.h b/src/common/tortls.h
index 3adb1b2..6510fdb 100644
--- a/src/common/tortls.h
+++ b/src/common/tortls.h
@@ -176,6 +176,7 @@ extern uint64_t total_bytes_written_by_tls;
 
 #endif /* endif TORTLS_PRIVATE */
 
+tor_x509_cert_t *tor_x509_cert_dup(const tor_x509_cert_t *cert);
 const char *tor_tls_err_to_string(int err);
 void tor_tls_get_state_description(tor_tls_t *tls, char *buf, size_t sz);
 





More information about the tor-commits mailing list