Skip to content

Commit b110aa0

Browse files
committed
tests/parsec-cli-tests.sh: Add RSA_KEY_SIZE flag
This flag can be used for testing parsec on slower platforms where RSA 2048 key operations are time consuming. Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
1 parent 2c78cc3 commit b110aa0

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

tests/ci.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ fi
3232
./target/debug/parsec-tool --help
3333

3434
PARSEC_TOOL="./target/debug/parsec-tool" tests/parsec-cli-tests.sh -d
35+
PARSEC_TOOL="./target/debug/parsec-tool" tests/parsec-cli-tests.sh -d --rsa-key-size 1024

tests/parsec-cli-tests.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,16 @@ create_key() {
5656
EXTRA_CREATE_KEY_ARGS=""
5757
fi
5858

59+
if [ "$RSA_KEY_SIZE" -a "$1" = "RSA" ]; then
60+
KEY_LEN="--bits $RSA_KEY_SIZE"
61+
else
62+
KEY_LEN=""
63+
fi
64+
5965
echo
6066
echo "- Creating an $1 key and exporting its public part"
6167
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
6369

6470
if ! run_cmd $PARSEC_TOOL_CMD list-keys | tee /dev/stderr | grep -q "$KEY"; then
6571
echo "Error: $KEY is not listed"
@@ -101,7 +107,7 @@ test_crypto_provider() {
101107
test_encryption() {
102108
# $1 - algorithm
103109
KEY="anta-key-rsa-encrypt"
104-
TEST_STR="$(date) Parsec public key encryption test"
110+
TEST_STR="$(date) Parsec public key encryption"
105111
ALG="$1"
106112

107113
create_key "RSA" "$KEY" "$ALG"
@@ -236,16 +242,19 @@ test_csr() {
236242

237243
test_rsa_key_bits() {
238244
KEY="anta-key-rsa-bits"
239-
DEFAULT_SIZE=2048
240245

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
242250
key_size=$1
243251
key_param="--bits $1"
244252
else
245-
key_size=${DEFAULT_SIZE}
253+
key_size=2048
246254
key_param=""
247255
fi
248256

257+
echo "Creating ${key_size}-bit RSA key."
249258
run_cmd $PARSEC_TOOL_CMD create-rsa-key --key-name $KEY $key_param
250259
run_cmd $PARSEC_TOOL_CMD export-public-key --key-name $KEY >${MY_TMP}/checksize-${KEY}.pem
251260
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=
261270
# Test both RSA PKCS#1 v1.5 (default) and RSA OAEP encryption algorithms
262271
NO_OAEP=
263272
NO_PKCS1_V15=
273+
RSA_KEY_SIZE=
264274
while [ "$#" -gt 0 ]; do
265275
case "$1" in
266276
-[0-9]* )
@@ -277,6 +287,9 @@ while [ "$#" -gt 0 ]; do
277287
--no-v1.5 )
278288
NO_PKCS1_V15="true"
279289
;;
290+
--rsa-key-size )
291+
shift; RSA_KEY_SIZE=$1
292+
;;
280293
*)
281294
cat <<EOF
282295
Usage: $0 [parameter]
@@ -286,6 +299,7 @@ Usage: $0 [parameter]
286299
-N: Test only the provider with N ID
287300
--no-oaep: Do not test RSA-OAEP(SHA256) encryption/decryption operations
288301
--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
289303
290304
Environment variables used if defined:
291305
PARSEC_SERVICE_ENDPOINT - Parsec service API endpoint

0 commit comments

Comments
 (0)