Exemplo n.º 1
0
static int
cast5_setkey(u_int8_t **sched, u_int8_t *key, int len)
{
	int err;

	*sched = malloc(sizeof(cast_key), M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
	if (*sched != NULL) {
		cast_setkey((cast_key *)*sched, key, len);
		err = 0;
	} else
		err = ENOMEM;
	return err;
}
Exemplo n.º 2
0
// CAST
static dword
func8(dword aKey)
{
	static cast_key CASTKey;
	static bool CASTInited = false;
	byte Key[16] = {
		0x40, 0xF2, 0x41, 0xB2, 0x69, 0xF6, 0xF1, 0xAF,
		0x63, 0xF4, 0x5E, 0xFF, 0x0E, 0x1C, 0x11, 0x9B
	};
	if(!CASTInited)
	{
		cast_setkey(&CASTKey, Key, 16);
		CASTInited = true;
	}
	byte inBlock[8] = {0, 0, 0, 0, 0, 0, 0, 0};
	byte outBlock[8] = {0, 0, 0, 0, 0, 0, 0, 0};
	*(dword*)(inBlock) = aKey;
	cast_decrypt(&CASTKey, inBlock, outBlock);
	return *(dword*)(outBlock);
}