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

Unified 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: Add tests for ConvertBaseUTCTime 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 side-by-side diff with in-line comments
Download patch
Index: net/cert/internal/parse_ocsp.cc
diff --git a/net/cert/internal/parse_ocsp.cc b/net/cert/internal/parse_ocsp.cc
index 0243d9537b6216cdd4aa2854ee317f60a9bad2fa..1628ecb8827fc1beaa7e290f6b060457c5e58918 100644
--- a/net/cert/internal/parse_ocsp.cc
+++ b/net/cert/internal/parse_ocsp.cc
@@ -529,4 +529,30 @@ bool GetOCSPCertStatus(const OCSPResponseData& response_data,
return found;
}
+bool CheckOCSPDateValid(const OCSPSingleResponse& response,
+ const base::Time& verify_time,
+ const base::TimeDelta& max_age) {
+ der::GeneralizedTime verify_time_der = der::ConvertBaseUTCTime(verify_time);
+
+ // Enforce thisUpdate <= |verify_time|.
Ryan Sleevi 2016/06/28 17:33:30 Unnecessary comment
dadrian 2016/06/29 22:54:02 Done.
+ if (response.this_update > verify_time_der)
Ryan Sleevi 2016/06/28 17:33:29 Why use > when the comment describes it as <=?
dadrian 2016/06/28 19:15:27 In addressing previous comments from svaldez, I ch
+ return false;
+
+ // Enforce |verify_time| < thisUpdate + |max_age|.
Ryan Sleevi 2016/06/28 17:33:29 Unnecessary comment
dadrian 2016/06/29 22:54:02 Done.
+ der::GeneralizedTime lower_bound =
+ der::ConvertBaseUTCTime(verify_time - max_age);
+ if (response.this_update <= lower_bound)
Ryan Sleevi 2016/06/28 17:33:30 DESIGN: This code is quite confusing with the comm
dadrian 2016/06/28 19:15:27 It's written this way because addition is not defi
Ryan Sleevi 2016/06/28 19:26:44 If I understand your response, you're arguing that
dadrian 2016/06/29 22:54:02 Done.
+ return false;
+
+ // Enforce |verify_time| < nextUpdate, if present.
+ if (response.has_next_update &&
+ (response.next_update <= response.this_update)) {
+ return false;
+ }
+ if (response.has_next_update && (response.next_update <= verify_time_der))
+ return false;
Ryan Sleevi 2016/06/28 17:33:29 DESIGN: Why structure the conditionals like this?
dadrian 2016/06/28 19:15:27 I was trying to avoid the possible future bug, whe
Ryan Sleevi 2016/06/28 19:26:44 I don't think the readability sacrifice is worth t
dadrian 2016/06/29 22:54:02 Done.
+
+ return true;
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698