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