Exemplo n.º 1
0
int main(int argc, char *argv[])
{
	if (argc != 2)
		fail("usage: sceverify filename");

	ptr = mmap_file(argv[1]);

	type = be16(ptr + 0x0a);

	if (type == 1)
		read_self_header();
	else if(type == 3)
		read_pkg_header();
	else if(type == 4)
		read_spp_header();
	else
		fail("Unknown type: %d", type);

	if (flags & 0x8000)
		fail("devkit file; nothing to verify");

	if (klist == NULL)
		fail("no key found");

	decrypt();
	verify_signature();
	verify_hashes();

	if (did_fail)
		printf(" * please not that the hash will always fail for "
		       "unaligned non-LOAD phdrs\n");
	return 0;
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
	if (argc != 3)
		fail("usage: scesekrit signedfile1 signedfile2");

	ptr1 = mmap_file(argv[1]);
	ptr2 = mmap_file(argv[2]);

	type = be16(ptr1 + 0x0a);
	if (type != be16(ptr2 + 0x0a))
		fail("Files must be the same type");
	
	if (type == 1) {
		read_self_header(ptr1, &info1);
	} else if(type == 3) {
		read_pkg_header(ptr1, &info1);
	} else
		fail("Unknown type: %d", type);

	if ((info1.flags) & 0x8000)
		fail("devkit file; nothing to verify");

	if (klist == NULL)
		fail("no key found");

	decrypt(ptr1);
	
	if (type == 1) {
		read_self_header(ptr2, &info2);
	} else if(type == 3) {
		read_pkg_header(ptr2, &info2);
	} else
		fail("Unknown type: %d", type);

	if ((info2.flags) & 0x8000)
		fail("devkit file; nothing to verify");

	if (klist == NULL)
		fail("no key found");

	decrypt(ptr2);

	u8* s1;
	u8* s2;
	u8 z1[21];
	u8 z2[21];
	u8* r1;
	u8* r2;
	u8 ec[21];
	u8 n[21];
	z1[0] = 0;
	z2[0] = 0;
	
	ecdsa_get_params(klist->keys[keyid].ctype, ec, ec, ec, n, ec, ec);

	printf("%s ", argv[1]);
	verify_signature(ptr1, &info1, z1 + 1, &s1, &r1);
	printf("%s ", argv[2]);
	verify_signature(ptr2, &info2, z2 + 1, &s2, &r2);

	if (memcmp(r1, r2, 21))
		fail("Both files must share the same r signature value.");

	const char* dA = calculate_private_key(s1, s2, z1, z2, n, r1);

	int len = strlen(dA);
	int i;
	printf("Private Key: ");
	for (i = len / 2; i < 21; i++)
		printf("00");
	printf("%s\n", dA);

	return 0;
}