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

Side by Side Diff: components/gcm_driver/crypto/gcm_encryption_provider.h

Issue 1953273002: Add support to GCMKeyStore for multiple keys per app_id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@iid6fixstore
Patch Set: Simplify Decrypt fallback by banning IID token & GCM reg from sharing same app_id Created 4 years, 7 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_ 5 #ifndef COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_
6 #define COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_ 6 #define COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 ~GCMEncryptionProvider(); 75 ~GCMEncryptionProvider();
76 76
77 // Initializes the encryption provider with the |store_path| and the 77 // Initializes the encryption provider with the |store_path| and the
78 // |blocking_task_runner|. Done separately from the constructor in order to 78 // |blocking_task_runner|. Done separately from the constructor in order to
79 // avoid needing a blocking task runner for anything using GCMDriver. 79 // avoid needing a blocking task runner for anything using GCMDriver.
80 void Init( 80 void Init(
81 const base::FilePath& store_path, 81 const base::FilePath& store_path,
82 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner); 82 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner);
83 83
84 // Retrieves the public key and authentication secret associated with the 84 // Retrieves the public key and authentication secret associated with the
85 // |app_id|. If none have been associated yet, they will be created. 85 // |app_id| + authorized entity pair. Will create this info if necessary.
86 // |instance_id_authorized_entity|: pass InstanceID token's authorized_entity
87 // or "" for legacy GCM registrations.
Peter Beverloo 2016/05/09 14:10:09 nit: I would like to find a better way of phrasing
Peter Beverloo 2016/05/09 14:10:09 nit: Here and elsewhere, please be consistent with
johnme 2016/05/09 18:15:54 Done ("non-InstanceID", since the v3/v4 split requ
johnme 2016/05/09 18:15:54 Done.
86 void GetEncryptionInfo(const std::string& app_id, 88 void GetEncryptionInfo(const std::string& app_id,
89 const std::string& instance_id_authorized_entity,
Peter Beverloo 2016/05/09 14:10:09 nit: s/instance_id_authorized_entity/authorized_en
johnme 2016/05/09 18:15:54 Done (thank goodness for git cl format!).
87 const EncryptionInfoCallback& callback); 90 const EncryptionInfoCallback& callback);
88 91
89 // Removes all encryption information associated with the |app_id|. Will 92 // Removes all encryption information associated with the |app_id| +
90 // invoke the |callback| when this has finished. 93 // authorized entity pair, then invokes |callback|.
94 // |instance_id_authorized_entity|: pass InstanceID token's authorized_entity
95 // or "*" to remove for all InstanceID tokens
96 // or "" for legacy GCM registrations.
91 void RemoveEncryptionInfo(const std::string& app_id, 97 void RemoveEncryptionInfo(const std::string& app_id,
98 const std::string& instance_id_authorized_entity,
92 const base::Closure& callback); 99 const base::Closure& callback);
93 100
94 // Determines whether |message| contains encrypted content. 101 // Determines whether |message| contains encrypted content.
95 bool IsEncryptedMessage(const IncomingMessage& message) const; 102 bool IsEncryptedMessage(const IncomingMessage& message) const;
96 103
97 // Attempts to decrypt the |message|. If the |message| is not encrypted, the 104 // Attempts to decrypt the |message|. If the |message| is not encrypted, the
98 // |callback| will be invoked immediately. Otherwise |callback| will be called 105 // |callback| will be invoked immediately. Otherwise |callback| will be called
99 // asynchronously when |message| has been decrypted. A dispatchable message 106 // asynchronously when |message| has been decrypted. A dispatchable message
100 // will be used in case of success, an empty message in case of failure. 107 // will be used in case of success, an empty message in case of failure.
101 void DecryptMessage(const std::string& app_id, 108 void DecryptMessage(const std::string& app_id,
102 const IncomingMessage& message, 109 const IncomingMessage& message,
103 const MessageCallback& callback); 110 const MessageCallback& callback);
104 111
105 private: 112 private:
106 FRIEND_TEST_ALL_PREFIXES(GCMEncryptionProviderTest, EncryptionRoundTrip); 113 friend class GCMEncryptionProviderTest;
114 FRIEND_TEST_ALL_PREFIXES(GCMEncryptionProviderTest,
115 EncryptionRoundTripGCMRegistration);
116 FRIEND_TEST_ALL_PREFIXES(GCMEncryptionProviderTest,
117 EncryptionRoundTripInstanceIDToken);
107 118
108 void DidGetEncryptionInfo(const std::string& app_id, 119 void DidGetEncryptionInfo(const std::string& app_id,
120 const std::string& instance_id_authorized_entity,
109 const EncryptionInfoCallback& callback, 121 const EncryptionInfoCallback& callback,
110 const KeyPair& pair, 122 const KeyPair& pair,
111 const std::string& auth_secret); 123 const std::string& auth_secret);
112 124
113 void DidCreateEncryptionInfo(const EncryptionInfoCallback& callback, 125 void DidCreateEncryptionInfo(const EncryptionInfoCallback& callback,
114 const KeyPair& pair, 126 const KeyPair& pair,
115 const std::string& auth_secret); 127 const std::string& auth_secret);
116 128
117 void DecryptMessageWithKey(const IncomingMessage& message, 129 void DecryptMessageWithKey(const IncomingMessage& message,
118 const MessageCallback& callback, 130 const MessageCallback& callback,
119 const std::string& salt, 131 const std::string& salt,
120 const std::string& dh, 132 const std::string& dh,
121 uint64_t rs, 133 uint64_t rs,
122 const KeyPair& pair, 134 const KeyPair& pair,
123 const std::string& auth_secret); 135 const std::string& auth_secret);
124 136
125 std::unique_ptr<GCMKeyStore> key_store_; 137 std::unique_ptr<GCMKeyStore> key_store_;
126 138
127 base::WeakPtrFactory<GCMEncryptionProvider> weak_ptr_factory_; 139 base::WeakPtrFactory<GCMEncryptionProvider> weak_ptr_factory_;
128 140
129 DISALLOW_COPY_AND_ASSIGN(GCMEncryptionProvider); 141 DISALLOW_COPY_AND_ASSIGN(GCMEncryptionProvider);
130 }; 142 };
131 143
132 } // namespace gcm 144 } // namespace gcm
133 145
134 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_ 146 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698