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

Side by Side Diff: chrome/browser/extensions/api/certificate_provider/certificate_provider_apitest.cc

Issue 2408063002: Switch remaining scoped_openssl_types uses to BoringSSL scopers. (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <openssl/evp.h> 5 #include <openssl/evp.h>
6 #include <openssl/rsa.h> 6 #include <openssl/rsa.h>
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
(...skipping 15 matching lines...) Expand all
26 #include "components/policy/core/browser/browser_policy_connector.h" 26 #include "components/policy/core/browser/browser_policy_connector.h"
27 #include "components/policy/core/common/mock_configuration_policy_provider.h" 27 #include "components/policy/core/common/mock_configuration_policy_provider.h"
28 #include "components/policy/core/common/policy_map.h" 28 #include "components/policy/core/common/policy_map.h"
29 #include "components/policy/core/common/policy_types.h" 29 #include "components/policy/core/common/policy_types.h"
30 #include "components/policy/policy_constants.h" 30 #include "components/policy/policy_constants.h"
31 #include "content/public/browser/render_frame_host.h" 31 #include "content/public/browser/render_frame_host.h"
32 #include "content/public/browser/web_contents.h" 32 #include "content/public/browser/web_contents.h"
33 #include "content/public/test/test_navigation_observer.h" 33 #include "content/public/test/test_navigation_observer.h"
34 #include "content/public/test/test_utils.h" 34 #include "content/public/test/test_utils.h"
35 #include "crypto/rsa_private_key.h" 35 #include "crypto/rsa_private_key.h"
36 #include "crypto/scoped_openssl_types.h"
37 #include "extensions/common/extension.h" 36 #include "extensions/common/extension.h"
38 #include "extensions/test/result_catcher.h" 37 #include "extensions/test/result_catcher.h"
39 #include "net/test/spawned_test_server/spawned_test_server.h" 38 #include "net/test/spawned_test_server/spawned_test_server.h"
40 #include "testing/gmock/include/gmock/gmock.h" 39 #include "testing/gmock/include/gmock/gmock.h"
41 40
42 using testing::Return; 41 using testing::Return;
43 using testing::_; 42 using testing::_;
44 43
45 namespace { 44 namespace {
46 45
(...skipping 28 matching lines...) Expand all
75 } 74 }
76 75
77 callback.Run(); 76 callback.Run();
78 } 77 }
79 78
80 // See net::SSLPrivateKey::SignDigest for the expected padding and DigestInfo 79 // See net::SSLPrivateKey::SignDigest for the expected padding and DigestInfo
81 // prefixing. 80 // prefixing.
82 bool RsaSign(const std::vector<uint8_t>& digest, 81 bool RsaSign(const std::vector<uint8_t>& digest,
83 crypto::RSAPrivateKey* key, 82 crypto::RSAPrivateKey* key,
84 std::vector<uint8_t>* signature) { 83 std::vector<uint8_t>* signature) {
85 crypto::ScopedRSA rsa_key(EVP_PKEY_get1_RSA(key->key())); 84 RSA* rsa_key = EVP_PKEY_get0_RSA(key->key());
davidben 2016/10/11 18:58:18 get0 is the same as get1 but doesn't take an unnec
86 if (!rsa_key) 85 if (!rsa_key)
87 return false; 86 return false;
88 87
89 uint8_t* prefixed_digest = nullptr; 88 uint8_t* prefixed_digest = nullptr;
90 size_t prefixed_digest_len = 0; 89 size_t prefixed_digest_len = 0;
91 int is_alloced = 0; 90 int is_alloced = 0;
92 if (!RSA_add_pkcs1_prefix(&prefixed_digest, &prefixed_digest_len, &is_alloced, 91 if (!RSA_add_pkcs1_prefix(&prefixed_digest, &prefixed_digest_len, &is_alloced,
93 NID_sha1, digest.data(), digest.size())) { 92 NID_sha1, digest.data(), digest.size())) {
94 return false; 93 return false;
95 } 94 }
96 size_t len = 0; 95 size_t len = 0;
97 signature->resize(RSA_size(rsa_key.get())); 96 signature->resize(RSA_size(rsa_key));
98 const int rv = 97 const int rv =
99 RSA_sign_raw(rsa_key.get(), &len, signature->data(), signature->size(), 98 RSA_sign_raw(rsa_key, &len, signature->data(), signature->size(),
100 prefixed_digest, prefixed_digest_len, RSA_PKCS1_PADDING); 99 prefixed_digest, prefixed_digest_len, RSA_PKCS1_PADDING);
101 if (is_alloced) 100 if (is_alloced)
102 free(prefixed_digest); 101 free(prefixed_digest);
103 102
104 if (rv) { 103 if (rv) {
105 signature->resize(len); 104 signature->resize(len);
106 return true; 105 return true;
107 } else { 106 } else {
108 signature->clear(); 107 signature->clear();
109 return false; 108 return false;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 base::RunLoop run_loop; 260 base::RunLoop run_loop;
262 const std::string code = "replyWithSignatureSecondTime();"; 261 const std::string code = "replyWithSignatureSecondTime();";
263 bool result = false; 262 bool result = false;
264 extension_contents->GetMainFrame()->ExecuteJavaScriptForTests( 263 extension_contents->GetMainFrame()->ExecuteJavaScriptForTests(
265 base::ASCIIToUTF16(code), 264 base::ASCIIToUTF16(code),
266 base::Bind(&StoreBool, &result, run_loop.QuitClosure())); 265 base::Bind(&StoreBool, &result, run_loop.QuitClosure()));
267 run_loop.Run(); 266 run_loop.Run();
268 EXPECT_TRUE(result); 267 EXPECT_TRUE(result);
269 } 268 }
270 } 269 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698