2
0
Эх сурвалжийг харах

Key should be AES-128, not AES-256

JC Brand 6 жил өмнө
parent
commit
bd1fd7eef1

+ 4 - 6
dist/converse.js

@@ -71600,7 +71600,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
   const TAG_LENGTH = 128;
   const KEY_ALGO = {
     'name': "AES-GCM",
-    'length': 256
+    'length': 128
   };
 
   function parseBundle(bundle_el) {
@@ -71771,17 +71771,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
 
         getKeyAndTag(string) {
           return {
-            'key': string.slice(0, 43),
-            // 256bit key
-            'tag': string.slice(43, string.length) // rest is tag
-
+            'key': string.slice(0, 22),
+            'tag': string.slice(22)
           };
         },
 
         decryptMessage(obj) {
           const _converse = this.__super__._converse,
                 key_obj = {
-            "alg": "A256GCM",
+            "alg": "A128GCM",
             "ext": true,
             "k": obj.key,
             "key_ops": ["encrypt", "decrypt"],

+ 5 - 6
src/converse-omemo.js

@@ -28,7 +28,7 @@
     const TAG_LENGTH = 128;
     const KEY_ALGO = {
         'name': "AES-GCM",
-        'length': 256
+        'length': 128
     };
 
 
@@ -203,15 +203,15 @@
 
                 getKeyAndTag (string) {
                     return {
-                        'key': string.slice(0, 43), // 256bit key
-                        'tag': string.slice(43, string.length) // rest is tag
+                        'key': string.slice(0, 22),
+                        'tag': string.slice(22)
                     }
                 },
 
                 decryptMessage (obj) {
                     const { _converse } = this.__super__,
                           key_obj = {
-                              "alg": "A256GCM",
+                              "alg": "A128GCM",
                               "ext": true,
                               "k": obj.key,
                               "key_ops": ["encrypt","decrypt"],
@@ -222,7 +222,7 @@
                             const algo = {
                                 'name': "AES-GCM",
                                 'iv': u.base64ToArrayBuffer(obj.iv),
-                                'tagLength': TAG_LENGTH 
+                                'tagLength': TAG_LENGTH
                             }
                             return window.crypto.subtle.decrypt(algo, key_obj, u.base64ToArrayBuffer(obj.payload));
                         }).then(out => (new TextDecoder()).decode(out));
@@ -435,7 +435,6 @@
                                 });
                                 _converse.log(e, Strophe.LogLevel.ERROR);
                             });
-                        
                     } else {
                         return this.__super__.sendMessage.apply(this, arguments);
                     }