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

Side by Side Diff: net/ssl/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: fix net_nacl 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_SSL_PRIVATE_KEY_H_
6 #define NET_SSL_SSL_PRIVATE_KEY_H_
7
8 #include <vector>
9
10 #include "base/callback_forward.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string_piece.h"
14 #include "net/base/net_errors.h"
15
16 namespace net {
17
18 // An interface for a private key for use with SSL client authentication.
19 class SSLPrivateKey {
20 public:
21 using SignCallback = base::Callback<void(Error, const std::vector<uint8_t>&)>;
Ryan Sleevi 2015/06/23 15:27:29 need stdint.h
davidben 2015/06/24 21:43:12 Done.
22
23 enum class Type {
24 RSA,
25 ECDSA,
26 };
27
28 enum class Hash {
29 MD5_SHA1,
30 MD5,
31 SHA1,
32 SHA224,
33 SHA256,
34 SHA384,
35 SHA512,
36 };
37
38 SSLPrivateKey() {}
39 virtual ~SSLPrivateKey() {}
40
41 // Returns whether the key is an RSA key or an ECDSA key. Although the signing
42 // interface is type-agnositic and type tags in interfaces are discouraged,
43 // TLS has key-specific logic in selecting which hashes to sign. Exposing the
44 // key type avoids replicating BoringSSL's TLS-specific logic in SSLPrivateKey
45 // implementations and complicating the interface between Chromium and
46 // BoringSSL.
47 virtual Type GetType() = 0;
48
49 // Returns true if the key supports signing hashes of type |hash|.
50 virtual bool SupportsHash(Hash hash) = 0;
51
52 // Returns the maximum size of a signature. For an RSA key, this must be the
53 // size of the modulus in bytes.
54 virtual size_t GetMaxSignatureLength() = 0;
Ryan Sleevi 2015/06/23 15:27:29 While reviewing this, I still found it confusing t
davidben 2015/06/24 21:43:12 Done, though I think a comment is sufficient for s
Ryan Sleevi 2015/06/30 10:18:22 If the suggestion is that if you wanted bits, you'
55
56 // Asynchronously signs an |input| which was computed with the hash |hash|. On
57 // completion, it calls |callback| with the signature or an error code if the
58 // operation failed. For an RSA key, the signature is a PKCS#1 signature. The
59 // SSLPrivateKey implementation is responsible for prepending the DigestInfo
60 // prefix and adding PKCS#1 padding.
61 virtual void SignDigest(Hash hash,
62 const base::StringPiece& input,
63 const SignCallback& callback) = 0;
64
65 private:
66 DISALLOW_COPY_AND_ASSIGN(SSLPrivateKey);
67 };
68
69 } // namespace net
70
71 #endif // NET_SSL_SSL_PRIVATE_KEY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698