Skip to content
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

issue with mbx_sm4_xts_encrypt/decrypt_mb16 #88

Open
Jingkai opened this issue Dec 31, 2024 · 1 comment
Open

issue with mbx_sm4_xts_encrypt/decrypt_mb16 #88

Jingkai opened this issue Dec 31, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Jingkai
Copy link

Jingkai commented Dec 31, 2024

Attempted to use the functions mbx_sm4_xts_encrypt/decrypt_mb16 for data encryption and decryption, but found inconsistencies in the data before encryption and after decryption.

TRANSPOSE_OUT_512(TMP[0], TMP[1], TMP[2], TMP[3], TMP[16], TMP[17], TMP[18], TMP[19]); TMP[0] = _mm512_shuffle_epi8(TMP[0], M512(swapBytes)); TMP[1] = _mm512_shuffle_epi8(TMP[1], M512(swapBytes)); TMP[2] = _mm512_shuffle_epi8(TMP[2], M512(swapBytes)); TMP[3] = _mm512_shuffle_epi8(TMP[3], M512(swapBytes)); **_mm512_storeu_si512((__m512i*)loc_out[13], _mm512_xor_si512(TMP[1], TWEAK[13]));** _mm512_storeu_si512((__m512i*)loc_out[13], _mm512_xor_si512(TMP[1], TWEAK[13])); _mm512_storeu_si512((__m512i*)loc_out[14], _mm512_xor_si512(TMP[2], TWEAK[14])); _mm512_storeu_si512((__m512i*)loc_out[15], _mm512_xor_si512(TMP[3], TWEAK[15]));

It seems there is an issue at line 552.
_mm512_storeu_si512((__m512i*)loc_out[13], _mm512_xor_si512(TMP[1], TWEAK[13]));

it should be
__mm512_storeu_si512((__m512i*)loc_out[12], _mm512_xor_si512(TMP[0], TWEAK[12]));

@rcao8
Copy link

rcao8 commented Dec 31, 2024

Thank you @Jingkai for posting. We will work on it.

@rcao8 rcao8 added the bug Something isn't working label Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants