2014-01-21 10:10:33 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_psm__NSSCertDBTrustDomain_h
|
|
|
|
#define mozilla_psm__NSSCertDBTrustDomain_h
|
|
|
|
|
2014-03-21 01:29:21 +04:00
|
|
|
#include "pkix/pkixtypes.h"
|
2014-01-21 10:10:33 +04:00
|
|
|
#include "secmodt.h"
|
|
|
|
#include "CertVerifier.h"
|
|
|
|
|
|
|
|
namespace mozilla { namespace psm {
|
|
|
|
|
|
|
|
SECStatus InitializeNSS(const char* dir, bool readOnly);
|
|
|
|
|
2014-01-20 13:30:25 +04:00
|
|
|
void DisableMD5();
|
|
|
|
|
2014-01-21 10:10:33 +04:00
|
|
|
extern const char BUILTIN_ROOTS_MODULE_DEFAULT_NAME[];
|
|
|
|
|
2014-03-13 00:08:48 +04:00
|
|
|
void PORT_Free_string(char* str);
|
|
|
|
|
2014-01-21 10:10:33 +04:00
|
|
|
// The dir parameter is the path to the directory containing the NSS builtin
|
|
|
|
// roots module. Usually this is the same as the path to the other NSS shared
|
|
|
|
// libraries. If it is null then the (library) path will be searched.
|
|
|
|
//
|
|
|
|
// The modNameUTF8 parameter should usually be
|
|
|
|
// BUILTIN_ROOTS_MODULE_DEFAULT_NAME.
|
|
|
|
SECStatus LoadLoadableRoots(/*optional*/ const char* dir,
|
|
|
|
const char* modNameUTF8);
|
|
|
|
|
|
|
|
void UnloadLoadableRoots(const char* modNameUTF8);
|
|
|
|
|
2013-07-09 03:30:59 +04:00
|
|
|
// Caller must free the result with PR_Free
|
|
|
|
char* DefaultServerNicknameForCert(CERTCertificate* cert);
|
|
|
|
|
2014-07-07 02:55:38 +04:00
|
|
|
void SaveIntermediateCerts(const ScopedCERTCertList& certList);
|
2013-07-09 03:30:59 +04:00
|
|
|
|
2014-03-21 01:29:21 +04:00
|
|
|
class NSSCertDBTrustDomain : public mozilla::pkix::TrustDomain
|
2014-02-10 23:41:12 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2014-07-18 22:48:49 +04:00
|
|
|
typedef mozilla::pkix::Result Result;
|
|
|
|
|
2014-02-24 10:15:53 +04:00
|
|
|
enum OCSPFetching {
|
|
|
|
NeverFetchOCSP = 0,
|
|
|
|
FetchOCSPForDVSoftFail = 1,
|
|
|
|
FetchOCSPForDVHardFail = 2,
|
|
|
|
FetchOCSPForEV = 3,
|
|
|
|
LocalOnlyOCSPForEV = 4,
|
|
|
|
};
|
|
|
|
NSSCertDBTrustDomain(SECTrustType certDBTrustType, OCSPFetching ocspFetching,
|
2014-02-06 02:49:10 +04:00
|
|
|
OCSPCache& ocspCache, void* pinArg,
|
2014-05-22 02:42:21 +04:00
|
|
|
CertVerifier::ocsp_get_config ocspGETConfig,
|
2014-07-07 02:55:38 +04:00
|
|
|
/*optional*/ CERTChainVerifyCallback* checkChainCallback = nullptr,
|
|
|
|
/*optional*/ ScopedCERTCertList* builtChain = nullptr);
|
2014-02-10 23:41:12 +04:00
|
|
|
|
2014-07-31 23:17:31 +04:00
|
|
|
virtual Result FindIssuer(mozilla::pkix::Input encodedIssuerName,
|
2014-07-18 22:48:49 +04:00
|
|
|
IssuerChecker& checker,
|
2014-08-02 19:49:12 +04:00
|
|
|
mozilla::pkix::Time time) MOZ_OVERRIDE;
|
2014-02-10 23:41:12 +04:00
|
|
|
|
2014-07-18 22:48:49 +04:00
|
|
|
virtual Result GetCertTrust(mozilla::pkix::EndEntityOrCA endEntityOrCA,
|
|
|
|
const mozilla::pkix::CertPolicyId& policy,
|
2014-07-31 23:17:31 +04:00
|
|
|
mozilla::pkix::Input candidateCertDER,
|
2014-07-20 22:06:26 +04:00
|
|
|
/*out*/ mozilla::pkix::TrustLevel& trustLevel)
|
2014-07-18 22:48:49 +04:00
|
|
|
MOZ_OVERRIDE;
|
2014-02-10 23:41:12 +04:00
|
|
|
|
2014-07-31 23:17:31 +04:00
|
|
|
virtual Result CheckPublicKey(mozilla::pkix::Input subjectPublicKeyInfo)
|
2014-07-18 22:48:49 +04:00
|
|
|
MOZ_OVERRIDE;
|
2014-02-10 23:41:12 +04:00
|
|
|
|
2014-07-18 22:48:49 +04:00
|
|
|
virtual Result VerifySignedData(
|
|
|
|
const mozilla::pkix::SignedDataWithSignature& signedData,
|
2014-07-31 23:17:31 +04:00
|
|
|
mozilla::pkix::Input subjectPublicKeyInfo)
|
2014-07-19 09:30:51 +04:00
|
|
|
MOZ_OVERRIDE;
|
2014-07-07 06:36:05 +04:00
|
|
|
|
2014-07-31 23:17:31 +04:00
|
|
|
virtual Result DigestBuf(mozilla::pkix::Input item,
|
2014-07-19 09:30:51 +04:00
|
|
|
/*out*/ uint8_t* digestBuf,
|
2014-07-18 22:48:49 +04:00
|
|
|
size_t digestBufLen) MOZ_OVERRIDE;
|
2014-02-17 05:35:40 +04:00
|
|
|
|
2014-07-19 09:30:51 +04:00
|
|
|
virtual Result CheckRevocation(
|
|
|
|
mozilla::pkix::EndEntityOrCA endEntityOrCA,
|
|
|
|
const mozilla::pkix::CertID& certID,
|
2014-08-02 19:49:12 +04:00
|
|
|
mozilla::pkix::Time time,
|
2014-07-31 23:17:31 +04:00
|
|
|
/*optional*/ const mozilla::pkix::Input* stapledOCSPResponse,
|
|
|
|
/*optional*/ const mozilla::pkix::Input* aiaExtension)
|
2014-07-19 09:30:51 +04:00
|
|
|
MOZ_OVERRIDE;
|
2014-02-06 02:49:10 +04:00
|
|
|
|
2014-07-18 22:48:49 +04:00
|
|
|
virtual Result IsChainValid(const mozilla::pkix::DERArray& certChain)
|
|
|
|
MOZ_OVERRIDE;
|
2014-07-16 03:49:00 +04:00
|
|
|
|
2014-02-10 23:41:12 +04:00
|
|
|
private:
|
2014-04-29 03:38:15 +04:00
|
|
|
enum EncodedResponseSource {
|
|
|
|
ResponseIsFromNetwork = 1,
|
|
|
|
ResponseWasStapled = 2
|
|
|
|
};
|
2014-07-18 22:48:49 +04:00
|
|
|
Result VerifyAndMaybeCacheEncodedOCSPResponse(
|
2014-08-02 19:49:12 +04:00
|
|
|
const mozilla::pkix::CertID& certID, mozilla::pkix::Time time,
|
2014-07-31 23:17:31 +04:00
|
|
|
uint16_t maxLifetimeInDays, mozilla::pkix::Input encodedResponse,
|
2014-06-20 20:01:57 +04:00
|
|
|
EncodedResponseSource responseSource, /*out*/ bool& expired);
|
2014-03-13 00:08:48 +04:00
|
|
|
|
2014-02-10 23:41:12 +04:00
|
|
|
const SECTrustType mCertDBTrustType;
|
2014-02-24 10:15:53 +04:00
|
|
|
const OCSPFetching mOCSPFetching;
|
2014-03-13 00:08:48 +04:00
|
|
|
OCSPCache& mOCSPCache; // non-owning!
|
2014-02-10 23:41:12 +04:00
|
|
|
void* mPinArg; // non-owning!
|
2014-05-22 02:42:21 +04:00
|
|
|
const CertVerifier::ocsp_get_config mOCSPGetConfig;
|
2014-02-06 02:49:10 +04:00
|
|
|
CERTChainVerifyCallback* mCheckChainCallback; // non-owning!
|
2014-07-07 02:55:38 +04:00
|
|
|
ScopedCERTCertList* mBuiltChain; // non-owning
|
2014-02-10 23:41:12 +04:00
|
|
|
};
|
|
|
|
|
2014-01-21 10:10:33 +04:00
|
|
|
} } // namespace mozilla::psm
|
|
|
|
|
|
|
|
#endif // mozilla_psm__NSSCertDBTrustDomain_h
|