| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SSL_CHANNEL_ID_STORE_H_ | 5 #ifndef NET_SSL_CHANNEL_ID_STORE_H_ |
| 6 #define NET_SSL_CHANNEL_ID_STORE_H_ | 6 #define NET_SSL_CHANNEL_ID_STORE_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <memory> |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "crypto/ec_private_key.h" | 15 #include "crypto/ec_private_key.h" |
| 16 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
| 17 | 17 |
| 18 namespace net { | 18 namespace net { |
| 19 | 19 |
| 20 // An interface for storing and retrieving channel ID keypairs. | 20 // An interface for storing and retrieving channel ID keypairs. |
| 21 // See https://tools.ietf.org/html/draft-balfanz-tls-channelid-01 | 21 // See https://tools.ietf.org/html/draft-balfanz-tls-channelid-01 |
| 22 | 22 |
| 23 // Owned only by a single ChannelIDService object, which is responsible | 23 // Owned only by a single ChannelIDService object, which is responsible |
| 24 // for deleting it. | 24 // for deleting it. |
| 25 class NET_EXPORT ChannelIDStore | 25 class NET_EXPORT ChannelIDStore |
| 26 : NON_EXPORTED_BASE(public base::NonThreadSafe) { | 26 : NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 27 public: | 27 public: |
| 28 // The ChannelID class contains a keypair, along with the corresponding | 28 // The ChannelID class contains a keypair, along with the corresponding |
| 29 // hostname (server identifier) and creation time. | 29 // hostname (server identifier) and creation time. |
| 30 class NET_EXPORT ChannelID { | 30 class NET_EXPORT ChannelID { |
| 31 public: | 31 public: |
| 32 ChannelID(); | 32 ChannelID(); |
| 33 ChannelID(const std::string& server_identifier, | 33 ChannelID(const std::string& server_identifier, |
| 34 base::Time creation_time, | 34 base::Time creation_time, |
| 35 scoped_ptr<crypto::ECPrivateKey> key); | 35 std::unique_ptr<crypto::ECPrivateKey> key); |
| 36 ChannelID(const ChannelID& other); | 36 ChannelID(const ChannelID& other); |
| 37 ChannelID& operator=(const ChannelID& other); | 37 ChannelID& operator=(const ChannelID& other); |
| 38 ~ChannelID(); | 38 ~ChannelID(); |
| 39 | 39 |
| 40 // Server identifier. | 40 // Server identifier. |
| 41 const std::string& server_identifier() const { return server_identifier_; } | 41 const std::string& server_identifier() const { return server_identifier_; } |
| 42 // The time the keypair was created. | 42 // The time the keypair was created. |
| 43 base::Time creation_time() const { return creation_time_; } | 43 base::Time creation_time() const { return creation_time_; } |
| 44 // Returns the keypair for the channel ID. This pointer is only valid for | 44 // Returns the keypair for the channel ID. This pointer is only valid for |
| 45 // the lifetime of the ChannelID object - the ECPrivateKey object remains | 45 // the lifetime of the ChannelID object - the ECPrivateKey object remains |
| 46 // owned by the ChannelID object; no ownership is transferred. | 46 // owned by the ChannelID object; no ownership is transferred. |
| 47 crypto::ECPrivateKey* key() const { return key_.get(); } | 47 crypto::ECPrivateKey* key() const { return key_.get(); } |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 std::string server_identifier_; | 50 std::string server_identifier_; |
| 51 base::Time creation_time_; | 51 base::Time creation_time_; |
| 52 scoped_ptr<crypto::ECPrivateKey> key_; | 52 std::unique_ptr<crypto::ECPrivateKey> key_; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 typedef std::list<ChannelID> ChannelIDList; | 55 typedef std::list<ChannelID> ChannelIDList; |
| 56 | 56 |
| 57 typedef base::Callback< | 57 typedef base::Callback< |
| 58 void(int, const std::string&, scoped_ptr<crypto::ECPrivateKey>)> | 58 void(int, const std::string&, std::unique_ptr<crypto::ECPrivateKey>)> |
| 59 GetChannelIDCallback; | 59 GetChannelIDCallback; |
| 60 typedef base::Callback<void(const ChannelIDList&)> GetChannelIDListCallback; | 60 typedef base::Callback<void(const ChannelIDList&)> GetChannelIDListCallback; |
| 61 | 61 |
| 62 virtual ~ChannelIDStore() {} | 62 virtual ~ChannelIDStore() {} |
| 63 | 63 |
| 64 // GetChannelID may return the result synchronously through the | 64 // GetChannelID may return the result synchronously through the |
| 65 // output parameters, in which case it will return either OK if a keypair is | 65 // output parameters, in which case it will return either OK if a keypair is |
| 66 // found in the store, or ERR_FILE_NOT_FOUND if none is found. If the | 66 // found in the store, or ERR_FILE_NOT_FOUND if none is found. If the |
| 67 // result cannot be returned synchronously, GetChannelID will | 67 // result cannot be returned synchronously, GetChannelID will |
| 68 // return ERR_IO_PENDING and the callback will be called with the result | 68 // return ERR_IO_PENDING and the callback will be called with the result |
| 69 // asynchronously. | 69 // asynchronously. |
| 70 virtual int GetChannelID(const std::string& server_identifier, | 70 virtual int GetChannelID(const std::string& server_identifier, |
| 71 scoped_ptr<crypto::ECPrivateKey>* key_result, | 71 std::unique_ptr<crypto::ECPrivateKey>* key_result, |
| 72 const GetChannelIDCallback& callback) = 0; | 72 const GetChannelIDCallback& callback) = 0; |
| 73 | 73 |
| 74 // Adds the keypair for a hostname to the store. | 74 // Adds the keypair for a hostname to the store. |
| 75 virtual void SetChannelID(scoped_ptr<ChannelID> channel_id) = 0; | 75 virtual void SetChannelID(std::unique_ptr<ChannelID> channel_id) = 0; |
| 76 | 76 |
| 77 // Removes a keypair from the store. | 77 // Removes a keypair from the store. |
| 78 virtual void DeleteChannelID( | 78 virtual void DeleteChannelID( |
| 79 const std::string& server_identifier, | 79 const std::string& server_identifier, |
| 80 const base::Closure& completion_callback) = 0; | 80 const base::Closure& completion_callback) = 0; |
| 81 | 81 |
| 82 // Deletes all of the channel ID keypairs that have a creation_date greater | 82 // Deletes all of the channel ID keypairs that have a creation_date greater |
| 83 // than or equal to |delete_begin| and less than |delete_end|. If a | 83 // than or equal to |delete_begin| and less than |delete_end|. If a |
| 84 // base::Time value is_null, that side of the comparison is unbounded. | 84 // base::Time value is_null, that side of the comparison is unbounded. |
| 85 virtual void DeleteAllCreatedBetween( | 85 virtual void DeleteAllCreatedBetween( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 106 virtual void SetForceKeepSessionState() = 0; | 106 virtual void SetForceKeepSessionState() = 0; |
| 107 | 107 |
| 108 // Returns true if this ChannelIDStore is ephemeral, and false if it is | 108 // Returns true if this ChannelIDStore is ephemeral, and false if it is |
| 109 // persistent. | 109 // persistent. |
| 110 virtual bool IsEphemeral() = 0; | 110 virtual bool IsEphemeral() = 0; |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 } // namespace net | 113 } // namespace net |
| 114 | 114 |
| 115 #endif // NET_SSL_CHANNEL_ID_STORE_H_ | 115 #endif // NET_SSL_CHANNEL_ID_STORE_H_ |
| OLD | NEW |