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/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 "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "content/child/webcrypto/crypto_data.h" | 9 #include "content/child/webcrypto/crypto_data.h" |
10 #include "content/child/webcrypto/shared_crypto.h" | 10 #include "content/child/webcrypto/shared_crypto.h" |
11 #include "content/child/webcrypto/status.h" | 11 #include "content/child/webcrypto/status.h" |
12 #include "content/child/webcrypto/webcrypto_util.h" | 12 #include "content/child/webcrypto/webcrypto_util.h" |
13 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" | 13 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" |
14 #include "third_party/WebKit/public/platform/WebString.h" | 14 #include "third_party/WebKit/public/platform/WebString.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 using webcrypto::Status; | 18 using webcrypto::Status; |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 void CompleteWithError(const Status& status, blink::WebCryptoResult* result) { | 22 void CompleteWithError(const Status& status, blink::WebCryptoResult* result) { |
23 DCHECK(status.IsError()); | 23 DCHECK(status.IsError()); |
24 | 24 |
25 #if defined(WEBCRYPTO_HAS_ERROR_TYPE) | |
26 result->completeWithError(status.error_type(), | 25 result->completeWithError(status.error_type(), |
27 blink::WebString::fromUTF8(status.error_details())); | 26 blink::WebString::fromUTF8(status.error_details())); |
28 #else | |
29 // TODO(eroman): Delete once Blink changes have rolled into Chromium. | |
30 if (!status.error_details().empty()) | |
31 result->completeWithError( | |
32 blink::WebString::fromUTF8(status.error_details())); | |
33 else | |
34 result->completeWithError(); | |
35 #endif | |
36 } | 27 } |
37 | 28 |
38 bool IsAlgorithmAsymmetric(const blink::WebCryptoAlgorithm& algorithm) { | 29 bool IsAlgorithmAsymmetric(const blink::WebCryptoAlgorithm& algorithm) { |
39 // TODO(padolph): include all other asymmetric algorithms once they are | 30 // TODO(padolph): include all other asymmetric algorithms once they are |
40 // defined, e.g. EC and DH. | 31 // defined, e.g. EC and DH. |
41 return (algorithm.id() == blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5 || | 32 return (algorithm.id() == blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5 || |
42 algorithm.id() == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 || | 33 algorithm.id() == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 || |
43 algorithm.id() == blink::WebCryptoAlgorithmIdRsaOaep); | 34 algorithm.id() == blink::WebCryptoAlgorithmIdRsaOaep); |
44 } | 35 } |
45 | 36 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 272 } |
282 | 273 |
283 bool WebCryptoImpl::serializeKeyForClone( | 274 bool WebCryptoImpl::serializeKeyForClone( |
284 const blink::WebCryptoKey& key, | 275 const blink::WebCryptoKey& key, |
285 blink::WebVector<unsigned char>& key_data) { | 276 blink::WebVector<unsigned char>& key_data) { |
286 Status status = webcrypto::SerializeKeyForClone(key, &key_data); | 277 Status status = webcrypto::SerializeKeyForClone(key, &key_data); |
287 return status.IsSuccess(); | 278 return status.IsSuccess(); |
288 } | 279 } |
289 | 280 |
290 } // namespace content | 281 } // namespace content |
OLD | NEW |