Changeset View
Changeset View
Standalone View
Standalone View
libgcrypt-1.6.2/cipher/whirlpool.c
Context not available. | |||||
/* Number of rounds. */ | /* Number of rounds. */ | ||||
#define R 10 | #define R 10 | ||||
/* USE_AMD64_ASM indicates whether to use AMD64 assembly code. */ | |||||
#undef USE_AMD64_ASM | |||||
#if defined(__x86_64__) && defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) | |||||
# define USE_AMD64_ASM 1 | |||||
#endif | |||||
/* Types. */ | /* Types. */ | ||||
typedef u64 whirlpool_block_t[BLOCK_SIZE / 8]; | typedef u64 whirlpool_block_t[BLOCK_SIZE / 8]; | ||||
Context not available. | |||||
U64_C (0xf8c7f8933fed6bf8), U64_C (0x86228644a411c286), | U64_C (0xf8c7f8933fed6bf8), U64_C (0x86228644a411c286), | ||||
}; | }; | ||||
#ifdef USE_AMD64_ASM | |||||
/* Assembly implementation of Whirlpool */ | |||||
extern void _gcry_whirlpool_transform_amd64 | |||||
(unsigned char hash[BLOCK_SIZE], const unsigned char block[BLOCK_SIZE]); | |||||
static unsigned int | |||||
whirlpool_transform (void *ctx, const unsigned char *data) | |||||
{ | |||||
whirlpool_context_t *context = ctx; | |||||
_gcry_whirlpool_transform_amd64 (context->hash_state, data); | |||||
return 4 * sizeof(void*); | |||||
} | |||||
#else /*!USE_AMD64_ASM*/ | |||||
␌ | ␌ | ||||
/* | /* | ||||
* Transform block. | * Transform block. | ||||
Context not available. | |||||
return /*burn_stack*/ 4 * sizeof(whirlpool_block_t) + 2 * sizeof(int) + | return /*burn_stack*/ 4 * sizeof(whirlpool_block_t) + 2 * sizeof(int) + | ||||
4 * sizeof(void*); | 4 * sizeof(void*); | ||||
} | } | ||||
#endif /*!USE_AMD64_ASM*/ | |||||
static void | static void | ||||
whirlpool_init (void *ctx, unsigned int flags) | whirlpool_init (void *ctx, unsigned int flags) | ||||
Context not available. | |||||
context->bugemu.count += 32; | context->bugemu.count += 32; | ||||
whirlpool_add_bugemu (context, NULL, 0); | whirlpool_add_bugemu (context, NULL, 0); | ||||
#ifdef USE_AMD64_ASM | |||||
for (i = 0; i < 8; i++) \ | |||||
buf_put_le64((context->bctx.buf) + i * 8, (context->hash_state)[i]); | |||||
#else | |||||
block_to_buffer (context->bctx.buf, context->hash_state, i); | block_to_buffer (context->bctx.buf, context->hash_state, i); | ||||
#endif | |||||
} | } | ||||
Context not available. | |||||
context->bctx.count += 32; | context->bctx.count += 32; | ||||
whirlpool_write (context, NULL, 0); | whirlpool_write (context, NULL, 0); | ||||
#ifdef USE_AMD64_ASM | |||||
for (i = 0; i < 8; i++) \ | |||||
buf_put_le64((context->bctx.buf) + i * 8, (context->hash_state)[i]); | |||||
#else | |||||
block_to_buffer (context->bctx.buf, context->hash_state, i); | block_to_buffer (context->bctx.buf, context->hash_state, i); | ||||
#endif | |||||
} | } | ||||
static byte * | static byte * | ||||
Context not available. |