Bug 1525872 PushEvent.data is null for push messages encrypted with aes128gcm r=JanH a=lizzard
authorAndrei Lazar <andrei.a.lazar@softvision.ro>
Mon, 18 Feb 2019 08:15:26 +0000
changeset 516057 6fec628734c8d1e2fcd72c14296424f459413e8e
parent 516056 6ecdb201bbdb462f3255fd50bb9c6d4b5f1fe78d
child 516058 8b328a01648ca83883c2de044a2e4c7154779260
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJanH, lizzard
bugs1525872
milestone66.0
Bug 1525872 PushEvent.data is null for push messages encrypted with aes128gcm r=JanH a=lizzard Added check for AES128GCM encoding since we won't have separate enckey and cryptokey but rather encoded in the body. Differential Revision: https://phabricator.services.mozilla.com/D19806
dom/push/PushServiceAndroidGCM.jsm
--- a/dom/push/PushServiceAndroidGCM.jsm
+++ b/dom/push/PushServiceAndroidGCM.jsm
@@ -108,29 +108,36 @@ var PushServiceAndroidGCM = {
       });
   },
 
   _messageAndHeaders(data) {
     // Default is no data (and no encryption).
     let message = null;
     let headers = null;
 
-    if (data.message && data.enc && (data.enckey || data.cryptokey)) {
-      headers = {
-        encryption_key: data.enckey,
-        crypto_key: data.cryptokey,
-        encryption: data.enc,
-        encoding: data.con,
-      };
+    if (data.message) {
+      if (data.enc && (data.enckey || data.cryptokey)) {
+        headers = {
+          encryption_key: data.enckey,
+          crypto_key: data.cryptokey,
+          encryption: data.enc,
+          encoding: data.con,
+        };
+      } else if (data.con == 'aes128gcm') {
+        headers = {
+          encoding: data.con,
+        };
+      }
       // Ciphertext is (urlsafe) Base 64 encoded.
       message = ChromeUtils.base64URLDecode(data.message, {
         // The Push server may append padding.
         padding: "ignore",
       });
     }
+
     return { headers, message };
   },
 
   _configure: function(serverURL, debug) {
     return EventDispatcher.instance.sendRequestForResult({
       type: "PushServiceAndroidGCM:Configure",
       endpoint: serverURL.spec,
       debug: debug,