OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/renderer/webcrypto_impl.h" | 5 #include "content/renderer/webcrypto_impl.h" |
6 | 6 |
| 7 // TODO(bryaneyler): Also include these in OpenSSL build. Issue 267888. |
| 8 #if defined(USE_NSS) |
| 9 #include "content/renderer/webcrypto_digest.h" |
| 10 #endif |
| 11 |
| 12 #include "base/memory/scoped_ptr.h" |
7 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" | 13 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" |
8 | 14 |
9 namespace content { | 15 namespace content { |
10 | 16 |
11 WebKit::WebCryptoOperation* WebCryptoImpl::digest( | 17 void WebCryptoImpl::digest( |
12 const WebKit::WebCryptoAlgorithm& algorithm) { | 18 const WebKit::WebCryptoAlgorithm& algorithm, |
| 19 WebKit::WebCryptoOperationResult& result) { |
| 20 // TODO(bryaneyler): Also include these in OpenSSL build. Issue 267888. |
| 21 #if defined(USE_NSS) |
13 switch (algorithm.id()) { | 22 switch (algorithm.id()) { |
14 case WebKit::WebCryptoAlgorithmIdSha1: | 23 case WebKit::WebCryptoAlgorithmIdSha1: |
15 case WebKit::WebCryptoAlgorithmIdSha224: | 24 case WebKit::WebCryptoAlgorithmIdSha224: |
16 case WebKit::WebCryptoAlgorithmIdSha256: | 25 case WebKit::WebCryptoAlgorithmIdSha256: |
17 case WebKit::WebCryptoAlgorithmIdSha384: | 26 case WebKit::WebCryptoAlgorithmIdSha384: |
18 case WebKit::WebCryptoAlgorithmIdSha512: | 27 case WebKit::WebCryptoAlgorithmIdSha512: { |
19 // TODO(eroman): Implement. | 28 scoped_ptr<WebCryptoDigest> operation( |
20 return NULL; | 29 new WebCryptoDigest(result)); |
| 30 |
| 31 if (!operation->Initialize(algorithm)) { |
| 32 result.initializationFailed(); |
| 33 } else { |
| 34 result.initializationSucceeded(operation.release()); |
| 35 } |
| 36 return; |
| 37 } |
21 default: | 38 default: |
22 // Not a digest algorithm. | 39 // Not a digest algorithm. |
23 return NULL; | 40 result.initializationFailed(); |
| 41 return; |
24 } | 42 } |
| 43 #else |
| 44 // No way to process. |
| 45 result.initializationFailed(); |
| 46 #endif |
25 } | 47 } |
26 | 48 |
27 } // namespace content | 49 } // namespace content |
OLD | NEW |