aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tests/test-otputil-otp.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-otputil-otp.sh')
-rwxr-xr-xtests/test-otputil-otp.sh129
1 files changed, 129 insertions, 0 deletions
diff --git a/tests/test-otputil-otp.sh b/tests/test-otputil-otp.sh
new file mode 100755
index 0000000..09a534c
--- /dev/null
+++ b/tests/test-otputil-otp.sh
@@ -0,0 +1,129 @@
1#!/bin/sh
2#
3# OTP Utilities
4# Copyright (C) 2022 David M. Syzdek <david@syzdek.net>.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met:
9#
10# * Redistributions of source code must retain the above copyright
11# notice, this list of conditions and the following disclaimer.
12# * Redistributions in binary form must reproduce the above copyright
13# notice, this list of conditions and the following disclaimer in the
14# documentation and/or other materials provided with the distribution.
15# * Neither the name of David M. Syzdek nor the
16# names of its contributors may be used to endorse or promote products
17# derived from this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO
21# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID M SYZDEK BE LIABLE FOR
23# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29# SUCH DAMAGE.
30#
31
32my_field()
33{
34 cut -d: -f${1} \
35 |sed \
36 -e 's/^-\{1,\}//g' \
37 -e 's/-\{1,\}$//g' \
38 -e 's/-/ /g'
39}
40
41my_payload()
42{
43 PAYLOAD_LINE=$(awk '/^__PAYLOAD_BELOW__/ {print NR + 1; exit 0; }' $0)
44 TOTAL_LINES=$(($(wc -l "$0" |awk '{print$1}')+1))
45 if test "x${PAYLOAD_LINE}" == "x${TOTAL_LINES}";then
46 return 0;
47 fi
48 tail -n+${PAYLOAD_LINE} $0 \
49 |egrep -v '^[[:space:]]{0,}#|^[[:space:]]{0,}$' \
50 |sed -e 's/[[:space:]]/-/g'
51 return 0;
52}
53
54REC_ERR=0;
55
56for REC in $(my_payload);do
57 REC_HASH="$( echo "${REC}" |my_field 1 )"
58 REC_PASS="$( echo "${REC}" |my_field 2 )"
59 REC_SEED="$( echo "${REC}" |my_field 3 )"
60 REC_SEQ="$( echo "${REC}" |my_field 4 )"
61 REC_HEX="$( echo "${REC}" |my_field 5 )"
62 REC_SIX="$( echo "${REC}" |my_field 6 )"
63 REC_ALT="$( echo "${REC}" |my_field 7 )"
64
65 ./src/otputil -vv \
66 "otp-${REC_HASH}" \
67 "${REC_SEQ}" \
68 "${REC_SEED}" \
69 "${REC_HEX}" \
70 -P "${REC_PASS}" \
71 || REC_ERR=$((${REC_ERR}+1))
72
73 ./src/otputil -vv \
74 "otp-${REC_HASH}" \
75 "${REC_SEQ}" \
76 "${REC_SEED}" \
77 "${REC_SIX}" \
78 -P "${REC_PASS}" \
79 || REC_ERR=$((${REC_ERR}+1))
80
81 if test -z "${REC_ALT}";then
82 continue;
83 fi
84 ./src/otputil -vv \
85 "otp-${REC_HASH}" \
86 "${REC_SEQ}" \
87 "${REC_SEED}" \
88 "${REC_ALT}" \
89 -P "${REC_PASS}" \
90 || REC_ERR=$((${REC_ERR}+1))
91done
92
93echo "${REC_ERR} error(s) encountered"
94
95if test ${REC_ERR} -ne 0;then
96 exit 1;
97fi
98exit 0
99# end of script
100__PAYLOAD_BELOW__
101md5 :A_Valid_Pass_Phrase :AValidSeed :99 :85C4 3EE0 3857 765B :FOWL KID MASH DEAD DUAL OAF :Fot Acle Amu J ln Sax :
102md4 :This is a test. :TeSt :0 :D185 4218 EBBB 0B51 :ROME MUG FRED SCAN LIVE LACE :AER Il ERE Fao iso NIG :
103md4 :This is a test. :TeSt :1 :6347 3EF0 1CD0 B444 :CARD SAD MINI RYE COL KIN :CVA ISN Oys Mau ably hs :
104md4 :This is a test. :TeSt :99 :C5E6 1277 6E6C 237A :NOTE OUT IBIS SINK NAVE MODE :TEM TAX alo LEY God Hei :
105md4 :AbCdEfGhIjK :alpha1 :0 :5007 6F47 EB1A DE4E :AWAY SEN ROOK SALT LICE MAP :bw JER GLB kob cep MFA :
106md4 :AbCdEfGhIjK :alpha1 :1 :65D2 0D19 49B5 F7AB :CHEW GRIM WU HANG BUCK SAID :Dmd shf FALA boc que Lib :
107md4 :AbCdEfGhIjK :alpha1 :99 :D150 C82C CE6F 62D1 :ROIL FREE COG HUNK WAIT COCA :MIM IQS MHZ THO vr Hy :
108md4 :OTP's are good :correct :0 :849C 79D4 F6F5 5388 :FOOL STEM DONE TOOL BECK NILE :GOO fi IMP Hep EYRY QAT :
109md4 :OTP's are good :correct :1 :8C09 92FB 2508 47B1 :GIST AMOS MOOT AIDS FOOD SEEM :Cva Ys pw ios foy GOA :
110md4 :OTP's are good :correct :99 :3F3B F4B4 145F D74B :TAG SLOW NOV MIN WOOL KENO :Hup anet Ks kye Dur CTF :
111md5 :This is a test. :TeSt :0 :9E87 6134 D904 99DD :INCH SEA ANNE LONG AHEM TOUR :moid cuvy cise agal Bwr lax :
112md5 :This is a test. :TeSt :1 :7965 E054 36F5 029F :EASE OIL FUM CURE AWRY AVIS :bhat aces Ador pf Doat mi :
113md5 :This is a test. :TeSt :99 :50FE 1962 C496 5880 :BAIL TUFT BITS GANG CHEF THY :che Cob Mba Ods Cai bogs :
114md5 :AbCdEfGhIjK :alpha1 :0 :8706 6DD9 644B F206 :FULL PEW DOWN ONCE MORT ARC :esca Fod peh crt Eyl Bael :
115md5 :AbCdEfGhIjK :alpha1 :1 :7CD3 4C10 40AD D14B :FACT HOOF AT FIST SITE KENT :Ghi Pcp Ta didy tod ile :
116md5 :AbCdEfGhIjK :alpha1 :99 :5AA3 7A81 F212 146C :BODE HOP JAKE STOW JUT RAP :Fri Arcs bels tss Csi Cors :
117md5 :OTP's are good :correct :0 :F205 7539 43DE 4CF9 :ULAN NEW ARMY FUSE SUIT EYED :gaw kos apr tx Bs fels :
118md5 :OTP's are good :correct :1 :DDCD AC95 6F23 4937 :SKIM CULT LOB SLAM POE HOWL :ber frat ute Fcs bsf dyn :
119md5 :OTP's are good :correct :99 :B203 E28F A525 BE47 :LONG IVY JULY AJAR BOND LEE :agal Cmd frg Lewd in Duny :
120sha1 :This is a test. :TeSt :0 :BB9E 6AE1 979D 8FF4 :MILT VARY MAST OK SEES WENT :Gid hup Ai ex Ide aft :
121sha1 :This is a test. :TeSt :1 :63D9 3663 9734 385B :CART OTTO HIVE ODE VAT NUT :chi dft Rv avie arg Lld :
122sha1 :This is a test. :TeSt :99 :87FE C776 8B73 CCF9 :GAFF WAIT SKID GIG SKY EYED :allo Mc oof Dogs Gre fack :
123sha1 :AbCdEfGhIjK :alpha1 :0 :AD85 F658 EBE3 83C9 :LEST OR HEEL SCOT ROB SUIT :csi crs Adit ecg Cdr Yi :
124sha1 :AbCdEfGhIjK :alpha1 :1 :D07C E229 B5CF 119B :RITE TAKE GELD COST TUNE RECK :bs ph Saz fsb bute Meu :
125sha1 :AbCdEfGhIjK :alpha1 :99 :27BC 7103 5AAF 3DC6 :MAY STAR TIN LYON VEDA STAN :Arx Ios Fax n daw Kan :
126sha1 :OTP's are good :correct :0 :D51F 3E99 BF8E 6F0B :RUST WELT KICK FELL TAIL FRAU :gur Ami cebu nv Goe Iof :
127sha1 :OTP's are good :correct :1 :82AE B52D 9437 74E4 :FLIT DOSE ALSO MEW DRUM DEFY :Gis ctf pfg Kex fro Cuda :
128sha1 :OTP's are good :correct :99 :4F29 6A74 FE15 67EC :AURA ALOE HURL WING BERG WAIT :Moul oos Ci anni Awin Mc :
129# end of payload