1# -*- tcl -*- 2# otp.test: tests the OTP implementation. Most of the tests are directly 3# copied from RFC 2289. 4# 5# This file contains a collection of tests for one or more of the Tcl 6# built-in commands. Sourcing this file into Tcl runs the tests and 7# generates output for errors. No output means no errors were found. 8# 9# Copyright (c) 2006 Patrick Thoyts 10# 11# RCS: @(#) $Id: otp.test,v 1.2 2006/10/09 21:41:41 andreas_kupries Exp $ 12 13# ------------------------------------------------------------------------- 14 15source [file join \ 16 [file dirname [file dirname [file join [pwd] [info script]]]] \ 17 devtools testutilities.tcl] 18 19testsNeedTcl 8.2 20testsNeedTcltest 1.0 21 22testing { 23 useLocal otp.tcl otp 24} 25 26# ------------------------------------------------------------------------- 27 28set tests_md5 { 29 0 "This is a test." "TeSt" 0 "9E876134D90499DD" "INCH SEA ANNE LONG AHEM TOUR" 30 1 "This is a test." "TeSt" 1 "7965E05436F5029F" "EASE OIL FUM CURE AWRY AVIS" 31 2 "This is a test." "TeSt" 99 "50FE1962C4965880" "BAIL TUFT BITS GANG CHEF THY" 32 3 "AbCdEfGhIjK" "alpha1" 0 "87066DD9644BF206" "FULL PEW DOWN ONCE MORT ARC" 33 4 "AbCdEfGhIjK" "alpha1" 1 "7CD34C1040ADD14B" "FACT HOOF AT FIST SITE KENT" 34 5 "AbCdEfGhIjK" "alpha1" 99 "5AA37A81F212146C" "BODE HOP JAKE STOW JUT RAP" 35 6 "OTP's are good" "correct" 0 "F205753943DE4CF9" "ULAN NEW ARMY FUSE SUIT EYED" 36 7 "OTP's are good" "correct" 1 "DDCDAC956F234937" "SKIM CULT LOB SLAM POE HOWL" 37 8 "OTP's are good" "correct" 99 "B203E28FA525BE47" "LONG IVY JULY AJAR BOND LEE" 38} 39 40foreach {ndx pass seed cnt hex wrds} $tests_md5 { 41 test otp-md5-hex-$ndx "otp-md5 check hex result" { 42 list [catch { 43 set res [::otp::otp-md5 -hex -seed $seed -count $cnt $pass] 44 string toupper $res 45 } msg] $msg 46 } [list 0 $hex] 47} 48 49foreach {ndx pass seed cnt hex wrds} $tests_md5 { 50 test otp-md5-words-$ndx "otp-md5 check words encoding" { 51 list [catch { 52 set res [::otp::otp-md5 -words -seed $seed -count $cnt $pass] 53 } msg] $msg 54 } [list 0 $wrds] 55} 56 57 58set tests_md4 { 59 0 "This is a test." "TeSt" 0 "D1854218EBBB0B51" "ROME MUG FRED SCAN LIVE LACE" 60 1 "This is a test." "TeSt" 1 "63473EF01CD0B444" "CARD SAD MINI RYE COL KIN" 61 2 "This is a test." "TeSt" 99 "C5E612776E6C237A" "NOTE OUT IBIS SINK NAVE MODE" 62 3 "AbCdEfGhIjK" "alpha1" 0 "50076F47EB1ADE4E" "AWAY SEN ROOK SALT LICE MAP" 63 4 "AbCdEfGhIjK" "alpha1" 1 "65D20D1949B5F7AB" "CHEW GRIM WU HANG BUCK SAID" 64 5 "AbCdEfGhIjK" "alpha1" 99 "D150C82CCE6F62D1" "ROIL FREE COG HUNK WAIT COCA" 65 6 "OTP's are good" "correct" 0 "849C79D4F6F55388" "FOOL STEM DONE TOOL BECK NILE" 66 7 "OTP's are good" "correct" 1 "8C0992FB250847B1" "GIST AMOS MOOT AIDS FOOD SEEM" 67 8 "OTP's are good" "correct" 99 "3F3BF4B4145FD74B" "TAG SLOW NOV MIN WOOL KENO" 68} 69 70foreach {ndx pass seed cnt hex wrds} $tests_md4 { 71 test otp-md4-hex-$ndx "otp-md4 check hex result" { 72 list [catch { 73 set res [::otp::otp-md4 -hex -seed $seed -count $cnt $pass] 74 string toupper $res 75 } msg] $msg 76 } [list 0 $hex] 77} 78 79foreach {ndx pass seed cnt hex wrds} $tests_md4 { 80 test otp-md4-words-$ndx "otp-md4 check words encoding" { 81 list [catch { 82 set res [::otp::otp-md4 -words -seed $seed -count $cnt $pass] 83 } msg] $msg 84 } [list 0 $wrds] 85} 86 87set tests_sha1 { 88 0 "This is a test." "TeSt" 0 "BB9E6AE1979D8FF4" "MILT VARY MAST OK SEES WENT" 89 1 "This is a test." "TeSt" 1 "63D936639734385B" "CART OTTO HIVE ODE VAT NUT" 90 2 "This is a test." "TeSt" 99 "87FEC7768B73CCF9" "GAFF WAIT SKID GIG SKY EYED" 91 3 "AbCdEfGhIjK" "alpha1" 0 "AD85F658EBE383C9" "LEST OR HEEL SCOT ROB SUIT" 92 4 "AbCdEfGhIjK" "alpha1" 1 "D07CE229B5CF119B" "RITE TAKE GELD COST TUNE RECK" 93 5 "AbCdEfGhIjK" "alpha1" 99 "27BC71035AAF3DC6" "MAY STAR TIN LYON VEDA STAN" 94 6 "OTP's are good" "correct" 0 "D51F3E99BF8E6F0B" "RUST WELT KICK FELL TAIL FRAU" 95 7 "OTP's are good" "correct" 1 "82AEB52D943774E4" "FLIT DOSE ALSO MEW DRUM DEFY" 96 8 "OTP's are good" "correct" 99 "4F296A74FE1567EC" "AURA ALOE HURL WING BERG WAIT" 97} 98 99foreach {ndx pass seed cnt hex wrds} $tests_sha1 { 100 test otp-sha1-hex-$ndx "otp-sha1 check hex result" { 101 list [catch { 102 set res [::otp::otp-sha1 -hex -seed $seed -count $cnt $pass] 103 string toupper $res 104 } msg] $msg 105 } [list 0 $hex] 106} 107 108foreach {ndx pass seed cnt hex wrds} $tests_sha1 { 109 test otp-sha1-words-$ndx "otp-sha1 check words encoding" { 110 list [catch { 111 set res [::otp::otp-sha1 -words -seed $seed -count $cnt $pass] 112 } msg] $msg 113 } [list 0 $wrds] 114} 115 116set tests_rmd160 { 117 0 "This is a test." "TeSt" 0 "3A1BFB10A64B4CCD" "SAG SLUG NICE AMOS LUSH CHUM" 118 1 "This is a test." "TeSt" 1 "39D56BF655E65DE7" "SAC LAVA WORD LEAD CHEW VAST" 119 2 "This is a test." "TeSt" 99 "42F84BA862941033" "UN NAVY THEE NOLL TO HEN" 120 3 "AbCdEfGhIjK" "alpha1" 0 "726EDD1BB5DB3642" "DENY DREW YEA COVE LOWE JUG" 121 4 "AbCdEfGhIjK" "alpha1" 1 "46A231C501A1D2CE" "YAW ELY DEBT ARK IDA CLAW" 122 5 "AbCdEfGhIjK" "alpha1" 99 "848664EF3A300CC9" "FOOL PER SHE DOCK ADD CENT" 123 6 "OTP's are good" "correct" 0 "F90D03CC969208C8" "WEAN CLUB VALE NOW JOB CASH" 124 7 "OTP's are good" "correct" 1 "B6F5D25A08A90009" "MANA LIEU HELL ELK GREW AVE" 125 8 "OTP's are good" "correct" 99 "C890C1F05018BA5F" "ONCE FRAY EROS JADE GINA ONE" 126} 127 128foreach {ndx pass seed cnt hex wrds} $tests_rmd160 { 129 test otp-rmd160-hex-$ndx "otp-rmd160 check hex result" { 130 list [catch { 131 set res [::otp::otp-rmd160 -hex -seed $seed -count $cnt $pass] 132 string toupper $res 133 } msg] $msg 134 } [list 0 $hex] 135} 136 137foreach {ndx pass seed cnt hex wrds} $tests_rmd160 { 138 test otp-rmd160-words-$ndx "otp-rmd160 check words result" { 139 list [catch { 140 set res [::otp::otp-rmd160 -words -seed $seed -count $cnt $pass] 141 } msg] $msg 142 } [list 0 $wrds] 143} 144# ------------------------------------------------------------------------- 145 146testsuiteCleanup 147