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

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: 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
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 38629f90fd49f18b620cc269863cd2b3f7fb5787..2e3834dcb7f35c05cc25ff66c5607696163b088e 100644
--- a/content/child/webcrypto/shared_crypto_unittest.cc
+++ b/content/child/webcrypto/shared_crypto_unittest.cc
@@ -2626,33 +2626,38 @@ TEST_F(SharedCryptoTest, MAYBE(GenerateKeyPairRsa)) {
ExportKey(blink::WebCryptoKeyFormatSpki, private_key, &output));
}
-TEST_F(SharedCryptoTest, MAYBE(GenerateKeyPairRsaBadModulusLength)) {
- const unsigned int kBadModulus[] = {
+TEST_F(SharedCryptoTest, GenerateKeyPairRsaBadModulusLength) {
+ 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(
+ const Status expected_error =
+ modulus_length_bits == 0 ? Status::ErrorGenerateRsaZeroModulus()
Ryan Sleevi 2014/07/21 21:36:45 Why is this a special case? Just seems like it sho
eroman 2014/07/21 21:52:21 Done. Indeed, not sure why this was a separate er
+ : Status::ErrorGenerateRsaUnsupportedModulus();
+
+ EXPECT_EQ(
+ expected_error,
GenerateKeyPair(
- algorithm, extractable, usage_mask, &public_key, &private_key)
- .IsSuccess());
+ algorithm, extractable, usage_mask, &public_key, &private_key));
}
}

Powered by Google App Engine
This is Rietveld 408576698