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

20240516-wc_AesXtsEnDecryptFinal #7549

Merged
merged 1 commit into from
May 16, 2024

Conversation

douzzer
Copy link
Contributor

@douzzer douzzer commented May 16, 2024

AES-XTS: add wc_AesXtsEncryptFinal() and wc_AesXtsDecryptFinal() for API consistency, and add error-checking (block alignment check) to wc_AesXtsEncryptUpdate() and wc_AesXtsDecryptUpdate().

tested with wolfssl-multi-test.sh ... linuxkm-aesxts-cryptonly-noasm-LKCAPI-no-twc-insmod-crypto-fuzzer linuxkm-aesxts-cryptonly-aesni-LKCAPI-no-twc-insmod-crypto-fuzzer linuxkm-aesxts-cryptonly-noasm-ECB-LKCAPI-no-twc-insmod-crypto-fuzzer linuxkm-aesxts-cryptonly-aesni-ECB-LKCAPI-no-twc-insmod-crypto-fuzzer linuxkm-fips-dev-static-hash-intelasm-LKCS-insmod-6.1.73-fortify check-source-text all-g++

…API consistency, and add error-checking (block alignment check) to wc_AesXtsEncryptUpdate() and wc_AesXtsDecryptUpdate().
Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SparkiDev please review

{
int ret;
if (sz > 0)
ret = AesXtsEncryptUpdate(xaes, out, in, sz, i);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this input "sz" not have to be multiple of block size?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's right. for the last call, the input can have any length >= AES_BLOCK_SIZE. if the length isn't a multiple of the block size, then the ciphertext stealing stuff is used to finish out the message. and btw that's exactly why only the last call can be non-block-aligned.

return AesXtsEncryptUpdate(xaes, out, in, sz, i);
}

int wc_AesXtsEncryptFinal(XtsAes* xaes, byte* out, const byte* in, word32 sz,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What value does "final" add? Is it the zero'ing of "i"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a couple things:

(1) lets us add error-checking for all calls to Update() to make sure they're correctly block-aligned (trying to get ahead of ZenDesk tickets on that).

(2) the zeroing lets us check for API abuse, in that it guarantees a wrong result if the user calls Update after a Final, and of course it also prevents anything valuable from leaking out through the IV.

@douzzer douzzer requested a review from dgarske May 16, 2024 22:20
Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answers satisfy my concerns. @SparkiDev please finalize. Thanks

@SparkiDev SparkiDev removed the request for review from kaleb-himes May 16, 2024 23:43
@SparkiDev SparkiDev merged commit c0015cb into wolfSSL:master May 16, 2024
105 checks passed
jefferyq2 pushed a commit to jefferyq2/wolfssl that referenced this pull request Jun 9, 2024
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.

4 participants