| 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 "content/child/webcrypto/test/test_helpers.h" | 5 #include "content/child/webcrypto/test/test_helpers.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 memcmp(a.bytes(), b.bytes(), a.byte_length()) == 0; | 68 memcmp(a.bytes(), b.bytes(), a.byte_length()) == 0; |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool operator!=(const CryptoData& a, const CryptoData& b) { | 71 bool operator!=(const CryptoData& a, const CryptoData& b) { |
| 72 return !(a == b); | 72 return !(a == b); |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool SupportsAesGcm() { | 75 bool SupportsAesGcm() { |
| 76 std::vector<uint8_t> key_raw(16, 0); | 76 std::vector<uint8_t> key_raw(16, 0); |
| 77 | 77 |
| 78 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); | 78 blink::WebCryptoKey key; |
| 79 Status status = ImportKey(blink::WebCryptoKeyFormatRaw, | 79 Status status = ImportKey(blink::WebCryptoKeyFormatRaw, |
| 80 CryptoData(key_raw), | 80 CryptoData(key_raw), |
| 81 CreateAlgorithm(blink::WebCryptoAlgorithmIdAesGcm), | 81 CreateAlgorithm(blink::WebCryptoAlgorithmIdAesGcm), |
| 82 true, | 82 true, |
| 83 blink::WebCryptoKeyUsageEncrypt, | 83 blink::WebCryptoKeyUsageEncrypt, |
| 84 &key); | 84 &key); |
| 85 | 85 |
| 86 if (status.IsError()) | 86 if (status.IsError()) |
| 87 EXPECT_EQ(blink::WebCryptoErrorTypeNotSupported, status.error_type()); | 87 EXPECT_EQ(blink::WebCryptoErrorTypeNotSupported, status.error_type()); |
| 88 return status.IsSuccess(); | 88 return status.IsSuccess(); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 "A56E4A0E701017589A5187DC7EA841D156F2EC0E36AD52A44DFEB1E61F7AD991D8C51056" | 319 "A56E4A0E701017589A5187DC7EA841D156F2EC0E36AD52A44DFEB1E61F7AD991D8C51056" |
| 320 "FFEDB162B4C0F283A12A88A394DFF526AB7291CBB307CEABFCE0B1DFD5CD9508096D5B2B" | 320 "FFEDB162B4C0F283A12A88A394DFF526AB7291CBB307CEABFCE0B1DFD5CD9508096D5B2B" |
| 321 "8B6DF5D671EF6377C0921CB23C270A70E2598E6FF89D19F105ACC2D3F0CB35F29280E138" | 321 "8B6DF5D671EF6377C0921CB23C270A70E2598E6FF89D19F105ACC2D3F0CB35F29280E138" |
| 322 "6B6F64C4EF22E1E1F20D0CE8CFFB2249BD9A2137"; | 322 "6B6F64C4EF22E1E1F20D0CE8CFFB2249BD9A2137"; |
| 323 const char* const kPublicKeyExponentHex = "010001"; | 323 const char* const kPublicKeyExponentHex = "010001"; |
| 324 | 324 |
| 325 blink::WebCryptoKey ImportSecretKeyFromRaw( | 325 blink::WebCryptoKey ImportSecretKeyFromRaw( |
| 326 const std::vector<uint8_t>& key_raw, | 326 const std::vector<uint8_t>& key_raw, |
| 327 const blink::WebCryptoAlgorithm& algorithm, | 327 const blink::WebCryptoAlgorithm& algorithm, |
| 328 blink::WebCryptoKeyUsageMask usage) { | 328 blink::WebCryptoKeyUsageMask usage) { |
| 329 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); | 329 blink::WebCryptoKey key; |
| 330 bool extractable = true; | 330 bool extractable = true; |
| 331 EXPECT_EQ(Status::Success(), | 331 EXPECT_EQ(Status::Success(), |
| 332 ImportKey(blink::WebCryptoKeyFormatRaw, | 332 ImportKey(blink::WebCryptoKeyFormatRaw, |
| 333 CryptoData(key_raw), | 333 CryptoData(key_raw), |
| 334 algorithm, | 334 algorithm, |
| 335 extractable, | 335 extractable, |
| 336 usage, | 336 usage, |
| 337 &key)); | 337 &key)); |
| 338 | 338 |
| 339 EXPECT_FALSE(key.isNull()); | 339 EXPECT_FALSE(key.isNull()); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 | 613 |
| 614 *public_key = result.public_key(); | 614 *public_key = result.public_key(); |
| 615 *private_key = result.private_key(); | 615 *private_key = result.private_key(); |
| 616 | 616 |
| 617 return Status::Success(); | 617 return Status::Success(); |
| 618 } | 618 } |
| 619 | 619 |
| 620 } // namespace webcrypto | 620 } // namespace webcrypto |
| 621 | 621 |
| 622 } // namesapce content | 622 } // namesapce content |
| OLD | NEW |