]> git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/importExport/importExport
Security-57337.20.44.tar.gz
[apple/security.git] / SecurityTests / clxutils / importExport / importExport
1 #! /bin/csh -f
2 #
3 # Run import/export tests.
4 #
5 # Run this from SecurityTests/clxutils/importExport. The
6 # kcImport and kcExport programs must exist in the location
7 # specified by the LOCAL_BUILD_DIR env var.
8 #
9 if ( ! -e setupCommon ) then
10 echo === You do not seem to be in the clxutils/importExport directory.
11 echo === Try running this script from there.
12 exit(1)
13 endif
14
15
16 source setupCommon
17
18 # for debug only
19 # echo importExport test running as `whoami`
20 # echo importExport test using HOME $HOME
21 # echo importExport test using keychain $KEYCHAIN at path $KEYCHAIN_PATH
22
23 # user specified variables
24 set QUIET=NO
25 set QUIET_ARG=
26 set NOACL_ARG=
27 set INIT_ONLY=NO
28 set NOCLEAN=NO
29 set NOCLEAN_ARG=
30
31 #
32 # Verify existence of a few crucial things before we start.
33 #
34 if( ( ! -e $KCIMPORT ) || \
35 ( ! -e $KCEXPORT ) || \
36 ( ! -e $RSATOOL) ) then
37 echo === You do not seem to have all of the required executables.
38 echo === Please build all of cspxutils and clxutils.
39 echo === See the README files in those directories for info.
40 exit(1)
41 endif
42
43 # user options
44
45 while ( $#argv > 0 )
46 switch ( "$argv[1]" )
47 case q:
48 set QUIET=YES
49 set QUIET_ARG=q
50 shift
51 breaksw
52 case n:
53 set NOACL=YES
54 set NOACL_ARG=n
55 shift
56 breaksw
57 case i:
58 set INIT_ONLY=YES
59 shift
60 breaksw
61 case N:
62 set NOCLEAN_ARG=N
63 set NOCLEAN=YES
64 shift
65 breaksw
66 default:
67 echo Usage: importExport \[q\(uiet\)\] \[n\(oACL\)\] \[i\(nitOnly\)\] \[N\(oClean\)\]
68 exit(1)
69 endsw
70 end
71
72 if ($QUIET == NO) then
73 echo === Creating empty $KEYCHAIN... ===
74 endif
75 set cmd="$RM -f $KEYCHAIN_PATH"
76 if ($QUIET == NO) then
77 echo $cmd
78 endif
79 $cmd || exit(1)
80
81 #
82 # We have to use full path here because certtool doesn't follow the rules
83 # w.r.t. root's keychain directory
84 #
85 set cmd="$CERTTOOL y k=$KEYCHAIN_PATH c p=$KEYCHAIN_PWD"
86 if($QUIET == NO) then
87 echo $cmd
88 endif
89 $cmd > /dev/null || exit(1)
90
91 if($INIT_ONLY == YES) then
92 echo ...init complete. Ready for standalone tests.
93 exit(0)
94 endif
95
96 ./importExportRawKey $QUIET_ARG $NOACL_ARG $NOCLEAN_ARG || exit(1)
97 ./importExportECDSA_P12 $QUIET_ARG $NOCLEAN_ARG || exit(1)
98 ./impExpOpensslEcdsa $QUIET_ARG $NOCLEAN_ARG || exit(1)
99 ./importExportPkcs7 $QUIET_ARG $NOACL_ARG $NOCLEAN_ARG || exit(1)
100 ./importExportPkcs8 $QUIET_ARG $NOACL_ARG $NOCLEAN_ARG || exit(1)
101 ./importExportPkcs12 $QUIET_ARG $NOACL_ARG $NOCLEAN_ARG || exit(1)
102 ./importExportOpensslWrap $QUIET_ARG $NOACL_ARG $NOCLEAN_ARG || exit(1)
103 ./importExportAgg $QUIET_ARG $NOACL_ARG $NOCLEAN_ARG || exit(1)
104 ./importExportOpenssh $QUIET_ARG $NOACL_ARG $NOCLEAN_ARG || exit(1)
105
106 # cleanup
107 if ($NOCLEAN == NO) then
108 set cmd="$SECURITY delete-keychain $KEYCHAIN_PATH"
109 if ($QUIET == NO) then
110 echo $cmd
111 endif
112 $cmd || exit(1)
113 endif
114
115 if ($QUIET == NO) then
116 echo "##### Import/Export Test complete #####"
117 endif