Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(986)

Side by Side Diff: net/http/transport_security_state.h

Issue 2066603004: Return enum from TransportSecurityState::CheckPublicKeyPins (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef NET_HTTP_TRANSPORT_SECURITY_STATE_H_ 5 #ifndef NET_HTTP_TRANSPORT_SECURITY_STATE_H_
6 #define NET_HTTP_TRANSPORT_SECURITY_STATE_H_ 6 #define NET_HTTP_TRANSPORT_SECURITY_STATE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 bool HasNext() const { return iterator_ != end_; } 100 bool HasNext() const { return iterator_ != end_; }
101 void Advance() { ++iterator_; } 101 void Advance() { ++iterator_; }
102 const std::string& hostname() const { return iterator_->first; } 102 const std::string& hostname() const { return iterator_->first; }
103 const STSState& domain_state() const { return iterator_->second; } 103 const STSState& domain_state() const { return iterator_->second; }
104 104
105 private: 105 private:
106 std::map<std::string, STSState>::const_iterator iterator_; 106 std::map<std::string, STSState>::const_iterator iterator_;
107 std::map<std::string, STSState>::const_iterator end_; 107 std::map<std::string, STSState>::const_iterator end_;
108 }; 108 };
109 109
110 // PKPStatus describes the result of a pinning check.
111 enum class PKPStatus { VIOLATED = -1, OK = 0, BYPASSED = 1 };
Ryan Sleevi 2016/06/15 02:04:03 STYLE: No need to assign explicit values. STYLE: N
dadrian 2016/06/15 02:47:55 I went with violated because that's what I've hear
dadrian 2016/06/15 18:58:28 I left it with enum class because I think we want
Ryan Sleevi 2016/06/15 19:02:23 Scoping benefits? We don't gain anything in terms
dadrian 2016/06/15 19:33:16 Both? We're trying to represent the result of PKP
112
110 // A PKPState describes the public key pinning state. 113 // A PKPState describes the public key pinning state.
111 class NET_EXPORT PKPState { 114 class NET_EXPORT PKPState {
112 public: 115 public:
113 PKPState(); 116 PKPState();
114 PKPState(const PKPState& other); 117 PKPState(const PKPState& other);
115 ~PKPState(); 118 ~PKPState();
116 119
117 // The absolute time (UTC) when the |spki_hashes| (and other state) were 120 // The absolute time (UTC) when the |spki_hashes| (and other state) were
118 // observed. 121 // observed.
119 base::Time last_observed; 122 base::Time last_observed;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 TransportSecurityState(); 255 TransportSecurityState();
253 ~TransportSecurityState(); 256 ~TransportSecurityState();
254 257
255 // These functions search for static and dynamic STS and PKP states, and 258 // These functions search for static and dynamic STS and PKP states, and
256 // invoke the functions of the same name on them. These functions are the 259 // invoke the functions of the same name on them. These functions are the
257 // primary public interface; direct access to STS and PKP states is best 260 // primary public interface; direct access to STS and PKP states is best
258 // left to tests. The caller needs to handle the optional pinning override 261 // left to tests. The caller needs to handle the optional pinning override
259 // when is_issued_by_known_root is false. 262 // when is_issued_by_known_root is false.
260 bool ShouldSSLErrorsBeFatal(const std::string& host); 263 bool ShouldSSLErrorsBeFatal(const std::string& host);
261 bool ShouldUpgradeToSSL(const std::string& host); 264 bool ShouldUpgradeToSSL(const std::string& host);
262 bool CheckPublicKeyPins(const HostPortPair& host_port_pair, 265 PKPStatus CheckPublicKeyPins(
263 bool is_issued_by_known_root, 266 const HostPortPair& host_port_pair,
264 const HashValueVector& hashes, 267 bool is_issued_by_known_root,
265 const X509Certificate* served_certificate_chain, 268 const HashValueVector& hashes,
266 const X509Certificate* validated_certificate_chain, 269 const X509Certificate* served_certificate_chain,
267 const PublicKeyPinReportStatus report_status, 270 const X509Certificate* validated_certificate_chain,
268 std::string* failure_log); 271 const PublicKeyPinReportStatus report_status,
272 std::string* failure_log);
269 bool HasPublicKeyPins(const std::string& host); 273 bool HasPublicKeyPins(const std::string& host);
270 274
271 // Assign a |Delegate| for persisting the transport security state. If 275 // Assign a |Delegate| for persisting the transport security state. If
272 // |NULL|, state will not be persisted. The caller retains 276 // |NULL|, state will not be persisted. The caller retains
273 // ownership of |delegate|. 277 // ownership of |delegate|.
274 // Note: This is only used for serializing/deserializing the 278 // Note: This is only used for serializing/deserializing the
275 // TransportSecurityState. 279 // TransportSecurityState.
276 void SetDelegate(Delegate* delegate); 280 void SetDelegate(Delegate* delegate);
277 281
278 void SetReportSender(ReportSenderInterface* report_sender); 282 void SetReportSender(ReportSenderInterface* report_sender);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 // representation of first-class DomainStates, and exposing the preloads 408 // representation of first-class DomainStates, and exposing the preloads
405 // to the caller with |GetStaticDomainState|. 409 // to the caller with |GetStaticDomainState|.
406 static void ReportUMAOnPinFailure(const std::string& host); 410 static void ReportUMAOnPinFailure(const std::string& host);
407 411
408 // IsBuildTimely returns true if the current build is new enough ensure that 412 // IsBuildTimely returns true if the current build is new enough ensure that
409 // built in security information (i.e. HSTS preloading and pinning 413 // built in security information (i.e. HSTS preloading and pinning
410 // information) is timely. 414 // information) is timely.
411 static bool IsBuildTimely(); 415 static bool IsBuildTimely();
412 416
413 // Helper method for actually checking pins. 417 // Helper method for actually checking pins.
414 bool CheckPublicKeyPinsImpl( 418 PKPStatus CheckPublicKeyPinsImpl(
415 const HostPortPair& host_port_pair, 419 const HostPortPair& host_port_pair,
416 bool is_issued_by_known_root, 420 bool is_issued_by_known_root,
417 const HashValueVector& hashes, 421 const HashValueVector& hashes,
418 const X509Certificate* served_certificate_chain, 422 const X509Certificate* served_certificate_chain,
419 const X509Certificate* validated_certificate_chain, 423 const X509Certificate* validated_certificate_chain,
420 const PublicKeyPinReportStatus report_status, 424 const PublicKeyPinReportStatus report_status,
421 std::string* failure_log); 425 std::string* failure_log);
422 426
423 // If a Delegate is present, notify it that the internal state has 427 // If a Delegate is present, notify it that the internal state has
424 // changed. 428 // changed.
(...skipping 20 matching lines...) Expand all
445 void EnableSTSHost(const std::string& host, const STSState& state); 449 void EnableSTSHost(const std::string& host, const STSState& state);
446 void EnablePKPHost(const std::string& host, const PKPState& state); 450 void EnablePKPHost(const std::string& host, const PKPState& state);
447 451
448 // Returns true if a request to |host_port_pair| with the given 452 // Returns true if a request to |host_port_pair| with the given
449 // SubjectPublicKeyInfo |hashes| satisfies the pins in |pkp_state|, 453 // SubjectPublicKeyInfo |hashes| satisfies the pins in |pkp_state|,
450 // and false otherwise. If a violation is found and reporting is 454 // and false otherwise. If a violation is found and reporting is
451 // configured (i.e. there is a report URI in |pkp_state| and 455 // configured (i.e. there is a report URI in |pkp_state| and
452 // |report_status| says to), this method sends an HPKP violation 456 // |report_status| says to), this method sends an HPKP violation
453 // report containing |served_certificate_chain| and 457 // report containing |served_certificate_chain| and
454 // |validated_certificate_chain|. 458 // |validated_certificate_chain|.
455 bool CheckPinsAndMaybeSendReport( 459 PKPStatus CheckPinsAndMaybeSendReport(
456 const HostPortPair& host_port_pair, 460 const HostPortPair& host_port_pair,
457 bool is_issued_by_known_root, 461 bool is_issued_by_known_root,
458 const TransportSecurityState::PKPState& pkp_state, 462 const TransportSecurityState::PKPState& pkp_state,
459 const HashValueVector& hashes, 463 const HashValueVector& hashes,
460 const X509Certificate* served_certificate_chain, 464 const X509Certificate* served_certificate_chain,
461 const X509Certificate* validated_certificate_chain, 465 const X509Certificate* validated_certificate_chain,
462 const TransportSecurityState::PublicKeyPinReportStatus report_status, 466 const TransportSecurityState::PublicKeyPinReportStatus report_status,
463 std::string* failure_log); 467 std::string* failure_log);
464 468
465 // Returns true and updates |*expect_ct_result| iff there is a static 469 // Returns true and updates |*expect_ct_result| iff there is a static
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 // rate-limiting. 506 // rate-limiting.
503 ExpiringCache<std::string, bool, base::TimeTicks, std::less<base::TimeTicks>> 507 ExpiringCache<std::string, bool, base::TimeTicks, std::less<base::TimeTicks>>
504 sent_reports_cache_; 508 sent_reports_cache_;
505 509
506 DISALLOW_COPY_AND_ASSIGN(TransportSecurityState); 510 DISALLOW_COPY_AND_ASSIGN(TransportSecurityState);
507 }; 511 };
508 512
509 } // namespace net 513 } // namespace net
510 514
511 #endif // NET_HTTP_TRANSPORT_SECURITY_STATE_H_ 515 #endif // NET_HTTP_TRANSPORT_SECURITY_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698