Skip to content

Commit

Permalink
Add RSA_KEY_SIZE flag to cli test script
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
gowthamsk-arm committed Nov 23, 2023
1 parent 2c78cc3 commit 4340aab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions tests/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ fi
./target/debug/parsec-tool --help

PARSEC_TOOL="./target/debug/parsec-tool" tests/parsec-cli-tests.sh -d
PARSEC_TOOL="./target/debug/parsec-tool" tests/parsec-cli-tests.sh --rsa-key-size 1024
23 changes: 18 additions & 5 deletions tests/parsec-cli-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@ create_key() {
EXTRA_CREATE_KEY_ARGS=""
fi

if [ "$RSA_KEY_SIZE" -a "$1" = "RSA" ]; then
KEY_LEN="--bits $RSA_KEY_SIZE"
else
KEY_LEN=""
fi

echo
echo "- Creating an $1 key and exporting its public part"
type_lower=$(echo $1 | tr '[:upper:]' '[:lower:]')
run_cmd $PARSEC_TOOL_CMD create-${type_lower}-key --key-name $KEY $EXTRA_CREATE_KEY_ARGS
run_cmd $PARSEC_TOOL_CMD create-${type_lower}-key --key-name $KEY $EXTRA_CREATE_KEY_ARGS $KEY_LEN

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

create_key "RSA" "$KEY" "$ALG"
Expand Down Expand Up @@ -236,13 +242,15 @@ test_csr() {

test_rsa_key_bits() {
KEY="anta-key-rsa-bits"
DEFAULT_SIZE=2048

if [ -n "$1" ]; then
if [ "$RSA_KEY_SIZE" ]; then
key_size="$RSA_KEY_SIZE"
key_param="--bits $RSA_KEY_SIZE"
else if [ -n "$1" ]; then
key_size=$1
key_param="--bits $1"
else
key_size=${DEFAULT_SIZE}
key_size=2048
key_param=""
fi

Expand All @@ -261,6 +269,7 @@ PROVIDER=
# Test both RSA PKCS#1 v1.5 (default) and RSA OAEP encryption algorithms
NO_OAEP=
NO_PKCS1_V15=
RSA_KEY_SIZE=
while [ "$#" -gt 0 ]; do
case "$1" in
-[0-9]* )
Expand All @@ -277,6 +286,9 @@ while [ "$#" -gt 0 ]; do
--no-v1.5 )
NO_PKCS1_V15="true"
;;
--rsa-key-size )
shift; RSA_KEY_SIZE=$1
;;
*)
cat <<EOF
Usage: $0 [parameter]
Expand All @@ -286,6 +298,7 @@ Usage: $0 [parameter]
-N: Test only the provider with N ID
--no-oaep: Do not test RSA-OAEP(SHA256) encryption/decryption operations
--no-v1.5: Do not test RSA-PKCS#1-v1.5 encryption/decryption operations
--rsa-key-size: Perform all RSA operations with a fixed key length
Environment variables used if defined:
PARSEC_SERVICE_ENDPOINT - Parsec service API endpoint
Expand Down

0 comments on commit 4340aab

Please sign in to comment.