MultiLogCTVerifier.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef MultiLogCTVerifier_h
  6. #define MultiLogCTVerifier_h
  7. #include "CTLogVerifier.h"
  8. #include "CTVerifyResult.h"
  9. #include "mozilla/Vector.h"
  10. #include "pkix/Input.h"
  11. #include "pkix/Result.h"
  12. #include "pkix/Time.h"
  13. #include "SignedCertificateTimestamp.h"
  14. namespace mozilla { namespace ct {
  15. // A Certificate Transparency verifier that can verify Signed Certificate
  16. // Timestamps from multiple logs.
  17. class MultiLogCTVerifier
  18. {
  19. public:
  20. // Adds a new log to the list of known logs to verify against.
  21. pkix::Result AddLog(pkix::Input publicKey);
  22. // Verifies SCTs embedded in the certificate itself, SCTs embedded in a
  23. // stapled OCSP response, and SCTs obtained via the
  24. // signed_certificate_timestamp TLS extension on the given |cert|.
  25. //
  26. // A certificate is permitted but not required to use multiple sources for
  27. // SCTs. It is expected that most certificates will use only one source
  28. // (embedding, TLS extension or OCSP stapling).
  29. //
  30. // The verifier stops on fatal errors (such as out of memory or invalid
  31. // DER encoding of |cert|), but it does not stop on SCT decoding errors. See
  32. // CTVerifyResult for more details.
  33. //
  34. // The internal state of the verifier object is not modified
  35. // during the verification process.
  36. //
  37. // |cert| DER-encoded certificate to be validated using the provided SCTs.
  38. // |sctListFromCert| SCT list embedded in |cert|, empty if not present.
  39. // |issuerSubjectPublicKeyInfo| SPKI of |cert|'s issuer. Can be empty,
  40. // in which case the embedded SCT list
  41. // won't be verified.
  42. // |sctListFromOCSPResponse| SCT list included in a stapled OCSP response
  43. // for |cert|. Empty if not available.
  44. // |sctListFromTLSExtension| is the SCT list from the TLS extension. Empty
  45. // if no extension was present.
  46. // |time| the current time. Used to make sure SCTs are not in the future.
  47. // |result| will be filled with the SCTs present, divided into categories
  48. // based on the verification result.
  49. pkix::Result Verify(pkix::Input cert,
  50. pkix::Input issuerSubjectPublicKeyInfo,
  51. pkix::Input sctListFromCert,
  52. pkix::Input sctListFromOCSPResponse,
  53. pkix::Input sctListFromTLSExtension,
  54. pkix::Time time,
  55. CTVerifyResult& result);
  56. private:
  57. // Verifies a list of SCTs from |encodedSctList| over |expectedEntry|,
  58. // placing the verification results in |result|. The SCTs in the list
  59. // come from |origin| (as will be reflected in the origin field of each SCT).
  60. pkix::Result VerifySCTs(pkix::Input encodedSctList,
  61. const LogEntry& expectedEntry,
  62. SignedCertificateTimestamp::Origin origin,
  63. pkix::Time time,
  64. CTVerifyResult& result);
  65. // Verifies a single, parsed SCT against all known logs.
  66. // Note: moves |sct| to the target list in |result|, invalidating |sct|.
  67. pkix::Result VerifySingleSCT(SignedCertificateTimestamp&& sct,
  68. const ct::LogEntry& expectedEntry,
  69. pkix::Time time,
  70. CTVerifyResult& result);
  71. // The list of known logs.
  72. Vector<CTLogVerifier> mLogs;
  73. };
  74. } } // namespace mozilla::ct
  75. #endif // MultiLogCTVerifier_h