Skip to content

Commit

Permalink
Don't sign extensions with an unsupported/invalid private key
Browse files Browse the repository at this point in the history
BUG=125997
TEST=manually test with unsupported/invalid key


Review URL: http://codereview.chromium.org/10370002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135292 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
rsleevi@chromium.org committed May 4, 2012
1 parent cd06427 commit b163bc1
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions crypto/rsa_private_key_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,18 @@ RSAPrivateKey* RSAPrivateKey::CreateFromPrivateKeyInfo(
return NULL;

PrivateKeyInfoCodec pki(false); // Little-Endian
pki.Import(input);

int blob_size = sizeof(PUBLICKEYSTRUC) +
sizeof(RSAPUBKEY) +
pki.modulus()->size() +
pki.prime1()->size() +
pki.prime2()->size() +
pki.exponent1()->size() +
pki.exponent2()->size() +
pki.coefficient()->size() +
pki.private_exponent()->size();
if (!pki.Import(input))
return NULL;

size_t blob_size = sizeof(PUBLICKEYSTRUC) +
sizeof(RSAPUBKEY) +
pki.modulus()->size() +
pki.prime1()->size() +
pki.prime2()->size() +
pki.exponent1()->size() +
pki.exponent2()->size() +
pki.coefficient()->size() +
pki.private_exponent()->size();
scoped_array<BYTE> blob(new BYTE[blob_size]);

uint8* dest = blob.get();
Expand Down Expand Up @@ -98,9 +99,11 @@ RSAPrivateKey* RSAPrivateKey::CreateFromPrivateKeyInfo(
return NULL;
}
if (!CryptImportKey(result->provider_,
reinterpret_cast<uint8*>(public_key_struc), blob_size, 0,
CRYPT_EXPORTABLE, result->key_.receive()))
reinterpret_cast<uint8*>(public_key_struc),
static_cast<DWORD>(blob_size), 0, CRYPT_EXPORTABLE,
result->key_.receive())) {
return NULL;
}

return result.release();
}
Expand Down

0 comments on commit b163bc1

Please sign in to comment.