OCSPVerificationTrustDomain.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. #include "OCSPVerificationTrustDomain.h"
  6. using namespace mozilla;
  7. using namespace mozilla::pkix;
  8. namespace mozilla { namespace psm {
  9. OCSPVerificationTrustDomain::OCSPVerificationTrustDomain(
  10. NSSCertDBTrustDomain& certDBTrustDomain)
  11. : mCertDBTrustDomain(certDBTrustDomain)
  12. {
  13. }
  14. Result
  15. OCSPVerificationTrustDomain::GetCertTrust(EndEntityOrCA endEntityOrCA,
  16. const CertPolicyId& policy,
  17. Input candidateCertDER,
  18. /*out*/ TrustLevel& trustLevel)
  19. {
  20. return mCertDBTrustDomain.GetCertTrust(endEntityOrCA, policy,
  21. candidateCertDER, trustLevel);
  22. }
  23. Result
  24. OCSPVerificationTrustDomain::FindIssuer(Input, IssuerChecker&, Time)
  25. {
  26. // We do not expect this to be called for OCSP signers
  27. return Result::FATAL_ERROR_LIBRARY_FAILURE;
  28. }
  29. Result
  30. OCSPVerificationTrustDomain::IsChainValid(const DERArray&, Time, const CertPolicyId&)
  31. {
  32. // We do not expect this to be called for OCSP signers
  33. return Result::FATAL_ERROR_LIBRARY_FAILURE;
  34. }
  35. Result
  36. OCSPVerificationTrustDomain::CheckRevocation(EndEntityOrCA, const CertID&,
  37. Time, Duration, const Input*,
  38. const Input*, const Input*)
  39. {
  40. // We do not expect this to be called for OCSP signers
  41. return Result::FATAL_ERROR_LIBRARY_FAILURE;
  42. }
  43. Result
  44. OCSPVerificationTrustDomain::CheckSignatureDigestAlgorithm(
  45. DigestAlgorithm aAlg, EndEntityOrCA aEEOrCA, Time notBefore)
  46. {
  47. // The reason for wrapping the NSSCertDBTrustDomain in an
  48. // OCSPVerificationTrustDomain is to allow us to bypass the weaker signature
  49. // algorithm check - thus all allowable signature digest algorithms should
  50. // always be accepted. This is only needed while we gather telemetry on SHA-1.
  51. return Success;
  52. }
  53. Result
  54. OCSPVerificationTrustDomain::CheckRSAPublicKeyModulusSizeInBits(
  55. EndEntityOrCA aEEOrCA, unsigned int aModulusSizeInBits)
  56. {
  57. return mCertDBTrustDomain.
  58. CheckRSAPublicKeyModulusSizeInBits(aEEOrCA, aModulusSizeInBits);
  59. }
  60. Result
  61. OCSPVerificationTrustDomain::VerifyRSAPKCS1SignedDigest(
  62. const SignedDigest& aSignedDigest, Input aSubjectPublicKeyInfo)
  63. {
  64. return mCertDBTrustDomain.VerifyRSAPKCS1SignedDigest(aSignedDigest,
  65. aSubjectPublicKeyInfo);
  66. }
  67. Result
  68. OCSPVerificationTrustDomain::CheckECDSACurveIsAcceptable(
  69. EndEntityOrCA aEEOrCA, NamedCurve aCurve)
  70. {
  71. return mCertDBTrustDomain.CheckECDSACurveIsAcceptable(aEEOrCA, aCurve);
  72. }
  73. Result
  74. OCSPVerificationTrustDomain::VerifyECDSASignedDigest(
  75. const SignedDigest& aSignedDigest, Input aSubjectPublicKeyInfo)
  76. {
  77. return mCertDBTrustDomain.VerifyECDSASignedDigest(aSignedDigest,
  78. aSubjectPublicKeyInfo);
  79. }
  80. Result
  81. OCSPVerificationTrustDomain::CheckValidityIsAcceptable(
  82. Time notBefore, Time notAfter, EndEntityOrCA endEntityOrCA,
  83. KeyPurposeId keyPurpose)
  84. {
  85. return mCertDBTrustDomain.CheckValidityIsAcceptable(notBefore, notAfter,
  86. endEntityOrCA,
  87. keyPurpose);
  88. }
  89. Result
  90. OCSPVerificationTrustDomain::NetscapeStepUpMatchesServerAuth(Time notBefore,
  91. /*out*/ bool& matches)
  92. {
  93. return mCertDBTrustDomain.NetscapeStepUpMatchesServerAuth(notBefore, matches);
  94. }
  95. void
  96. OCSPVerificationTrustDomain::NoteAuxiliaryExtension(
  97. AuxiliaryExtension extension, Input extensionData)
  98. {
  99. mCertDBTrustDomain.NoteAuxiliaryExtension(extension, extensionData);
  100. }
  101. Result
  102. OCSPVerificationTrustDomain::DigestBuf(
  103. Input item, DigestAlgorithm digestAlg,
  104. /*out*/ uint8_t* digestBuf, size_t digestBufLen)
  105. {
  106. return mCertDBTrustDomain.DigestBuf(item, digestAlg, digestBuf, digestBufLen);
  107. }
  108. } } // namespace mozilla::psm