aboutsummaryrefslogtreecommitdiffstats
path: root/install.cpp
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2012-07-25 13:10:58 -0700
committerDoug Zongker <dougz@android.com>2012-07-25 13:10:58 -0700
commit17495277b1a6328f5cae68523ad00be1f1107950 (patch)
tree1f24ec32e8d3cb586c2514180eeff4a539f5d8df /install.cpp
parentaade2e590e17b0f47dbf554f7df5824ba4096212 (diff)
downloadbootable_recovery-17495277b1a6328f5cae68523ad00be1f1107950.zip
bootable_recovery-17495277b1a6328f5cae68523ad00be1f1107950.tar.gz
bootable_recovery-17495277b1a6328f5cae68523ad00be1f1107950.tar.bz2
support version 2 (2048-bit e=65537) keys in recovery
Change-Id: I9849c69777d513bb12926c8c622d1c12d2da568a
Diffstat (limited to 'install.cpp')
-rw-r--r--install.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/install.cpp b/install.cpp
index 4d73aa9..819650e 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);
}
}