/* Check OCSP response is valid at the specified time
* (allowing for some margin of error).
*/
- if ( response->this_update > ( time + OCSP_ERROR_MARGIN_TIME ) ) {
+ if ( response->this_update > ( time + X509_ERROR_MARGIN_TIME ) ) {
DBGC ( ocsp, "OCSP %p \"%s\" response is not yet valid (at "
"time %lld)\n", ocsp, ocsp->cert->subject.name, time );
return -EACCES_STALE;
}
- if ( response->next_update < ( time - OCSP_ERROR_MARGIN_TIME ) ) {
+ if ( response->next_update < ( time - X509_ERROR_MARGIN_TIME ) ) {
DBGC ( ocsp, "OCSP %p \"%s\" response is stale (at time "
"%lld)\n", ocsp, ocsp->cert->subject.name, time );
return -EACCES_STALE;
struct x509_validity *validity = &cert->validity;
/* Check validity period */
- if ( time < validity->not_before.time ) {
+ if ( validity->not_before.time > ( time + X509_ERROR_MARGIN_TIME ) ) {
DBGC ( cert, "X509 %p \"%s\" is not yet valid (at time %lld)\n",
cert, cert->subject.name, time );
return -EACCES_EXPIRED;
}
- if ( time > validity->not_after.time ) {
+ if ( validity->not_after.time < ( time - X509_ERROR_MARGIN_TIME ) ) {
DBGC ( cert, "X509 %p \"%s\" has expired (at time %lld)\n",
cert, cert->subject.name, time );
return -EACCES_EXPIRED;
#define OCSP_STATUS_SIG_REQUIRED 0x05
#define OCSP_STATUS_UNAUTHORIZED 0x06
-/** Margin of error allowed in OCSP response times
- *
- * We allow a generous margin of error: 12 hours to allow for the
- * local time zone being non-GMT, plus 30 minutes to allow for general
- * clock drift.
- */
-#define OCSP_ERROR_MARGIN_TIME ( ( 12 * 60 + 30 ) * 60 )
-
/** An OCSP request */
struct ocsp_request {
/** Request builder */
struct x509_time not_after;
};
+/** Margin of error allowed in X.509 response times
+ *
+ * We allow a generous margin of error: 12 hours to allow for the
+ * local time zone being non-GMT, plus 30 minutes to allow for general
+ * clock drift.
+ */
+#define X509_ERROR_MARGIN_TIME ( ( 12 * 60 + 30 ) * 60 )
+
/** An X.509 certificate public key */
struct x509_public_key {
/** Raw public key information */