]> git.saurik.com Git - apple/security.git/blame - SecurityTests/clxutils/importExport/importExportPkcs7
Security-57740.31.2.tar.gz
[apple/security.git] / SecurityTests / clxutils / importExport / importExportPkcs7
CommitLineData
d8f41ccd
A
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
10source setupCommon
11
12# PKCS7 blob
13set PKCS7_FILE=${BUILD_DIR}/certs.p7r
14set PKCS7_FILE_PEM=${PKCS7_FILE}.pem
15
16# user specified variables
17set QUIET=NO
18set KEYSIZE=512
19set NOACL=NO
20set NOACL_ARG=
21set NOCLEAN=NO
22
23#
24# Verify existence of a few crucial things before we start.
25#
26if( ( ! -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)
33endif
34
35# user options
36
37while ( $#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
56end
57
58echo === Begin PKCS7 test ====
59if ($QUIET == NO) then
60 echo $CLEANKC
61endif
62$CLEANKC || exit(1)
63if ($QUIET == NO) then
64 echo Creating PKCS7 DER blob with openssl...
65endif
66set cmd="$OPENSSL crl2pkcs7 -outform DER -nocrl -certfile cdnow_v300.pem -certfile amazon_v3.100.pem -certfile localcert.pem -out $PKCS7_FILE"
67if ($QUIET == NO) then
68 echo $cmd
69endif
70$cmd || exit(1)
71if ($QUIET == NO) then
72 echo Importing result...
73endif
74set cmd="$KCIMPORT $PKCS7_FILE -k $KEYCHAIN -C 3 -K 0 -I 0 -T agg -F pkcs7 -q $NOACL_ARG"
75if ($QUIET == NO) then
76 echo $cmd
77endif
78$cmd || exit(1)
79
80if ($QUIET == NO) then
81 echo Creating PKCS7 PEM blob with openssl...
82endif
83set cmd="$OPENSSL crl2pkcs7 -outform PEM -nocrl -certfile cdnow_v300.pem -certfile amazon_v3.100.pem -certfile localcert.pem -out $PKCS7_FILE_PEM"
84if ($QUIET == NO) then
85 echo $cmd
86endif
87$cmd || exit(1)
88if ($QUIET == NO) then
89 echo Importing result...
90 echo $CLEANKC
91endif
92$CLEANKC || exit(1)
93set cmd="$KCIMPORT $PKCS7_FILE_PEM -f pkcs7 -k $KEYCHAIN -C 3 -K 0 -I 0 -T agg -F pkcs7 -q $NOACL_ARG"
94if ($QUIET == NO) then
95 echo $cmd
96endif
97$cmd || exit(1)
98
99if ($QUIET == NO) then
100 echo Exporting PKCS7 PEM blob...
101endif
102set cmd="$RM $PKCS7_FILE_PEM $PKCS7_FILE"
103if ($QUIET == NO) then
104 echo $cmd
105endif
106$cmd || exit(1)
107set cmd="$KCEXPORT $KEYCHAIN -t all -f pkcs7 -o $PKCS7_FILE -q"
108if ($QUIET == NO) then
109 echo $cmd
110endif
111$cmd || exit(1)
112if ($QUIET == NO) then
113 echo Importing result...
114 echo $CLEANKC
115endif
116$CLEANKC || exit(1)
117set cmd="$KCIMPORT $PKCS7_FILE -k $KEYCHAIN -C 3 -K 0 -I 0 -T agg -F pkcs7 -q $NOACL_ARG"
118if ($QUIET == NO) then
119 echo $cmd
120endif
121$cmd || exit(1)
122
123# cleanup
124if($NOCLEAN == NO) then
125set cmd="rm -f $PKCS7_FILE $PKCS7_FILE_PEM"
126 if ($QUIET == NO) then
127 echo $cmd
128 endif
129 $cmd || exit(1)
130endif
131
132if ($QUIET == NO) then
133 echo === PKCS7 test complete ===
134endif
135