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

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

Issue 243433006: [webcrypto] Set the error type for failures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 815c9c2050776c12eabaa076da3e1865b6ebd706..b1d886b4393b470b84ce313ac813f325a0886db2 100644
--- a/content/child/webcrypto/shared_crypto_unittest.cc
+++ b/content/child/webcrypto/shared_crypto_unittest.cc
@@ -479,7 +479,7 @@ Status AesGcmEncrypt(const blink::WebCryptoKey& key,
if (output.byteLength() * 8 < tag_length_bits) {
EXPECT_TRUE(false);
- return Status::Error();
+ return Status::OperationError();
}
// The encryption result is cipher text with authentication tag appended.
@@ -684,7 +684,7 @@ TEST_F(SharedCryptoTest, CheckAesGcm) {
TEST_F(SharedCryptoTest, StatusToString) {
EXPECT_EQ("Success", Status::Success().ToString());
- EXPECT_EQ("", Status::Error().ToString());
+ EXPECT_EQ("", Status::OperationError().ToString());
EXPECT_EQ("The requested operation is unsupported",
Status::ErrorUnsupported().ToString());
EXPECT_EQ("The required JWK property \"kty\" was missing",
@@ -902,7 +902,7 @@ TEST_F(SharedCryptoTest, AesCbcFailures) {
std::vector<uint8> iv(16);
blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
- EXPECT_STATUS(Status::Error(),
+ EXPECT_STATUS(Status::ErrorImportAesKeyLength(),
ImportKey(blink::WebCryptoKeyFormatRaw,
CryptoData(key_raw),
CreateAesCbcAlgorithm(iv),
@@ -972,7 +972,7 @@ TEST_F(SharedCryptoTest, MAYBE(AesCbcSampleSets)) {
// up testing decryption over empty cipher text.
if (test_cipher_text.size() >= kAesCbcBlockSize) {
EXPECT_STATUS(
- Status::Error(),
+ Status::OperationError(),
Decrypt(CreateAesCbcAlgorithm(test_iv),
key,
CryptoData(&test_cipher_text[0],
@@ -984,7 +984,7 @@ TEST_F(SharedCryptoTest, MAYBE(AesCbcSampleSets)) {
// a few bytes off the cipher text.
if (test_cipher_text.size() > 3) {
EXPECT_STATUS(
- Status::Error(),
+ Status::OperationError(),
Decrypt(CreateAesCbcAlgorithm(test_iv),
key,
CryptoData(&test_cipher_text[0], test_cipher_text.size() - 3),
@@ -1822,7 +1822,7 @@ TEST_F(SharedCryptoTest, MAYBE(ImportExportSpki)) {
// Failing case: Bad DER encoding.
EXPECT_STATUS(
- Status::Error(),
+ Status::OperationError(),
ImportKey(blink::WebCryptoKeyFormatSpki,
CryptoData(HexStringToBytes("618333c4cb")),
CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5),
@@ -1831,7 +1831,7 @@ TEST_F(SharedCryptoTest, MAYBE(ImportExportSpki)) {
&key));
// Failing case: Import RSA key but provide an inconsistent input algorithm.
- EXPECT_STATUS(Status::Error(),
+ EXPECT_STATUS(Status::OperationError(),
ImportKey(blink::WebCryptoKeyFormatSpki,
CryptoData(HexStringToBytes(kPublicKeySpkiDerHex)),
CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc),
@@ -1905,7 +1905,7 @@ TEST_F(SharedCryptoTest, MAYBE(ImportExportPkcs8)) {
// Failing case: Bad DER encoding.
EXPECT_STATUS(
- Status::Error(),
+ Status::OperationError(),
ImportKey(blink::WebCryptoKeyFormatPkcs8,
CryptoData(HexStringToBytes("618333c4cb")),
CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5),
@@ -1914,7 +1914,7 @@ TEST_F(SharedCryptoTest, MAYBE(ImportExportPkcs8)) {
&key));
// Failing case: Import RSA key but provide an inconsistent input algorithm.
- EXPECT_STATUS(Status::Error(),
+ EXPECT_STATUS(Status::OperationError(),
ImportKey(blink::WebCryptoKeyFormatPkcs8,
CryptoData(HexStringToBytes(kPrivateKeyPkcs8DerHex)),
CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc),
@@ -2229,7 +2229,7 @@ TEST_F(SharedCryptoTest, MAYBE(RsaEsFailures)) {
algorithm, private_key, CryptoData(message_hex), &encrypted_data));
// Fail encrypt with empty message.
- EXPECT_STATUS(Status::Error(),
+ EXPECT_STATUS(Status::ErrorDataTooSmall(),
Encrypt(algorithm,
public_key,
CryptoData(std::vector<uint8>()),
@@ -2263,7 +2263,7 @@ TEST_F(SharedCryptoTest, MAYBE(RsaEsFailures)) {
static_cast<uint8*>(encrypted_data.data()) + encrypted_data.byteLength());
corrupted_data[corrupted_data.size() / 2] ^= 0x01;
EXPECT_STATUS(
- Status::Error(),
+ Status::OperationError(),
Decrypt(
algorithm, private_key, CryptoData(corrupted_data), &decrypted_data));
@@ -2507,7 +2507,7 @@ TEST_F(SharedCryptoTest, MAYBE(AesKwKeyImport)) {
ExpectArrayBufferMatchesHex(key_raw_hex_in, key_raw_out);
// Fail import of 0 length key
- EXPECT_STATUS(Status::Error(),
+ EXPECT_STATUS(Status::ErrorImportAesKeyLength(),
ImportKey(blink::WebCryptoKeyFormatRaw,
CryptoData(HexStringToBytes("")),
algorithm,
@@ -2517,7 +2517,7 @@ TEST_F(SharedCryptoTest, MAYBE(AesKwKeyImport)) {
// Fail import of 124-bit KEK
key_raw_hex_in = "3e4566a2bdaa10cb68134fa66c15ddb";
- EXPECT_STATUS(Status::Error(),
+ EXPECT_STATUS(Status::ErrorImportAesKeyLength(),
ImportKey(blink::WebCryptoKeyFormatRaw,
CryptoData(HexStringToBytes(key_raw_hex_in)),
algorithm,
@@ -2527,7 +2527,7 @@ TEST_F(SharedCryptoTest, MAYBE(AesKwKeyImport)) {
// Fail import of 200-bit KEK
key_raw_hex_in = "0a1d88608a5ad9fec64f1ada269ebab4baa2feeb8d95638c0e";
- EXPECT_STATUS(Status::Error(),
+ EXPECT_STATUS(Status::ErrorImportAesKeyLength(),
ImportKey(blink::WebCryptoKeyFormatRaw,
CryptoData(HexStringToBytes(key_raw_hex_in)),
algorithm,
@@ -2538,7 +2538,7 @@ TEST_F(SharedCryptoTest, MAYBE(AesKwKeyImport)) {
// Fail import of 260-bit KEK
key_raw_hex_in =
"72d4e475ff34215416c9ad9c8281247a4d730c5f275ac23f376e73e3bce8d7d5a";
- EXPECT_STATUS(Status::Error(),
+ EXPECT_STATUS(Status::ErrorImportAesKeyLength(),
ImportKey(blink::WebCryptoKeyFormatRaw,
CryptoData(HexStringToBytes(key_raw_hex_in)),
algorithm,
@@ -2732,7 +2732,7 @@ TEST_F(SharedCryptoTest, MAYBE(AesKwRawSymkeyUnwrapCorruptData)) {
// AES-KW's built-in integrity check.
blink::WebCryptoKey unwrapped_key = blink::WebCryptoKey::createNull();
EXPECT_STATUS(
- Status::Error(),
+ Status::OperationError(),
UnwrapKey(blink::WebCryptoKeyFormatRaw,
CryptoData(Corrupted(test_ciphertext)),
wrapping_key,
@@ -2867,7 +2867,7 @@ TEST_F(SharedCryptoTest, MAYBE(AesGcmSampleSets)) {
EXPECT_TRUE(ArrayBufferMatches(test_plain_text, plain_text));
// Decryption should fail if any of the inputs are tampered with.
- EXPECT_STATUS(Status::Error(),
+ EXPECT_STATUS(Status::OperationError(),
AesGcmDecrypt(key,
Corrupted(test_iv),
test_additional_data,
@@ -2875,7 +2875,7 @@ TEST_F(SharedCryptoTest, MAYBE(AesGcmSampleSets)) {
test_cipher_text,
test_authentication_tag,
&plain_text));
- EXPECT_STATUS(Status::Error(),
+ EXPECT_STATUS(Status::OperationError(),
AesGcmDecrypt(key,
test_iv,
Corrupted(test_additional_data),
@@ -2883,7 +2883,7 @@ TEST_F(SharedCryptoTest, MAYBE(AesGcmSampleSets)) {
test_cipher_text,
test_authentication_tag,
&plain_text));
- EXPECT_STATUS(Status::Error(),
+ EXPECT_STATUS(Status::OperationError(),
AesGcmDecrypt(key,
test_iv,
test_additional_data,
@@ -2891,7 +2891,7 @@ TEST_F(SharedCryptoTest, MAYBE(AesGcmSampleSets)) {
Corrupted(test_cipher_text),
test_authentication_tag,
&plain_text));
- EXPECT_STATUS(Status::Error(),
+ EXPECT_STATUS(Status::OperationError(),
AesGcmDecrypt(key,
test_iv,
test_additional_data,
@@ -3253,7 +3253,7 @@ TEST_F(SharedCryptoTest, MAYBE(RsaEsJwkSymkeyWrapUnwrapErrors)) {
// Treat the ciphertext as a wrapped key and try to unwrap it. Ensure a
// generic error is received.
blink::WebCryptoKey unwrapped_key = blink::WebCryptoKey::createNull();
- EXPECT_STATUS(Status::Error(),
+ EXPECT_STATUS(Status::OperationError(),
UnwrapKey(blink::WebCryptoKeyFormatJwk,
CryptoData(ciphertext),
private_wrapping_key,

Powered by Google App Engine
This is Rietveld 408576698