mincrypt: support SHA-256 hash algorithm
- adds a library to compute the SHA-256 hash
- updates the RSA verifier to take an argument specifying either SHA-1
or SHA-256
- updates DumpPublicKey to with new "key" version numbers for
specifying SHA-256
- adds new argument to adb auth code to maintain existing behavior
Change-Id: I5b1406cf57c2b8993f6032eda3e29139f7740839
diff --git a/libmincrypt/rsa.c b/libmincrypt/rsa.c
index b4ee6af..0cdbaa2 100644
--- a/libmincrypt/rsa.c
+++ b/libmincrypt/rsa.c
@@ -30,23 +30,26 @@
int RSA_e_f4_verify(const RSAPublicKey* key,
const uint8_t* signature,
const int len,
- const uint8_t* sha);
+ const uint8_t* hash,
+ const int hash_len);
int RSA_e_3_verify(const RSAPublicKey *key,
const uint8_t *signature,
const int len,
- const uint8_t *sha);
+ const uint8_t *hash,
+ const int hash_len);
int RSA_verify(const RSAPublicKey *key,
const uint8_t *signature,
const int len,
- const uint8_t *sha) {
+ const uint8_t *hash,
+ const int hash_len) {
switch (key->exponent) {
case 3:
- return RSA_e_3_verify(key, signature, len, sha);
+ return RSA_e_3_verify(key, signature, len, hash, hash_len);
break;
case 65537:
- return RSA_e_f4_verify(key, signature, len, sha);
+ return RSA_e_f4_verify(key, signature, len, hash, hash_len);
break;
default:
return 0;