summaryrefslogtreecommitdiffstats
path: root/install.cpp
diff options
context:
space:
mode:
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 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);
}
}