RustCrypto / block-modes

Collection of generic block mode algorithms written in pure Rust
64 stars 13 forks source link

cbc: tweak code to help with codegen #15

Closed newpavlov closed 2 years ago

newpavlov commented 2 years ago

The tweaks were developed by inspecting assembly generated for AES-NI backend by the latest Nightly.

Benchmarks results before:

test cbc_aes128_decrypt_block  ... bench:      21,150 ns/iter (+/- 4,893) = 774 MB/s
test cbc_aes128_decrypt_blocks ... bench:       5,491 ns/iter (+/- 579) = 2983 MB/s
test cbc_aes128_encrypt_block  ... bench:      17,941 ns/iter (+/- 2,325) = 913 MB/s
test cbc_aes128_encrypt_blocks ... bench:      18,062 ns/iter (+/- 1,679) = 907 MB/s

After:

test cbc_aes128_decrypt_block  ... bench:      10,109 ns/iter (+/- 564) = 1620 MB/s
test cbc_aes128_decrypt_blocks ... bench:       3,597 ns/iter (+/- 758) = 4554 MB/s
test cbc_aes128_encrypt_block  ... bench:      16,654 ns/iter (+/- 1,828) = 983 MB/s
test cbc_aes128_encrypt_blocks ... bench:      16,478 ns/iter (+/- 695) = 994 MB/s