From e2fb60b1d7af5d2045db0e937abe90e4045c95e1 Mon Sep 17 00:00:00 2001 From: "David M. Syzdek" Date: Thu, 12 Jan 2023 15:59:37 -0900 Subject: libotputil: updating otputil_otp_str() to include encoding --- include/otputil.h | 1 + lib/libotputil/lrfc2289-otp.c | 4 +++- tests/test-otp.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/otputil.h b/include/otputil.h index 9e2f261..933f3e1 100644 --- a/include/otputil.h +++ b/include/otputil.h @@ -416,6 +416,7 @@ otputil_otp_str( const char * otp_seed, int otp_seq, int otp_hash, + int otp_encoding, char * dst, size_t dstlen ); diff --git a/lib/libotputil/lrfc2289-otp.c b/lib/libotputil/lrfc2289-otp.c index d02343a..ba180bb 100644 --- a/lib/libotputil/lrfc2289-otp.c +++ b/lib/libotputil/lrfc2289-otp.c @@ -156,6 +156,7 @@ otputil_otp_str( const char * otp_seed, int otp_seq, int otp_hash, + int otp_encoding, char * dst, size_t dstlen ) { @@ -166,6 +167,7 @@ otputil_otp_str( dstlen = ((dst)) ? dstlen : sizeof(buff); dst = ((dst)) ? dst : buff; + otp_encoding = ((otp_encoding)) ? otp_encoding : otputil_defaults.otp_encoding; res.bv_val = bv_val; res.bv_len = sizeof(bv_val); @@ -180,7 +182,7 @@ otputil_otp_str( bv_val[5] = (val >> 16) & 0xff; bv_val[6] = (val >> 8) & 0xff; bv_val[7] = (val >> 0) & 0xff; - otputil_otp_encode(&res, dst, dstlen, OTPUTIL_ENC_SIXWORD); + otputil_otp_encode(&res, dst, dstlen, otp_encoding); return(dst); } diff --git a/tests/test-otp.c b/tests/test-otp.c index 1c17cd1..73db97e 100644 --- a/tests/test-otp.c +++ b/tests/test-otp.c @@ -216,7 +216,7 @@ main( printf("%s\n", rec->six); }; - if ((res = otputil_otp_str(rec->pass, rec->seed, rec->count, rec->method, NULL, 0)) == NULL) + if ((res = otputil_otp_str(rec->pass, rec->seed, rec->count, rec->method, OTPUTIL_ENC_SIXWORD, NULL, 0)) == NULL) { printf("otputil_otp_str(): unknown error\n"); if (!(ignore_errors)) -- cgit v1.2.3