|
Description
|
Konstantin Ananyev found that replacing the following code in des3_crunch_block() (and des3_crunch_block()) -
tmp = (((uint64_t)block[0] << 56) | ((uint64_t)block[1] << 48) |
((uint64_t)block[2] << 40) | ((uint64_t)block[3] << 32) |
((uint64_t)block[4] << 24) | ((uint64_t)block[5] << 16) |
((uint64_t)block[6] << 8) | (uint64_t)block[7]);
if (decrypt == B_TRUE)
tmp = des_crypt_impl(ksch->ksch_decrypt, tmp, 3);
else
tmp = des_crypt_impl(ksch->ksch_encrypt, tmp, 3);
out_block[0] = tmp >> 56;
out_block[1] = tmp >> 48;
out_block[2] = tmp >> 40;
out_block[3] = tmp >> 32;
out_block[4] = tmp >> 24;
out_block[5] = tmp >> 16;
out_block[6] = tmp >> 8;
out_block[7] = (uint8_t)tmp;
with a bswapq (for X64) improved the performance upto 10% for udp over IPsec. This code is run for x32/x64 and for unaligned case on SPARC.
We can use the bswap instruction to do similar optimization on x32.
A code inspection found that similar code is found in
usr/src/common/crypto/aes/aes_cbc_crypt.c (for ccm mode)
usr/src/common/crypto/des/des_cbc_crypt.c
usr/src/common/crypto/des/des_impl.c (the above example)
usr/src/common/crypto/sha2/sha2.c
usr/src/uts/common/crypto/io/aes.c
|