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

Side by Side Diff: components/webcrypto/algorithms/asymmetric_key_util.cc

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 11 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/web_view/web_view_impl.cc ('k') | components/webcrypto/algorithms/ec.cc » ('j') | 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/algorithms/asymmetric_key_util.h" 5 #include "components/webcrypto/algorithms/asymmetric_key_util.h"
6 6
7 #include <openssl/pkcs12.h> 7 #include <openssl/pkcs12.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility>
9 10
10 #include "components/webcrypto/algorithms/util.h" 11 #include "components/webcrypto/algorithms/util.h"
11 #include "components/webcrypto/blink_key_handle.h" 12 #include "components/webcrypto/blink_key_handle.h"
12 #include "components/webcrypto/crypto_data.h" 13 #include "components/webcrypto/crypto_data.h"
13 #include "components/webcrypto/generate_key_result.h" 14 #include "components/webcrypto/generate_key_result.h"
14 #include "components/webcrypto/status.h" 15 #include "components/webcrypto/status.h"
15 #include "crypto/openssl_util.h" 16 #include "crypto/openssl_util.h"
16 17
17 namespace webcrypto { 18 namespace webcrypto {
18 19
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 blink::WebCryptoKeyUsageMask usages, 65 blink::WebCryptoKeyUsageMask usages,
65 blink::WebCryptoKey* key) { 66 blink::WebCryptoKey* key) {
66 // Serialize the key at creation time so that if structured cloning is 67 // Serialize the key at creation time so that if structured cloning is
67 // requested it can be done synchronously from the Blink thread. 68 // requested it can be done synchronously from the Blink thread.
68 std::vector<uint8_t> spki_data; 69 std::vector<uint8_t> spki_data;
69 Status status = ExportPKeySpki(public_key.get(), &spki_data); 70 Status status = ExportPKeySpki(public_key.get(), &spki_data);
70 if (status.IsError()) 71 if (status.IsError())
71 return status; 72 return status;
72 73
73 *key = blink::WebCryptoKey::create( 74 *key = blink::WebCryptoKey::create(
74 CreateAsymmetricKeyHandle(public_key.Pass(), spki_data), 75 CreateAsymmetricKeyHandle(std::move(public_key), spki_data),
75 blink::WebCryptoKeyTypePublic, extractable, algorithm, usages); 76 blink::WebCryptoKeyTypePublic, extractable, algorithm, usages);
76 return Status::Success(); 77 return Status::Success();
77 } 78 }
78 79
79 Status CreateWebCryptoPrivateKey(crypto::ScopedEVP_PKEY private_key, 80 Status CreateWebCryptoPrivateKey(crypto::ScopedEVP_PKEY private_key,
80 const blink::WebCryptoKeyAlgorithm& algorithm, 81 const blink::WebCryptoKeyAlgorithm& algorithm,
81 bool extractable, 82 bool extractable,
82 blink::WebCryptoKeyUsageMask usages, 83 blink::WebCryptoKeyUsageMask usages,
83 blink::WebCryptoKey* key) { 84 blink::WebCryptoKey* key) {
84 // Serialize the key at creation time so that if structured cloning is 85 // Serialize the key at creation time so that if structured cloning is
85 // requested it can be done synchronously from the Blink thread. 86 // requested it can be done synchronously from the Blink thread.
86 std::vector<uint8_t> pkcs8_data; 87 std::vector<uint8_t> pkcs8_data;
87 Status status = ExportPKeyPkcs8(private_key.get(), &pkcs8_data); 88 Status status = ExportPKeyPkcs8(private_key.get(), &pkcs8_data);
88 if (status.IsError()) 89 if (status.IsError())
89 return status; 90 return status;
90 91
91 *key = blink::WebCryptoKey::create( 92 *key = blink::WebCryptoKey::create(
92 CreateAsymmetricKeyHandle(private_key.Pass(), pkcs8_data), 93 CreateAsymmetricKeyHandle(std::move(private_key), pkcs8_data),
93 blink::WebCryptoKeyTypePrivate, extractable, algorithm, usages); 94 blink::WebCryptoKeyTypePrivate, extractable, algorithm, usages);
94 return Status::Success(); 95 return Status::Success();
95 } 96 }
96 97
97 Status CheckPrivateKeyCreationUsages( 98 Status CheckPrivateKeyCreationUsages(
98 blink::WebCryptoKeyUsageMask all_possible_usages, 99 blink::WebCryptoKeyUsageMask all_possible_usages,
99 blink::WebCryptoKeyUsageMask actual_usages) { 100 blink::WebCryptoKeyUsageMask actual_usages) {
100 return CheckKeyCreationUsages(all_possible_usages, actual_usages, 101 return CheckKeyCreationUsages(all_possible_usages, actual_usages,
101 EmptyUsagePolicy::REJECT_EMPTY); 102 EmptyUsagePolicy::REJECT_EMPTY);
102 } 103 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 return status; 187 return status;
187 188
188 *public_usages = combined_usages & all_public_usages; 189 *public_usages = combined_usages & all_public_usages;
189 *private_usages = combined_usages & all_private_usages; 190 *private_usages = combined_usages & all_private_usages;
190 191
191 // Ensure that the private key has non-empty usages. 192 // Ensure that the private key has non-empty usages.
192 return CheckPrivateKeyCreationUsages(all_private_usages, *private_usages); 193 return CheckPrivateKeyCreationUsages(all_private_usages, *private_usages);
193 } 194 }
194 195
195 } // namespace webcrypto 196 } // namespace webcrypto
OLDNEW
« no previous file with comments | « components/web_view/web_view_impl.cc ('k') | components/webcrypto/algorithms/ec.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698