3 # test libsecurity_cms.
11 # safely look for this required env var
13 setenv
| /usr
/bin
/grep LOCAL_BUILD_DIR
> /dev
/null
15 echo Please
set env var LOCAL_BUILD_DIR.
18 set BUILD_DIR
=$LOCAL_BUILD_DIR
21 # Default options: identities, keychain, etc.; overridable
24 set SIGNER
=dmitch@apple.com
25 set RECIP
=dmitch@apple.com
26 set SIGNER2
=dmitch@dmitch.com
27 set RECIP2
=dmitch@dmitch.com
28 # specifying an anchorFile implies manual SecTrustEval
35 set USE_REF_BLOBS
= YES
72 set SRCH_KC
="-k $argv[2]"
81 set ANCHOR_CERT
="-A $argv[2]"
92 set BUILD_DIR
=$LOCAL_BUILD_DIR
93 set CMSTOOL
=$BUILD_DIR/newCmsTool
95 # the files we act on - we only write to $BUILD_DIR. If we're using reference blobs,
96 # we copy them to the build directory and then run as usual.
99 set RPTEXT
=${BUILD_DIR}/rptext
101 set OTHER_CERT0
=GTE_SGC.cer
102 set OTHER_CERT1
=dmitchIChat.cer
103 set CERT_FILEBASE
=${BUILD_DIR}/outcert
105 set STD_SIGN_CMD
="$CMSTOOL sign $SRCH_KC -S $SIGNER $QUIET_ARG $MULTI_UPDATE"
106 set STD_ENCR_CMD
="$CMSTOOL envel $SRCH_KC -r $RECIP $QUIET_ARG $MULTI_UPDATE"
107 set STD_SIGN_ENCR_CMD
="$CMSTOOL signEnv $SRCH_KC -S $SIGNER -r $RECIP $QUIET_ARG $MULTI_UPDATE"
108 set STD_PARSE_CMD
="$CMSTOOL parse -o $RPTEXT $SRCH_KC $ANCHOR_CERT $MANUAL_EVAL $QUIET_ARG $MULTI_UPDATE"
109 set STD_CMP_CMD
="cmp $PTEXT $RPTEXT"
112 set O_SIGN
=${BUILD_DIR}/sign.p7
113 set O_ENV
=${BUILD_DIR}/env.p7
114 set O_SIGN_ENV
=${BUILD_DIR}/signEnv.p7
115 # eContentType = auth
116 set O_SIGN_AUTH
=${BUILD_DIR}/sign_auth.p7
117 set O_SIGN_ENV_AUTH
=${BUILD_DIR}/signEnv_auth.p7
119 set O_SIGN_DETACH
=${BUILD_DIR}/sign_det.p7
121 set O_SIGN_TWO
=${BUILD_DIR}/sign_two.p7
122 set O_SIGN_ENV_TWO_SIGN
=${BUILD_DIR}/signEnv_twoSign.p7
124 set O_ENV_TWO
=${BUILD_DIR}/env_two.p7
125 set O_SIGN_ENV_TWO_SIGN_TWO_RECIP
=${BUILD_DIR}/signEnv_twoSign_twoRecip.p7
126 # additional certs - one signed, sone signed/encryped, one certs only
127 set O_SIGN_ADD_CERTS
=${BUILD_DIR}/sign_certs.p7
128 set O_SIGN_ENV_ADD_CERTS
=${BUILD_DIR}/signEnv_certs.p7
129 set O_SIGN_ONLY_CERTS
=${BUILD_DIR}/certsOnly.p7
131 set O_SIGN_NONE
=${BUILD_DIR}/sign_nocerts.p7
132 set O_SIGN_SIGNER
=${BUILD_DIR}/sign_signer.p7
133 set O_SIGN_WITHROOT
=${BUILD_DIR}/sign_withroot.p7
135 if($USE_REF_BLOBS == YES
) then
136 if($QUIET == NO
) then
137 echo copying reference blobs to Build directory...
138 echo "cp *.p7 ${BUILD_DIR}/"
140 cp *.p7
${BUILD_DIR} || exit(1)
142 if($QUIET == NO
) then
143 echo generating blobs
in Build directory...
146 set cmd
="$STD_SIGN_CMD -i $PTEXT -o $O_SIGN"
147 if($QUIET == NO
) then
152 set cmd
="$STD_ENCR_CMD -i $PTEXT -o $O_ENV"
153 if($QUIET == NO
) then
158 set cmd
="$STD_SIGN_ENCR_CMD -i $PTEXT -o $O_SIGN_ENV"
159 if($QUIET == NO
) then
164 set cmd
="$STD_SIGN_CMD -i $PTEXT -o $O_SIGN_AUTH -e a"
165 if($QUIET == NO
) then
170 set cmd
="$STD_SIGN_ENCR_CMD -i $PTEXT -o $O_SIGN_ENV_AUTH -e a"
171 if($QUIET == NO
) then
176 set cmd
="$STD_SIGN_CMD -i $PTEXT -o $O_SIGN_DETACH -d"
177 if($QUIET == NO
) then
182 set cmd
="$STD_SIGN_CMD -i $PTEXT -o $O_SIGN_TWO -S $SIGNER2"
183 if($QUIET == NO
) then
188 set cmd
="$STD_SIGN_ENCR_CMD -i $PTEXT -o $O_SIGN_ENV_TWO_SIGN -S $SIGNER2"
189 if($QUIET == NO
) then
194 set cmd
="$STD_ENCR_CMD -i $PTEXT -o $O_ENV_TWO -r $RECIP2"
195 if($QUIET == NO
) then
200 set cmd
="$STD_SIGN_ENCR_CMD -i $PTEXT -o $O_SIGN_ENV_TWO_SIGN_TWO_RECIP -S $SIGNER2 -r $RECIP2"
201 if($QUIET == NO
) then
206 set cmd
="$STD_SIGN_CMD -i $PTEXT -o $O_SIGN_ADD_CERTS -C $OTHER_CERT0 -C $OTHER_CERT1"
207 if($QUIET == NO
) then
212 set cmd
="$STD_SIGN_ENCR_CMD -i $PTEXT -o $O_SIGN_ENV_ADD_CERTS -C $OTHER_CERT0 -C $OTHER_CERT1"
213 if($QUIET == NO
) then
218 set cmd
="$CMSTOOL certs -o $O_SIGN_ONLY_CERTS $QUIET_ARG -C $OTHER_CERT0 -C $OTHER_CERT1"
219 if($QUIET == NO
) then
224 set cmd
="$STD_SIGN_CMD -i $PTEXT -o $O_SIGN_NONE -t none"
225 if($QUIET == NO
) then
230 set cmd
="$STD_SIGN_CMD -i $PTEXT -o $O_SIGN_SIGNER -t signer"
231 if($QUIET == NO
) then
236 set cmd
="$STD_SIGN_CMD -i $PTEXT -o $O_SIGN_WITHROOT -t chainWithRoot"
237 if($QUIET == NO
) then
244 if($QUIET == NO
) then
245 echo verifying blobs
in Build directory...
248 # Note we expect there to be twp certs per signer...true for the current
252 set cmd
="$STD_PARSE_CMD -i $O_SIGN -v sign -E d -s 1 -N 2"
253 if($QUIET == NO
) then
257 set cmd
="$STD_CMP_CMD"
258 if($QUIET == NO
) then
262 if($QUIET == NO
) then
268 set cmd
="$STD_PARSE_CMD -i $O_ENV -v encr -N 0"
269 if($QUIET == NO
) then
273 set cmd
="$STD_CMP_CMD"
274 if($QUIET == NO
) then
278 if($QUIET == NO
) then
284 set cmd
="$STD_PARSE_CMD -i $O_SIGN_ENV -v signEnv -E d -s 1 -N 2"
285 if($QUIET == NO
) then
289 set cmd
="$STD_CMP_CMD"
290 if($QUIET == NO
) then
294 if($QUIET == NO
) then
299 # signed, eContentType auth
300 set cmd
="$STD_PARSE_CMD -i $O_SIGN_AUTH -v sign -E a -s 1 -N 2"
301 if($QUIET == NO
) then
305 set cmd
="$STD_CMP_CMD"
306 if($QUIET == NO
) then
310 if($QUIET == NO
) then
315 # signed & enveloped, eContentType auth
316 set cmd
="$STD_PARSE_CMD -i $O_SIGN_ENV_AUTH -v signEnv -E a -s 1 -N 2"
317 if($QUIET == NO
) then
321 set cmd
="$STD_CMP_CMD"
322 if($QUIET == NO
) then
326 if($QUIET == NO
) then
331 # signed, detached content - no output
332 set cmd
="$CMSTOOL parse -i $O_SIGN_DETACH -D $PTEXT $SRCH_KC $ANCHOR_CERT $MANUAL_EVAL -v sign -E d -s 1 $QUIET_ARG $MULTI_UPDATE -N 2"
333 if($QUIET == NO
) then
338 # signed, two signers
339 set cmd
="$STD_PARSE_CMD -i $O_SIGN_TWO -v sign -E d -s 2 -N 4"
340 if($QUIET == NO
) then
344 set cmd
="$STD_CMP_CMD"
345 if($QUIET == NO
) then
349 if($QUIET == NO
) then
354 # signed & enveloped, two signers
355 set cmd
="$STD_PARSE_CMD -i $O_SIGN_ENV_TWO_SIGN -v signEnv -E d -s 2 -N 4"
356 if($QUIET == NO
) then
360 set cmd
="$STD_CMP_CMD"
361 if($QUIET == NO
) then
365 if($QUIET == NO
) then
370 # enveloped, two recipients
371 set cmd
="$STD_PARSE_CMD -i $O_ENV_TWO -v encr -N 0"
372 if($QUIET == NO
) then
376 set cmd
="$STD_CMP_CMD"
377 if($QUIET == NO
) then
381 if($QUIET == NO
) then
386 # signed & enveloped, two signers, two recipients
387 set cmd
="$STD_PARSE_CMD -i $O_SIGN_ENV_TWO_SIGN_TWO_RECIP -v signEnv -E d -s 2 -N 4"
388 if($QUIET == NO
) then
392 set cmd
="$STD_CMP_CMD"
393 if($QUIET == NO
) then
398 # additional certs with signer
399 set cmd
="$STD_PARSE_CMD -i $O_SIGN_ADD_CERTS -v sign -E d -s 1 -N 4"
400 if($QUIET == NO
) then
404 set cmd
="$STD_CMP_CMD"
405 if($QUIET == NO
) then
409 if($QUIET == NO
) then
414 # additional certs with signer & recipient
415 set cmd
="$STD_PARSE_CMD -i $O_SIGN_ENV_ADD_CERTS -v signEnv -E d -s 1 -N 4"
416 if($QUIET == NO
) then
420 set cmd
="$STD_CMP_CMD"
421 if($QUIET == NO
) then
425 if($QUIET == NO
) then
430 # cert chain options - first, no certs
431 set cmd
="$STD_PARSE_CMD -i $O_SIGN_NONE -v sign -E d -s 1 -N 0"
432 if($QUIET == NO
) then
436 set cmd
="$STD_CMP_CMD"
437 if($QUIET == NO
) then
441 if($QUIET == NO
) then
446 # cert chain options - signer certs
447 set cmd
="$STD_PARSE_CMD -i $O_SIGN_SIGNER -v sign -E d -s 1 -N 1"
448 if($QUIET == NO
) then
452 set cmd
="$STD_CMP_CMD"
453 if($QUIET == NO
) then
457 if($QUIET == NO
) then
462 # cert chain options - chain with root
463 set cmd
="$STD_PARSE_CMD -i $O_SIGN_WITHROOT -v sign -E d -s 1 -N 3"
464 if($QUIET == NO
) then
468 set cmd
="$STD_CMP_CMD"
469 if($QUIET == NO
) then
473 if($QUIET == NO
) then
479 set cmd
="$CMSTOOL parse -i $O_SIGN_ONLY_CERTS $QUIET_ARG $MULTI_UPDATE -v sign -s 0 -N 2 -f $CERT_FILEBASE"
480 if($QUIET == NO
) then
484 # the order here is affected by the size of the certs: the certs are encoded in the
485 # p7 blob as a SET OF, which when DER-encoded (as opposed to BER encoded), is ordered,
486 # with the length octets happening to determine the order (if the certs are different
487 # sizes). We know that OTHER_CERT1 is smaller that OTHER_CERT0...
488 set cmd
="cmp $OTHER_CERT1 ${CERT_FILEBASE}_0.cer"
489 if($QUIET == NO
) then
493 set cmd
="cmp $OTHER_CERT0 ${CERT_FILEBASE}_1.cer"
494 if($QUIET == NO
) then
498 set cmd
="rm ${CERT_FILEBASE}_0.cer ${CERT_FILEBASE}_1.cer"
499 if($QUIET == NO
) then
504 if($QUIET == NO
) then
505 echo === cmstest Succeeded
===