static void encrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes) { const unsigned int bsize = TF_BLOCK_SIZE; struct crypt_priv *ctx = priv; int i; ctx->fpu_enabled = twofish_fpu_begin(ctx->fpu_enabled, nbytes); while (nbytes >= TF_AVX2_PARALLEL_BLOCKS * bsize) { twofish_ecb_enc_16way(ctx->ctx, srcdst, srcdst); srcdst += bsize * TF_AVX2_PARALLEL_BLOCKS; nbytes -= bsize * TF_AVX2_PARALLEL_BLOCKS; } while (nbytes >= 8 * bsize) { twofish_ecb_enc_8way(ctx->ctx, srcdst, srcdst); srcdst += bsize * 8; nbytes -= bsize * 8; } while (nbytes >= 3 * bsize) { twofish_enc_blk_3way(ctx->ctx, srcdst, srcdst); srcdst += bsize * 3; nbytes -= bsize * 3; } for (i = 0; i < nbytes / bsize; i++, srcdst += bsize) twofish_enc_blk(ctx->ctx, srcdst, srcdst); }
static void encrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes) { const unsigned int bsize = TF_BLOCK_SIZE; struct crypt_priv *ctx = priv; int i; ctx->fpu_enabled = twofish_fpu_begin(ctx->fpu_enabled, nbytes); if (nbytes == bsize * TWOFISH_PARALLEL_BLOCKS) { twofish_ecb_enc_8way(ctx->ctx, srcdst, srcdst); return; } for (i = 0; i < nbytes / (bsize * 3); i++, srcdst += bsize * 3) twofish_enc_blk_3way(ctx->ctx, srcdst, srcdst); nbytes %= bsize * 3; for (i = 0; i < nbytes / bsize; i++, srcdst += bsize) twofish_enc_blk(ctx->ctx, srcdst, srcdst); }