diff options
| author | David M. Syzdek <david@syzdek.net> | 2023-01-12 15:10:09 -0900 |
|---|---|---|
| committer | David M. Syzdek <david@syzdek.net> | 2023-01-12 15:10:09 -0900 |
| commit | 6a6d1f9911a5b48cb2ba4863c04f7239fa1d1f10 (patch) | |
| tree | 9c13b8f564ef986caa4fa383a03f95aacc503761 /lib | |
| parent | f018bf05d975e14e4c2c81ef06174561f4a83d34 (diff) | |
| download | otputils-6a6d1f9911a5b48cb2ba4863c04f7239fa1d1f10.tar.gz otputils-6a6d1f9911a5b48cb2ba4863c04f7239fa1d1f10.tar.bz2 otputils-6a6d1f9911a5b48cb2ba4863c04f7239fa1d1f10.tar.xz otputils-6a6d1f9911a5b48cb2ba4863c04f7239fa1d1f10.zip | |
libotputil: updating otputil_otp_code() to use S/KEY if seed is NULL.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libotputil/lrfc2289-otp.c | 21 |
1 files 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( | |||
| 85 | int pos; | 85 | int pos; |
| 86 | 86 | ||
| 87 | assert(otp_pass != NULL); | 87 | assert(otp_pass != NULL); |
| 88 | assert(otp_seed != NULL); | ||
| 89 | 88 | ||
| 90 | // check otp_seed | 89 | // check otp_seed |
| 91 | for(len = 0; ((otp_seed[len])); len++) | 90 | secret[0] = '\0'; |
| 91 | if ((otp_seed)) | ||
| 92 | { | 92 | { |
| 93 | if (len > OTPUTIL_OTP_SEED_MAX_LEN) | 93 | for(len = 0; ((otp_seed[len])); len++) |
| 94 | return(-1); | 94 | { |
| 95 | if (!(isalnum(otp_seed[len]))) | 95 | if (len > OTPUTIL_OTP_SEED_MAX_LEN) |
| 96 | return(-1); | ||
| 97 | if (!(isalnum(otp_seed[len]))) | ||
| 98 | return(-1); | ||
| 99 | secret[len] = tolower(otp_seed[len]); | ||
| 100 | }; | ||
| 101 | secret[len] = '\0'; | ||
| 102 | if (len < OTPUTIL_OTP_SEED_MIN_LEN) | ||
| 96 | return(-1); | 103 | return(-1); |
| 97 | secret[len] = tolower(otp_seed[len]); | ||
| 98 | }; | 104 | }; |
| 99 | secret[len] = '\0'; | ||
| 100 | if (len < OTPUTIL_OTP_SEED_MIN_LEN) | ||
| 101 | return(-1); | ||
| 102 | 105 | ||
| 103 | // check otp_pass | 106 | // check otp_pass |
| 104 | len = strlen(otp_pass); | 107 | len = strlen(otp_pass); |
