| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 NET_SSL_THREADED_SSL_PRIVATE_KEY_H_ | 5 #ifndef NET_SSL_THREADED_SSL_PRIVATE_KEY_H_ |
| 6 #define NET_SSL_THREADED_SSL_PRIVATE_KEY_H_ | 6 #define NET_SSL_THREADED_SSL_PRIVATE_KEY_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // task runner. | 27 // task runner. |
| 28 class ThreadedSSLPrivateKey : public SSLPrivateKey { | 28 class ThreadedSSLPrivateKey : public SSLPrivateKey { |
| 29 public: | 29 public: |
| 30 // Interface for consumers to implement to perform the actual signing | 30 // Interface for consumers to implement to perform the actual signing |
| 31 // operation. | 31 // operation. |
| 32 class Delegate { | 32 class Delegate { |
| 33 public: | 33 public: |
| 34 Delegate() {} | 34 Delegate() {} |
| 35 virtual ~Delegate() {} | 35 virtual ~Delegate() {} |
| 36 | 36 |
| 37 // These methods behave as those of the same name on SSLPrivateKey. They | 37 // Returns the digests that are supported by the key in decreasing |
| 38 // must be callable on any thread. | 38 // preference. This method must be callable on any thread. |
| 39 virtual Type GetType() = 0; | |
| 40 virtual std::vector<SSLPrivateKey::Hash> GetDigestPreferences() = 0; | 39 virtual std::vector<SSLPrivateKey::Hash> GetDigestPreferences() = 0; |
| 41 virtual size_t GetMaxSignatureLengthInBytes() = 0; | |
| 42 | 40 |
| 43 // Signs |input| as a digest of type |hash|. On success it returns OK and | 41 // Signs |input| as a digest of type |hash|. On success it returns OK and |
| 44 // sets |signature| to the resulting signature. Otherwise it returns a net | 42 // sets |signature| to the resulting signature. Otherwise it returns a net |
| 45 // error code. It will only be called on the task runner passed to the | 43 // error code. It will only be called on the task runner passed to the |
| 46 // owning ThreadedSSLPrivateKey. | 44 // owning ThreadedSSLPrivateKey. |
| 47 virtual Error SignDigest(Hash hash, | 45 virtual Error SignDigest(Hash hash, |
| 48 const base::StringPiece& input, | 46 const base::StringPiece& input, |
| 49 std::vector<uint8_t>* signature) = 0; | 47 std::vector<uint8_t>* signature) = 0; |
| 50 | 48 |
| 51 private: | 49 private: |
| 52 DISALLOW_COPY_AND_ASSIGN(Delegate); | 50 DISALLOW_COPY_AND_ASSIGN(Delegate); |
| 53 }; | 51 }; |
| 54 | 52 |
| 55 ThreadedSSLPrivateKey( | 53 ThreadedSSLPrivateKey( |
| 56 std::unique_ptr<Delegate> delegate, | 54 std::unique_ptr<Delegate> delegate, |
| 57 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 55 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| 58 | 56 |
| 59 // SSLPrivateKey implementation. | 57 // SSLPrivateKey implementation. |
| 60 Type GetType() override; | |
| 61 std::vector<SSLPrivateKey::Hash> GetDigestPreferences() override; | 58 std::vector<SSLPrivateKey::Hash> GetDigestPreferences() override; |
| 62 size_t GetMaxSignatureLengthInBytes() override; | |
| 63 void SignDigest(Hash hash, | 59 void SignDigest(Hash hash, |
| 64 const base::StringPiece& input, | 60 const base::StringPiece& input, |
| 65 const SignCallback& callback) override; | 61 const SignCallback& callback) override; |
| 66 | 62 |
| 67 private: | 63 private: |
| 68 ~ThreadedSSLPrivateKey() override; | 64 ~ThreadedSSLPrivateKey() override; |
| 69 class Core; | 65 class Core; |
| 70 | 66 |
| 71 scoped_refptr<Core> core_; | 67 scoped_refptr<Core> core_; |
| 72 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 68 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 73 base::WeakPtrFactory<ThreadedSSLPrivateKey> weak_factory_; | 69 base::WeakPtrFactory<ThreadedSSLPrivateKey> weak_factory_; |
| 74 | 70 |
| 75 DISALLOW_COPY_AND_ASSIGN(ThreadedSSLPrivateKey); | 71 DISALLOW_COPY_AND_ASSIGN(ThreadedSSLPrivateKey); |
| 76 }; | 72 }; |
| 77 | 73 |
| 78 } // namespace net | 74 } // namespace net |
| 79 | 75 |
| 80 #endif // NET_SSL_THREADED_SSL_PRIVATE_KEY_H_ | 76 #endif // NET_SSL_THREADED_SSL_PRIVATE_KEY_H_ |
| OLD | NEW |