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

Unified 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: more mac build fix, this is blind while mac checkout syncs 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/ssl/ssl_private_key.h ('k') | net/ssl/threaded_ssl_private_key.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ssl/threaded_ssl_private_key.h
diff --git a/net/ssl/threaded_ssl_private_key.h b/net/ssl/threaded_ssl_private_key.h
new file mode 100644
index 0000000000000000000000000000000000000000..9c364dd8acaedf664e628bbe4dcc044a5002b065
--- /dev/null
+++ b/net/ssl/threaded_ssl_private_key.h
@@ -0,0 +1,77 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_SSL_THREADED_SSL_PRIVATE_KEY_H_
+#define NET_SSL_THREADED_SSL_PRIVATE_KEY_H_
+
+#include <stdint.h>
+
+#include <vector>
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "base/strings/string_piece.h"
+#include "net/ssl/ssl_private_key.h"
+
+namespace base {
+class TaskRunner;
+}
+
+namespace net {
+
+// An SSLPrivateKey implementation which offloads key operations to a background
+// task runner.
+class ThreadedSSLPrivateKey : public SSLPrivateKey {
+ public:
+ // Interface for consumers to implement to perform the actual signing
+ // operation.
+ class Delegate {
+ public:
+ Delegate() {}
+ virtual ~Delegate() {}
+
+ // These methods behave as those of the same name on SSLPrivateKey. They
+ // must be callable on any thread.
+ virtual Type GetType() = 0;
+ virtual bool SupportsHash(Hash hash) = 0;
+ virtual size_t GetMaxSignatureLengthInBytes() = 0;
+
+ // Signs |input| as a digest of type |hash|. On sucess it returns OK and
+ // sets |signature| to the resulting signature. Otherwise it returns a net
+ // error code. It will only be called on the task runner passed to the
+ // owning ThreadedSSLPrivateKey.
+ virtual Error SignDigest(Hash hash,
+ const base::StringPiece& input,
+ std::vector<uint8_t>* signature) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Delegate);
+ };
+
+ ThreadedSSLPrivateKey(scoped_ptr<Delegate> delegate,
+ scoped_refptr<base::TaskRunner> task_runner);
+ ~ThreadedSSLPrivateKey() override;
+
+ // SSLPrivateKey implementation.
+ Type GetType() override;
+ bool SupportsHash(Hash hash) override;
+ size_t GetMaxSignatureLengthInBytes() override;
+ void SignDigest(Hash hash,
+ const base::StringPiece& input,
+ const SignCallback& callback) override;
+
+ private:
+ class Core;
+
+ scoped_refptr<Core> core_;
+ scoped_refptr<base::TaskRunner> task_runner_;
+ base::WeakPtrFactory<ThreadedSSLPrivateKey> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ThreadedSSLPrivateKey);
+};
+
+} // namespace net
+
+#endif // NET_SSL_THREADED_SSL_PRIVATE_KEY_H_
« no previous file with comments | « net/ssl/ssl_private_key.h ('k') | net/ssl/threaded_ssl_private_key.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698