From 6a6d1f9911a5b48cb2ba4863c04f7239fa1d1f10 Mon Sep 17 00:00:00 2001 From: "David M. Syzdek" Date: Thu, 12 Jan 2023 15:10:09 -0900 Subject: libotputil: updating otputil_otp_code() to use S/KEY if seed is NULL. --- lib/libotputil/lrfc2289-otp.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/libotputil/lrfc2289-otp.c b/lib/libotputil/lrfc2289-otp.c index 807c2da..1ba7828 100644 --- a/lib/libotputil/lrfc2289-otp.c +++ b/lib/libotputil/lrfc2289-otp.c @@ -85,20 +85,23 @@ otputil_otp_code( int pos; assert(otp_pass != NULL); - assert(otp_seed != NULL); // check otp_seed - for(len = 0; ((otp_seed[len])); len++) + secret[0] = '\0'; + if ((otp_seed)) { - if (len > OTPUTIL_OTP_SEED_MAX_LEN) - return(-1); - if (!(isalnum(otp_seed[len]))) + for(len = 0; ((otp_seed[len])); len++) + { + if (len > OTPUTIL_OTP_SEED_MAX_LEN) + return(-1); + if (!(isalnum(otp_seed[len]))) + return(-1); + secret[len] = tolower(otp_seed[len]); + }; + secret[len] = '\0'; + if (len < OTPUTIL_OTP_SEED_MIN_LEN) return(-1); - secret[len] = tolower(otp_seed[len]); }; - secret[len] = '\0'; - if (len < OTPUTIL_OTP_SEED_MIN_LEN) - return(-1); // check otp_pass len = strlen(otp_pass); -- cgit v1.2.3