3 # Run import/export tests for raw key pairs.
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 KEYSUBTOOL
=.
/importExportKeyTool
14 # RSA key pair, BSAFE format, generated by rsatool
15 set RSA_KEY_BSAFE
=${BUILD_DIR}/rsaBsafe
16 set RSA_PUB_KEY_BSAFE
=${RSA_KEY_BSAFE}_pub.der
17 set RSA_PRIV_KEY_BSAFE
=${RSA_KEY_BSAFE}_priv.der
19 # RSA key pair, openssl format, generated by rsatool
20 set RSA_KEY_OPENSSL
=${BUILD_DIR}/rsaOpenssl
21 set RSA_PUB_KEY_OPENSSL
=${RSA_KEY_OPENSSL}_pub.der
22 set RSA_PRIV_KEY_OPENSSL
=${RSA_KEY_OPENSSL}_priv.der
24 # DSA key pair, BSAFE format, generated by rsatool
25 set DSA_KEY_BSAFE
=${BUILD_DIR}/dsaBsafe
26 set DSA_PUB_KEY_BSAFE
=${DSA_KEY_BSAFE}_pub.der
27 set DSA_PRIV_KEY_BSAFE
=${DSA_KEY_BSAFE}_priv.der
29 # DSA key pair, openssl format, generated by rsatool
30 set DSA_KEY_OPENSSL
=${BUILD_DIR}/dsaOpenssl
31 set DSA_PUB_KEY_OPENSSL
=${DSA_KEY_OPENSSL}_pub.der
32 set DSA_PRIV_KEY_OPENSSL
=${DSA_KEY_OPENSSL}_priv.der
34 # RSA private key, generated by openssl, PEM format
35 set RSA_PRIV_KEY_PEM
=${RSA_PRIV_KEY_OPENSSL}.pem
38 set DSA_PARAMS_512_DER
=dsaParams_512.der
39 set DSA_PARAMS_512_PEM
=dsaParamOpenssl.pem
41 # ECDSA key pair, pub=X509, priv=pkcs8, generated by rsatool
42 set ECDSA_KEY_BASE
=${BUILD_DIR}/ecdsaBase
43 set ECDSA_PUB_KEY
=${ECDSA_KEY_BASE}_pub.der
44 set ECDSA_PRIV_KEY
=${ECDSA_KEY_BASE}_priv.der
45 set ECDSA_KEY_SIZE
=256
47 # user specified variables
55 # Verify existence of a few crucial things before we start.
57 if( ( ! -e $KCIMPORT ) || \
58 ( ! -e $KCEXPORT ) || \
59 ( ! -e $RSATOOL) ) then
60 echo === You
do not seem to have all of the required executables.
61 echo === Please build all of cspxutils and clxutils.
62 echo === See the README files
in those directories
for info.
85 echo Usage
: importExportRawKey \
[q\
(uiet\
)\
] \
[n\
(oACL\
)\
] \
[N\
(oClean\
)\
]
90 echo === Begin Raw Key Pair
test ===
91 if ($QUIET == NO
) then
97 ### Basic RSA key pair testing, openssl generated
100 # Create RSA key pair using openssl
101 # private keys are only generated in PEM format
102 if ($QUIET == NO
) then
103 echo === RSA key pair testing
, openssl generated
===
104 echo Creating RSA key pair using openssl...
106 set cmd
="$RM -f $RSA_PRIV_KEY_PEM $RSA_PRIV_KEY_OPENSSL"
107 if ($QUIET == NO
) then
111 set cmd
="$OPENSSL genrsa -out $RSA_PRIV_KEY_PEM $KEYSIZE"
112 if ($QUIET == NO
) then
115 $cmd >& /dev
/null
|| exit(1)
116 set cmd
="$BUILD_DIR/pemtool d $RSA_PRIV_KEY_PEM $RSA_PRIV_KEY_OPENSSL q"
117 if ($QUIET == NO
) then
121 set cmd
="$OPENSSL rsa -inform PEM -outform DER -in $RSA_PRIV_KEY_PEM -out $RSA_PUB_KEY_OPENSSL -pubout"
122 if ($QUIET == NO
) then
125 $cmd >& /dev
/null
|| exit(1)
127 $KEYSUBTOOL $RSA_PUB_KEY_OPENSSL $RSA_PRIV_KEY_OPENSSL $KEYCHAIN openssl
$QUIET $NOACL $NOCLEAN || exit(1)
131 ### Basic RSA key pair testing, BSAFE format
134 # Create RSA key pair in BSAFE format
135 if ($QUIET == NO
) then
136 echo === RSA key pair testing
, BSAFE format
===
137 echo Creating RSA key pair
in BSAFE format...
139 set cmd
="$RM -f $RSA_PUB_KEY_BSAFE $RSA_PRIV_KEY_BSAFE"
140 if ($QUIET == NO
) then
144 set cmd
="$RSATOOL g k=$RSA_KEY_BSAFE z=$KEYSIZE b=1 v=8 q"
145 if ($QUIET == NO
) then
150 $KEYSUBTOOL $RSA_PUB_KEY_BSAFE $RSA_PRIV_KEY_BSAFE $KEYCHAIN bsafe
$QUIET $NOACL $NOCLEAN || exit(1)
153 ### Basic RSA key pair testing, openssl format
156 # Create RSA key pair in openssl format
157 if ($QUIET == NO
) then
158 echo === RSA key pair testing
, OpenSSL format
===
159 echo Creating RSA key pair
in OpenSSL format...
161 set cmd
="$RM -f $RSA_PUB_KEY_OPENSSL $RSA_PRIV_KEY_OPENSSL"
162 if ($QUIET == NO
) then
166 set cmd
="$RSATOOL g k=$RSA_KEY_OPENSSL z=$KEYSIZE b=x v=1 q"
167 if ($QUIET == NO
) then
172 $KEYSUBTOOL $RSA_PUB_KEY_OPENSSL $RSA_PRIV_KEY_OPENSSL $KEYCHAIN openssl
$QUIET $NOACL $NOCLEAN || exit(1)
175 ### Basic DSA key pair testing, BSAFE format
178 if ($QUIET == NO
) then
179 echo === DSA key pair testing
, BSAFE format
===
180 echo Creating DSA key pair
in BSAFE format...
182 set cmd
="$RM -f $DSA_PUB_KEY_BSAFE $DSA_PRIV_KEY_BSAFE"
183 if ($QUIET == NO
) then
187 set cmd
="$RSATOOL g a=d k=$DSA_KEY_BSAFE z=$KEYSIZE b=b v=b m=$DSA_PARAMS_512_DER q"
188 if ($QUIET == NO
) then
193 $KEYSUBTOOL $DSA_PUB_KEY_BSAFE $DSA_PRIV_KEY_BSAFE $KEYCHAIN bsafe
$QUIET $NOACL $NOCLEAN || exit(1)
196 ### Basic DSA key pair testing, openssl format
199 # Create DSA key pair in openssl format
200 if ($QUIET == NO
) then
201 echo === DSA key pair testing
, OpenSSL format
===
202 echo Creating DSA key pair
in OpenSSL format...
204 set cmd
="$RM -f $DSA_PUB_KEY_OPENSSL $DSA_PRIV_KEY_OPENSSL"
205 if ($QUIET == NO
) then
209 set cmd
="$RSATOOL g a=d k=$DSA_KEY_OPENSSL z=$KEYSIZE b=x v=o m=$DSA_PARAMS_512_DER q"
210 if ($QUIET == NO
) then
215 $KEYSUBTOOL $DSA_PUB_KEY_OPENSSL $DSA_PRIV_KEY_OPENSSL $KEYCHAIN openssl
$QUIET $NOACL $NOCLEAN || exit(1)
218 ### Basic ECDSA key pair testing, default format
221 # Create ECDSA key pair
222 if ($QUIET == NO
) then
223 echo === ECDSA key pair testing
, default format
===
224 echo Creating ECDSA key pair
in default format...
226 set cmd
="$RM -f $ECDSA_PUB_KEY $ECDSA_PRIV_KEY"
227 if ($QUIET == NO
) then
231 set cmd
="$RSATOOL g a=e k=$ECDSA_KEY_BASE z=$ECDSA_KEY_SIZE q"
232 if ($QUIET == NO
) then
237 $KEYSUBTOOL $ECDSA_PUB_KEY $ECDSA_PRIV_KEY $KEYCHAIN openssl
$QUIET $NOACL $NOCLEAN || exit(1)
241 if ($NOCLEAN == NO
) then
242 set cmd1
="rm -f $RSA_KEY_BSAFE $RSA_PUB_KEY_BSAFE $RSA_PRIV_KEY_BSAFE $RSA_KEY_OPENSSL $RSA_PUB_KEY_OPENSSL $RSA_PRIV_KEY_OPENSSL"
243 set cmd2
="rm -f $DSA_KEY_BSAFE $DSA_PUB_KEY_BSAFE $DSA_PRIV_KEY_BSAFE $DSA_KEY_OPENSSL $DSA_PUB_KEY_OPENSSL $DSA_PRIV_KEY_OPENSSL $RSA_PRIV_KEY_PEM"
244 set cmd3
="rm -f $ECDSA_PUB_KEY $ECDSA_PRIV_KEY"
245 if ($QUIET == NO
) then
255 if ($QUIET == NO
) then
256 echo === Raw Key Pair
test complete
===