Rate This Document
Findability
Accuracy
Completeness
Readability

Testing Algorithm Performance Using OpenSSL/Tongsuo and KAE

You can use commands provided in this section to test the performance before and after KAE is invoked in RSA (synchronous and asynchronous modes), SM3, SM4 (CBC mode), and AES (asynchronous CBC mode).

If Tongsuo is used for encryption and decryption, the test method is the same as that of OpenSSL.

The following test case data is from CentOS 7.6.

Verifying OpenSSL

Check the OpenSSL version.
1
openssl version
If the OpenSSL version is not the one used during KAE installation, set the following environment variables to specify OpenSSL: In the following commands, /path/install indicates the OpenSSL installation path.
1
2
export PATH=/path/install/bin:$PATH
export LD_LIBRARY_PATH=/path/install/lib:$LD_LIBRARY_PATH

Testing the RSA Algorithm Performance in Synchronous Mode

  • Use the OpenSSL software algorithm to test the performance of the RSA algorithm.
    1
    openssl speed -elapsed rsa2048
    
    The command output is as follows:
    1
    2
    3
    ...
                     sign    verify    sign/s verify/s
    rsa 2048 bits 0.001384s 0.000035s   724.1  28365.8.
    
  • Use KAE to test the performance of the RSA algorithm.
    1
    openssl speed -elapsed -engine kae rsa2048
    
    The command output is as follows:
    1
    2
    3
    ....
                     sign    verify    sign/s verify/s
    rsa 2048 bits 0.000355s 0.000022s   2819.0  45478.4
    

After KAE is used, the signature speed is improved from 724.1 sign/s to 2,819 sign/s.

Testing the RSA Algorithm Performance in Asynchronous Mode

  • Use the OpenSSL software algorithm to test the asynchronous RSA algorithm performance.
    1
    openssl speed -elapsed -async_jobs 36 rsa2048 
    
    The command output is as follows:
    1
    2
    3
    ....
                      sign    verify    sign/s verify/s
    rsa 2048 bits 0.001318s 0.000032s    735.7  28555
    
  • Use KAE to test the asynchronous RSA algorithm performance.
    1
    openssl speed -engine kae -elapsed -async_jobs 36 rsa2048 
    
    The command output is as follows:
    1
    2
    3
    .... 
                      sign    verify    sign/s verify/s
    rsa 2048 bits 0.000018s 0.000009s  54384.1 105317.0
    

After KAE is used, the asynchronous RSA signature speed is improved from 735.7 sign/s to 54,384.1 sign/s.

Testing the SM4 Algorithm Performance in CBC Mode

  • Use the OpenSSL software algorithm to test the performance of the SM4 algorithm in CBC mode.
    1
    openssl speed -elapsed -evp sm4-cbc
    
    The command output is as follows:
    1
    2
    3
    4
    5
    You have chosen to measure elapsed time instead of user CPU time.
    ....
    Doing sm4-cbc for 3s on 10240 size blocks: 2196 sm4-cbc's in 3.00s  ....
    type          51200 bytes 102400 bytes1048576 bytes2097152 bytes4194304 bytes8388608 bytes
    sm4-cbc          82312.53k    85196.80k    85284.18k    85000.85k    85284.18k    85261.26k
    
  • Use KAE to test the performance of the SM4 algorithm in CBC mode.
    1
    openssl speed -elapsed -engine kae -evp sm4-cbc
    
    The command output is as follows:
    1
    2
    3
    4
    5
    6
    7
    engine "kae" set. 
    You have chosen to measure elapsed time instead of user CPU time.
    ...
    Doing sm4-cbc for 3s on 1048576 size blocks: 11409 sm4-cbc's in 3.00s
    ...
    type          51200 bytes 102400 bytes1048576 bytes2097152 bytes4194304 bytes8388608 bytes
    sm4-cbc         383317.33k   389427.20k   395313.15k   392954.73k   394264.58k   394264.58k
    

After KAE acceleration, the operational speed of the SM4 algorithm in CBC mode increases from 82,312.53 kbit/s to 383,317.33 kbit/s when the input data block size is 8 MB.

Testing the SM3 Algorithm Performance

  • Use the OpenSSL software algorithm to test the performance of the SM3 algorithm.
    1
    openssl speed -elapsed -evp sm3
    
    The result is as follows:
    1
    2
    3
    4
    5
    You have chosen to measure elapsed time instead of user CPU time.
    Doing sm3 for 3s on 102400 size blocks: 1536 sm3's in 3.00s
    ....
    type          51200 bytes 102400 bytes1048576 bytes2097152 bytes4194304 bytes8388608 bytes
    sm3              50568.53k    52428.80k    52428.80k    52428.80k    52428.80k    52428.80k
    
  • Use KAE to test the performance of the SM3 algorithm.
    1
    openssl speed -elapsed -engine kae -evp sm3
    
    The result is as follows:
    1
    2
    3
    4
    5
    6
    engine "kae" set.
    You have chosen to measure elapsed time instead of user CPU time.
    Doing sm3 for 3s on 102400 size blocks: 19540 sm3's in 3.00s
    ....
    type            51200 bytes  102400 bytes  1048576 bytes 2097152 bytes 4194304 bytes 8388608 bytes
    sm3             648243.20k   666965.33k   677030.57k   678778.20k   676681.05k   668292.44k
    

After KAE acceleration, the operational speed of the SM3 algorithm increases from 52,428.80 kbit/s to 668,292.44 kbit/s when the input data block size is 8 MB.

Testing the Asynchronous Performance of the AES Algorithm in CBC Mode

  • Use the OpenSSL software algorithm to test the asynchronous performance of the AES algorithm in CBC mode.
    1
    openssl speed -elapsed -evp aes-128-cbc -async_jobs 4
    
    The command output is as follows:
    1
    2
    3
    4
    5
    6
    You have chosen to measure elapsed time instead of user CPU time.
    Doing aes-128-cbc for 3s on 51200 size blocks: 65773 aes-128-cbc's in 3.00s
    Doing aes-128-cbc for 3s on 102400 size blocks: 32910 aes-128-cbc's in 3.00s
    ....
    type          51200 bytes 102400 bytes1048576 bytes2097152 bytes4194304 bytes8388608 bytes
    aes-128-cbc    1122525.87k  1123328.00k  1120578.22k  1121277.27k  1119879.17k  1115684.86k
    
  • Use KAE to test the asynchronous performance of the AES algorithm in CBC mode.
    1
    openssl speed -elapsed -evp aes-128-cbc -async_jobs 4 -engine kae
    
    The output is displayed as follows:
    1
    2
    3
    4
    5
    6
    7
    engine "kae" set.
    You have chosen to measure elapsed time instead of user CPU time.
    Doing aes-128-cbc for 3s on 51200 size blocks: 219553 aes-128-cbc's in 3.00s
    Doing aes-128-cbc for 3s on 102400 size blocks: 117093 aes-128-cbc's in 3.00s
    ....
    type          51200 bytes 102400 bytes1048576 bytes2097152 bytes4194304 bytes8388608 bytes
    aes-128-cbc    3747037.87k  3996774.40k  1189085.18k  1196774.74k  1196979.11k  1199570.94k
    
  • The OpenSSL test data length is defined in the lengths_list array in the speed.c file (the speed.c file is in the app directory of the OpenSSL source package, for example, openssl-1.1.1a/apps/speed.c). Testers can modify the data here, compile and install OpenSSL by referring to Installing OpenSSL/Tongsuo, and perform the test. That is how the length of the test data (such as 51,200 bytes and 102,400 bytes) is calculated.
  • The AES algorithm supports only asynchronous usage when the data length is 256 KB or less.
  • After KAE acceleration, the operational speed of the AES algorithm increases from 1,123,328.00 kbit/s to 3,996,774.40 kbit/s when the input data block size is 100 KB.