]> git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/importExport/importExportPkcs7
Security-57031.30.12.tar.gz
[apple/security.git] / SecurityTests / clxutils / importExport / importExportPkcs7
1 #! /bin/csh -f
2 #
3 # Run import/export tests for PKCS7.
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
10 source setupCommon
11
12 # PKCS7 blob
13 set PKCS7_FILE=${BUILD_DIR}/certs.p7r
14 set PKCS7_FILE_PEM=${PKCS7_FILE}.pem
15
16 # user specified variables
17 set QUIET=NO
18 set KEYSIZE=512
19 set NOACL=NO
20 set NOACL_ARG=
21 set NOCLEAN=NO
22
23 #
24 # Verify existence of a few crucial things before we start.
25 #
26 if( ( ! -e $KCIMPORT ) || \
27 ( ! -e $KCEXPORT ) || \
28 ( ! -e $RSATOOL) ) then
29 echo === You do not seem to have all of the required executables.
30 echo === Please build all of cspxutils and clxutils.
31 echo === See the README files in those directories for info.
32 exit(1)
33 endif
34
35 # user options
36
37 while ( $#argv > 0 )
38 switch ( "$argv[1]" )
39 case q:
40 set QUIET=YES
41 shift
42 breaksw
43 case n:
44 set NOACL=YES
45 set NOACL_ARG=-n
46 shift
47 breaksw
48 case N:
49 set NOCLEAN=YES
50 shift
51 breaksw
52 default:
53 echo Usage: importExportPkcs7 \[q\(uiet\)\] \[n\(oACL\)\] \[N\(oClean\)\]
54 exit(1)
55 endsw
56 end
57
58 echo === Begin PKCS7 test ====
59 if ($QUIET == NO) then
60 echo $CLEANKC
61 endif
62 $CLEANKC || exit(1)
63 if ($QUIET == NO) then
64 echo Creating PKCS7 DER blob with openssl...
65 endif
66 set cmd="$OPENSSL crl2pkcs7 -outform DER -nocrl -certfile cdnow_v300.pem -certfile amazon_v3.100.pem -certfile localcert.pem -out $PKCS7_FILE"
67 if ($QUIET == NO) then
68 echo $cmd
69 endif
70 $cmd || exit(1)
71 if ($QUIET == NO) then
72 echo Importing result...
73 endif
74 set cmd="$KCIMPORT $PKCS7_FILE -k $KEYCHAIN -C 3 -K 0 -I 0 -T agg -F pkcs7 -q $NOACL_ARG"
75 if ($QUIET == NO) then
76 echo $cmd
77 endif
78 $cmd || exit(1)
79
80 if ($QUIET == NO) then
81 echo Creating PKCS7 PEM blob with openssl...
82 endif
83 set cmd="$OPENSSL crl2pkcs7 -outform PEM -nocrl -certfile cdnow_v300.pem -certfile amazon_v3.100.pem -certfile localcert.pem -out $PKCS7_FILE_PEM"
84 if ($QUIET == NO) then
85 echo $cmd
86 endif
87 $cmd || exit(1)
88 if ($QUIET == NO) then
89 echo Importing result...
90 echo $CLEANKC
91 endif
92 $CLEANKC || exit(1)
93 set cmd="$KCIMPORT $PKCS7_FILE_PEM -f pkcs7 -k $KEYCHAIN -C 3 -K 0 -I 0 -T agg -F pkcs7 -q $NOACL_ARG"
94 if ($QUIET == NO) then
95 echo $cmd
96 endif
97 $cmd || exit(1)
98
99 if ($QUIET == NO) then
100 echo Exporting PKCS7 PEM blob...
101 endif
102 set cmd="$RM $PKCS7_FILE_PEM $PKCS7_FILE"
103 if ($QUIET == NO) then
104 echo $cmd
105 endif
106 $cmd || exit(1)
107 set cmd="$KCEXPORT $KEYCHAIN -t all -f pkcs7 -o $PKCS7_FILE -q"
108 if ($QUIET == NO) then
109 echo $cmd
110 endif
111 $cmd || exit(1)
112 if ($QUIET == NO) then
113 echo Importing result...
114 echo $CLEANKC
115 endif
116 $CLEANKC || exit(1)
117 set cmd="$KCIMPORT $PKCS7_FILE -k $KEYCHAIN -C 3 -K 0 -I 0 -T agg -F pkcs7 -q $NOACL_ARG"
118 if ($QUIET == NO) then
119 echo $cmd
120 endif
121 $cmd || exit(1)
122
123 # cleanup
124 if($NOCLEAN == NO) then
125 set cmd="rm -f $PKCS7_FILE $PKCS7_FILE_PEM"
126 if ($QUIET == NO) then
127 echo $cmd
128 endif
129 $cmd || exit(1)
130 endif
131
132 if ($QUIET == NO) then
133 echo === PKCS7 test complete ===
134 endif
135