mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-09-13 13:27:43 +02:00
signature clock skew code.
git-svn-id: file:///svn/unbound/trunk@1590 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
@@ -1073,13 +1073,29 @@ check_dates(struct val_env* ve, uint32_t unow,
|
||||
return 0;
|
||||
}
|
||||
if(incep - now > 0) {
|
||||
sigdate_error("verify: signature bad, current time is"
|
||||
" before inception date", expi, incep, now);
|
||||
return 0;
|
||||
/* within skew ? (calc here to avoid calculation normally) */
|
||||
int32_t skew = (expi-incep)/10;
|
||||
if(skew < ve->skew_min) skew = ve->skew_min;
|
||||
if(skew > ve->skew_max) skew = ve->skew_max;
|
||||
if(incep - now > skew) {
|
||||
sigdate_error("verify: signature bad, current time is"
|
||||
" before inception date", expi, incep, now);
|
||||
return 0;
|
||||
}
|
||||
sigdate_error("verify warning suspicious signature inception "
|
||||
" or bad local clock", expi, incep, now);
|
||||
}
|
||||
if(now - expi > 0) {
|
||||
sigdate_error("verify: signature expired", expi, incep, now);
|
||||
return 0;
|
||||
int32_t skew = (expi-incep)/10;
|
||||
if(skew < ve->skew_min) skew = ve->skew_min;
|
||||
if(skew > ve->skew_max) skew = ve->skew_max;
|
||||
if(now - expi > skew) {
|
||||
sigdate_error("verify: signature expired", expi,
|
||||
incep, now);
|
||||
return 0;
|
||||
}
|
||||
sigdate_error("verify warning suspicious signature expiration "
|
||||
" or bad local clock", expi, incep, now);
|
||||
}
|
||||
return 1;
|
||||
|
||||
|
||||
@@ -122,6 +122,8 @@ val_apply_cfg(struct module_env* env, struct val_env* val_env,
|
||||
return 0;
|
||||
}
|
||||
val_env->date_override = cfg->val_date_override;
|
||||
val_env->skew_min = cfg->val_sig_skew_min;
|
||||
val_env->skew_max = cfg->val_sig_skew_max;
|
||||
c = cfg_count_numbers(cfg->val_nsec3_key_iterations);
|
||||
if(c < 1 || (c&1)) {
|
||||
log_err("validator: unparseable or odd nsec3 key "
|
||||
|
||||
@@ -71,6 +71,12 @@ struct val_env {
|
||||
* if 0, current time is used for rrsig validation */
|
||||
int32_t date_override;
|
||||
|
||||
/** clock skew min for signatures */
|
||||
int32_t skew_min;
|
||||
|
||||
/** clock skew max for signatures */
|
||||
int32_t skew_max;
|
||||
|
||||
/** TTL for bogus data; used instead of untrusted TTL from data.
|
||||
* Bogus data will not be verified more often than this interval.
|
||||
* seconds. */
|
||||
|
||||
Reference in New Issue
Block a user