]>
git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/importExport/impExpOpensslEcdsaTool
3 # Run one iteration of PKCS8 portion of import/export tests.
4 # Only used as a subroutine call from importExportPkcs8.
7 # impExpOpensslEcdsaTool keySizeBits quiet(YES|NO) noACL(YES|NO) securePhrase(YES|NO) noClean(YES|NO)
9 if ( $#argv != 5 ) then
17 if ($QUIET == YES
) then
22 if ($argv[3] == YES
) then
25 set SECURE_PHRASE_ARG
=
26 if ($argv[4] == YES
) then
27 set SECURE_PHRASE_ARG
=-Z
34 set OS_CURVE
= prime256v1
37 set OS_CURVE
= secp384r1
40 set OS_CURVE
= secp521r1
43 echo "***Unknown key size"
50 set OS_PWD_ARG
="-passout pass:$PASSWORD"
52 set PLAINTEXT
=somePlainText
53 set SIGFILE
=${BUILD_DIR}/ecdsaSig
54 set KEYBASE
=${BUILD_DIR}/opensslGen
55 # formats of these - with _priv.der, _pub.der suffixes - dictated by rsatool
56 set KEYFILE_PRIV
=${KEYBASE}_priv.der
57 set KEYFILE_PUB
=${KEYBASE}_pub.der
58 set EXPORT_KEYBASE
=${BUILD_DIR}/ecdsaExpFromP8
59 set EXPORT_KEYFILE
=${EXPORT_KEYBASE}_priv.der
60 set P8FILE
=${BUILD_DIR}/ecdsaPriv.p8
63 if ($QUIET == NO
) then
68 # generate the single key
69 set cmd
="$OPENSSL ecparam -genkey -outform DER -out $KEYFILE_PRIV -name $OS_CURVE -noout"
70 if ($QUIET == NO
) then
76 set cmd
="$RSATOOL s a=e k=$KEYBASE v=o p=$PLAINTEXT s=$SIGFILE $QUIET_ARG"
77 if ($QUIET == NO
) then
82 # Public key in openssl form is the unified key produced by openssl
83 set cmd
="cp $KEYFILE_PRIV $KEYFILE_PUB"
84 if ($QUIET == NO
) then
90 set cmd
="$RSATOOL v a=e k=$KEYBASE b=L p=$PLAINTEXT s=$SIGFILE $QUIET_ARG"
91 if ($QUIET == NO
) then
96 # Use openssl to create a p8 with the private key
97 set cmd
="$OPENSSL pkcs8 -topk8 -inform DER -outform DER -in $KEYFILE_PRIV -out $P8FILE $OS_PWD_ARG"
98 if ($QUIET == NO
) then
103 # Import that p8, no ACL, extractable in the clear
104 set cmd
="$KCIMPORT $P8FILE -k $KEYCHAIN -f pkcs8 -w -n -e -z $PASSWORD $QUIET_ARG_N"
105 if ($QUIET == NO
) then
110 # export in openssl format
111 set cmd
="$KCEXPORT $KEYCHAIN -f openssl -o $EXPORT_KEYFILE -t privKeys $QUIET_ARG_N"
112 if ($QUIET == NO
) then
117 # Sign and verify again
118 set cmd
="$RSATOOL s a=e k=$EXPORT_KEYBASE v=o p=$PLAINTEXT s=$SIGFILE $QUIET_ARG"
119 if ($QUIET == NO
) then
124 set cmd
="$RSATOOL v a=e k=$KEYBASE b=L p=$PLAINTEXT s=$SIGFILE $QUIET_ARG"
125 if ($QUIET == NO
) then
130 if($NOCLEAN == NO
) then
131 set cmd
="rm -f $SIGFILE $KEYFILE_PRIV $KEYFILE_PUB $EXPORT_KEYFILE $P8FILE"
132 if ($QUIET == NO
) then