OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/cert/internal/trust_store.h" | 5 #include "net/cert/internal/trust_store.h" |
6 | 6 |
7 namespace net { | 7 namespace net { |
8 | 8 |
9 scoped_refptr<TrustAnchor> TrustAnchor::CreateFromCertificateNoConstraints( | 9 CertificateTrust CertificateTrust::ForTrustAnchor() { |
10 scoped_refptr<ParsedCertificate> cert) { | 10 CertificateTrust result; |
11 return scoped_refptr<TrustAnchor>(new TrustAnchor(std::move(cert), false)); | 11 result.type = CertificateTrustType::TRUSTED_ANCHOR; |
| 12 return result; |
12 } | 13 } |
13 | 14 |
14 scoped_refptr<TrustAnchor> TrustAnchor::CreateFromCertificateWithConstraints( | 15 CertificateTrust CertificateTrust::ForTrustAnchorEnforcingConstraints() { |
15 scoped_refptr<ParsedCertificate> cert) { | 16 CertificateTrust result; |
16 return scoped_refptr<TrustAnchor>(new TrustAnchor(std::move(cert), true)); | 17 result.type = CertificateTrustType::TRUSTED_ANCHOR_WITH_CONSTRAINTS; |
| 18 return result; |
17 } | 19 } |
18 | 20 |
19 der::Input TrustAnchor::spki() const { | 21 CertificateTrust CertificateTrust::Unspecified() { |
20 return cert_->tbs().spki_tlv; | 22 CertificateTrust result; |
| 23 result.type = CertificateTrustType::UNSPECIFIED; |
| 24 return result; |
21 } | 25 } |
22 | 26 |
23 der::Input TrustAnchor::normalized_subject() const { | 27 bool CertificateTrust::IsTrustAnchor() const { |
24 return cert_->normalized_subject(); | 28 switch (type) { |
| 29 case CertificateTrustType::DISTRUSTED: |
| 30 case CertificateTrustType::UNSPECIFIED: |
| 31 return false; |
| 32 case CertificateTrustType::TRUSTED_ANCHOR: |
| 33 case CertificateTrustType::TRUSTED_ANCHOR_WITH_CONSTRAINTS: |
| 34 return true; |
| 35 } |
| 36 |
| 37 NOTREACHED(); |
| 38 return false; |
25 } | 39 } |
26 | 40 |
27 const scoped_refptr<ParsedCertificate>& TrustAnchor::cert() const { | 41 bool CertificateTrust::IsDistrusted() const { |
28 return cert_; | 42 switch (type) { |
| 43 case CertificateTrustType::DISTRUSTED: |
| 44 return true; |
| 45 case CertificateTrustType::UNSPECIFIED: |
| 46 case CertificateTrustType::TRUSTED_ANCHOR: |
| 47 case CertificateTrustType::TRUSTED_ANCHOR_WITH_CONSTRAINTS: |
| 48 return false; |
| 49 } |
| 50 |
| 51 NOTREACHED(); |
| 52 return false; |
29 } | 53 } |
30 | 54 |
31 TrustAnchor::TrustAnchor(scoped_refptr<ParsedCertificate> cert, | 55 bool CertificateTrust::HasUnspecifiedTrust() const { |
32 bool enforces_constraints) | 56 switch (type) { |
33 : cert_(std::move(cert)), enforces_constraints_(enforces_constraints) { | 57 case CertificateTrustType::UNSPECIFIED: |
34 DCHECK(cert_); | 58 return true; |
| 59 case CertificateTrustType::DISTRUSTED: |
| 60 case CertificateTrustType::TRUSTED_ANCHOR: |
| 61 case CertificateTrustType::TRUSTED_ANCHOR_WITH_CONSTRAINTS: |
| 62 return false; |
| 63 } |
| 64 |
| 65 NOTREACHED(); |
| 66 return true; |
35 } | 67 } |
36 | 68 |
37 TrustAnchor::~TrustAnchor() = default; | 69 TrustStore::TrustStore() = default; |
38 | 70 |
39 TrustStore::TrustStore() = default; | 71 void TrustStore::AsyncGetIssuersOf(const ParsedCertificate* cert, |
40 TrustStore::~TrustStore() = default; | 72 std::unique_ptr<Request>* out_req) { |
| 73 out_req->reset(); |
| 74 } |
41 | 75 |
42 } // namespace net | 76 } // namespace net |
OLD | NEW |