3 # Run import/export tests for traditional openssl wrapped keys.
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.
12 set OPENSSLEXPORTTOOL
=.
/exportOpensslTool
15 set OS_PWD_ARG
="-passout pass:$PASSWORD"
17 # RSA private key, raw format, generated by openssl
18 set RSA_RAW_PRIV_KEY
=${BUILD_DIR}/rsapriv_raw.pem
20 # RSA private key, openssl wrap format, generated by openssl
21 set RSA_PRIV_KEY
=${BUILD_DIR}/rsapriv.os
23 # RSA private key, openssl wrap format, generated by kcExport
24 set RSA_PRIV_KEY_EXP
=${BUILD_DIR}/rsapriv_exp_os
26 # RSA private key, raw format, generated by openssl
27 set DSA_RAW_PRIV_KEY
=${BUILD_DIR}/dsapriv_raw.pem
29 # DSA private key, PEM, generated by openssl
30 set DSA_PRIV_KEY
=${BUILD_DIR}/dsapriv.pem
32 # DSA private key, openssl wrap format, generated by kcExport
33 set DSA_PRIV_KEY_EXP
=${BUILD_DIR}/dsapriv_exp_os
35 # raw private key converted by openssl from our exported wrap
36 set PRIV_KEY_PARSE
=${BUILD_DIR}/privkey_parse
39 set DSA_PARAMS
=dsaParamOpenssl.pem
41 # user specified variables
48 set SECURE_PHRASE_ARG
=
67 set SECURE_PHRASE_ARG
=-Z
75 echo Usage
: importExportOpensslWrap \
[q\
(uiet\
)\
] \
[n\
(oACL\
)\
] \
[s\
(ecurePassphrase\
)\
] \
[N\
(oClean\
)\
]
80 echo === Begin Openssl wrap
test ===
81 if ($QUIET == NO
) then
86 if ($QUIET == NO
) then
87 echo ...Testing import of RSA key generated by openssl
89 set cmd
="$RM -f $RSA_PRIV_KEY"
90 if ($QUIET == NO
) then
95 # generate RSA with openssl
97 set cmd
="$OPENSSL genrsa -out $RSA_PRIV_KEY $OS_PWD_ARG -des $KEYSIZE"
98 if ($QUIET == NO
) then
101 $cmd >& /dev
/null
|| exit(1)
106 set cmd
="$KCIMPORT $RSA_PRIV_KEY -k $KEYCHAIN -z $PASSWORD -f openssl -w -K 1 $QUIET_ARG $NOACL_ARG $SECURE_PHRASE_ARG"
107 if ($QUIET == NO
) then
112 # verify by examining the keychain
114 set cmd
="$DBVERIFY $KEYCHAIN_PATH rsa priv $KEYSIZE $QUIET_ARG"
115 if ($QUIET == NO
) then
123 if ($QUIET == NO
) then
124 echo ...Testing import of DSA key generated by openssl
126 if ($QUIET == NO
) then
130 set cmd
="$RM -f $DSA_PRIV_KEY"
131 if ($QUIET == NO
) then
136 # generate DSA with openssl
138 set cmd
="$OPENSSL gendsa -out $DSA_PRIV_KEY $OS_PWD_ARG -des $DSA_PARAMS"
139 if ($QUIET == NO
) then
142 $cmd >& /dev
/null
|| exit(1)
146 set cmd
="$KCIMPORT $DSA_PRIV_KEY -k $KEYCHAIN -z $PASSWORD -f openssl -w -K 1 $QUIET_ARG $NOACL_ARG $SECURE_PHRASE_ARG"
147 if ($QUIET == NO
) then
152 # verify by examining the keychain
154 set cmd
="$DBVERIFY $KEYCHAIN_PATH dsa priv $KEYSIZE $QUIET_ARG"
155 if ($QUIET == NO
) then
160 # openssl wrap form Export
162 if ($QUIET == NO
) then
163 echo ...testing openssl
export of RSA private key
166 # generate raw RSA with openssl
168 set cmd
="$OPENSSL genrsa -out $RSA_RAW_PRIV_KEY $KEYSIZE"
169 if ($QUIET == NO
) then
172 $cmd >& /dev
/null
|| exit(1)
174 set cmd
="$OPENSSLEXPORTTOOL $RSA_RAW_PRIV_KEY $RSA_PRIV_KEY_EXP $PRIV_KEY_PARSE rsa 512 $QUIET $NOACL $SECURE_PHRASE"
177 if ($QUIET == NO
) then
178 echo ...testing openssl
export of DSA private key
181 # generate DSA with openssl
183 set cmd
="$OPENSSL gendsa -out $DSA_RAW_PRIV_KEY $DSA_PARAMS"
184 if ($QUIET == NO
) then
187 $cmd >& /dev
/null
|| exit(1)
189 set cmd
="$OPENSSLEXPORTTOOL $DSA_RAW_PRIV_KEY $DSA_PRIV_KEY_EXP $PRIV_KEY_PARSE dsa 512 $QUIET $NOACL $SECURE_PHRASE"
193 if ($NOCLEAN == NO
) then
194 set cmd1
="rm -f $RSA_RAW_PRIV_KEY $RSA_PRIV_KEY $RSA_PRIV_KEY_EXP $DSA_RAW_PRIV_KEY"
195 set cmd2
="rm -f $DSA_PRIV_KEY $DSA_PRIV_KEY_EXP $PRIV_KEY_PARSE"
196 if ($QUIET == NO
) then
204 if ($QUIET == NO
) then
205 echo === Openssl wrap
test complete
===