| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/stl_util.h" | 5 #include "base/stl_util.h" |
| 6 #include "content/child/webcrypto/algorithm_dispatch.h" | 6 #include "content/child/webcrypto/algorithm_dispatch.h" |
| 7 #include "content/child/webcrypto/crypto_data.h" | 7 #include "content/child/webcrypto/crypto_data.h" |
| 8 #include "content/child/webcrypto/status.h" | 8 #include "content/child/webcrypto/status.h" |
| 9 #include "content/child/webcrypto/test/test_helpers.h" | 9 #include "content/child/webcrypto/test/test_helpers.h" |
| 10 #include "content/child/webcrypto/webcrypto_util.h" | 10 #include "content/child/webcrypto/webcrypto_util.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 return Decrypt(algorithm, key, CryptoData(cipher_text_with_tag), plain_text); | 102 return Decrypt(algorithm, key, CryptoData(cipher_text_with_tag), plain_text); |
| 103 } | 103 } |
| 104 | 104 |
| 105 TEST(WebCryptoAesGcmTest, GenerateKeyBadLength) { | 105 TEST(WebCryptoAesGcmTest, GenerateKeyBadLength) { |
| 106 if (!SupportsAesGcm()) { | 106 if (!SupportsAesGcm()) { |
| 107 LOG(WARNING) << "AES GCM not supported, skipping tests"; | 107 LOG(WARNING) << "AES GCM not supported, skipping tests"; |
| 108 return; | 108 return; |
| 109 } | 109 } |
| 110 | 110 |
| 111 const unsigned short kKeyLen[] = {0, 127, 257}; | 111 const unsigned short kKeyLen[] = {0, 127, 257}; |
| 112 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); | 112 blink::WebCryptoKey key; |
| 113 for (size_t i = 0; i < arraysize(kKeyLen); ++i) { | 113 for (size_t i = 0; i < arraysize(kKeyLen); ++i) { |
| 114 SCOPED_TRACE(i); | 114 SCOPED_TRACE(i); |
| 115 EXPECT_EQ(Status::ErrorGenerateKeyLength(), | 115 EXPECT_EQ(Status::ErrorGenerateKeyLength(), |
| 116 GenerateSecretKey( | 116 GenerateSecretKey( |
| 117 CreateAesGcmKeyGenAlgorithm(kKeyLen[i]), true, 0, &key)); | 117 CreateAesGcmKeyGenAlgorithm(kKeyLen[i]), true, 0, &key)); |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 TEST(WebCryptoAesGcmTest, ImportExportJwk) { | 121 TEST(WebCryptoAesGcmTest, ImportExportJwk) { |
| 122 // Some Linux test runners may not have a new enough version of NSS. | 122 // Some Linux test runners may not have a new enough version of NSS. |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 &plain_text)); | 261 &plain_text)); |
| 262 } | 262 } |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 | 265 |
| 266 } // namespace | 266 } // namespace |
| 267 | 267 |
| 268 } // namespace webcrypto | 268 } // namespace webcrypto |
| 269 | 269 |
| 270 } // namespace content | 270 } // namespace content |
| OLD | NEW |