@@ -56,10 +56,16 @@ create_key() {
56
56
EXTRA_CREATE_KEY_ARGS=" "
57
57
fi
58
58
59
+ if [ " $RSA_KEY_SIZE " -a " $1 " = " RSA" ]; then
60
+ KEY_LEN=" --bits $RSA_KEY_SIZE "
61
+ else
62
+ KEY_LEN=" "
63
+ fi
64
+
59
65
echo
60
66
echo " - Creating an $1 key and exporting its public part"
61
67
type_lower=$( echo $1 | tr ' [:upper:]' ' [:lower:]' )
62
- run_cmd $PARSEC_TOOL_CMD create-${type_lower} -key --key-name $KEY $EXTRA_CREATE_KEY_ARGS
68
+ run_cmd $PARSEC_TOOL_CMD create-${type_lower} -key --key-name $KEY $EXTRA_CREATE_KEY_ARGS $KEY_LEN
63
69
64
70
if ! run_cmd $PARSEC_TOOL_CMD list-keys | tee /dev/stderr | grep -q " $KEY " ; then
65
71
echo " Error: $KEY is not listed"
@@ -101,7 +107,7 @@ test_crypto_provider() {
101
107
test_encryption () {
102
108
# $1 - algorithm
103
109
KEY=" anta-key-rsa-encrypt"
104
- TEST_STR=" $( date) Parsec public key encryption test "
110
+ TEST_STR=" $( date) Parsec public key encryption"
105
111
ALG=" $1 "
106
112
107
113
create_key " RSA" " $KEY " " $ALG "
@@ -236,16 +242,19 @@ test_csr() {
236
242
237
243
test_rsa_key_bits () {
238
244
KEY=" anta-key-rsa-bits"
239
- DEFAULT_SIZE=2048
240
245
241
- if [ -n " $1 " ]; then
246
+ if [ " $RSA_KEY_SIZE " ]; then
247
+ key_size=" $RSA_KEY_SIZE "
248
+ key_param=" --bits $RSA_KEY_SIZE "
249
+ elif [ -n " $1 " ]; then
242
250
key_size=$1
243
251
key_param=" --bits $1 "
244
252
else
245
- key_size=${DEFAULT_SIZE}
253
+ key_size=2048
246
254
key_param=" "
247
255
fi
248
256
257
+ echo " Creating ${key_size} -bit RSA key."
249
258
run_cmd $PARSEC_TOOL_CMD create-rsa-key --key-name $KEY $key_param
250
259
run_cmd $PARSEC_TOOL_CMD export-public-key --key-name $KEY > ${MY_TMP} /checksize-${KEY} .pem
251
260
if ! run_cmd $OPENSSL rsa -pubin -text -noout -in ${MY_TMP} /checksize-${KEY} .pem | grep -q " Public-Key: (${key_size} bit)" ; then
@@ -261,6 +270,7 @@ PROVIDER=
261
270
# Test both RSA PKCS#1 v1.5 (default) and RSA OAEP encryption algorithms
262
271
NO_OAEP=
263
272
NO_PKCS1_V15=
273
+ RSA_KEY_SIZE=
264
274
while [ " $# " -gt 0 ]; do
265
275
case " $1 " in
266
276
-[0-9]* )
@@ -277,6 +287,9 @@ while [ "$#" -gt 0 ]; do
277
287
--no-v1.5 )
278
288
NO_PKCS1_V15=" true"
279
289
;;
290
+ --rsa-key-size )
291
+ shift ; RSA_KEY_SIZE=$1
292
+ ;;
280
293
* )
281
294
cat << EOF
282
295
Usage: $0 [parameter]
@@ -286,6 +299,7 @@ Usage: $0 [parameter]
286
299
-N: Test only the provider with N ID
287
300
--no-oaep: Do not test RSA-OAEP(SHA256) encryption/decryption operations
288
301
--no-v1.5: Do not test RSA-PKCS#1-v1.5 encryption/decryption operations
302
+ --rsa-key-size: Perform all RSA operations with the specified key length
289
303
290
304
Environment variables used if defined:
291
305
PARSEC_SERVICE_ENDPOINT - Parsec service API endpoint
0 commit comments