From dbf6dab7b229428fe832cc01156e977612eba02a Mon Sep 17 00:00:00 2001 From: Jeff Connelly Date: Tue, 3 Jun 2008 16:12:39 -0700 Subject: [PATCH] Optionally (disable) warning on replaying a previously sent messages. --- libotp.c | 2 ++ libotp.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/libotp.c b/libotp.c index 89da4d3..f7f63e3 100644 --- a/libotp.c +++ b/libotp.c @@ -446,8 +446,10 @@ unsigned int otp_decrypt(char *input, char **out) msg = unpackage(input); if (msg->offset < read_offset(msg->pad)) { +#ifdef WARN_REPLAY fprintf(stderr, "** warning: this is an old message! possible replay attack: %ld < %ld\n", msg->offset, read_offset(msg->pad)); +#endif } length = msg->length; diff --git a/libotp.h b/libotp.h index 433e6cc..f979dd8 100644 --- a/libotp.h +++ b/libotp.h @@ -21,6 +21,9 @@ #define PAD_NAME_LENGTH 4 #define MAX_CONFIG_LINE 1024 /* should be enough, >MAX_PATH */ +/* Define to get warnings if a message is replayed. */ +/*#define WARN_REPLAY*/ + /* One-time pad. */ typedef struct _PAD { char *local_filename; -- 2.11.4.GIT