static void twofish_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
{
	struct twofish_ctx *ctx = crypto_tfm_ctx(tfm);
	const __le32 *src = (const __le32 *)in;
	__le32 *dst = (__le32 *)out;

	/*                                     */
	u32 a, b, c, d;
	
	/*                                         */
	u32 x, y;

	/*                              */
	INPACK (0, a, 0);
	INPACK (1, b, 1);
	INPACK (2, c, 2);
	INPACK (3, d, 3);
	
	/*                            */
	ENCCYCLE (0);
	ENCCYCLE (1);
	ENCCYCLE (2);
	ENCCYCLE (3);
	ENCCYCLE (4);
	ENCCYCLE (5);
	ENCCYCLE (6);
	ENCCYCLE (7);
	
	/*                                 */
	OUTUNPACK (0, c, 4);
	OUTUNPACK (1, d, 5);
	OUTUNPACK (2, a, 6);
	OUTUNPACK (3, b, 7);
	
}
示例#2
0
void Twofish::encrypt(const byte* inBlock, const byte* xorBlock,
                  byte* outBlock) const
{
	word32 x, y, a, b, c, d;

	gpBlock::Get(inBlock)(a)(b)(c)(d);

	a ^= k_[0];
	b ^= k_[1];
	c ^= k_[2];
	d ^= k_[3];

	const word32 *k = k_+8;

	ENCCYCLE (0);
	ENCCYCLE (1);
	ENCCYCLE (2);
	ENCCYCLE (3);
	ENCCYCLE (4);
	ENCCYCLE (5);
	ENCCYCLE (6);
	ENCCYCLE (7);

	c ^= k_[4];
	d ^= k_[5];
	a ^= k_[6];
	b ^= k_[7]; 

	gpBlock::Put(xorBlock, outBlock)(c)(d)(a)(b);
}
示例#3
0
文件: twofish.c 项目: 274914765/C
/* Encrypt one block.  in and out may be the same. */
static void twofish_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
{
    struct twofish_ctx *ctx = crypto_tfm_ctx(tfm);
    const __le32 *src = (const __le32 *)in;
    __le32 *dst = (__le32 *)out;

    /* The four 32-bit chunks of the text. */
    u32 a, b, c, d;
    
    /* Temporaries used by the round function. */
    u32 x, y;

    /* Input whitening and packing. */
    INPACK (0, a, 0);
    INPACK (1, b, 1);
    INPACK (2, c, 2);
    INPACK (3, d, 3);
    
    /* Encryption Feistel cycles. */
    ENCCYCLE (0);
    ENCCYCLE (1);
    ENCCYCLE (2);
    ENCCYCLE (3);
    ENCCYCLE (4);
    ENCCYCLE (5);
    ENCCYCLE (6);
    ENCCYCLE (7);
    
    /* Output whitening and unpacking. */
    OUTUNPACK (0, c, 4);
    OUTUNPACK (1, d, 5);
    OUTUNPACK (2, a, 6);
    OUTUNPACK (3, b, 7);
    
}
示例#4
0
文件: twofish.c 项目: vonwenm/FreeVMS
static void
do_twofish_encrypt (const TWOFISH_context *ctx, byte *out, const byte *in)
{
  /* The four 32-bit chunks of the text. */
  u32 a, b, c, d;

  /* Temporaries used by the round function. */
  u32 x, y;

  /* Input whitening and packing. */
  INPACK (0, a, 0);
  INPACK (1, b, 1);
  INPACK (2, c, 2);
  INPACK (3, d, 3);

  /* Encryption Feistel cycles. */
  ENCCYCLE (0);
  ENCCYCLE (1);
  ENCCYCLE (2);
  ENCCYCLE (3);
  ENCCYCLE (4);
  ENCCYCLE (5);
  ENCCYCLE (6);
  ENCCYCLE (7);

  /* Output whitening and unpacking. */
  OUTUNPACK (0, c, 4);
  OUTUNPACK (1, d, 5);
  OUTUNPACK (2, a, 6);
  OUTUNPACK (3, b, 7);
}