示例#1
0
int sceDrmBBMacFinal(MAC_KEY *mkey, u8 *buf, u8 *vkey)
{
	int i, retv, code;
	u8 *kbuf, tmp[16], tmp1[16];
	u32 t0, v0, v1;

	if (mkey->pad_size > 16)
		return 0x80510302;

	code = (mkey->type == 2) ? 0x3A : 0x38;
	kbuf = kirk_buf + 0x14;

	memset(kbuf, 0, 16);
	retv = kirk4(kirk_buf, 16, code);
	
	if (retv)
		goto _exit;
	
	memcpy(tmp, kbuf, 16);

	t0 = (tmp[0] & 0x80) ? 0x87 : 0;
	for (i = 0; i < 15; i++)
	{
		v1 = tmp[i + 0];
		v0 = tmp[i + 1];
		v1 <<= 1;
		v0 >>= 7;
		v0 |= v1;
		tmp[i + 0] = v0;
	}
	v0 = tmp[15];
	v0 <<= 1;
	v0 ^= t0;
	tmp[15] = v0;

	if (mkey->pad_size < 16)
	{
		t0 = (tmp[0] & 0x80) ? 0x87 : 0;
		for (i = 0; i < 15; i++)
		{
			v1 = tmp[i + 0];
			v0 = tmp[i + 1];
			v1 <<= 1;
			v0 >>= 7;
			v0 |= v1;
			tmp[i + 0] = v0;
		}
		v0 = tmp[15];
		v0 <<= 1;
		v0 ^= t0;
		tmp[15] = v0;

		mkey->pad[mkey->pad_size] = 0x80;
		if (mkey->pad_size + 1 < 16)
			memset(mkey->pad + mkey->pad_size + 1, 0, 16 - mkey->pad_size - 1);
	}
示例#2
0
// Called by sceDrmBBMacUpdate
// encrypt_buf
static int sub_158(u8 *buf, int size, u8 *key, int key_type)
{
	int i, retv;

	for(i=0; i<16; i++){
		buf[0x14+i] ^= key[i];
	}

	retv = kirk4(buf, size, key_type);
	if(retv)
		return retv;

	// copy last 16 bytes to keys
	memcpy(key, buf+size+4, 16);

	return 0;
}
示例#3
0
/*
	Internal functions.
*/
static int encrypt_buf(u8 *buf, int size, u8 *key, int key_type)
{
	int i, retv;

	for (i = 0; i < 16; i++) {
		buf[0x14+i] ^= key[i];
	}

	retv = kirk4(buf, size, key_type);
	
	if (retv)
		return retv;

	memcpy(key, buf + size + 4, 16);

	return 0;
}