diff options
| author | David M. Syzdek <david@syzdek.net> | 2023-01-12 02:04:19 -0900 |
|---|---|---|
| committer | David M. Syzdek <david@syzdek.net> | 2023-01-12 02:04:19 -0900 |
| commit | f102dfcd298b323f6d0a97d19b3688bfc84a75da (patch) | |
| tree | 3c5e6d8e3d955ee2c8450622698fe88b521ce0cd | |
| parent | 9fcee0c6a6a8641d19c3d0a1124d91cf6b620f9d (diff) | |
| download | otputils-f102dfcd298b323f6d0a97d19b3688bfc84a75da.tar.gz otputils-f102dfcd298b323f6d0a97d19b3688bfc84a75da.tar.bz2 otputils-f102dfcd298b323f6d0a97d19b3688bfc84a75da.tar.xz otputils-f102dfcd298b323f6d0a97d19b3688bfc84a75da.zip | |
libotputil: fixing seed processing in otputil_otp_code()
| -rw-r--r-- | lib/libotputil/lrfc2289-otp.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/libotputil/lrfc2289-otp.c b/lib/libotputil/lrfc2289-otp.c index e3512f3..82f344f 100644 --- a/lib/libotputil/lrfc2289-otp.c +++ b/lib/libotputil/lrfc2289-otp.c | |||
| @@ -87,24 +87,29 @@ otputil_otp_code( | |||
| 87 | assert(otp_pass != NULL); | 87 | assert(otp_pass != NULL); |
| 88 | assert(otp_seed != NULL); | 88 | assert(otp_seed != NULL); |
| 89 | 89 | ||
| 90 | // check otp_pass | ||
| 91 | len = strlen(otp_pass); | ||
| 92 | if ((len > OTPUTIL_OTP_PASS_MAX_LEN) || (len < OTPUTIL_OTP_PASS_MIN_LEN)) | ||
| 93 | return(-1); | ||
| 94 | |||
| 95 | // check otp_seed | 90 | // check otp_seed |
| 96 | for(len = 0; ((otp_seed[len])); len++) | 91 | for(len = 0; ((otp_seed[len])); len++) |
| 92 | { | ||
| 93 | if (len > OTPUTIL_OTP_SEED_MAX_LEN) | ||
| 94 | return(-1); | ||
| 97 | if (!(isalnum(otp_seed[len]))) | 95 | if (!(isalnum(otp_seed[len]))) |
| 98 | return(-1); | 96 | return(-1); |
| 99 | if ((len > OTPUTIL_OTP_SEED_MAX_LEN) || (len < OTPUTIL_OTP_SEED_MIN_LEN)) | 97 | secret[len] = tolower(otp_seed[len]); |
| 98 | }; | ||
| 99 | secret[len] = '\0'; | ||
| 100 | if (len < OTPUTIL_OTP_SEED_MIN_LEN) | ||
| 100 | return(-1); | 101 | return(-1); |
| 101 | 102 | ||
| 103 | // check otp_pass | ||
| 104 | len = strlen(otp_pass); | ||
| 105 | if ((len > OTPUTIL_OTP_PASS_MAX_LEN) || (len < OTPUTIL_OTP_PASS_MIN_LEN)) | ||
| 106 | return(-1); | ||
| 107 | |||
| 102 | // check otp_hash | 108 | // check otp_hash |
| 103 | if ((evp_md = otputil_evp_md(otp_hash)) == NULL) | 109 | if ((evp_md = otputil_evp_md(otp_hash)) == NULL) |
| 104 | return(-1); | 110 | return(-1); |
| 105 | 111 | ||
| 106 | // generate secret | 112 | // generate secret |
| 107 | bindle_strlcpy(secret, otp_seed, sizeof(secret)); | ||
| 108 | bindle_strlcat(secret, otp_pass, sizeof(secret)); | 113 | bindle_strlcat(secret, otp_pass, sizeof(secret)); |
| 109 | secret_len = (unsigned)strlen(secret); | 114 | secret_len = (unsigned)strlen(secret); |
| 110 | 115 | ||
