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

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: Remove extra include. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cert/internal/parse_ocsp.h ('k') | net/cert/internal/parse_ocsp_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..21ce878b3cfc78b7b3f9a894850e6024eb579bf2 100644
--- a/net/cert/internal/parse_ocsp.cc
+++ b/net/cert/internal/parse_ocsp.cc
@@ -7,6 +7,7 @@
#include "base/sha1.h"
#include "crypto/sha2.h"
#include "net/cert/internal/parse_ocsp.h"
+#include "net/der/encode_values.h"
namespace net {
@@ -529,4 +530,28 @@ 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;
+ if (!der::EncodeTimeAsGeneralizedTime(verify_time, &verify_time_der))
+ return false;
+
+ if (response.this_update > verify_time_der)
+ return false; // Response is not yet valid.
+
+ if (response.has_next_update && (response.next_update <= verify_time_der))
+ return false; // Response is no longer valid.
+
+ der::GeneralizedTime earliest_this_update;
+ if (!der::EncodeTimeAsGeneralizedTime(verify_time - max_age,
+ &earliest_this_update)) {
+ return false;
+ }
+ if (response.this_update < earliest_this_update)
+ return false; // Response is too old.
+
+ return true;
+}
+
} // namespace net
« no previous file with comments | « net/cert/internal/parse_ocsp.h ('k') | net/cert/internal/parse_ocsp_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698