Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef AppTrustDomain_h
8 : #define AppTrustDomain_h
9 :
10 : #include "pkix/pkixtypes.h"
11 : #include "mozilla/StaticMutex.h"
12 : #include "mozilla/UniquePtr.h"
13 : #include "nsDebug.h"
14 : #include "nsIX509CertDB.h"
15 : #include "ScopedNSSTypes.h"
16 :
17 : namespace mozilla { namespace psm {
18 :
19 0 : class AppTrustDomain final : public mozilla::pkix::TrustDomain
20 : {
21 : public:
22 : typedef mozilla::pkix::Result Result;
23 :
24 : AppTrustDomain(UniqueCERTCertList& certChain, void* pinArg);
25 :
26 : nsresult SetTrustedRoot(AppTrustedRoot trustedRoot);
27 :
28 : virtual Result GetCertTrust(mozilla::pkix::EndEntityOrCA endEntityOrCA,
29 : const mozilla::pkix::CertPolicyId& policy,
30 : mozilla::pkix::Input candidateCertDER,
31 : /*out*/ mozilla::pkix::TrustLevel& trustLevel)
32 : override;
33 : virtual Result FindIssuer(mozilla::pkix::Input encodedIssuerName,
34 : IssuerChecker& checker,
35 : mozilla::pkix::Time time) override;
36 : virtual Result CheckRevocation(mozilla::pkix::EndEntityOrCA endEntityOrCA,
37 : const mozilla::pkix::CertID& certID,
38 : mozilla::pkix::Time time,
39 : mozilla::pkix::Duration validityDuration,
40 : /*optional*/ const mozilla::pkix::Input* stapledOCSPresponse,
41 : /*optional*/ const mozilla::pkix::Input* aiaExtension) override;
42 : virtual Result IsChainValid(const mozilla::pkix::DERArray& certChain,
43 : mozilla::pkix::Time time,
44 : const mozilla::pkix::CertPolicyId& requiredPolicy)
45 : override;
46 : virtual Result CheckSignatureDigestAlgorithm(
47 : mozilla::pkix::DigestAlgorithm digestAlg,
48 : mozilla::pkix::EndEntityOrCA endEntityOrCA,
49 : mozilla::pkix::Time notBefore) override;
50 : virtual Result CheckRSAPublicKeyModulusSizeInBits(
51 : mozilla::pkix::EndEntityOrCA endEntityOrCA,
52 : unsigned int modulusSizeInBits) override;
53 : virtual Result VerifyRSAPKCS1SignedDigest(
54 : const mozilla::pkix::SignedDigest& signedDigest,
55 : mozilla::pkix::Input subjectPublicKeyInfo) override;
56 : virtual Result CheckECDSACurveIsAcceptable(
57 : mozilla::pkix::EndEntityOrCA endEntityOrCA,
58 : mozilla::pkix::NamedCurve curve) override;
59 : virtual Result VerifyECDSASignedDigest(
60 : const mozilla::pkix::SignedDigest& signedDigest,
61 : mozilla::pkix::Input subjectPublicKeyInfo) override;
62 : virtual Result CheckValidityIsAcceptable(
63 : mozilla::pkix::Time notBefore, mozilla::pkix::Time notAfter,
64 : mozilla::pkix::EndEntityOrCA endEntityOrCA,
65 : mozilla::pkix::KeyPurposeId keyPurpose) override;
66 : virtual Result NetscapeStepUpMatchesServerAuth(
67 : mozilla::pkix::Time notBefore,
68 : /*out*/ bool& matches) override;
69 : virtual void NoteAuxiliaryExtension(
70 : mozilla::pkix::AuxiliaryExtension extension,
71 : mozilla::pkix::Input extensionData) override;
72 : virtual Result DigestBuf(mozilla::pkix::Input item,
73 : mozilla::pkix::DigestAlgorithm digestAlg,
74 : /*out*/ uint8_t* digestBuf,
75 : size_t digestBufLen) override;
76 :
77 : private:
78 : /*out*/ UniqueCERTCertList& mCertChain;
79 : void* mPinArg; // non-owning!
80 : UniqueCERTCertificate mTrustedRoot;
81 :
82 : static StaticMutex sMutex;
83 : static UniquePtr<unsigned char[]> sDevImportedDERData;
84 : static unsigned int sDevImportedDERLen;
85 : };
86 :
87 : } } // namespace mozilla::psm
88 :
89 : #endif // AppTrustDomain_h
|