summaryrefslogtreecommitdiffstats
path: root/install.cpp
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2012-07-25 22:10:58 +0200
committerDoug Zongker <dougz@android.com>2012-07-25 22:10:58 +0200
commit17495277b1a6328f5cae68523ad00be1f1107950 (patch)
tree1f24ec32e8d3cb586c2514180eeff4a539f5d8df /install.cpp
parentam dd6cd4fc: Merge "graphics: add support for "single buffering"" (diff)
downloadandroid_bootable_recovery-17495277b1a6328f5cae68523ad00be1f1107950.tar
android_bootable_recovery-17495277b1a6328f5cae68523ad00be1f1107950.tar.gz
android_bootable_recovery-17495277b1a6328f5cae68523ad00be1f1107950.tar.bz2
android_bootable_recovery-17495277b1a6328f5cae68523ad00be1f1107950.tar.lz
android_bootable_recovery-17495277b1a6328f5cae68523ad00be1f1107950.tar.xz
android_bootable_recovery-17495277b1a6328f5cae68523ad00be1f1107950.tar.zst
android_bootable_recovery-17495277b1a6328f5cae68523ad00be1f1107950.zip
Diffstat (limited to '')
-rw-r--r--install.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/install.cpp b/install.cpp
index 4d73aa9b0..819650e1f 100644
--- a/install.cpp
+++ b/install.cpp
@@ -180,6 +180,12 @@ try_update_binary(const char *path, ZipArchive *zip, int* wipe_cache) {
//
// "{64,0xc926ad21,{1795090719,...,-695002876},{-857949815,...,1175080310}}"
//
+// For key versions newer than the original 2048-bit e=3 keys
+// supported by Android, the string is preceded by a version
+// identifier, eg:
+//
+// "v2 {64,0xc926ad21,{1795090719,...,-695002876},{-857949815,...,1175080310}}"
+//
// (Note that the braces and commas in this example are actual
// characters the parser expects to find in the file; the ellipses
// indicate more numbers omitted from this example.)
@@ -206,7 +212,23 @@ load_keys(const char* filename, int* numKeys) {
++*numKeys;
out = (RSAPublicKey*)realloc(out, *numKeys * sizeof(RSAPublicKey));
RSAPublicKey* key = out + (*numKeys - 1);
- if (fscanf(f, " { %i , 0x%x , { %u",
+
+ char start_char;
+ if (fscanf(f, " %c", &start_char) != 1) goto exit;
+ if (start_char == '{') {
+ // a version 1 key has no version specifier.
+ key->exponent = 3;
+ } else if (start_char == 'v') {
+ int version;
+ if (fscanf(f, "%d {", &version) != 1) goto exit;
+ if (version == 2) {
+ key->exponent = 65537;
+ } else {
+ goto exit;
+ }
+ }
+
+ if (fscanf(f, " %i , 0x%x , { %u",
&(key->len), &(key->n0inv), &(key->n[0])) != 3) {
goto exit;
}
@@ -237,6 +259,8 @@ load_keys(const char* filename, int* numKeys) {
LOGE("unexpected character between keys\n");
goto exit;
}
+
+ LOGI("read key e=%d\n", key->exponent);
}
}