Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/security/manager/ssl/nsNSSCertTrust.h
Line
Count
Source (jump to first uncovered line)
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
#ifndef nsNSSCertTrust_h
6
#define nsNSSCertTrust_h
7
8
#include "certdb.h"
9
#include "certt.h"
10
11
/*
12
 * Class for maintaining trust flags for an NSS certificate.
13
 */
14
class nsNSSCertTrust
15
{
16
public:
17
  nsNSSCertTrust();
18
  nsNSSCertTrust(unsigned int ssl, unsigned int email);
19
  explicit nsNSSCertTrust(CERTCertTrust *t);
20
  virtual ~nsNSSCertTrust();
21
22
  /* query */
23
  bool HasAnyCA();
24
  bool HasAnyUser();
25
  bool HasPeer(bool checkSSL = true, bool checkEmail = true);
26
  bool HasTrustedCA(bool checkSSL = true, bool checkEmail = true);
27
  bool HasTrustedPeer(bool checkSSL = true, bool checkEmail = true);
28
29
  /* common defaults */
30
  /* equivalent to "c,c,c" */
31
  void SetValidCA();
32
  /* equivalent to "p,p,p" */
33
  void SetValidPeer();
34
35
  /* general setters */
36
  /* read: "p, P, c, C, T, u, w" */
37
  void SetSSLTrust(bool peer, bool tPeer,
38
                   bool ca,   bool tCA, bool tClientCA,
39
                   bool user, bool warn);
40
41
  void SetEmailTrust(bool peer, bool tPeer,
42
                     bool ca,   bool tCA, bool tClientCA,
43
                     bool user, bool warn);
44
45
  /* set c <--> CT */
46
  void AddCATrust(bool ssl, bool email);
47
  /* set p <--> P */
48
  void AddPeerTrust(bool ssl, bool email);
49
50
0
  CERTCertTrust& GetTrust() { return mTrust; }
51
52
private:
53
  void addTrust(unsigned int *t, unsigned int v);
54
  void removeTrust(unsigned int *t, unsigned int v);
55
  bool hasTrust(unsigned int t, unsigned int v);
56
  CERTCertTrust mTrust;
57
};
58
59
#endif // nsNSSCertTrust_h