Print this page
4896 Performance improvements for KCF AES modes

*** 20,29 **** --- 20,32 ---- */ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ + /* + * Copyright 2015 by Saso Kiselkov. All rights reserved. + */ /* * Blowfish encryption/decryption and keyschedule code. */
*** 697,707 **** return (NULL); } void ! blowfish_copy_block(uint8_t *in, uint8_t *out) { if (IS_P2ALIGNED(in, sizeof (uint32_t)) && IS_P2ALIGNED(out, sizeof (uint32_t))) { /* LINTED: pointer alignment */ *(uint32_t *)&out[0] = *(uint32_t *)&in[0]; --- 700,710 ---- return (NULL); } void ! blowfish_copy_block(const uint8_t *in, uint8_t *out) { if (IS_P2ALIGNED(in, sizeof (uint32_t)) && IS_P2ALIGNED(out, sizeof (uint32_t))) { /* LINTED: pointer alignment */ *(uint32_t *)&out[0] = *(uint32_t *)&in[0];
*** 712,722 **** } } /* XOR block of data into dest */ void ! blowfish_xor_block(uint8_t *data, uint8_t *dst) { if (IS_P2ALIGNED(dst, sizeof (uint32_t)) && IS_P2ALIGNED(data, sizeof (uint32_t))) { /* LINTED: pointer alignment */ *(uint32_t *)&dst[0] ^= *(uint32_t *)&data[0]; --- 715,725 ---- } } /* XOR block of data into dest */ void ! blowfish_xor_block(const uint8_t *data, uint8_t *dst) { if (IS_P2ALIGNED(dst, sizeof (uint32_t)) && IS_P2ALIGNED(data, sizeof (uint32_t))) { /* LINTED: pointer alignment */ *(uint32_t *)&dst[0] ^= *(uint32_t *)&data[0];
*** 738,751 **** int rv; if (blowfish_ctx->bc_flags & CBC_MODE) { rv = cbc_encrypt_contiguous_blocks(ctx, data, length, out, BLOWFISH_BLOCK_LEN, blowfish_encrypt_block, ! blowfish_copy_block, blowfish_xor_block); } else { rv = ecb_cipher_contiguous_blocks(ctx, data, length, out, ! BLOWFISH_BLOCK_LEN, blowfish_encrypt_block); } return (rv); } /* --- 741,754 ---- int rv; if (blowfish_ctx->bc_flags & CBC_MODE) { rv = cbc_encrypt_contiguous_blocks(ctx, data, length, out, BLOWFISH_BLOCK_LEN, blowfish_encrypt_block, ! blowfish_copy_block, blowfish_xor_block, NULL); } else { rv = ecb_cipher_contiguous_blocks(ctx, data, length, out, ! BLOWFISH_BLOCK_LEN, blowfish_encrypt_block, NULL); } return (rv); } /*
*** 759,772 **** int rv; if (blowfish_ctx->bc_flags & CBC_MODE) { rv = cbc_decrypt_contiguous_blocks(ctx, data, length, out, BLOWFISH_BLOCK_LEN, blowfish_decrypt_block, ! blowfish_copy_block, blowfish_xor_block); } else { rv = ecb_cipher_contiguous_blocks(ctx, data, length, out, ! BLOWFISH_BLOCK_LEN, blowfish_decrypt_block); if (rv == CRYPTO_DATA_LEN_RANGE) rv = CRYPTO_ENCRYPTED_DATA_LEN_RANGE; } return (rv); } --- 762,775 ---- int rv; if (blowfish_ctx->bc_flags & CBC_MODE) { rv = cbc_decrypt_contiguous_blocks(ctx, data, length, out, BLOWFISH_BLOCK_LEN, blowfish_decrypt_block, ! blowfish_copy_block, blowfish_xor_block, NULL, NULL); } else { rv = ecb_cipher_contiguous_blocks(ctx, data, length, out, ! BLOWFISH_BLOCK_LEN, blowfish_decrypt_block, NULL); if (rv == CRYPTO_DATA_LEN_RANGE) rv = CRYPTO_ENCRYPTED_DATA_LEN_RANGE; } return (rv); }