Skip to content

uadk: support aead stream mode and sm4-sm3 alg#657

Merged
Liulongfang merged 6 commits intoLinaro:masterfrom
lin755:master
Jan 13, 2025
Merged

uadk: support aead stream mode and sm4-sm3 alg#657
Liulongfang merged 6 commits intoLinaro:masterfrom
lin755:master

Conversation

@lin755
Copy link
Copy Markdown
Collaborator

@lin755 lin755 commented Dec 30, 2024

Wenkai Lin (6):
uadk/v1: support the hmac(sm3)-cbc(sm4) algorithm
uadk: fix for the algorithm name of the aead cbc mode
uadk/v1: Add stream mode for AES-GCM and SM4-GCM
uadk/v1: add assoc bytes check
uadk/v1: set aead msg state for the hardware v2
uadk/v1: fix input length check for aead stream mode.

Add the algorithm hmac(sm3)-cbc(sm4) to the nosva scene,
the following fileds of the session setup need to be set,
the calg(WCRYPTO_CIPHER_SM4), the cmode(WCRYPTO_CIPHER_CBC),
the dalg(WCRYPTO_SM3) and the dmode(WCRYPTO_DIGEST_HMAC).

Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
Signed-off-by: Qi Tao <taoqi10@huawei.com>
Currently, the algorithm name of the aead cbc mode
is designed only for sha256, but it is not suitable
any more when other algorithms are added, such as
hmac(sm3)-cbc(aes).
Now a common name is used, authenc(generic,cbc(aes)),
the actual algorithm and mode are still specified
by dalg and dmode in the session setup.

Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
Signed-off-by: Qi Tao <taoqi10@huawei.com>
In stream processing encryption mode, a long file
needs to be encrypted. When the accelerator is invoked,
the encryption result of each block is assembled.
The assembled result is the same as the result of
encrypting the entire file at a time.
For hisi_sec, the AAD is filled to the first message,
plaintext are done with the middle and the end message.
In an encrypted stream, the first and the end message
are unique and must be delivered to hardware.

Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
Signed-off-by: Qi Tao <taoqi10@huawei.com>
For the gcm stream mode, assoc bytes should not be 0,
check it to avoid hardware error.

Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
Signed-off-by: Qi Tao <taoqi10@huawei.com>
The hardware only uses the block mode, so set the aead
message state to the block mode first.

Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
Signed-off-by: Qi Tao <taoqi10@huawei.com>
The hardware supports only 16-byte alignment for the aead
middle messages, the invalid length check is added now.

Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
Signed-off-by: Qi Tao <taoqi10@huawei.com>
@gaozhangfei
Copy link
Copy Markdown
Collaborator

close this pr? only keep pr to develop?

@lin755
Copy link
Copy Markdown
Collaborator Author

lin755 commented Jan 13, 2025

close this pr? only keep pr to develop?
It has been fully tested as a stable version, so it can be merged into master.

@Liulongfang Liulongfang merged commit cecad35 into Linaro:master Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants