Index: components/gcm_driver/crypto/gcm_encryption_provider.h |
diff --git a/components/gcm_driver/crypto/gcm_encryption_provider.h b/components/gcm_driver/crypto/gcm_encryption_provider.h |
index fce5732b0c64bd9c5f57c6fa5587b546a9d9b212..e4cff8dc1d0378af8f656eaa653463eb36ef68eb 100644 |
--- a/components/gcm_driver/crypto/gcm_encryption_provider.h |
+++ b/components/gcm_driver/crypto/gcm_encryption_provider.h |
@@ -20,7 +20,10 @@ class SequencedTaskRunner; |
namespace gcm { |
+struct EncryptionHeaderValue; |
+struct EncryptionKeyHeaderValue; |
class GCMKeyStore; |
+struct IncomingMessage; |
class KeyPair; |
// Provider that enables the GCM Driver to deal with encryption key management |
@@ -30,6 +33,10 @@ class GCMEncryptionProvider { |
// Callback to be invoked when the public encryption key is available. |
using PublicKeyCallback = base::Callback<void(const std::string&)>; |
+ // Callback to be invoked when a message may have been decrypted. |
+ using MessageCallback = |
+ base::Callback<void(const IncomingMessage&, bool decryption_successful)>; |
+ |
GCMEncryptionProvider(); |
~GCMEncryptionProvider(); |
@@ -45,6 +52,15 @@ class GCMEncryptionProvider { |
void GetPublicKey(const std::string& app_id, |
const PublicKeyCallback& callback); |
+ // Determines whether |message| contains encrypted content. |
+ bool IsEncryptedMessage(const IncomingMessage& message) const; |
+ |
+ // Decrypts |message| and stores the result in |decrypted_message|. The return |
+ // value indicates whether the message could be decrypted successfully. |
+ void DecryptMessage(const std::string& app_id, |
+ const IncomingMessage& message, |
+ const MessageCallback& callback); |
+ |
private: |
void DidGetPublicKey(const std::string& app_id, |
const PublicKeyCallback& callback, |
@@ -53,6 +69,14 @@ class GCMEncryptionProvider { |
void DidCreatePublicKey(const PublicKeyCallback& callback, |
const KeyPair& pair); |
+ void DecryptMessageWithKey( |
+ const IncomingMessage& message, |
+ const MessageCallback& callback, |
+ const EncryptionHeaderValue& encryption_header, |
+ const EncryptionKeyHeaderValue& encryption_key_header, |
+ const std::string& ciphertext, |
+ const KeyPair& pair); |
+ |
scoped_refptr<GCMKeyStore> key_store_; |
base::WeakPtrFactory<GCMEncryptionProvider> weak_ptr_factory_; |