Skip to content

fix(internal): use block size instead of key size for sym encryption - #698

Merged
whooo merged 1 commit into
tpm2-software:masterfrom
gomesj:master
Aug 5, 2026
Merged

fix(internal): use block size instead of key size for sym encryption#698
whooo merged 1 commit into
tpm2-software:masterfrom
gomesj:master

Conversation

@gomesj

@gomesj gomesj commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

For modes like CFB, OFB and CBC, python cryptography library expects IV size to be equal to the block size.
AES uses a fixed block size of 128 bits (and so does Camellia from a quick search).
This creates a size difference between key and block size when using any key size higher than 128 bits.
While this might not cover expectations for all possible modes, changing the IV size from key length to block size should fix compability with 256 bits key size for the modes currently supported in the internal crypto library (currently mainly CFB due to _symdef_to_crypt).

@whooo

whooo commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Just a small nitpick thing, could you change "fix(internal)" in the commit to "internal/crypto"?
Just to keep it inline with (most) other commit messages.
Otherwise it looks good to me

For modes like CFB, OFB and CBC, python cryptography library expects IV
size to be equal to the block size.
AES uses a fixed block size of 128 bits (and so does Camellia from a
quick search).
This creates a size difference between key and block size when using any
key size higher than 128 bits.
While this might not cover expectations for all possible modes, changing
the IV size from key length to block size should fix compability with
256 bits key size for the modes currently supported in the internal
crypto library (currently mainly CFB due to `_symdef_to_crypt`).

Signed-off-by: Julien Gomes <julien@arista.com>
@gomesj

gomesj commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Sure thing, changed the commit message prefix to "internal/crypto"

@whooo
whooo merged commit e96a9c1 into tpm2-software:master Aug 5, 2026
30 checks passed
@whooo

whooo commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

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.

2 participants