]>
git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/importExport/exportPkcs8Tool
3 # Run one iteration of PKCS8 export test.
4 # Only used as a subroutine call from importExportPkcs8.
7 # exportPkcs8Tool rawKey p8keyGen p8KeyParse keychain p8Format(PEM|DER) alg(rsa|dsa) keysize quiet(YES|NO) noACL(YES|NO) securePhrase(YES|NO)
9 if ( $#argv != 10 ) then
13 set PKCS8_KEY_EXP
=$argv[2]
14 set PKCS8_KEY_PARSE_OS
=$argv[3]
21 if ($QUIET == YES
) then
25 if ($argv[9] == YES
) then
28 set SECURE_PHRASE_ARG
=
29 if ($argv[10] == YES
) then
30 set SECURE_PHRASE_ARG
=-Z
34 if ($FORMAT == PEM
) then
38 set BUILD_DIR
=$LOCAL_BUILD_DIR
42 set P8_PASSWORD
=foobar
43 set OS_PWD_ARG
="-passout pass:$P8_PASSWORD"
45 if ($QUIET == NO
) then
52 set cmd
="$KCIMPORT $RAWKEY -k $KEYCHAIN -f openssl -F openssl -T priv -K 1 $QUIET_ARG $NOACL_ARG $SECURE_PHRASE_ARG"
53 if ($QUIET == NO
) then
57 set cmd
="$DBVERIFY $KEYCHAIN_PATH $KEY_ALG priv $KEY_SIZE $QUIET_ARG"
58 if ($QUIET == NO
) then
63 # Export it in P8 form
65 set cmd
="$RM -f $PKCS8_KEY_EXP"
66 if ($QUIET == NO
) then
70 set cmd
="$KCEXPORT $KEYCHAIN -t privKeys -f pkcs8 -z $P8_PASSWORD -o $PKCS8_KEY_EXP $PEM_ARG -q $SECURE_PHRASE_ARG"
71 if ($QUIET == NO
) then
76 # Ensure that openssl can read it
78 set cmd
="$RM -f $PKCS8_KEY_PARSE_OS"
79 if ($QUIET == NO
) then
83 set cmd
="$OPENSSL pkcs8 -inform $FORMAT -outform DER -in $PKCS8_KEY_EXP -passin pass:$P8_PASSWORD -out $PKCS8_KEY_PARSE_OS"
84 if ($QUIET == NO
) then
89 # Then ensure we can read the parsed result
91 if ($QUIET == NO
) then
95 set cmd
="$KCIMPORT $PKCS8_KEY_PARSE_OS -k $KEYCHAIN -f openssl -F openssl -T priv -K 1 $QUIET_ARG $NOACL_ARG $SECURE_PHRASE_ARG"
96 if ($QUIET == NO
) then
100 set cmd
="$DBVERIFY $KEYCHAIN_PATH $KEY_ALG priv $KEY_SIZE $QUIET_ARG"
101 if ($QUIET == NO
) then