X-Git-Url: https://git.distorted.org.uk/~mdw/tripe/blobdiff_plain/7cd79da096ced70c89af673bc0c87990eaa68528..f43df819b3b11fa95a68f6feb58070268d40b1a8:/keyset.c diff --git a/keyset.c b/keyset.c index 9b804ea6..bb2397fc 100644 --- a/keyset.c +++ b/keyset.c @@ -250,30 +250,6 @@ static int dodecrypt(keyset *ks, unsigned ty, buf *b, buf *bb, uint32 *seq) return (0); } -/* --- @dosequence@ --- * - * - * Arguments: @keyset *ks@ = pointer to a keyset - * @uint32 seq@ = a sequence number from a packet - * - * Returns: Zero if the sequence number is OK, nonzero if it's not. - * - * Use: Checks a sequence number. The data in the keyset which keeps - * track of valid sequence numbers is updated if the sequence - * number given is good. It's assumed that the sequence number - * has already been checked for authenticity. - */ - -static int dosequence(keyset *ks, uint32 seq) -{ - switch (seq_check(&ks->iseq, seq)) { - case SEQ_OK: break; - case SEQ_OLD: a_warn("SYMM replay old-sequence"); return (-1); - case SEQ_REPLAY: a_warn("SYMM replay duplicated-sequence"); return (-1); - default: abort(); - } - return (0); -} - /*----- Operations on a single keyset -------------------------------------*/ /* --- @ks_drop@ --- * @@ -468,7 +444,7 @@ int ks_decrypt(keyset *ks, unsigned ty, buf *b, buf *bb) if (!KEYOK(ks, now) || buf_ensure(bb, BLEN(b)) || dodecrypt(ks, ty, b, bb, &seq) || - dosequence(ks, seq)) + seq_check(&ks->iseq, seq, "SYMM")) return (-1); return (0); } @@ -612,7 +588,7 @@ int ksl_decrypt(keyset **ksroot, unsigned ty, buf *b, buf *bb) ks->seq); ) ks->f &= ~KSF_LISTEN; } - return (dosequence(ks, seq)); + return (seq_check(&ks->iseq, seq, "SYMM")); } } T( trace(T_KEYSET, "keyset: no matching keys, or incorrect MAC"); )