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

Unified Diff: content/child/webcrypto/test/aes_cbc_unittest.cc

Issue 512023002: Refactor the interface for generating keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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/test/aes_cbc_unittest.cc
diff --git a/content/child/webcrypto/test/aes_cbc_unittest.cc b/content/child/webcrypto/test/aes_cbc_unittest.cc
index a0112c09f609bb0e4fdd3dd7dc2421bd3baf2610..30080772b718860a8e53d9ee0cb4297ba8cfaff1 100644
--- a/content/child/webcrypto/test/aes_cbc_unittest.cc
+++ b/content/child/webcrypto/test/aes_cbc_unittest.cc
@@ -261,12 +261,13 @@ TEST(WebCryptoAesCbcTest, GenerateKeyIsRandom) {
// Generate a small sample of keys.
for (int j = 0; j < 16; ++j) {
- ASSERT_EQ(Status::Success(),
- GenerateSecretKey(
- CreateAesCbcKeyGenAlgorithm(kKeyLength[key_length_i]),
- true,
- 0,
- &key));
+ ASSERT_EQ(
+ Status::Success(),
+ GenerateKey(CreateAesCbcKeyGenAlgorithm(kKeyLength[key_length_i]),
+ true,
+ 0,
+ NULL,
+ &key));
EXPECT_TRUE(key.handle());
EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type());
ASSERT_EQ(Status::Success(),
@@ -286,9 +287,10 @@ TEST(WebCryptoAesCbcTest, GenerateKeyBadLength) {
blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kKeyLen); ++i) {
SCOPED_TRACE(i);
- EXPECT_EQ(Status::ErrorGenerateKeyLength(),
- GenerateSecretKey(
- CreateAesCbcKeyGenAlgorithm(kKeyLen[i]), true, 0, &key));
+ EXPECT_EQ(
+ Status::ErrorGenerateKeyLength(),
+ GenerateKey(
+ CreateAesCbcKeyGenAlgorithm(kKeyLen[i]), true, 0, NULL, &key));
}
}
@@ -841,10 +843,11 @@ TEST(WebCryptoAesCbcTest, ImportAesCbc192Jwk) {
// AES 192-bit is not allowed: http://crbug.com/381829
TEST(WebCryptoAesCbcTest, GenerateAesCbc192) {
blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
- Status status = GenerateSecretKey(CreateAesCbcKeyGenAlgorithm(192),
- true,
- blink::WebCryptoKeyUsageEncrypt,
- &key);
+ Status status = GenerateKey(CreateAesCbcKeyGenAlgorithm(192),
+ true,
+ blink::WebCryptoKeyUsageEncrypt,
+ NULL,
+ &key);
ASSERT_EQ(Status::ErrorAes192BitUnsupported(), status);
}
@@ -914,9 +917,10 @@ TEST(WebCryptoAesCbcTest, GenerateKeyBadUsages) {
blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
- ASSERT_EQ(Status::ErrorCreateKeyBadUsages(),
- GenerateSecretKey(
- CreateAesCbcKeyGenAlgorithm(128), true, bad_usages[i], &key));
+ ASSERT_EQ(
+ Status::ErrorCreateKeyBadUsages(),
+ GenerateKey(
+ CreateAesCbcKeyGenAlgorithm(128), true, bad_usages[i], NULL, &key));
}
}
@@ -930,11 +934,12 @@ TEST(WebCryptoAesCbcTest, WrapUnwrapRoundtripSpkiPkcs8) {
// Generate the wrapping key.
blink::WebCryptoKey wrapping_key = blink::WebCryptoKey::createNull();
ASSERT_EQ(Status::Success(),
- GenerateSecretKey(CreateAesCbcKeyGenAlgorithm(128),
- true,
- blink::WebCryptoKeyUsageWrapKey |
- blink::WebCryptoKeyUsageUnwrapKey,
- &wrapping_key));
+ GenerateKey(CreateAesCbcKeyGenAlgorithm(128),
+ true,
+ blink::WebCryptoKeyUsageWrapKey |
+ blink::WebCryptoKeyUsageUnwrapKey,
+ NULL,
+ &wrapping_key));
// Generate an RSA key pair to be wrapped.
const unsigned int modulus_length = 256;
@@ -943,15 +948,15 @@ TEST(WebCryptoAesCbcTest, WrapUnwrapRoundtripSpkiPkcs8) {
blink::WebCryptoKey public_key = blink::WebCryptoKey::createNull();
blink::WebCryptoKey private_key = blink::WebCryptoKey::createNull();
ASSERT_EQ(Status::Success(),
- GenerateKeyPair(CreateRsaHashedKeyGenAlgorithm(
- blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
- blink::WebCryptoAlgorithmIdSha256,
- modulus_length,
- public_exponent),
- true,
- 0,
- &public_key,
- &private_key));
+ GenerateKey(CreateRsaHashedKeyGenAlgorithm(
+ blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
+ blink::WebCryptoAlgorithmIdSha256,
+ modulus_length,
+ public_exponent),
+ true,
+ 0,
+ &public_key,
+ &private_key));
// Export key pair as SPKI + PKCS8
std::vector<uint8_t> public_key_spki;

Powered by Google App Engine
This is Rietveld 408576698