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

Side by Side Diff: content/child/webcrypto/shared_crypto_unittest.cc

Issue 400473003: [webcrypto] Support 256-bit AES-GCM for OpenSSL implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/child/webcrypto/openssl/aes_gcm_openssl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 3268 matching lines...) Expand 10 before | Expand all | Expand 10 after
3279 const std::vector<uint8_t> test_additional_data = 3279 const std::vector<uint8_t> test_additional_data =
3280 GetBytesFromHexString(test, "additional_data"); 3280 GetBytesFromHexString(test, "additional_data");
3281 const std::vector<uint8_t> test_plain_text = 3281 const std::vector<uint8_t> test_plain_text =
3282 GetBytesFromHexString(test, "plain_text"); 3282 GetBytesFromHexString(test, "plain_text");
3283 const std::vector<uint8_t> test_authentication_tag = 3283 const std::vector<uint8_t> test_authentication_tag =
3284 GetBytesFromHexString(test, "authentication_tag"); 3284 GetBytesFromHexString(test, "authentication_tag");
3285 const unsigned int test_tag_size_bits = test_authentication_tag.size() * 8; 3285 const unsigned int test_tag_size_bits = test_authentication_tag.size() * 8;
3286 const std::vector<uint8_t> test_cipher_text = 3286 const std::vector<uint8_t> test_cipher_text =
3287 GetBytesFromHexString(test, "cipher_text"); 3287 GetBytesFromHexString(test, "cipher_text");
3288 3288
3289 #if defined(USE_OPENSSL)
3290 // TODO(eroman): Add support for 256-bit keys.
3291 if (test_key.size() == 32) {
3292 LOG(WARNING)
3293 << "OpenSSL doesn't support 256-bit keys for AES-GCM; skipping";
3294 continue;
3295 }
3296 #endif
3297
3298 blink::WebCryptoKey key = ImportSecretKeyFromRaw( 3289 blink::WebCryptoKey key = ImportSecretKeyFromRaw(
3299 test_key, 3290 test_key,
3300 CreateAlgorithm(blink::WebCryptoAlgorithmIdAesGcm), 3291 CreateAlgorithm(blink::WebCryptoAlgorithmIdAesGcm),
3301 blink::WebCryptoKeyUsageEncrypt | blink::WebCryptoKeyUsageDecrypt); 3292 blink::WebCryptoKeyUsageEncrypt | blink::WebCryptoKeyUsageDecrypt);
3302 3293
3303 // Verify exported raw key is identical to the imported data 3294 // Verify exported raw key is identical to the imported data
3304 std::vector<uint8_t> raw_key; 3295 std::vector<uint8_t> raw_key;
3305 EXPECT_EQ(Status::Success(), 3296 EXPECT_EQ(Status::Success(),
3306 ExportKey(blink::WebCryptoKeyFormatRaw, key, &raw_key)); 3297 ExportKey(blink::WebCryptoKeyFormatRaw, key, &raw_key));
3307 3298
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
4419 EXPECT_EQ(public_key_spki, unwrapped_public_key_spki); 4410 EXPECT_EQ(public_key_spki, unwrapped_public_key_spki);
4420 EXPECT_EQ(private_key_pkcs8, unwrapped_private_key_pkcs8); 4411 EXPECT_EQ(private_key_pkcs8, unwrapped_private_key_pkcs8);
4421 4412
4422 EXPECT_NE(public_key_spki, wrapped_public_key); 4413 EXPECT_NE(public_key_spki, wrapped_public_key);
4423 EXPECT_NE(private_key_pkcs8, wrapped_private_key); 4414 EXPECT_NE(private_key_pkcs8, wrapped_private_key);
4424 } 4415 }
4425 4416
4426 } // namespace webcrypto 4417 } // namespace webcrypto
4427 4418
4428 } // namespace content 4419 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/openssl/aes_gcm_openssl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698