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

Side by Side Diff: net/cert/internal/parse_ocsp.cc

Issue 2091103002: Add CheckOCSPDateValid() to net/cert/internal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from rsleevi@ Created 4 years, 5 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 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"
10 11
11 namespace net { 12 namespace net {
12 13
13 OCSPCertID::OCSPCertID() {} 14 OCSPCertID::OCSPCertID() {}
14 OCSPCertID::~OCSPCertID() {} 15 OCSPCertID::~OCSPCertID() {}
15 16
16 OCSPSingleResponse::OCSPSingleResponse() {} 17 OCSPSingleResponse::OCSPSingleResponse() {}
17 OCSPSingleResponse::~OCSPSingleResponse() {} 18 OCSPSingleResponse::~OCSPSingleResponse() {}
18 19
19 OCSPResponseData::OCSPResponseData() {} 20 OCSPResponseData::OCSPResponseData() {}
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 } 523 }
523 } 524 }
524 } 525 }
525 526
526 if (!found) 527 if (!found)
527 out->status = OCSPCertStatus::Status::UNKNOWN; 528 out->status = OCSPCertStatus::Status::UNKNOWN;
528 529
529 return found; 530 return found;
530 } 531 }
531 532
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 der::EncodeTimeAsGeneralizedTime(verify_time);
538
539 if (response.this_update > verify_time_der)
540 return false; // Response is not yet valid.
541
542 if (response.has_next_update && (response.next_update <= verify_time_der))
543 return false; // Response is no longer valid.
544
545 der::GeneralizedTime earliest_this_update =
546 der::EncodeTimeAsGeneralizedTime(verify_time - max_age);
547 if (response.this_update < earliest_this_update)
548 return false; // Response is too old.
549
550 return true;
551 }
552
532 } // namespace net 553 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698