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 | 11 |
11 #include "net/base/net_api.h" | 12 #include "net/base/net_api.h" |
12 | 13 |
13 namespace net { | 14 namespace net { |
14 | 15 |
15 // An interface for storing and retrieving origin bound certs. Origin bound | 16 // An interface for storing and retrieving origin bound certs. Origin bound |
16 // certificates are specified in | 17 // certificates are specified in |
17 // http://balfanz.github.com/tls-obc-spec/draft-balfanz-tls-obc-00.html. | 18 // http://balfanz.github.com/tls-obc-spec/draft-balfanz-tls-obc-00.html. |
18 | 19 |
19 // Owned only by a single OriginBoundCertService object, which is responsible | 20 // Owned only by a single OriginBoundCertService object, which is responsible |
20 // for deleting it. | 21 // for deleting it. |
21 | 22 |
22 class NET_API OriginBoundCertStore { | 23 class NET_API OriginBoundCertStore { |
23 public: | 24 public: |
| 25 // Used by GetAllOriginBoundCerts. |
| 26 struct OriginBoundCertInfo { |
| 27 std::string origin; // Origin, for instance "https://www.verisign.com:443". |
| 28 std::string private_key; // DER-encoded PrivateKeyInfo struct. |
| 29 std::string cert; // DER-encoded certificate. |
| 30 }; |
| 31 |
24 virtual ~OriginBoundCertStore() {} | 32 virtual ~OriginBoundCertStore() {} |
25 | 33 |
26 // TODO(rkn): Specify certificate type (RSA or DSA). | 34 // TODO(rkn): Specify certificate type (RSA or DSA). |
27 // TODO(rkn): File I/O may be required, so this should have an asynchronous | 35 // TODO(rkn): File I/O may be required, so this should have an asynchronous |
28 // interface. | 36 // interface. |
29 // Returns true on success. |private_key_result| stores a DER-encoded | 37 // Returns true on success. |private_key_result| stores a DER-encoded |
30 // PrivateKeyInfo struct and |cert_result| stores a DER-encoded | 38 // PrivateKeyInfo struct and |cert_result| stores a DER-encoded |
31 // certificate. Returns false if no origin bound cert exists for the | 39 // certificate. Returns false if no origin bound cert exists for the |
32 // specified origin. | 40 // specified origin. |
33 virtual bool GetOriginBoundCert(const std::string& origin, | 41 virtual bool GetOriginBoundCert(const std::string& origin, |
34 std::string* private_key_result, | 42 std::string* private_key_result, |
35 std::string* cert_result) = 0; | 43 std::string* cert_result) = 0; |
36 | 44 |
37 // Adds an origin bound cert to the store. | 45 // Adds an origin bound cert and the corresponding private key to the store. |
38 virtual bool SetOriginBoundCert(const std::string& origin, | 46 virtual void SetOriginBoundCert(const std::string& origin, |
39 const std::string& private_key, | 47 const std::string& private_key, |
40 const std::string& cert) = 0; | 48 const std::string& cert) = 0; |
41 | 49 |
| 50 // Removes an origin bound cert and the corresponding private key from the |
| 51 // store. |
| 52 virtual void DeleteOriginBoundCert(const std::string& origin) = 0; |
| 53 |
| 54 // Removes all origin bound certs and the corresponding private keys from |
| 55 // the store. |
| 56 virtual void DeleteAll() = 0; |
| 57 |
| 58 // Returns all origin bound certs and the corresponding private keys. |
| 59 virtual void GetAllOriginBoundCerts( |
| 60 std::vector<OriginBoundCertInfo>* origin_bound_certs) = 0; |
| 61 |
42 // Returns the number of certs in the store. | 62 // Returns the number of certs in the store. |
43 // Public only for unit testing. | 63 // Public only for unit testing. |
44 virtual int GetCertCount() = 0; | 64 virtual int GetCertCount() = 0; |
45 }; | 65 }; |
46 | 66 |
47 } // namespace net | 67 } // namespace net |
48 | 68 |
49 #endif // NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ | 69 #endif // NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ |
OLD | NEW |