|
@@ -67,6 +67,11 @@ int auth_checks_reg = 0;
|
|
int auth_checks_ood = 0;
|
|
int auth_checks_ood = 0;
|
|
int auth_checks_ind = 0;
|
|
int auth_checks_ind = 0;
|
|
|
|
|
|
|
|
+/* maximum time drift accepted for the nonce creation time
|
|
|
|
+ * (e.g. nonce generated by another proxy in the same cluster with the
|
|
|
|
+ * clock slightly in the future)
|
|
|
|
+ */
|
|
|
|
+unsigned int nonce_auth_max_drift = 3; /* in s */
|
|
|
|
|
|
/** Select extra check configuration based on request type.
|
|
/** Select extra check configuration based on request type.
|
|
* This function determines which configuration variable for
|
|
* This function determines which configuration variable for
|
|
@@ -269,8 +274,7 @@ int calc_nonce(char* nonce, int *nonce_len, int cfg, int since, int expires,
|
|
* @param b_nonce a pointer to a union bin_nonce to be checked.
|
|
* @param b_nonce a pointer to a union bin_nonce to be checked.
|
|
* @return 1 the nonce is stale, 0 the nonce is not stale.
|
|
* @return 1 the nonce is stale, 0 the nonce is not stale.
|
|
*/
|
|
*/
|
|
-#define is_bin_nonce_stale(b_nonce)\
|
|
|
|
- (get_bin_nonce_expire(b_nonce) < ser_time(0))
|
|
|
|
|
|
+#define is_bin_nonce_stale(b_nonce, t) (get_bin_nonce_expire(b_nonce) < (t))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -306,6 +310,7 @@ int check_nonce(auth_body_t* auth, str* secret1, str* secret2,
|
|
int since, b_nonce2_len, b_nonce_len, cfg;
|
|
int since, b_nonce2_len, b_nonce_len, cfg;
|
|
union bin_nonce b_nonce;
|
|
union bin_nonce b_nonce;
|
|
union bin_nonce b_nonce2;
|
|
union bin_nonce b_nonce2;
|
|
|
|
+ time_t t;
|
|
#if defined USE_NC || defined USE_OT_NONCE
|
|
#if defined USE_NC || defined USE_OT_NONCE
|
|
unsigned int n_id;
|
|
unsigned int n_id;
|
|
unsigned char pf;
|
|
unsigned char pf;
|
|
@@ -351,6 +356,13 @@ int check_nonce(auth_body_t* auth, str* secret1, str* secret2,
|
|
without prompting for password */
|
|
without prompting for password */
|
|
return 4;
|
|
return 4;
|
|
}
|
|
}
|
|
|
|
+ t=ser_time(0);
|
|
|
|
+ if (unlikely((since > t) && ((since-t) > nonce_auth_max_drift) )){
|
|
|
|
+ /* the nonce comes from the future, either because of an external
|
|
|
|
+ * time adjustment, or because it was generated by another host
|
|
|
|
+ * which has the time slightly unsynchronized */
|
|
|
|
+ return 4; /* consider it stale */
|
|
|
|
+ }
|
|
b_nonce2=b_nonce; /*pre-fill it with the values from the received nonce*/
|
|
b_nonce2=b_nonce; /*pre-fill it with the values from the received nonce*/
|
|
b_nonce2.n.expire=b_nonce.n.expire;
|
|
b_nonce2.n.expire=b_nonce.n.expire;
|
|
b_nonce2.n.since=b_nonce.n.since;
|
|
b_nonce2.n.since=b_nonce.n.since;
|
|
@@ -433,7 +445,7 @@ int check_nonce(auth_body_t* auth, str* secret1, str* secret2,
|
|
#ifdef USE_NC
|
|
#ifdef USE_NC
|
|
check_stale:
|
|
check_stale:
|
|
#endif /* USE_NC */
|
|
#endif /* USE_NC */
|
|
- if (unlikely(is_bin_nonce_stale(&b_nonce)))
|
|
|
|
|
|
+ if (unlikely(is_bin_nonce_stale(&b_nonce, t)))
|
|
return 4;
|
|
return 4;
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|