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

Side by Side Diff: components/webcrypto/blink_key_handle.cc

Issue 2407633002: Use new BoringSSL scopers in //components. (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
« no previous file with comments | « components/webcrypto/blink_key_handle.h ('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 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 "components/webcrypto/blink_key_handle.h" 5 #include "components/webcrypto/blink_key_handle.h"
6 6
7 #include <openssl/evp.h>
8
7 #include <utility> 9 #include <utility>
8 10
9 #include "base/logging.h" 11 #include "base/logging.h"
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "components/webcrypto/crypto_data.h" 13 #include "components/webcrypto/crypto_data.h"
12 #include "components/webcrypto/status.h" 14 #include "components/webcrypto/status.h"
13 15
14 namespace webcrypto { 16 namespace webcrypto {
15 17
16 namespace { 18 namespace {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 return serialized_key_data(); 62 return serialized_key_data();
61 } 63 }
62 64
63 private: 65 private:
64 DISALLOW_COPY_AND_ASSIGN(SymKey); 66 DISALLOW_COPY_AND_ASSIGN(SymKey);
65 }; 67 };
66 68
67 class AsymKey : public Key { 69 class AsymKey : public Key {
68 public: 70 public:
69 // After construction the |pkey| should NOT be mutated. 71 // After construction the |pkey| should NOT be mutated.
70 AsymKey(crypto::ScopedEVP_PKEY pkey, 72 AsymKey(bssl::UniquePtr<EVP_PKEY> pkey,
71 const std::vector<uint8_t>& serialized_key_data) 73 const std::vector<uint8_t>& serialized_key_data)
72 : Key(CryptoData(serialized_key_data)), pkey_(std::move(pkey)) {} 74 : Key(CryptoData(serialized_key_data)), pkey_(std::move(pkey)) {}
73 75
74 AsymKey* AsAsymKey() override { return this; } 76 AsymKey* AsAsymKey() override { return this; }
75 77
76 // The caller should NOT mutate this EVP_PKEY. 78 // The caller should NOT mutate this EVP_PKEY.
77 EVP_PKEY* pkey() { return pkey_.get(); } 79 EVP_PKEY* pkey() { return pkey_.get(); }
78 80
79 private: 81 private:
80 crypto::ScopedEVP_PKEY pkey_; 82 bssl::UniquePtr<EVP_PKEY> pkey_;
81 83
82 DISALLOW_COPY_AND_ASSIGN(AsymKey); 84 DISALLOW_COPY_AND_ASSIGN(AsymKey);
83 }; 85 };
84 86
85 Key* GetKey(const blink::WebCryptoKey& key) { 87 Key* GetKey(const blink::WebCryptoKey& key) {
86 return reinterpret_cast<Key*>(key.handle()); 88 return reinterpret_cast<Key*>(key.handle());
87 } 89 }
88 90
89 } // namespace 91 } // namespace
90 92
(...skipping 12 matching lines...) Expand all
103 const blink::WebCryptoKey& key) { 105 const blink::WebCryptoKey& key) {
104 return GetKey(key)->serialized_key_data(); 106 return GetKey(key)->serialized_key_data();
105 } 107 }
106 108
107 blink::WebCryptoKeyHandle* CreateSymmetricKeyHandle( 109 blink::WebCryptoKeyHandle* CreateSymmetricKeyHandle(
108 const CryptoData& key_bytes) { 110 const CryptoData& key_bytes) {
109 return new SymKey(key_bytes); 111 return new SymKey(key_bytes);
110 } 112 }
111 113
112 blink::WebCryptoKeyHandle* CreateAsymmetricKeyHandle( 114 blink::WebCryptoKeyHandle* CreateAsymmetricKeyHandle(
113 crypto::ScopedEVP_PKEY pkey, 115 bssl::UniquePtr<EVP_PKEY> pkey,
114 const std::vector<uint8_t>& serialized_key_data) { 116 const std::vector<uint8_t>& serialized_key_data) {
115 return new AsymKey(std::move(pkey), serialized_key_data); 117 return new AsymKey(std::move(pkey), serialized_key_data);
116 } 118 }
117 119
118 } // namespace webcrypto 120 } // namespace webcrypto
OLDNEW
« no previous file with comments | « components/webcrypto/blink_key_handle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698