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

Side by Side Diff: net/base/origin_bound_cert_store.h

Issue 8662036: Support EC certs in OriginBoundCertService and OriginBoundCertStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review changes Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « net/base/origin_bound_cert_service_unittest.cc ('k') | net/base/origin_bound_cert_store.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ssl_client_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 // The OriginBoundCert class contains a private key in addition to the origin
26 struct OriginBoundCertInfo { 27 // cert, and cert type.
27 std::string origin; // Origin, for instance "https://www.verisign.com:443". 28 class NET_EXPORT OriginBoundCert {
28 std::string private_key; // DER-encoded PrivateKeyInfo struct. 29 public:
29 std::string cert; // DER-encoded certificate. 30 OriginBoundCert();
31 OriginBoundCert(const std::string& origin,
32 SSLClientCertType type,
33 const std::string& private_key,
34 const std::string& cert);
35 ~OriginBoundCert();
36
37 // Origin, for instance "https://www.verisign.com:443"
38 const std::string& origin() const { return origin_; }
39 // TLS ClientCertificateType.
40 SSLClientCertType type() const { return type_; }
41 // The encoding of the private key depends on the type.
42 // rsa_sign: DER-encoded PrivateKeyInfo struct.
43 // ecdsa_sign: DER-encoded EncryptedPrivateKeyInfo struct.
44 const std::string& private_key() const { return private_key_; }
45 // DER-encoded certificate.
46 const std::string& cert() const { return cert_; }
47
48 private:
49 std::string origin_;
50 SSLClientCertType type_;
51 std::string private_key_;
52 std::string cert_;
30 }; 53 };
31 54
32 virtual ~OriginBoundCertStore() {} 55 virtual ~OriginBoundCertStore() {}
33 56
34 // TODO(rkn): Specify certificate type (RSA or DSA).
35 // TODO(rkn): File I/O may be required, so this should have an asynchronous 57 // TODO(rkn): File I/O may be required, so this should have an asynchronous
36 // interface. 58 // interface.
37 // Returns true on success. |private_key_result| stores a DER-encoded 59 // Returns true on success. |private_key_result| stores a DER-encoded
38 // PrivateKeyInfo struct and |cert_result| stores a DER-encoded 60 // PrivateKeyInfo struct and |cert_result| stores a DER-encoded
39 // certificate. Returns false if no origin bound cert exists for the 61 // certificate. Returns false if no origin bound cert exists for the
40 // specified origin. 62 // specified origin.
41 virtual bool GetOriginBoundCert(const std::string& origin, 63 virtual bool GetOriginBoundCert(
42 std::string* private_key_result, 64 const std::string& origin,
43 std::string* cert_result) = 0; 65 SSLClientCertType* type,
66 std::string* private_key_result,
67 std::string* cert_result) = 0;
44 68
45 // Adds an origin bound cert and the corresponding private key to the store. 69 // Adds an origin bound cert and the corresponding private key to the store.
46 virtual void SetOriginBoundCert(const std::string& origin, 70 virtual void SetOriginBoundCert(
47 const std::string& private_key, 71 const std::string& origin,
48 const std::string& cert) = 0; 72 SSLClientCertType type,
73 const std::string& private_key,
74 const std::string& cert) = 0;
49 75
50 // Removes an origin bound cert and the corresponding private key from the 76 // Removes an origin bound cert and the corresponding private key from the
51 // store. 77 // store.
52 virtual void DeleteOriginBoundCert(const std::string& origin) = 0; 78 virtual void DeleteOriginBoundCert(const std::string& origin) = 0;
53 79
54 // Removes all origin bound certs and the corresponding private keys from 80 // Removes all origin bound certs and the corresponding private keys from
55 // the store. 81 // the store.
56 virtual void DeleteAll() = 0; 82 virtual void DeleteAll() = 0;
57 83
58 // Returns all origin bound certs and the corresponding private keys. 84 // Returns all origin bound certs and the corresponding private keys.
59 virtual void GetAllOriginBoundCerts( 85 virtual void GetAllOriginBoundCerts(
60 std::vector<OriginBoundCertInfo>* origin_bound_certs) = 0; 86 std::vector<OriginBoundCert>* origin_bound_certs) = 0;
61 87
62 // Returns the number of certs in the store. 88 // Returns the number of certs in the store.
63 // Public only for unit testing. 89 // Public only for unit testing.
64 virtual int GetCertCount() = 0; 90 virtual int GetCertCount() = 0;
65 }; 91 };
66 92
67 } // namespace net 93 } // namespace net
68 94
69 #endif // NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ 95 #endif // NET_BASE_ORIGIN_BOUND_CERT_STORE_H_
OLDNEW
« no previous file with comments | « net/base/origin_bound_cert_service_unittest.cc ('k') | net/base/origin_bound_cert_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698