Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: net/ssl/threaded_ssl_private_key.h

Issue 1178193002: Sign CertificateVerify messages on a background thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rsleevi comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_SSL_THREADED_SSL_PRIVATE_KEY_H_
6 #define NET_SSL_THREADED_SSL_PRIVATE_KEY_H_
7
8 #include <stdint.h>
9
10 #include <vector>
11
12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/strings/string_piece.h"
16 #include "net/ssl/ssl_private_key.h"
17
18 namespace base {
19 class TaskRunner;
20 }
21
22 namespace net {
23
24 // An SSLPrivateKey implementation which offloads key operations to a background
25 // thread.
26 class ThreadedSSLPrivateKey : public SSLPrivateKey {
27 public:
28 // Interface for consumers to implement to perform the actual signing
29 // operation. All methods must be callable on any thread.
30 class Delegate {
31 public:
32 Delegate() {}
33 virtual ~Delegate() {}
34
35 virtual Type GetType() = 0;
36 virtual bool SupportsHash(Hash hash) = 0;
37 virtual size_t GetMaxSignatureLength() = 0;
38 virtual Error SignDigest(Hash hash,
39 const base::StringPiece& input,
40 std::vector<uint8_t>* signature) = 0;
41
42 private:
43 DISALLOW_COPY_AND_ASSIGN(Delegate);
44 };
45
46 ThreadedSSLPrivateKey(scoped_ptr<Delegate> delegate,
47 const scoped_refptr<base::TaskRunner>& task_runner);
48 ~ThreadedSSLPrivateKey() override;
49
50 // SSLPrivateKey implementation.
51 Type GetType() override;
52 bool SupportsHash(Hash hash) override;
53 size_t GetMaxSignatureLength() override;
54 void SignDigest(Hash hash,
55 const base::StringPiece& input,
56 const SignCallback& callback) override;
57
58 private:
59 class Core;
60
61 // A wrapper over SignCallback to ensure the callback isn't called if the key
62 // is destroyed.
63 void DoCallback(const SignCallback& callback,
64 std::vector<uint8_t>* signature,
65 Error error);
Ryan Sleevi 2015/06/15 22:55:23 nit: I'm still unclear why this needs to be a priv
davidben 2015/06/17 20:47:02 Done.
66
67 scoped_refptr<Core> core_;
68 scoped_refptr<base::TaskRunner> task_runner_;
69 base::WeakPtrFactory<ThreadedSSLPrivateKey> weak_factory_;
70
71 DISALLOW_COPY_AND_ASSIGN(ThreadedSSLPrivateKey);
72 };
73
74 } // namespace net
75
76 #endif // NET_SSL_THREADED_SSL_PRIVATE_KEY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698