aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/libotputil/lrfc2289-otp.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libotputil/lrfc2289-otp.c')
-rw-r--r--lib/libotputil/lrfc2289-otp.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/libotputil/lrfc2289-otp.c b/lib/libotputil/lrfc2289-otp.c
index e037f83..a9d55e4 100644
--- a/lib/libotputil/lrfc2289-otp.c
+++ b/lib/libotputil/lrfc2289-otp.c
@@ -124,4 +124,39 @@ otputil_otp_code(
124} 124}
125 125
126 126
127char *
128otputil_otp_str(
129 const char * otp_pass,
130 const char * otp_seed,
131 int otp_seq,
132 int otp_hash,
133 char * dst,
134 size_t dstlen )
135{
136 uint64_t val;
137 otputil_bv_t res;
138 uint8_t bv_val[8];
139 static char buff[32];
140
141 dstlen = ((dst)) ? dstlen : sizeof(buff);
142 dst = ((dst)) ? dst : buff;
143 res.bv_val = bv_val;
144 res.bv_len = sizeof(bv_val);
145
146 val = otputil_otp_code(otp_pass, otp_seed, otp_seq, otp_hash);
147
148 bv_val[0] = (val >> 56) & 0xff;
149 bv_val[1] = (val >> 48) & 0xff;
150 bv_val[2] = (val >> 40) & 0xff;
151 bv_val[3] = (val >> 32) & 0xff;
152 bv_val[4] = (val >> 24) & 0xff;
153 bv_val[5] = (val >> 16) & 0xff;
154 bv_val[6] = (val >> 8) & 0xff;
155 bv_val[7] = (val >> 0) & 0xff;
156 otputil_otp_encode(&res, dst, dstlen, OTPUTIL_ENC_SIXWORD);
157
158 return(dst);
159}
160
161
127/* end of source file */ 162/* end of source file */