diff options
| -rw-r--r-- | tests/test-otp-decode.c | 95 |
1 files changed, 84 insertions, 11 deletions
diff --git a/tests/test-otp-decode.c b/tests/test-otp-decode.c index 5567473..d358b09 100644 --- a/tests/test-otp-decode.c +++ b/tests/test-otp-decode.c | |||
| @@ -216,20 +216,93 @@ main( | |||
| 216 | }; | 216 | }; |
| 217 | 217 | ||
| 218 | // test HEX decoding | 218 | // test HEX decoding |
| 219 | if ((bv = otputil_otp_decode(rec->hex, NULL, 0)) == NULL) | 219 | if ((rec->hex)) |
| 220 | { | 220 | { |
| 221 | printf("%s: unable to decode\n", rec->hex); | 221 | if ((bv = otputil_otp_decode(rec->hex, NULL, 0)) == NULL) |
| 222 | if (!(ignore_errors)) | 222 | { |
| 223 | return(1); | 223 | printf("unable to decode hex: %s\n", rec->hex); |
| 224 | errs++; | 224 | if (!(ignore_errors)) |
| 225 | continue; | 225 | return(1); |
| 226 | errs++; | ||
| 227 | } else if (otputil_bvcmp(&dat, &bv) != 0) | ||
| 228 | { | ||
| 229 | my_bverror("hex decoding", dat, bv); | ||
| 230 | if (!(ignore_errors)) | ||
| 231 | return(1); | ||
| 232 | errs++; | ||
| 233 | }; | ||
| 226 | }; | 234 | }; |
| 227 | if (otputil_bvcmp(&dat, &bv) != 0) | 235 | |
| 236 | // test six-word decoding | ||
| 237 | if ((rec->six)) | ||
| 238 | { | ||
| 239 | if ((bv = otputil_otp_decode(rec->six, NULL, 0)) == NULL) | ||
| 240 | { | ||
| 241 | printf("unable to decode six-word S/KEY dictionary: %s\n", rec->six); | ||
| 242 | if (!(ignore_errors)) | ||
| 243 | return(1); | ||
| 244 | errs++; | ||
| 245 | } else if (otputil_bvcmp(&dat, &bv) != 0) | ||
| 246 | { | ||
| 247 | my_bverror("six-word S/KEY dictionary decoding", dat, bv); | ||
| 248 | if (!(ignore_errors)) | ||
| 249 | return(1); | ||
| 250 | errs++; | ||
| 251 | }; | ||
| 252 | }; | ||
| 253 | |||
| 254 | // test alt dictionary for md4 decoding | ||
| 255 | if ((rec->alt_md4)) | ||
| 256 | { | ||
| 257 | if ((bv = otputil_otp_decode(rec->alt_md4, NULL, OTPUTIL_MD_MD4)) == NULL) | ||
| 258 | { | ||
| 259 | printf("unable to decode six-word alt dictionary (MD4): %s\n", rec->alt_md4); | ||
| 260 | if (!(ignore_errors)) | ||
| 261 | return(1); | ||
| 262 | errs++; | ||
| 263 | } else if (otputil_bvcmp(&dat, &bv) != 0) | ||
| 264 | { | ||
| 265 | my_bverror("six-word alt dictionary (MD4) decoding", dat, bv); | ||
| 266 | if (!(ignore_errors)) | ||
| 267 | return(1); | ||
| 268 | errs++; | ||
| 269 | }; | ||
| 270 | }; | ||
| 271 | |||
| 272 | // test alt dictionary for md5 decoding | ||
| 273 | if ((rec->alt_md5)) | ||
| 274 | { | ||
| 275 | if ((bv = otputil_otp_decode(rec->alt_md5, NULL, OTPUTIL_MD_MD5)) == NULL) | ||
| 276 | { | ||
| 277 | printf("unable to decode six-word alt dictionary (MD5): %s\n", rec->alt_md5); | ||
| 278 | if (!(ignore_errors)) | ||
| 279 | return(1); | ||
| 280 | errs++; | ||
| 281 | } else if (otputil_bvcmp(&dat, &bv) != 0) | ||
| 282 | { | ||
| 283 | my_bverror("six-word alt dictionary (MD5) decoding", dat, bv); | ||
| 284 | if (!(ignore_errors)) | ||
| 285 | return(1); | ||
| 286 | errs++; | ||
| 287 | }; | ||
| 288 | }; | ||
| 289 | |||
| 290 | // test alt dictionary for sha1 decoding | ||
| 291 | if ((rec->alt_sha1)) | ||
| 228 | { | 292 | { |
| 229 | my_bverror("hex decoding", dat, bv); | 293 | if ((bv = otputil_otp_decode(rec->alt_sha1, NULL, OTPUTIL_MD_SHA1)) == NULL) |
| 230 | if (!(ignore_errors)) | 294 | { |
| 231 | return(1); | 295 | printf("unable to decode six-word alt dictionary (SHA1): %s\n", rec->alt_sha1); |
| 232 | errs++; | 296 | if (!(ignore_errors)) |
| 297 | return(1); | ||
| 298 | errs++; | ||
| 299 | } else if (otputil_bvcmp(&dat, &bv) != 0) | ||
| 300 | { | ||
| 301 | my_bverror("six-word alt dictionary (SHA1) decoding", dat, bv); | ||
| 302 | if (!(ignore_errors)) | ||
| 303 | return(1); | ||
| 304 | errs++; | ||
| 305 | }; | ||
| 233 | }; | 306 | }; |
| 234 | }; | 307 | }; |
| 235 | 308 | ||
