Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1629)

Unified Diff: content/child/webcrypto/shared_crypto_unittest.cc

Issue 401233004: Refactor RSA key generation for WebCrypto's NSS implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad merge Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/child/webcrypto/nss/rsa_key_nss.cc ('k') | content/child/webcrypto/status.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webcrypto/shared_crypto_unittest.cc
diff --git a/content/child/webcrypto/shared_crypto_unittest.cc b/content/child/webcrypto/shared_crypto_unittest.cc
index 72ba121c66d15fe9d0a4f12831deeb7aba61814f..ad01f4e1ecce1c874df19e99173ffa0d79d2d45b 100644
--- a/content/child/webcrypto/shared_crypto_unittest.cc
+++ b/content/child/webcrypto/shared_crypto_unittest.cc
@@ -2524,7 +2524,7 @@ TEST_F(SharedCryptoTest, MAYBE(GenerateKeyPairRsa)) {
blink::WebCryptoAlgorithmIdSha256,
0,
public_exponent);
- EXPECT_EQ(Status::ErrorGenerateRsaZeroModulus(),
+ EXPECT_EQ(Status::ErrorGenerateRsaUnsupportedModulus(),
GenerateKeyPair(
algorithm, extractable, usage_mask, &public_key, &private_key));
@@ -2627,32 +2627,33 @@ TEST_F(SharedCryptoTest, MAYBE(GenerateKeyPairRsa)) {
}
TEST_F(SharedCryptoTest, MAYBE(GenerateKeyPairRsaBadModulusLength)) {
- const unsigned int kBadModulus[] = {
+ const unsigned int kBadModulusBits[] = {
0,
- 255, // Not a multiple of 8.
+ 248, // Too small.
+ 257, // Not a multiple of 8.
1023, // Not a multiple of 8.
- 0xFFFFFFFF, // Cannot fit in a signed int.
+ 0xFFFFFFFF, // Too big.
16384 + 8, // 16384 is the maxmimum length that NSS succeeds for.
};
const std::vector<uint8_t> public_exponent = HexStringToBytes("010001");
- for (size_t i = 0; i < arraysize(kBadModulus); ++i) {
- const unsigned int modulus_length = kBadModulus[i];
+ for (size_t i = 0; i < arraysize(kBadModulusBits); ++i) {
+ const unsigned int modulus_length_bits = kBadModulusBits[i];
blink::WebCryptoAlgorithm algorithm = CreateRsaHashedKeyGenAlgorithm(
blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
blink::WebCryptoAlgorithmIdSha256,
- modulus_length,
+ modulus_length_bits,
public_exponent);
bool extractable = true;
const blink::WebCryptoKeyUsageMask usage_mask = 0;
blink::WebCryptoKey public_key = blink::WebCryptoKey::createNull();
blink::WebCryptoKey private_key = blink::WebCryptoKey::createNull();
- EXPECT_FALSE(
+ EXPECT_EQ(
+ Status::ErrorGenerateRsaUnsupportedModulus(),
GenerateKeyPair(
- algorithm, extractable, usage_mask, &public_key, &private_key)
- .IsSuccess());
+ algorithm, extractable, usage_mask, &public_key, &private_key));
}
}
« no previous file with comments | « content/child/webcrypto/nss/rsa_key_nss.cc ('k') | content/child/webcrypto/status.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698