/* Macros to compute the g() function in the encryption and decryption *rounds.G1isthestraightg()function;G2includesthe8-bit
* rotation for the high 32-bit word. */
/* Encryption and decryption Feistel rounds. Each one calls the two g() *macros,doesthePHT,andperformstheXORandtheappropriatebit *rotations.Theparametersaretheroundnumber(usedtoselectsubkeys),
* and the four 32-bit chunks of the text. */
#define ENCROUND(n, a, b, c, d) \
x = G1 (a); y = G2 (b); \
x += y; y += x + ctx->k[2 * (n) + 1]; \
(c) ^= x + ctx->k[2 * (n)]; \
(c) = ror32((c), 1); \
(d) = rol32((d), 1) ^ y
#define DECROUND(n, a, b, c, d) \
x = G1 (a); y = G2 (b); \
x += y; y += x; \
(d) ^= y + ctx->k[2 * (n) + 1]; \
(d) = ror32((d), 1); \
(c) = rol32((c), 1); \
(c) ^= (x + ctx->k[2 * (n)])
/* Encryption and decryption cycles; each one is simply two Feistel rounds
* with the 32-bit chunks re-ordered to simulate the "swap" */
#define ENCCYCLE(n) \
ENCROUND (2 * (n), a, b, c, d); \
ENCROUND (2 * (n) + 1, c, d, a, b)
/* Macros to convert the input and output bytes into 32-bit words, *andsimultaneouslyperformthewhiteningstep.INPACKpacksword *numbernintothevariablenamedbyx,usingwhiteningsubkeynumberm. *OUTUNPACKunpackswordnumbernfromthevariablenamedbyx,using
* whitening subkey number m. */
#define INPACK(n, x, m) \
x = get_unaligned_le32(in + (n) * 4) ^ ctx->w[m]
#define OUTUNPACK(n, x, m) \
x ^= ctx->w[m]; \
put_unaligned_le32(x, out + (n) * 4)
/* Encrypt one block. in and out may be the same. */ staticvoid twofish_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
{ struct twofish_ctx *ctx = crypto_tfm_ctx(tfm);
/* The four 32-bit chunks of the text. */
u32 a, b, c, d;
/* Temporaries used by the round function. */
u32 x, y;
/* Decrypt one block. in and out may be the same. */ staticvoid twofish_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
{ struct twofish_ctx *ctx = crypto_tfm_ctx(tfm);
/* The four 32-bit chunks of the text. */
u32 a, b, c, d;
/* Temporaries used by the round function. */
u32 x, y;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.