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

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

Issue 206833003: [webcrypto] Add wrap/unwrap forwarding methods to WebCryptoImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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/webcrypto_impl.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 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/webcrypto_impl.h" 5 #include "content/child/webcrypto/webcrypto_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/child/webcrypto/crypto_data.h" 8 #include "content/child/webcrypto/crypto_data.h"
9 #include "content/child/webcrypto/shared_crypto.h" 9 #include "content/child/webcrypto/shared_crypto.h"
10 #include "content/child/webcrypto/status.h" 10 #include "content/child/webcrypto/status.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 key, 189 key,
190 webcrypto::CryptoData(signature, signature_size), 190 webcrypto::CryptoData(signature, signature_size),
191 webcrypto::CryptoData(data, data_size), 191 webcrypto::CryptoData(data, data_size),
192 &signature_match); 192 &signature_match);
193 if (status.IsError()) 193 if (status.IsError())
194 CompleteWithError(status, &result); 194 CompleteWithError(status, &result);
195 else 195 else
196 result.completeWithBoolean(signature_match); 196 result.completeWithBoolean(signature_match);
197 } 197 }
198 198
199 void WebCryptoImpl::wrapKey(blink::WebCryptoKeyFormat format,
200 const blink::WebCryptoKey& key,
201 const blink::WebCryptoKey& wrapping_key,
202 const blink::WebCryptoAlgorithm& wrap_algorithm,
203 blink::WebCryptoResult result) {
204 blink::WebArrayBuffer buffer;
205 // TODO(eroman): Use the same parameter ordering.
206 Status status = webcrypto::WrapKey(
207 format, wrapping_key, key, wrap_algorithm, &buffer);
208 if (status.IsError())
209 CompleteWithError(status, &result);
210 else
211 result.completeWithBuffer(buffer);
212 }
213
214 void WebCryptoImpl::unwrapKey(
215 blink::WebCryptoKeyFormat format,
216 const unsigned char* wrapped_key,
217 unsigned wrapped_key_size,
218 const blink::WebCryptoKey& wrapping_key,
219 const blink::WebCryptoAlgorithm& unwrap_algorithm,
220 const blink::WebCryptoAlgorithm& unwrapped_key_algorithm,
221 bool extractable,
222 blink::WebCryptoKeyUsageMask usages,
223 blink::WebCryptoResult result) {
224 blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
225 Status status =
226 webcrypto::UnwrapKey(format,
227 webcrypto::CryptoData(wrapped_key, wrapped_key_size),
228 wrapping_key,
229 unwrap_algorithm,
230 unwrapped_key_algorithm,
231 extractable,
232 usages,
233 &key);
234 if (status.IsError())
235 CompleteWithError(status, &result);
236 else
237 result.completeWithKey(key);
238 }
239
199 bool WebCryptoImpl::digestSynchronous( 240 bool WebCryptoImpl::digestSynchronous(
200 const blink::WebCryptoAlgorithmId algorithm_id, 241 const blink::WebCryptoAlgorithmId algorithm_id,
201 const unsigned char* data, 242 const unsigned char* data,
202 unsigned int data_size, 243 unsigned int data_size,
203 blink::WebArrayBuffer& result) { 244 blink::WebArrayBuffer& result) {
204 blink::WebCryptoAlgorithm algorithm = 245 blink::WebCryptoAlgorithm algorithm =
205 blink::WebCryptoAlgorithm::adoptParamsAndCreate(algorithm_id, NULL); 246 blink::WebCryptoAlgorithm::adoptParamsAndCreate(algorithm_id, NULL);
206 return (webcrypto::Digest( 247 return (webcrypto::Digest(
207 algorithm, webcrypto::CryptoData(data, data_size), &result)) 248 algorithm, webcrypto::CryptoData(data, data_size), &result))
208 .IsSuccess(); 249 .IsSuccess();
(...skipping 18 matching lines...) Expand all
227 } 268 }
228 269
229 bool WebCryptoImpl::serializeKeyForClone( 270 bool WebCryptoImpl::serializeKeyForClone(
230 const blink::WebCryptoKey& key, 271 const blink::WebCryptoKey& key,
231 blink::WebVector<unsigned char>& key_data) { 272 blink::WebVector<unsigned char>& key_data) {
232 Status status = webcrypto::SerializeKeyForClone(key, &key_data); 273 Status status = webcrypto::SerializeKeyForClone(key, &key_data);
233 return status.IsSuccess(); 274 return status.IsSuccess();
234 } 275 }
235 276
236 } // namespace content 277 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/webcrypto_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698