| 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 #ifndef CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ |
| 6 #define CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ | 6 #define CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "third_party/WebKit/public/platform/WebCrypto.h" | 10 #include "third_party/WebKit/public/platform/WebCrypto.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 // Wrapper around the blink WebCrypto asynchronous interface, which forwards to | 14 // Wrapper around the blink WebCrypto asynchronous interface, which forwards to |
| 15 // the synchronous platfrom (NSS or OpenSSL) implementation. | 15 // the synchronous platfrom (NSS or OpenSSL) implementation. |
| 16 // | 16 // |
| 17 // TODO(eroman): Post the synchronous work to a background thread. | 17 // TODO(eroman): Post the synchronous work to a background thread. |
| 18 class WebCryptoImpl : public blink::WebCrypto { | 18 class WebCryptoImpl : public blink::WebCrypto { |
| 19 public: | 19 public: |
| 20 WebCryptoImpl(); | 20 WebCryptoImpl(); |
| 21 virtual ~WebCryptoImpl(); | 21 virtual ~WebCryptoImpl(); |
| 22 | 22 |
| 23 virtual void encrypt( | 23 virtual void encrypt(const blink::WebCryptoAlgorithm& algorithm, |
| 24 const blink::WebCryptoAlgorithm& algorithm, | 24 const blink::WebCryptoKey& key, |
| 25 const blink::WebCryptoKey& key, | 25 const unsigned char* data, |
| 26 const unsigned char* data, | 26 unsigned int data_size, |
| 27 unsigned int data_size, | 27 blink::WebCryptoResult result); |
| 28 blink::WebCryptoResult result); | 28 virtual void decrypt(const blink::WebCryptoAlgorithm& algorithm, |
| 29 virtual void decrypt( | 29 const blink::WebCryptoKey& key, |
| 30 const blink::WebCryptoAlgorithm& algorithm, | 30 const unsigned char* data, |
| 31 const blink::WebCryptoKey& key, | 31 unsigned int data_size, |
| 32 const unsigned char* data, | 32 blink::WebCryptoResult result); |
| 33 unsigned int data_size, | 33 virtual void digest(const blink::WebCryptoAlgorithm& algorithm, |
| 34 blink::WebCryptoResult result); | 34 const unsigned char* data, |
| 35 virtual void digest( | 35 unsigned int data_size, |
| 36 const blink::WebCryptoAlgorithm& algorithm, | 36 blink::WebCryptoResult result); |
| 37 const unsigned char* data, | 37 virtual void generateKey(const blink::WebCryptoAlgorithm& algorithm, |
| 38 unsigned int data_size, | 38 bool extractable, |
| 39 blink::WebCryptoResult result); | 39 blink::WebCryptoKeyUsageMask usage_mask, |
| 40 virtual void generateKey( | 40 blink::WebCryptoResult result); |
| 41 const blink::WebCryptoAlgorithm& algorithm, | 41 virtual void importKey(blink::WebCryptoKeyFormat format, |
| 42 bool extractable, | 42 const unsigned char* key_data, |
| 43 blink::WebCryptoKeyUsageMask usage_mask, | 43 unsigned int key_data_size, |
| 44 blink::WebCryptoResult result); | 44 const blink::WebCryptoAlgorithm& algorithm_or_null, |
| 45 virtual void importKey( | 45 bool extractable, |
| 46 blink::WebCryptoKeyFormat format, | 46 blink::WebCryptoKeyUsageMask usage_mask, |
| 47 const unsigned char* key_data, | 47 blink::WebCryptoResult result); |
| 48 unsigned int key_data_size, | 48 virtual void exportKey(blink::WebCryptoKeyFormat format, |
| 49 const blink::WebCryptoAlgorithm& algorithm_or_null, | 49 const blink::WebCryptoKey& key, |
| 50 bool extractable, | 50 blink::WebCryptoResult result); |
| 51 blink::WebCryptoKeyUsageMask usage_mask, | 51 virtual void sign(const blink::WebCryptoAlgorithm& algorithm, |
| 52 blink::WebCryptoResult result); | 52 const blink::WebCryptoKey& key, |
| 53 virtual void exportKey( | 53 const unsigned char* data, |
| 54 blink::WebCryptoKeyFormat format, | 54 unsigned int data_size, |
| 55 const blink::WebCryptoKey& key, | 55 blink::WebCryptoResult result); |
| 56 blink::WebCryptoResult result); | 56 virtual void verifySignature(const blink::WebCryptoAlgorithm& algorithm, |
| 57 virtual void sign( | 57 const blink::WebCryptoKey& key, |
| 58 const blink::WebCryptoAlgorithm& algorithm, | 58 const unsigned char* signature, |
| 59 const blink::WebCryptoKey& key, | 59 unsigned int signature_size, |
| 60 const unsigned char* data, | 60 const unsigned char* data, |
| 61 unsigned int data_size, | 61 unsigned int data_size, |
| 62 blink::WebCryptoResult result); | 62 blink::WebCryptoResult result); |
| 63 virtual void verifySignature( | |
| 64 const blink::WebCryptoAlgorithm& algorithm, | |
| 65 const blink::WebCryptoKey& key, | |
| 66 const unsigned char* signature, | |
| 67 unsigned int signature_size, | |
| 68 const unsigned char* data, | |
| 69 unsigned int data_size, | |
| 70 blink::WebCryptoResult result); | |
| 71 | 63 |
| 72 private: | 64 private: |
| 73 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl); | 65 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl); |
| 74 }; | 66 }; |
| 75 | 67 |
| 76 } // namespace content | 68 } // namespace content |
| 77 | 69 |
| 78 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ | 70 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ |
| OLD | NEW |