Add additional sanity checks to RSA verification code.

Also, make algorithm unsigned int in most places.

BUG=chrome-os-partner:701
TEST=existing RSA verification tests still pass

Review URL: http://codereview.chromium.org/3136017
This commit is contained in:
Gaurav Shah
2010-08-17 15:48:22 -07:00
parent 138acfe1ba
commit 47b593d849
10 changed files with 61 additions and 37 deletions

View File

@@ -114,12 +114,14 @@ int PublicKeyCopy(VbPublicKey* dest, const VbPublicKey* src) {
RSAPublicKey* PublicKeyToRSA(const VbPublicKey* key) {
RSAPublicKey *rsa;
int key_size;
if (kNumAlgorithms <= key->algorithm) {
VBDEBUG(("Invalid algorithm.\n"));
return NULL;
}
if (RSAProcessedKeySize((int)key->algorithm) != (int)key->key_size) {
if (!RSAProcessedKeySize((int)key->algorithm, &key_size) ||
key_size != (int)key->key_size) {
VBDEBUG(("Wrong key size for algorithm\n"));
return NULL;
}