diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-04 04:11:42 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-04 04:11:42 +0000 |
commit | b163bc18a6ee9a7f3f0b1c90977894bbbb1c99e0 (patch) | |
tree | 4c46b0178f60678df7933d6397a482730af121ea /crypto | |
parent | cd06427f46c00392361c28b773b4a73ccae1b073 (diff) | |
download | chromium_src-b163bc18a6ee9a7f3f0b1c90977894bbbb1c99e0.zip chromium_src-b163bc18a6ee9a7f3f0b1c90977894bbbb1c99e0.tar.gz chromium_src-b163bc18a6ee9a7f3f0b1c90977894bbbb1c99e0.tar.bz2 |
Don't sign extensions with an unsupported/invalid private key
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
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/rsa_private_key_win.cc | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/crypto/rsa_private_key_win.cc b/crypto/rsa_private_key_win.cc index 546a303..f870f6a 100644 --- a/crypto/rsa_private_key_win.cc +++ b/crypto/rsa_private_key_win.cc @@ -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(); @@ -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(); } |