]>
git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/importExport/exportOpensslTool
3 # Run one iteration of openssl wrap export test.
4 # Only used as a subroutine call from importExportOpensslWrap
7 # exportOpensslTool rawKey oskeyGen osKeyParse alg(rsa|dsa) keysize quiet(YES|NO) noACL(YES|NO) securePhrase(YES|NO)
9 if ( $#argv != 8 ) then
10 echo usage error
for exportOpensslTool
14 set OS_KEY_EXP
=$argv[2]
15 set OS_KEY_PARSE_OS
=$argv[3]
20 if ($QUIET == YES
) then
24 if ($argv[7] == YES
) then
27 set SECURE_PHRASE_ARG
=
28 if ($argv[8] == YES
) then
29 set SECURE_PHRASE_ARG
=-Z
35 set OS_PWD_ARG
="-passout pass:$PASSWORD"
37 if ($QUIET == NO
) then
44 set cmd
="$KCIMPORT $RAWKEY -k $KEYCHAIN -f openssl -F openssl -T priv -K 1 $QUIET_ARG $NOACL_ARG $SECURE_PHRASE_ARG"
45 if ($QUIET == NO
) then
49 set cmd
="$DBVERIFY $KEYCHAIN_PATH $KEY_ALG priv $KEY_SIZE $QUIET_ARG"
50 if ($QUIET == NO
) then
55 # Export it in openssl wrap form
57 set cmd
="$RM -f $OS_KEY_EXP"
58 if ($QUIET == NO
) then
62 set cmd
="$KCEXPORT $KEYCHAIN -t privKeys -f openssl -w -z $PASSWORD -o $OS_KEY_EXP -q $SECURE_PHRASE_ARG"
63 if ($QUIET == NO
) then
68 # Ensure that openssl can read it, then write it in unencrypted form
69 # Save openssl's stderr in a temp file and cat that to our stderr only on error.
71 set STDERR_TMP
=/tmp
/openssl_stderr
72 set cmd
="$RM -f $OS_KEY_PARSE_OS"
73 if ($QUIET == NO
) then
77 set cmd
="$OPENSSL $KEY_ALG -inform PEM -outform DER -in $OS_KEY_EXP -passin pass:$PASSWORD -out $OS_KEY_PARSE_OS"
78 if ($QUIET == NO
) then
83 cat $STDERR_TMP > /dev
/stderr
88 # Then ensure we can read the parsed result
90 if ($QUIET == NO
) then
94 set cmd
="$KCIMPORT $OS_KEY_PARSE_OS -k $KEYCHAIN -f openssl -F openssl -T priv -K 1 $QUIET_ARG $NOACL_ARG"
95 if ($QUIET == NO
) then
99 set cmd
="$DBVERIFY $KEYCHAIN_PATH $KEY_ALG priv $KEY_SIZE $QUIET_ARG"
100 if ($QUIET == NO
) then