[G1 Android Development] Sidonuke:
/* Find a /META-INF/xxx.SF signature file signed by a matching xxx.RSA file. */
static const ZipEntry *verifySignature(const ZipArchive *pArchive,
const RSAPublicKey *pKeys, unsigned int numKeys) {
static const char prefix[] = "META-INF/";
static const char rsa[] = ".RSA", sf[] = ".SF";

unsigned int i, j;
for (i = 0; i < mzZipEntryCount(pArchive); ++i) {
const ZipEntry *rsaEntry = mzGetZipEntryAt(pArchive, i);
UnterminatedString rsaName = mzGetZipEntryFileName(rsaEntry);
int rsaLen = mzGetZipEntryUncompLen(rsaEntry);
if (rsaLen >= RSANUMBYTES && rsaName.len > sizeof(prefix) &&
!strncmp(rsaName.str, prefix, sizeof(prefix) - 1) &&
!strncmp(rsaName.str + rsaName.len - sizeof(rsa) + 1,
rsa, sizeof(rsa) - 1)) {
char *sfName = malloc(rsaName.len - sizeof(rsa) + sizeof(sf) + 1);
if (sfName == NULL) {
LOGE("Can't allocate %d bytes for filename\n", rsaName.len);
continue;
}

/* Replace .RSA with .SF */
strncpy(sfName, rsaName.str, rsaName.len - sizeof(rsa) + 1);
strcpy(sfName + rsaName.len - sizeof(rsa) + 1, sf);
const ZipEntry *sfEntry = mzFindZipEntry(pArchive, sfName);
free(sfName);

if (sfEntry == NULL) {
LOGW("Missing signature file %s\n", sfName);
continue;
}

uint8_t sfDigest[SHA_DIGEST_SIZE];
if (!digestEntry(pArchive, sfEntry, NULL, 0, sfDigest)) continue;

char *rsaBuf = slurpEntry(pArchive, rsaEntry);
if (rsaBuf == NULL) continue;

/* Try to verify the signature with all the keys. */
uint8_t *sig = (uint8_t *) rsaBuf + rsaLen - RSANUMBYTES;
for (j = 0; j < numKeys; ++j) {
if (RSA_verify(&pKeys[j], sig, RSANUMBYTES, sfDigest)) {
free(rsaBuf);
LOGI("Verified %.*s\n", rsaName.len, rsaName.str);
return sfEntry;
}
}

free(rsaBuf);
LOGW("Can't verify %.*s\n", rsaName.len, rsaName.str);
}
}

LOGE("No signature (%d files)\n", mzZipEntryCount(pArchive));
return NULL;
}

verifier.c

http://android.git.kernel.org/?p=pl...c;hb=23580ca27a0a8109312fdd36cc363ad1f4719889

Now if we look at this part of the code

/* Try to verify the signature with all the keys. */
uint8_t *sig = (uint8_t *) rsaBuf + rsaLen - RSANUMBYTES;
for (j = 0; j < numKeys; ++j) {
if (RSA_verify(&pKeys[j], sig, RSANUMBYTES, sfDigest)) {
free(rsaBuf);
LOGI("Verified %.*s\n", rsaName.len, rsaName.str);
return sfEntry;
}
}

free(rsaBuf);
LOGW("Can't verify %.*s\n", rsaName.len, rsaName.str);

It takes all the public keys it has

pKeys

And Verifies it with the signature

sig

With the numb of bytes

RSANUMBYTES

And this

sfDigest

A simple If(RSA_verify()) == False == LOGW("Can't verify %.*s\n", rsaName.len, rsaName.str);

GG

Yeah this part is the current snag in our breaking of the verifySignature

And it seems pretty rock solid in terms of its security. Goodluck devs

EDIT:

http://android.git.kernel.org/?p=platform/recovery.git;a=blob_plain;f=install.c;hb=HEAD

/* List of public keys */
static const RSAPublicKey keys[] = {
#include "keys.inc"
};

if (!verify_jar_signature(zip, keys, sizeof(keys) / sizeof(keys[0]))) {
LOGE("Verification failed\n");
return INSTALL_CORRUPT;
}

So it loads up keys.inc which is basicly the keys within the binarys for the recovery system are loaded and used for comparing. Hex editing the recovery binarys would allow for a very nice back door to getting anything we want on the system

Or... we can compile our own binarys with no verifyer and have them loaded on.