summaryrefslogtreecommitdiff
path: root/chromium/net/cert/internal/trust_store.cc
blob: 1ef02d7bfc2b60d0785d6f5cd70c08e46e393b05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/cert/internal/trust_store.h"

namespace net {

CertificateTrust CertificateTrust::ForTrustAnchor() {
  CertificateTrust result;
  result.type = CertificateTrustType::TRUSTED_ANCHOR;
  return result;
}

CertificateTrust CertificateTrust::ForTrustAnchorEnforcingConstraints() {
  CertificateTrust result;
  result.type = CertificateTrustType::TRUSTED_ANCHOR_WITH_CONSTRAINTS;
  return result;
}

CertificateTrust CertificateTrust::ForUnspecified() {
  CertificateTrust result;
  result.type = CertificateTrustType::UNSPECIFIED;
  return result;
}

CertificateTrust CertificateTrust::ForDistrusted() {
  CertificateTrust result;
  result.type = CertificateTrustType::DISTRUSTED;
  return result;
}

bool CertificateTrust::IsTrustAnchor() const {
  switch (type) {
    case CertificateTrustType::DISTRUSTED:
    case CertificateTrustType::UNSPECIFIED:
      return false;
    case CertificateTrustType::TRUSTED_ANCHOR:
    case CertificateTrustType::TRUSTED_ANCHOR_WITH_CONSTRAINTS:
      return true;
  }

  NOTREACHED();
  return false;
}

bool CertificateTrust::IsDistrusted() const {
  switch (type) {
    case CertificateTrustType::DISTRUSTED:
      return true;
    case CertificateTrustType::UNSPECIFIED:
    case CertificateTrustType::TRUSTED_ANCHOR:
    case CertificateTrustType::TRUSTED_ANCHOR_WITH_CONSTRAINTS:
      return false;
  }

  NOTREACHED();
  return false;
}

bool CertificateTrust::HasUnspecifiedTrust() const {
  switch (type) {
    case CertificateTrustType::UNSPECIFIED:
      return true;
    case CertificateTrustType::DISTRUSTED:
    case CertificateTrustType::TRUSTED_ANCHOR:
    case CertificateTrustType::TRUSTED_ANCHOR_WITH_CONSTRAINTS:
      return false;
  }

  NOTREACHED();
  return true;
}

TrustStore::TrustStore() = default;

void TrustStore::AsyncGetIssuersOf(const ParsedCertificate* cert,
                                   std::unique_ptr<Request>* out_req) {
  out_req->reset();
}

}  // namespace net