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

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: Only EXPECT_DFATAL when LOG_DCHECK == LOG_DFATAL 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 // |authorized_entity| should be the InstanceID token's authorized entity, or
87 // "" for non-InstanceID GCM registrations.
86 void GetEncryptionInfo(const std::string& app_id, 88 void GetEncryptionInfo(const std::string& app_id,
89 const std::string& authorized_entity,
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|. |authorized_entity|
94 // should be the InstanceID token's authorized entity, or "*" to remove for
95 // all InstanceID tokens, or "" for non-InstanceID GCM registrations.
91 void RemoveEncryptionInfo(const std::string& app_id, 96 void RemoveEncryptionInfo(const std::string& app_id,
97 const std::string& authorized_entity,
92 const base::Closure& callback); 98 const base::Closure& callback);
93 99
94 // Determines whether |message| contains encrypted content. 100 // Determines whether |message| contains encrypted content.
95 bool IsEncryptedMessage(const IncomingMessage& message) const; 101 bool IsEncryptedMessage(const IncomingMessage& message) const;
96 102
97 // Attempts to decrypt the |message|. If the |message| is not encrypted, the 103 // Attempts to decrypt the |message|. If the |message| is not encrypted, the
98 // |callback| will be invoked immediately. Otherwise |callback| will be called 104 // |callback| will be invoked immediately. Otherwise |callback| will be called
99 // asynchronously when |message| has been decrypted. A dispatchable message 105 // asynchronously when |message| has been decrypted. A dispatchable message
100 // will be used in case of success, an empty message in case of failure. 106 // will be used in case of success, an empty message in case of failure.
101 void DecryptMessage(const std::string& app_id, 107 void DecryptMessage(const std::string& app_id,
102 const IncomingMessage& message, 108 const IncomingMessage& message,
103 const MessageCallback& callback); 109 const MessageCallback& callback);
104 110
105 private: 111 private:
106 FRIEND_TEST_ALL_PREFIXES(GCMEncryptionProviderTest, EncryptionRoundTrip); 112 friend class GCMEncryptionProviderTest;
113 FRIEND_TEST_ALL_PREFIXES(GCMEncryptionProviderTest,
114 EncryptionRoundTripGCMRegistration);
115 FRIEND_TEST_ALL_PREFIXES(GCMEncryptionProviderTest,
116 EncryptionRoundTripInstanceIDToken);
107 117
108 void DidGetEncryptionInfo(const std::string& app_id, 118 void DidGetEncryptionInfo(const std::string& app_id,
119 const std::string& authorized_entity,
109 const EncryptionInfoCallback& callback, 120 const EncryptionInfoCallback& callback,
110 const KeyPair& pair, 121 const KeyPair& pair,
111 const std::string& auth_secret); 122 const std::string& auth_secret);
112 123
113 void DidCreateEncryptionInfo(const EncryptionInfoCallback& callback, 124 void DidCreateEncryptionInfo(const EncryptionInfoCallback& callback,
114 const KeyPair& pair, 125 const KeyPair& pair,
115 const std::string& auth_secret); 126 const std::string& auth_secret);
116 127
117 void DecryptMessageWithKey(const IncomingMessage& message, 128 void DecryptMessageWithKey(const IncomingMessage& message,
118 const MessageCallback& callback, 129 const MessageCallback& callback,
119 const std::string& salt, 130 const std::string& salt,
120 const std::string& dh, 131 const std::string& dh,
121 uint64_t rs, 132 uint64_t rs,
122 const KeyPair& pair, 133 const KeyPair& pair,
123 const std::string& auth_secret); 134 const std::string& auth_secret);
124 135
125 std::unique_ptr<GCMKeyStore> key_store_; 136 std::unique_ptr<GCMKeyStore> key_store_;
126 137
127 base::WeakPtrFactory<GCMEncryptionProvider> weak_ptr_factory_; 138 base::WeakPtrFactory<GCMEncryptionProvider> weak_ptr_factory_;
128 139
129 DISALLOW_COPY_AND_ASSIGN(GCMEncryptionProvider); 140 DISALLOW_COPY_AND_ASSIGN(GCMEncryptionProvider);
130 }; 141 };
131 142
132 } // namespace gcm 143 } // namespace gcm
133 144
134 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_ 145 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_ENCRYPTION_PROVIDER_H_
OLDNEW
« no previous file with comments | « components/gcm_driver/crypto/BUILD.gn ('k') | components/gcm_driver/crypto/gcm_encryption_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698