1#! /bin/csh -f
2#
3# run CSP/X regression tests.
4#
5set BUILD_DIR=$LOCAL_BUILD_DIR
6#
7set QUICK_TEST = 1
8set QUIET= 
9set VERB= 
10# 
11# CSPDL null for bare CSP, 'D' for CSPDL combo
12#
13set CSPDL=
14set RAWCSP=YES
15#
16# note the 's' option is here for backwards compatibility; the short
17# option is now the default.
18#
19while ( $#argv > 0 )
20    switch ( "$argv[1]" )
21        case s:
22            set QUICK_TEST = 1
23            shift
24            breaksw
25        case l:
26            set QUICK_TEST = 0
27            shift
28            breaksw
29        case v:
30            set VERB = v
31            shift
32            breaksw
33        case q:
34            set QUIET = q
35            shift
36            breaksw
37        case D:
38            set CSPDL = D
39			set RAWCSP = NO
40            shift
41            breaksw
42        default:
43            cat cspdvt_usage
44            exit(1)
45    endsw
46end
47#
48# Select 'quick' or 'normal' test params
49#
50if($QUICK_TEST == 1) then
51    set SIGTEST_ARGS=
52    set BADSIG_ARGS="l=4 i=10"
53	set MACTEST_ARGS=
54	set BADMAC_ARGS=
55	set DSAPARTIAL_ARGS=
56	set HASHTEST_ARGS="l=100"
57	set HASHCLONE_ARGS=
58	set SYMTEST_ARGS=
59	set ASYMTEST_ARGS="u"
60	set MINIWRAP_ARGS="l=4"
61	set WRAPTEST_ARGS="l=2 k"
62	set PBETEST_ARGS="l=4"
63	set KEYHASH_ARGS=
64	set KEYHASH_ASYM_ARGS=
65	set KEYSTORE_ARGS=
66	set SYMDELTA_ARGS=
67	set SYMCOMPAT_ARGS=
68	set HASHCOMPAT_ARGS=
69	set ASYMCOMPAT_ARGS="l=2 k=512"
70	set MACCOMPAT_ARGS=
71	set BADATTR_ARGS=
72	set RAWSIG_ARGS="l=2 i=2 s"
73	set DHTEST_ARGS="i=dhParams_512.der"
74	set ECDHTEST_ARGS=
75else
76    set SIGTEST_ARGS=
77    set BADSIG_ARGS="l=20 k=r"
78	set DSAPARTIAL_ARGS="l=100"
79	set MACTEST_ARGS=
80	set BADMAC_ARGS="l=100"
81	set HASHTEST_ARGS="l=1000"
82	set HASHCLONE_ARGS="l=200"
83	set SYMTEST_ARGS="l=500"
84	set ASYMTEST_ARGS=
85	set MINIWRAP_ARGS=
86	set WRAPTEST_ARGS=
87	set PBETEST_ARGS=
88	set KEYHASH_ARGS=
89	set KEYHASH_ASYM_ARGS=
90	set KEYSTORE_ARGS=
91	set SYMDELTA_ARGS="l=50"
92	set SYMCOMPAT_ARGS=
93	set HASHCOMPAT_ARGS="l=1000"
94	set ASYMCOMPAT_ARGS="l=10"
95	set MACCOMPAT_ARGS="l=1000"
96	set BADATTR_ARGS=
97	set RAWSIG_ARGS=
98	set DHTEST_ARGS="k=1024"
99	set ECDHTEST_ARGS="l=100"
100endif
101#
102# First, test the basic Digest, MAC, and symmetrict algorithms in libSystem. 
103#
104set CSPXUTILS=`pwd`
105if($RAWCSP == YES) then
106	./ccdvt $QUIET || exit(1)
107endif
108#
109# Basic digest and MAC tests
110#
111$BUILD_DIR/hashTest $HASHTEST_ARGS $QUIET $VERB $CSPDL || exit(1)
112if($RAWCSP == YES) then
113	$BUILD_DIR/hashClone $HASHCLONE_ARGS $QUIET $VERB $CSPDL || exit(1)
114endif
115#TODO $BUILD_DIR/hashCompat $HASHCOMPAT_ARGS $QUIET $VERB $CSPDL || exit(1)
116$BUILD_DIR/sha2VectorsCdsa $QUIET $CSPDL || exit(1)
117#TODO $BUILD_DIR/macCompat $MACCOMPAT_ARGS $QUIET $VERB $CSPDL || exit(1)
118$BUILD_DIR/macTest $MACTEST_ARGS $QUIET $VERB $CSPDL || exit(1)
119$BUILD_DIR/badmac $BADMAC_ARGS $QUIET $VERB $CSPDL || exit(1)
120#
121# Basic symmetric encryption tests
122#
123# symTest - once with padding, once without
124$BUILD_DIR/symTest $SYMTEST_ARGS $QUIET $VERB $CSPDL || exit(1)
125$BUILD_DIR/symTest $SYMTEST_ARGS $QUIET $VERB $CSPDL o || exit(1)
126#
127# symCompat - once with the full set of algorithms
128#
129#TODO $BUILD_DIR/symCompat $SYMCOMPAT_ARGS $QUIET $VERB $CSPDL || exit(1)
130# 
131# And one specifically to test AES padding mode (which uses ssleay instead of 
132# the NIST reference implementation)
133#
134$BUILD_DIR/symCompat $SYMCOMPAT_ARGS a=a y $QUIET $VERB $CSPDL || exit(1)
135$BUILD_DIR/contextReuse $QUIET $VERB $CSPDL || exit(1)
136#
137# Signature tests
138#
139# One for RSA
140$BUILD_DIR/sigtest $SIGTEST_ARGS $QUIET $VERB $CSPDL || exit(1)
141# Several for for ECDSA, with some keys in blob form for raw CSP only
142$BUILD_DIR/sigtest a=E $SIGTEST_ARGS $QUIET $VERB $CSPDL || exit(1)
143if($RAWCSP == YES) then
144	$BUILD_DIR/sigtest a=7 b r $SIGTEST_ARGS $QUIET $VERB $CSPDL || exit(1)
145	$BUILD_DIR/sigtest a=8 k=256 b $SIGTEST_ARGS $QUIET $VERB $CSPDL || exit(1)
146	$BUILD_DIR/sigtest a=9 k=521 b r $SIGTEST_ARGS $QUIET $VERB $CSPDL || exit(1)
147else
148	$BUILD_DIR/sigtest a=7 $SIGTEST_ARGS $QUIET $VERB $CSPDL || exit(1)
149	$BUILD_DIR/sigtest a=8 k=256 $SIGTEST_ARGS $QUIET $VERB $CSPDL || exit(1)
150	$BUILD_DIR/sigtest a=9 k=521 $SIGTEST_ARGS $QUIET $VERB $CSPDL || exit(1)
151endif
152# this one tests all algorithms with random key sizes
153$BUILD_DIR/badsig $BADSIG_ARGS $QUIET $VERB $CSPDL || exit(1)
154#
155# Misc. CSP tests
156#
157$BUILD_DIR/keyDate $QUIET $VERB $CSPDL || exit(1)
158$BUILD_DIR/keyHash $KEYHASH_ARGS $QUIET $VERB $CSPDL || exit(1)
159cd $CSPXUTILS/keyHashAsym
160$BUILD_DIR/keyHashAsym $KEYHASH_ASYM_ARGS $QUIET $VERB $CSPDL || exit(1)
161if($RAWCSP == NO) then
162	$BUILD_DIR/keyStore $KEYSTORE_ARGS $QUIET $VERB || exit(1)
163endif
164if($RAWCSP == YES) then
165	$BUILD_DIR/dhTest $DHTEST_ARGS $QUIET $VERB $CSPDL || exit(1)
166endif
167#
168# One run for ECDH, one for ECDH_X963_KDF
169#
170$BUILD_DIR/ecdhTest $ECDHTEST_ARGS $QUIET $VERB $CSPDL || exit(1)
171$BUILD_DIR/ecdhTest X $ECDHTEST_ARGS $QUIET $VERB $CSPDL || exit(1)
172# this requires param files in cwd
173cd $CSPXUTILS/dsaPartial
174$BUILD_DIR/dsaPartial $DSAPARTIAL_ARGS $QUIET $VERB $CSPDL || exit(1)
175$BUILD_DIR/symDelta $SYMDELTA_ARGS $QUIET $VERB $CSPDL || exit(1)
176$BUILD_DIR/asymTest $ASYMTEST_ARGS $QUIET $VERB $CSPDL || exit(1)
177$BUILD_DIR/miniWrap $MINIWRAP_ARGS $QUIET $VERB $CSPDL || exit(1)
178$BUILD_DIR/wrapTest $WRAPTEST_ARGS $QUIET $VERB $CSPDL || exit(1)
179$BUILD_DIR/pbeTest $PBETEST_ARGS $QUIET $VERB $CSPDL || exit(1)
180#TODO $BUILD_DIR/asymCompat $ASYMCOMPAT_ARGS $QUIET $VERB $CSPDL || exit(1)
181#TODO $BUILD_DIR/badattr $BADATTR_ARGS $QUIET $VERB $CSPDL || exit(1)
182$BUILD_DIR/rawSig $RAWSIG_ARGS $QUIET $VERB $CSPDL || exit(1)
183$BUILD_DIR/ssl2Padding $QUIET $VERB $CSPDL || exit(1)
184
185echo ===== cspdvt success =====
186