Add sanity test command for SM2, including performance and basic function test command.
Signed-off-by: Zhiqi Song songzhiqi1@huawei.com --- test/sanity_test_provider.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/test/sanity_test_provider.sh b/test/sanity_test_provider.sh index 37b9f51..2fd8786 100755 --- a/test/sanity_test_provider.sh +++ b/test/sanity_test_provider.sh @@ -19,6 +19,8 @@ if ((major_version >= 3)); then cipher_algs=$(openssl list -provider $engine_id -cipher-algorithms) signature_algs=$(openssl list -provider $engine_id -signature-algorithms) keyexch_algs=$(openssl list -provider $engine_id -key-exchange-algorithms) + keymgmt_algs=$(openssl list -provider $engine_id -key-managers) + public_key_algs=$(openssl list -provider $engine_id -public-key-algorithms) fi
if [[ $digest_algs =~ "uadk_provider" ]]; then @@ -87,6 +89,36 @@ if [[ $signature_algs =~ "uadk_provider" ]]; then
openssl pkeyutl -decrypt -in enc.txt -inkey prikey.pem -out dec.txt \ -pkeyopt rsa_padding_mode:pkcs1 -provider $engine_id + +fi + +if [[ $keymgmt_algs =~ " SM2 } @ uadk_provider" ]]; then + echo "uadk_provider testing SM2 keymgmt" + #generate keypair + openssl ecparam -name SM2 -genkey -out sm2.key -provider $engine_id + #get pubkey + openssl ec -in sm2.key -pubout -out sm2.pub +fi + +if [[ $signature_algs =~ " SM2 } @ uadk_provider" ]]; then + echo "uadk_provider testing SM2 signature" + #speed test sign and verify + openssl speed -provider $engine_id sm2 + openssl speed -provider $engine_id -async_jobs 1 sm2 + #sign + echo "Content to be signed" > sign.data + openssl dgst -provider $engine_id -SM3 -sign sm2.key -out sm2_ec.sig sign.data + #verify + openssl dgst -provider $engine_id -SM3 -verify sm2.pub -signature sm2_ec.sig sign.data +fi + +if [[ $public_key_algs =~ " SM2 } @ uadk_provider" ]]; then + echo "uadk_provider testing SM2 asym cipher" + #encrypt + echo "Content to be encrypted" > plaintext.txt + openssl pkeyutl -encrypt -in plaintext.txt -out ciphertext.bin -inkey sm2.pub -pubin -provider $engine_id + #decrypt + openssl pkeyutl -decrypt -in ciphertext.bin -out plaintext.txt -inkey sm2.key -provider $engine_id fi
if [[ $keyexch_algs =~ "uadk_provider" ]]; then