weechat-matrix-protocol-script icon indicating copy to clipboard operation
weechat-matrix-protocol-script copied to clipboard

Encryption Does Not Work

Open brycied00d opened this issue 8 years ago • 13 comments
trafficstars

Going through the process of getting encryption to work, got all the pieces into place, but running /encrypt on is unsuccessful. My "matrix" buffer contains the following errors.

14:41:01 =!= | API call returned error: Unrecognized request(M_UNRECOGNIZED)
14:41:02 =!= | API call returned error: Unrecognized request(M_UNRECOGNIZED)
14:41:16     | Enabling encryption for outgoing messages in room !<redacted>:matrix.org
14:41:17 =!= | API call returned error: Unrecognized request(M_UNRECOGNIZED)
14:41:17 =!= | API call returned error: Unrecognized request(M_UNRECOGNIZED)
14:41:17 =!= | API call returned error: Unrecognized request(M_UNRECOGNIZED)
14:41:17 =!= | API call returned error: Unrecognized request(M_UNRECOGNIZED)

I enabled debugging and I see that matrix/olm is requested keys from the room's participants and the matrix.org homeserver is returning M_UNRECOGNIZED, presumably (this is my guess) due to the use of the legacy v2_alpha endpoint (https://matrix.org/docs/spec/legacy/#api-calls-using-the-user-interactive-authentication-mechanism).

Debugging output of one such request

14:46:58 =!= | olm: querying user_ids
14:46:58     | 1: @brycec:matrix.org
14:46:58 =!= | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
14:46:58     | request: 
14:46:58     |   post: 
14:46:58     |     postfields: {"device_keys":{"@brycec:matrix.org":[false]}}
14:46:58     |     accept_encoding: application/json
14:46:58     |     header: 1
14:46:58     |   url: https://matrix.org/_matrix/client/v2_alpha/keys/query/?access_token=[redacted]
14:46:59 =!= | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
14:46:59     | reply: 
14:46:59     |   stderr: 
14:46:59     |   rc: 0
14:46:59     |   command: url:https://matrix.org/_matrix/client/v2_alpha/keys/query/?access_token=[redacted]
14:46:59     |   stdout: HTTP/1.1 400 Bad Request 
14:46:59     | Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
14:46:59     | Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
14:46:59     | Access-Control-Allow-Origin: * 
14:46:59     | Content-Length: 59 
14:46:59     | Content-Type: application/json
14:46:59     | Date: Fri, 16 Dec 2016 22:46:59 GMT 
14:46:59     | Server: Synapse/0.18.5-rc3 (b=release-v0.18.5,t=v0.18.5-rc3,bae1115,dirty)
14:46:59     |  
14:46:59     | {"errcode":"M_UNRECOGNIZED","error":"Unrecognized request"}
14:46:59     |   extra: 
14:46:59 =!= | API call returned error: Unrecognized request(M_UNRECOGNIZED)

I found the encryption docs at http://matrix.org/speculator/spec/drafts%2Fe2e/client_server/unstable.html#post-matrix-client-unstable-keys-query and tried swapping v2_alpha with unstable as documented, but I get the same response and outcome. Digging through the debug logs, there are other failed calls regarding encryption.

15:13:19 =!= | Unknown event type m.room.encryption in room !<redacted>:matrix.org
15:13:19 =!= | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
15:13:19     | chunk:      
15:13:19     |   state_key:     
15:13:19     |   sender: @brycec:matrix.org
15:13:19     |   event_id: $1479774869751664OSzEP:matrix.org
15:13:19     |   unsigned: 
15:13:19     |     age: 2155128838
15:13:19     |   origin_server_ts: 1479774869203
15:13:19     |   content: 
15:13:19     |     algorithm: m.megolm.v1.aes-sha2
15:13:19     |   type: m.room.encryption
15:13:20 =!= | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
15:13:20     | reply: 
15:13:20     |   stderr:  
15:13:20     |   rc: 0
15:13:20     |   command: url:https://matrix.org/_matrix/client/unstable/keys/query/?access_token=[redacted]
15:13:20     |   stdout: HTTP/1.1 400 Bad Request 
15:13:20     | Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
15:13:20     | Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
15:13:20     | Access-Control-Allow-Origin: *
15:13:20     | Content-Length: 59 
15:13:20     | Content-Type: application/json
15:13:20     | Date: Fri, 16 Dec 2016 23:13:20 GMT
15:13:20     | Server: Synapse/0.18.5-rc3 (b=release-v0.18.5,t=v0.18.5-rc3,bae1115,dirty)
15:13:20     |  
15:13:20     | {"errcode":"M_UNRECOGNIZED","error":"Unrecognized request"}
15:13:20     |   extra: 
15:13:20 =!= | API call returned error: Unrecognized request(M_UNRECOGNIZED)
15:13:20 =!= | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
15:13:20     | reply: 
15:13:20     |   stderr: 
15:13:20     |   rc: 0    
15:13:20     |   command:
             | url:https://matrix.org/_matrix/client/unstable/keys/upload/FWqxAmrp2rK7vNfjwHYIZP5j7jaWUWDPErUSfbrhEP4?access_token=[redacted]
15:13:20     |   stdout: HTTP/1.1 400 Bad Request
15:13:20     | Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept 
15:13:20     | Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
15:13:20     | Access-Control-Allow-Origin: * 
15:13:20     | Content-Length: 59
15:13:20     | Content-Type: application/json
15:13:20     | Date: Fri, 16 Dec 2016 23:13:20 GMT  
15:13:20     | Server: Synapse/0.18.5-rc3 (b=release-v0.18.5,t=v0.18.5-rc3,bae1115,dirty)
15:13:20     |  
15:13:20     | {"errcode":"M_UNRECOGNIZED","error":"Unrecognized request"}
15:13:20     |   extra: 
15:13:20 =!= | API call returned error: Unrecognized request(M_UNRECOGNIZED)

And after reading the docs, I can see that weechat-matrix-protocol-script isn't using the current API instances and parameters.

If I've done something wrong, let me know. But as far as I can tell, encryption is simply broken at this time.

brycied00d avatar Dec 16 '16 23:12 brycied00d

yup, it's completely broken, sadly. it implements matrix's original crypto PoC which was plain double rethet (Olm), similar to Signal. the final e2e implementation is quite different (Megolm) and more complicated, and the script hasn't bern updated yet.

ara4n avatar Dec 17 '16 15:12 ara4n

If this is the unfortunate case, then may I recommend the Encryption section of the README.md be updated accordingly. Something like...

# Encryption

The current encryption implementation in weechat-matrix-protocol is incompatible with Matrix. It was written for an early proof-of-concept version of the protocol that used Olm, and does not work with thge current Matrix protocol which utilises Megolm.

brycied00d avatar Dec 17 '16 20:12 brycied00d

I noticed this change to README.md hasn't been published - is it still an issue?

chrisbward avatar Jul 20 '17 15:07 chrisbward

@chrisbward Yes, it is still an issue.

brycied00d avatar Jul 20 '17 17:07 brycied00d

Still an issue.

Determinant avatar Sep 02 '17 22:09 Determinant

Any chance of getting the README updated?

I just spent about an hour fighting with luajit, cjson + olm to get it to a point where Weechat would finally open without any errors... only to find that it still couldn't decrypt messages.

Thanks!

bovine3dom avatar Oct 05 '17 10:10 bovine3dom

All too familiar with your pain - I tried to reach out to them, project is dead

chrisbward avatar Oct 10 '17 08:10 chrisbward

Surprisingly, Tor is active and responsive in the project matrix room #weechat:hveem.no

ptman avatar Oct 10 '17 08:10 ptman

https://github.com/torhve/weechat-matrix-protocol-script/commit/25ec2f48357dd17178e2fffd4310ec50c722a0e0

ptman avatar Oct 10 '17 09:10 ptman

I've (finally) updated the readme to better reflect the current status.

torhve avatar Oct 10 '17 09:10 torhve

Is there documentation of what needs revision? The megolm documentation seems to suggest that olm is still used for underlying point-to-point cryptography, so presumably that part still works fine?

nwf avatar May 17 '18 00:05 nwf

let's vote for an Megolm implematation for Weechat Matrix script ?

sachaz avatar Jan 23 '19 17:01 sachaz

@sachaz voting accomplishes nothing unless someone has code for the implementation

There's an alternative python script for weechat( https://github.com/poljar/weechat-matrix ), and there exists a megolm python implementation ( https://github.com/matrix-org/matrix-python-sdk ). That's a more likely way forward.

ptman avatar Jan 24 '19 09:01 ptman