OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BASE_ORIGIN_BOUND_CERT_STORE_H_ | 5 #ifndef NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ |
6 #define NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ | 6 #define NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
13 #include "net/base/origin_bound_cert_type.h" | |
13 | 14 |
14 namespace net { | 15 namespace net { |
15 | 16 |
16 // An interface for storing and retrieving origin bound certs. Origin bound | 17 // An interface for storing and retrieving origin bound certs. Origin bound |
17 // certificates are specified in | 18 // certificates are specified in |
18 // http://balfanz.github.com/tls-obc-spec/draft-balfanz-tls-obc-00.html. | 19 // http://balfanz.github.com/tls-obc-spec/draft-balfanz-tls-obc-00.html. |
19 | 20 |
20 // Owned only by a single OriginBoundCertService object, which is responsible | 21 // Owned only by a single OriginBoundCertService object, which is responsible |
21 // for deleting it. | 22 // for deleting it. |
22 | 23 |
23 class NET_EXPORT OriginBoundCertStore { | 24 class NET_EXPORT OriginBoundCertStore { |
24 public: | 25 public: |
25 // Used by GetAllOriginBoundCerts. | 26 // Used by GetAllOriginBoundCerts. |
26 struct OriginBoundCertInfo { | 27 struct OriginBoundCertInfo { |
27 std::string origin; // Origin, for instance "https://www.verisign.com:443". | 28 std::string origin; // Origin, for instance "https://www.verisign.com:443". |
29 OriginBoundCertType type; | |
Ryan Sleevi
2011/11/25 00:07:02
This may put you close to the clang style warning
mattm
2011/12/02 01:55:59
will do.
| |
28 std::string private_key; // DER-encoded PrivateKeyInfo struct. | 30 std::string private_key; // DER-encoded PrivateKeyInfo struct. |
29 std::string cert; // DER-encoded certificate. | 31 std::string cert; // DER-encoded certificate. |
30 }; | 32 }; |
31 | 33 |
32 virtual ~OriginBoundCertStore() {} | 34 virtual ~OriginBoundCertStore() {} |
33 | 35 |
34 // TODO(rkn): Specify certificate type (RSA or DSA). | |
35 // TODO(rkn): File I/O may be required, so this should have an asynchronous | 36 // TODO(rkn): File I/O may be required, so this should have an asynchronous |
36 // interface. | 37 // interface. |
37 // Returns true on success. |private_key_result| stores a DER-encoded | 38 // Returns true on success. |private_key_result| stores a DER-encoded |
38 // PrivateKeyInfo struct and |cert_result| stores a DER-encoded | 39 // PrivateKeyInfo struct and |cert_result| stores a DER-encoded |
39 // certificate. Returns false if no origin bound cert exists for the | 40 // certificate. Returns false if no origin bound cert exists for the |
40 // specified origin. | 41 // specified origin. |
41 virtual bool GetOriginBoundCert(const std::string& origin, | 42 virtual bool GetOriginBoundCert( |
42 std::string* private_key_result, | 43 const std::string& origin, |
wtc
2011/11/30 23:23:40
IMPORTANT: I think we should also pass requested_t
mattm
2011/12/01 00:06:27
This is only storing one type of cert per origin.
| |
43 std::string* cert_result) = 0; | 44 OriginBoundCertType* type, |
45 std::string* private_key_result, | |
46 std::string* cert_result) = 0; | |
44 | 47 |
45 // Adds an origin bound cert and the corresponding private key to the store. | 48 // Adds an origin bound cert and the corresponding private key to the store. |
46 virtual void SetOriginBoundCert(const std::string& origin, | 49 virtual void SetOriginBoundCert( |
47 const std::string& private_key, | 50 const std::string& origin, |
48 const std::string& cert) = 0; | 51 OriginBoundCertType type, |
52 const std::string& private_key, | |
53 const std::string& cert) = 0; | |
49 | 54 |
50 // Removes an origin bound cert and the corresponding private key from the | 55 // Removes an origin bound cert and the corresponding private key from the |
51 // store. | 56 // store. |
52 virtual void DeleteOriginBoundCert(const std::string& origin) = 0; | 57 virtual void DeleteOriginBoundCert(const std::string& origin) = 0; |
53 | 58 |
54 // Removes all origin bound certs and the corresponding private keys from | 59 // Removes all origin bound certs and the corresponding private keys from |
55 // the store. | 60 // the store. |
56 virtual void DeleteAll() = 0; | 61 virtual void DeleteAll() = 0; |
57 | 62 |
58 // Returns all origin bound certs and the corresponding private keys. | 63 // Returns all origin bound certs and the corresponding private keys. |
59 virtual void GetAllOriginBoundCerts( | 64 virtual void GetAllOriginBoundCerts( |
60 std::vector<OriginBoundCertInfo>* origin_bound_certs) = 0; | 65 std::vector<OriginBoundCertInfo>* origin_bound_certs) = 0; |
61 | 66 |
62 // Returns the number of certs in the store. | 67 // Returns the number of certs in the store. |
63 // Public only for unit testing. | 68 // Public only for unit testing. |
64 virtual int GetCertCount() = 0; | 69 virtual int GetCertCount() = 0; |
65 }; | 70 }; |
66 | 71 |
67 } // namespace net | 72 } // namespace net |
68 | 73 |
69 #endif // NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ | 74 #endif // NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ |
OLD | NEW |