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
(cherry picked from commit 515e1639ef0ab5e3149fafeffce826cf654d616f)
Change-Id: Ib35643b3d864742e817ac6e725499b451e45afcf
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;