| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/sha1.h" | 7 #include "base/sha1.h" |
| 8 #include "crypto/sha2.h" | 8 #include "crypto/sha2.h" |
| 9 #include "net/cert/internal/parse_ocsp.h" | 9 #include "net/cert/internal/parse_ocsp.h" |
| 10 #include "net/der/encode_values.h" | |
| 11 | 10 |
| 12 namespace net { | 11 namespace net { |
| 13 | 12 |
| 14 OCSPCertID::OCSPCertID() {} | 13 OCSPCertID::OCSPCertID() {} |
| 15 OCSPCertID::~OCSPCertID() {} | 14 OCSPCertID::~OCSPCertID() {} |
| 16 | 15 |
| 17 OCSPSingleResponse::OCSPSingleResponse() {} | 16 OCSPSingleResponse::OCSPSingleResponse() {} |
| 18 OCSPSingleResponse::~OCSPSingleResponse() {} | 17 OCSPSingleResponse::~OCSPSingleResponse() {} |
| 19 | 18 |
| 20 OCSPResponseData::OCSPResponseData() {} | 19 OCSPResponseData::OCSPResponseData() {} |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 } | 522 } |
| 524 } | 523 } |
| 525 } | 524 } |
| 526 | 525 |
| 527 if (!found) | 526 if (!found) |
| 528 out->status = OCSPCertStatus::Status::UNKNOWN; | 527 out->status = OCSPCertStatus::Status::UNKNOWN; |
| 529 | 528 |
| 530 return found; | 529 return found; |
| 531 } | 530 } |
| 532 | 531 |
| 533 bool CheckOCSPDateValid(const OCSPSingleResponse& response, | |
| 534 const base::Time& verify_time, | |
| 535 const base::TimeDelta& max_age) { | |
| 536 der::GeneralizedTime verify_time_der; | |
| 537 if (!der::EncodeTimeAsGeneralizedTime(verify_time, &verify_time_der)) | |
| 538 return false; | |
| 539 | |
| 540 if (response.this_update > verify_time_der) | |
| 541 return false; // Response is not yet valid. | |
| 542 | |
| 543 if (response.has_next_update && (response.next_update <= verify_time_der)) | |
| 544 return false; // Response is no longer valid. | |
| 545 | |
| 546 der::GeneralizedTime earliest_this_update; | |
| 547 if (!der::EncodeTimeAsGeneralizedTime(verify_time - max_age, | |
| 548 &earliest_this_update)) { | |
| 549 return false; | |
| 550 } | |
| 551 if (response.this_update < earliest_this_update) | |
| 552 return false; // Response is too old. | |
| 553 | |
| 554 return true; | |
| 555 } | |
| 556 | |
| 557 } // namespace net | 532 } // namespace net |
| OLD | NEW |