-
Notifications
You must be signed in to change notification settings - Fork 20
uadk_provider: some algorithm optimization and problem fixing #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
/lgtm |
|
linux/scripts/checkpatch.pl patch/* ERROR: Macros with complex values should be enclosed in parentheses ERROR: Macros with complex values should be enclosed in parentheses ERROR: code indent should use tabs where possible |
|
build with some warning: |
Ignore problem "Macros with complex values should be enclosed", because adding parentheses will report an error. Other problems are solved. |
The problems similar to "warning: 'get_default_dh_keyexch' defined but not used" are ignored. The function will be invoked in the subsequent development. Other problems are solved. |
|
/lgtm |
后面会用到这个函数还是啥?没看懂, |
为啥几个括号会报错? |
后面有patch会调到这些函数 |
BN_DEF这个宏是用来表示数组的元素的不同形式
|
|
编译错误蛮难看的,其实可以用的时候再加,要是确实后面用到,可以先不管了 另外我测试的时候遇到这个错误 ./test/sanity_test.sh
|
|
docker openEuler 2403, openssl 3.0 环境下 920 2064EC83FFFF0000:error:030000BD:digital envelope routines:EVP_EncryptUpdate:update error:crypto/evp/evp_enc.c:690:
|
|
我用uadk_engine master
openssl 3.0 docker openEuler 2403, |
The major issues that have been resolved are as follows: 1. In uadk_prov_rsa_init(), a deadlock occurs when a lock is returned before it is released. 2. In rsa_check_bit_useful(), the unit of the bits parameter is bit, and the unit of the flen parameter is byte. They cannot be compared directly. 3. As "new" and "export" are keywords in C++, there will be compile error with mocker UT framework. 4. In the case of an exception, the return value of the RSA_padding_xxx function is not 0. 5. Switch to software calculation only when one of the following three conditions occur, indicating that the hardware initialization fails, hardware services fail to be executed and the packet length specification is not supported. Signed-off-by: Qi Tao <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
Add the input pointer length check for the digest and cipher to ensure that the input data is valid. Signed-off-by: Chenghai Huang <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
As DH needs FFC(Finite Field Cryptography) API of OpenSSL, but the OpenSSL3.x does not place these APIs in external header file currently. Therefore, we put the related APIs in independent file of uadk_provider. Signed-off-by: Zhiqi Song <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
Based on the original implementation, a unified data structure is used. And FFC-related extended functions are added. Signed-off-by: Zhiqi Song <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
The return value of the execution result is changed to the definition. Signed-off-by: Chenghai Huang <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
The length of the input IV and key pointer cannot exceed the maximum length. Otherwise, memory overwriting occurs during the copy. Signed-off-by: Chenghai Huang <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
There is no timeout exit condition in the loop. When busy is returned continuously, an infinite loop occurs. Signed-off-by: Chenghai Huang <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
Deleted unnecessary return values and modified the format. Use a unified format to define the return values of success and failure. Signed-off-by: Chenghai Huang <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
The following 17 AES algorithms are added: AES-128-CBC AES-192-CBC AES-256-CBC AES-128-ECB AES-192-ECB AES-256-ECB AES-128-XTS AES-256-XTS AES-128-CTR AES-192-CTR AES-256-CTR AES-128-OFB AES-192-OFB AES-256-OFB AES-128-CFB AES-192-CFB AES-256-CFB Signed-off-by: Chenghai Huang <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
In the update operation, the first packet needs to combine the previous unprocessed data into a 512 KB packet for calculation. Other data is calculated based on the maximum packet length (16M-512B) of the UADK In this way, a computing resource required for copying may be omitted, and a data volume of once hardware computation may be increased, thereby reducing a quantity of times of sending and receiving data, and better exerting hardware acceleration performance. Signed-off-by: Chenghai Huang <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
In the decrypted filled data update process, the input size will be zero when the input size is smaller than the block size. As a result, an error message indicating that the output size is 0 is reported by UDAK. Therefore, it need to check whether the input length is 0 before UADK encryption/decryption. In addition, if the input length is greater than 0 and smaller than the block size, that is, the length of the data currently to be processed is 0, the data needs to be cached in the buffer through ossl_cipher_trailingdata() and sent to the next step. Signed-off-by: Chenghai Huang <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
The ivlen param setting function is added. In addition, the pad param is missing in the ctx param table. As a result, users cannot set this parameter. This param is added. Signed-off-by: Chenghai Huang <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
The OpenSSL enc tool call EVP_CipherInit_ex() twice. The first time is to initialize the encryption/decryption algorithm, and the second time is to input the key and IV parameters. Therefore, an empty key and iv will be passed in the first call. A flag bit needs to be added to indicate whether the key and IV have been set. Otherwise, the key and IV that are not set will cause a cipher error. Signed-off-by: Chenghai Huang <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
The digest update after optimization needs to distinguish whether the buffer is copied. If the buffer is filled, the data in the buffer after the copy will be processed. Otherwise, the remaining data will be processed directly. Signed-off-by: Chenghai Huang <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
…functions Extract hardware initialization functions to separate functions. And add the unlock function when the process fork. Signed-off-by: Chenghai Huang <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
When the num of recv packets is greater than the expected number. The condition that expected nums equal to actual nums, for exiting the poll loop will cause a long retry loop. Therefore, the loop exit condition is modified, and full_sem is reduced when no task needs to be queried. Signed-off-by: Chenghai Huang <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
The key generation and key derivation functions of the x25519 and x448 algorithms are implemented separately before. This modification combines the similar logic to simplify the code, reducing code duplication ratio. Signed-off-by: Zhiqi Song <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
The length of the pubkey get from wd_ecxdh_get_out_params() may not be 'key_size', the actual value in 'dsize' may smaller than 'key_size'. So copy 'key_size' length to ecx_key->pubkey will make the reverse_bytes() operates on incorrect pubkey length, which will make the actual value changed. Fix this issue by using the length filled in 'dsize'. Signed-off-by: Zhiqi Song <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
Add AES-128-CBC-CTS AES-192-CBC-CTS AES-256-CBC-CTS to uadk_provider. Each alg has 3 modes, such as CS1, CS2, and CS3. The default mode is CS1. You can select a mode by setting the OSSL_CIPHER_PARAM_CTS_MODE parameter. Signed-off-by: Chenghai Huang <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
On openssl version 3.0, the pad function is not enabled in the default scenario. After the data encrypted by pad is decrypted, the result is inconsistent with the original data. Therefore, pad processing needs to be performed through soft calculation to ensure that the results are correct. Signed-off-by: Chenghai Huang <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
The IV has been updated by the uadk, the uadk engine does not need update it and use the right out_bytes to determine whether to update the IV. Signed-off-by: Wenkai Lin <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
Use UADK_PKEY_KEYMGMT_DESCR, UADK_PKEY_SIGNATURE_DESCR and UADK_PKEY_ASYM_CIPHER_DESCR macro to unify the definitions of RSA functions, reducing code duplication ratio. Signed-off-by: Zhiqi Song <[email protected]> Signed-off-by: Qi Tao <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
Rename get_default_xxx() function with algorithm specific name, avoid functions with the same name but different implementations. Signed-off-by: Zhiqi Song <[email protected]> Signed-off-by: Qi Tao <[email protected]> Signed-off-by: JiangShui Yang <[email protected]>
Can not convert ‘size_t*’ {‘long unsigned int*’}
to ‘int*’, which may cause data loss or other problems.
Signed-off-by: Qi Tao <[email protected]>
Signed-off-by: JiangShui Yang <[email protected]>
|
/lgtm |
/lgtm |
|
merged, |
Chenghai Huang (15):
uadk_provider: add input pointer length check for digest and cipher
uadk_provider: code cleanup for provider bio
uadk_provider: add length check for input pointer
uadk_provider: add a timeout exit condition to the loop
uadk_provider: code cleanup for uadk_provider and uadk_engine
uadk_provider: add aes alg for uadk_provider in openssl3.0
uadk_engine: optimized engine update process
uadk_provider: fix cipher issue when input len is 0 in decrypto update
uadk_provider: fix the set ctx param function for ivlen and pad
uadk_provider: fix the key and IV verification methods for cipher init
uadk_provider: fix the switch condition issue of soft digest in engine
uadk_provider: extract hardware initialization functions to separate
functions
uadk_provider: modify poll loop exit condition
uadk_provider: add aes cts alg to uadk_provider in openssl3.0
uadk_provider: bugfix cipher decryption issue
Qi Tao (2):
uadk_prov: fix some cleancode issues and bugs for rsa
uadk_prov: fix data type conversion errors
Wenkai Lin (1):
uadk_engine: remove update iv for cipher
Zhiqi Song (6):
uadk_provider: add openssl ffc library function
uadk_provider: reconstructing dh implementation
uadk_engine/ecx: merge some similar code logic
uadk_engine: fixup pubkey size used in reverse operation
uadk_provider/rsa: unify function definitions with macro
uadk_provider/pkey: fixup functions with the same name