Chromium Code Reviews| Index: net/ssl/ssl_private_key.h |
| diff --git a/net/ssl/ssl_private_key.h b/net/ssl/ssl_private_key.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8691f9c72dc500f01a8373bd6bb8b1f9fe8bc796 |
| --- /dev/null |
| +++ b/net/ssl/ssl_private_key.h |
| @@ -0,0 +1,66 @@ |
| +// 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_SSL_PRIVATE_KEY_H_ |
| +#define NET_SSL_SSL_PRIVATE_KEY_H_ |
| + |
| +#include <vector> |
| + |
| +#include "base/callback_forward.h" |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/strings/string_piece.h" |
| +#include "net/base/net_errors.h" |
| + |
| +namespace net { |
| + |
| +// An interface for a private key for use with SSL client authentication. |
| +class SSLPrivateKey { |
|
Ryan Sleevi
2015/06/12 23:37:20
It's unclear why you split this and the threaded i
davidben
2015/06/15 21:28:25
SSLClientSocketOpenSSL doesn't care that the opera
|
| + public: |
| + using SignCallback = base::Callback<void(Error, const std::vector<uint8_t>&)>; |
|
Ryan Sleevi
2015/06/12 23:37:20
Blergh; I generally hate typedefs like these; I fi
davidben
2015/06/15 21:28:25
It's used a medium-ish amount of times between thi
Ryan Sleevi
2015/06/15 22:35:27
I guess it depends on whether or not you're using
davidben
2015/06/15 22:41:20
Hrm? I'm not sure I follow. Is there any consumer
Ryan Sleevi
2015/06/15 23:02:06
Well, strictly speaking, callbacks are meant to br
|
| + |
| + enum class Type { |
| + RSA, |
| + ECDSA, |
| + }; |
| + |
| + enum class Hash { |
| + MD5_SHA1, |
| + MD5, |
| + SHA1, |
| + SHA224, |
| + SHA256, |
| + SHA384, |
| + SHA512, |
| + }; |
| + |
| + SSLPrivateKey() {} |
| + virtual ~SSLPrivateKey() {} |
| + |
| + // Returns whether the key is an RSA key or an ECDSA key. |
| + virtual Type GetType() = 0; |
|
Ryan Sleevi
2015/06/12 23:37:20
:/
This seems to violate http://google-styleguide
davidben
2015/06/15 21:28:24
Per out-of-band discussion, added a comment to Get
|
| + |
| + // Returns true if the key supports signing hashes of type |hash|. |
| + virtual bool SupportsHash(Hash hash) = 0; |
| + |
| + // Returns the maximum size of a signature. For an RSA key, this must be the |
| + // size of the modulus in bytes. |
| + virtual size_t GetMaxSignatureLength() = 0; |
|
Ryan Sleevi
2015/06/12 23:37:20
I suppose this API works because we assume asymetr
davidben
2015/06/15 21:28:25
I'm not sure what you mean. It's the caller's job
|
| + |
| + // Asynchronously signs an |input| which was computed with the hash |hash|. On |
| + // completion, it calls |callback| with the signature or an error code if the |
| + // operation failed. For an RSA key, the signature is a PKCS#1 signature. The |
| + // SSLPrivateKey implementation is responsible for prepending the DigestInfo |
| + // prefix and adding PKCS#1 padding. |
| + virtual void SignDigest(Hash hash, |
| + const base::StringPiece& input, |
| + const SignCallback& callback) = 0; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(SSLPrivateKey); |
| +}; |
| + |
| +} // namespace net |
| + |
| +#endif // NET_SSL_SSL_PRIVATE_KEY_H_ |