x509_nss.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* Copyright (c) 2003, Roger Dingledine.
  2. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  3. * Copyright (c) 2007-2018, The Tor Project, Inc. */
  4. /* See LICENSE for licensing information */
  5. /**
  6. * \file x509_nss.c
  7. * \brief Wrapper functions to present a consistent interface to
  8. * X.509 functions from NSS.
  9. **/
  10. #define TOR_X509_PRIVATE
  11. #include "lib/tls/x509.h"
  12. #include "lib/tls/tortls.h"
  13. #include "lib/crypt_ops/crypto_rand.h"
  14. #include "lib/crypt_ops/crypto_util.h"
  15. #include "lib/log/util_bug.h"
  16. MOCK_IMPL(tor_x509_cert_impl_t *,
  17. tor_tls_create_certificate,(crypto_pk_t *rsa,
  18. crypto_pk_t *rsa_sign,
  19. const char *cname,
  20. const char *cname_sign,
  21. unsigned int cert_lifetime))
  22. {
  23. tor_assert(rsa);
  24. tor_assert(rsa_sign);
  25. tor_assert(cname);
  26. tor_assert(cname_sign);
  27. (void) cert_lifetime;
  28. // XXXX
  29. return NULL;
  30. }
  31. MOCK_IMPL(tor_x509_cert_t *,
  32. tor_x509_cert_new,(tor_x509_cert_impl_t *x509_cert))
  33. {
  34. tor_assert(x509_cert);
  35. // XXXX
  36. return NULL;
  37. }
  38. tor_x509_cert_t *
  39. tor_x509_cert_dup(const tor_x509_cert_t *cert)
  40. {
  41. tor_assert(cert);
  42. // XXXX
  43. return NULL;
  44. }
  45. void
  46. tor_x509_cert_free_(tor_x509_cert_t *cert)
  47. {
  48. (void)cert;
  49. // XXXX
  50. }
  51. tor_x509_cert_t *
  52. tor_x509_cert_decode(const uint8_t *certificate,
  53. size_t certificate_len)
  54. {
  55. tor_assert(certificate);
  56. (void) certificate_len;
  57. // XXXX
  58. return NULL;
  59. }
  60. crypto_pk_t *
  61. tor_tls_cert_get_key(tor_x509_cert_t *cert)
  62. {
  63. tor_assert(cert);
  64. // XXXXX
  65. return NULL;
  66. }
  67. int
  68. tor_tls_cert_is_valid(int severity,
  69. const tor_x509_cert_t *cert,
  70. const tor_x509_cert_t *signing_cert,
  71. time_t now,
  72. int check_rsa_1024)
  73. {
  74. tor_assert(cert);
  75. tor_assert(signing_cert);
  76. (void)severity;
  77. (void)now;
  78. (void)check_rsa_1024;
  79. // XXXXX
  80. return 0;
  81. }
  82. int
  83. tor_x509_check_cert_lifetime_internal(int severity,
  84. const tor_x509_cert_impl_t *cert,
  85. time_t now,
  86. int past_tolerance,
  87. int future_tolerance)
  88. {
  89. tor_assert(cert);
  90. (void)severity;
  91. (void)now;
  92. (void)past_tolerance;
  93. (void)future_tolerance;
  94. // XXXX
  95. return -1;
  96. }
  97. #ifdef TOR_UNIT_TESTS
  98. tor_x509_cert_t *
  99. tor_x509_cert_replace_expiration(const tor_x509_cert_t *inp,
  100. time_t new_expiration_time,
  101. crypto_pk_t *signing_key)
  102. {
  103. tor_assert(inp);
  104. tor_assert(signing_key);
  105. (void)new_expiration_time;
  106. // XXXX
  107. return NULL;
  108. }
  109. #endif