[G1 Android Development] SirGe:
I am trying to find a way to re-load my G1 with signed-kila-ota-115247-prereq.TC4-RC19_RC28.zip, which was the last full update, since I lost root access with RC30 OTA.

It bombs by blowing the assert, that verifies the current version at the first line of update-script. I removed the assert line and then fixed up the SHA1 digests for the script in the manifest and for the manifest entry and the whole manifest file in CERT.SF. This ends up complaining about 376 missing checksums.

As far as I can verify, the checksums are correct (based on repeating the process with unmodified files), so there must be something, that verifies CERT.SF in CERT.RSA. As far as I can tell by dumping the CERT.RSA file, it has a bunch of keys belonging to HTC (or at least with references to HTC) and probably a signature for CERT.SF. The stuff in CERT.RSA can be had by reading the code... Given that google, android, t-mobile, or anything like that does not show up, I would suspect the keys belong to HTC, so the code probably goes from google android team to htc to be signed and then gets handed to t-mobile. Seems like this would keep the keys under the lid to some degree.

But if security for CERT.SF is enforced using an HMAC, then all we need is to find the key, since MAC algorithms (unlike public-key sigs) use the same key for producing and verifying the MAC. neoobs, what makes you think that HMACs are used here? I would expect just a plain vanilla RSA sig for CERT.CF, which seems pretty secure.

If you are not following the above, but want to:

- update.zip, which you can boot from the sdcard, is similar to a jar file. Google JAR file format for background. It contains a bunch of files to be processed plus a META-INF directory, which provides the installation security and a bootstrap.

- the bootstrap is in META-INF/com/google/android/update-script; this is a script in some simple script/shell-like language, pretty readable. In it's first line it tries to verify the currently installed Android release, as returned by the getprop function (a corresponding shell command is available in the Android shell).

- security is provided by three files in META-INF: MANIFEST.MF, CERT.SF and CERT.RSA. The first two are text files, very readable.

- manifest is a list of every file in the zip, except these three. For each file there is a complete path and a SHA1 digest in base64. SHA1 is a strong hash, NOT a signature. Google cryptographic hashes and digital signatures and SHA1 for info. Basically, it's a checksum, that cannot be faked (you cannot make up a file with a given checksum). On a unix box (or cygwin) there is an sha1sum command, that will generate these from any input. I am sure there are programs, that will produce this stuff in base64 encoding, but I was too lazy to look. This works:

$ <data-to-hash> | sha1sum - | perl -MMIME::Base64 -lpe 's/(\S+).*/encode_base64(pack("H*",$1))/e'

- CERT.SF is a signature file for the manifest. It has an SHA1 digest for the whole manifest as well as one for each entry in the manifest file. Instead of the digest for the file content, this file contains digests for the three-line entry in the manifest file (including a blank line) corresponding to each file in the update.

- CERT.RSA appears to be a file for verifying integrity of CERT.SF and possibly other pieces. Still working on this.

Hope this helps.

Any other suggestions for steps forward?