Yowsup: New enc type "skmsg", also new enc v(ersion) 2

Created on 26 Jun 2015  ·  35Comments  ·  Source: tgalal/yowsup

I received an encrypted message today which looked like this:

<message retry="2" participant="[email protected]" notify="xxx" phash="1:6juc6XCc" from="[email protected]" offline="2" type="text" id="1435254452-61" t="1435269065">
<enc type="skmsg" v="2">
�UOGl���ޝ
�j�6%2P�0Z;f������1O'�_zٕv����Վ�T�8��z:��-   ���i����?%<�9üD2~�D�GS�m�5� @U߫������
HEX:3308caf99c8e0610021a402563dc5cc5138c1b04f45746bf3942378e18d7ad430d9b554f476c9f91c1de9d0ac56ab636253250e5305a3b66a8a0b4dff3ff314f27f3b95f7ad9957699cfe0bdc1d58edc5402d03897937a3adce22d09f48400ced1698bbc9a9f3f253cd339c3bc44327e01b244d647531db16da4350eb0204055dfab87e8f78b07fc0bef86
</enc>
</message>

When YowAxolotlLayer tries to process it, this happens:

File "/usr/local/lib/python2.7/site-packages/yowsup/layers/axolotl/protocolentities/message_encrypted.py", line 24, in setEncProps
assert encType in "pkmsg", "msg"
AssertionError: msg

axolotl

Most helpful comment

@msshapira I am working on it on wa16 branch

All 35 comments

interesting, do you know what device and version the message came from ?
it seem like its https://en.wikipedia.org/wiki/PKCS_12

@assegaf its TextSecure, not PKCS https://github.com/WhisperSystems/libaxolotl-java

oh I see, seem its the new version 2 ?
I wonder from what version and Device, whatsapp update it

I asked the sender of this message. She specified the following:

Android 4.1.1
WhatsApp 2.12.124
On an Asus Padfone 2

Any news on this?

I don't see group encryption with 2.12.161 version

I tried to check newest 2.12.158 android, seem its send using encription as default , not checking first if target support encription or not
sample TX :
[message to="[email protected]" type="text" id="1435182781-2"]
[enc v="2" type="pkmsg" ]
* some encoded msg *
[/enc]
[/message]

kinda weird, pkmsg and skmsg, thats two different mode, except @prasselpikachu have typo ?

The reason I saw this was exactly the type; It made yowsup crash in the first place due to EncryptedMessageProtocolEntity asserting type == "pkmsg"

@assegaf pkmsg is PreKeyMessage skmsg is SenderKeyMessage, RTFM please before asking.

And i still see no group encryption for me, so can't sniff it and implement it

Same issue for me

what vrsion you using? i'm updating whatsapp every day and still see no group encryption

@CODeRUS 2.12.158, android 5.0.2

Correct me if I don't get it, but what does this have to do with group messages? Looking at the JID, it's a private message, right?

seem from group.
from="[email protected]" ..

Oh, you're right. Nevermind lol

I had this problem whenever the program received messages from a group I created, but it didn't happen on groups created by other numbers. Changing the env to S40YowsupEnv() solved it for me.

Try this,
Login with WHATSAPP_VER = "2.12.81" and you always receive <enc v="1" ...>
Login with WHATSAPP_VER = "2.12._88_" and you start to receive <enc v="2" ...>

Decrypting v="2" message with existing v="1" code:
<message from="[email protected]" id="1436700596-18" type="text" t="1436774161" notify="XXXXX XXXXX"> <enc v="2" type="msg">330A21051628D4A152DF1B536DCC3B00EB946967DF63964CB174D1F636B406395A16EC0F100218032210EC2F66534BE7600279B886AB34E5CA525BBCDEFCC11CEA75</enc> </message>

WhisperMessage
ratchetKey = 051628D4A152DF1B536DCC3B00EB946967DF63964CB174D1F636B406395A16EC0F
counter = 2
previousCounter = 3
ciphertext = EC2F66534BE7600279B886AB34E5CA52
`[LF] [LEN]content[SOH]'

Just seems to add some additional SOH padding after the message, and LF and LEN before it.

Besides that, it seems you can decode v2 encrypted messages with v1 decryption

@CharlesOkwuagwu thanks for the info!

Hi @tgalal,

Update: The complete format is <LF><LEN>your_message<SOH>

The <LEN> is a variable length, 7-Bit encoded integer,
(see here: http://stackoverflow.com/questions/31501672/unusual-integer-encoding-to-bytes-what-scheme-is-this )

Live SAMPLES:

<message from="[email protected]" id="1437486017.--27" type="text" t="1437486019" notify="Charles O">
  <enc v="2" type="msg">330A210598295375CBD82881463F9A4EEDCB6F6CA515EA379862911D34071064D274DD531003180022105283CA018BE0F0F1828DE6C2C667E91E8587B105FEB5525C</enc>
</message>

WhisperMessage
ratchetKey = 0598295375CBD82881463F9A4EEDCB6F6CA515EA379862911D34071064D274DD53
counter = 3
previousCounter = 0
ciphertext = 5283CA018BE0F0F1828DE6C2C667E91E

Decrypted = 0A013001
0

<message from="[email protected]" id="1437486022.--29" type="text" t="1437486023" notify="Charles O">
  <enc v="2" type="msg">330A210546E30D20EC5C5EF2486771287536E7954A78956B7E0D327A28DB35B73B13EC7710001803221016D1C693AF9204E066C417E3F76028C683D0E991A1FBCC58</enc>
</message>

WhisperMessage
ratchetKey = 0546E30D20EC5C5EF2486771287536E7954A78956B7E0D327A28DB35B73B13EC77
counter = 0
previousCounter = 3
ciphertext = 16D1C693AF9204E066C417E3F76028C6

Decrypted = 0A0930303030303030303001

000000000

<message from="[email protected]" id="1437486043.--36" type="text" t="1437486044" notify="Charles O">
rx   <enc v="2" type="msg">330A21055965E057DB29C539AB533D4DF3A587094066BA6A40EA898D0117D8C72C084E361000180022C001ED6710EC983671467AC26EF5140E00A71CB70DD4CA84F65E9129F07AD6C8153B437447B4934F2A93FFE324D6AA0E68D142C45F2BBCB99442BFD59E1957A2F674B110EDF9C763FB1E0EAE12EC615A8301E39D9957C62B35851963C7223B4A907F4AB44E1E7C6E3BD817F359FC788940DD5F44B30AD7C7123A6EA82699B2F8A54980EA546CDA17402013665EAD02FEC969F0E365F4FD8D87226D5E8FA0B76254FC8D6D6672CBF284F983D95B32EDE4B2725CFEFDEAB99321D1B26555E648CA330724C7D3CE437BC4A9</enc>
rx </message>

WhisperMessage
ratchetKey = 055965E057DB29C539AB533D4DF3A587094066BA6A40EA898D0117D8C72C084E36
counter = 0
previousCounter = 0
ciphertext = ED6710EC983671467AC26EF5140E00A71CB70DD4CA84F65E9129F07AD6C8153B437447B4934F2A93FFE324D6AA0E68D142C45F2BBCB99442BFD59E1957A2F674B110EDF9C763FB1E0EAE12EC615A8301E39D9957C62B35851963C7223B4A907F4AB44E1E7C6E3BD817F359FC788940DD5F44B30AD7C7123A6EA82699B2F8A54980EA546CDA17402013665EAD02FEC969F0E365F4FD8D87226D5E8FA0B76254FC8D6D6672CBF284F983D95B32EDE4B2725CFEFDEAB99321D1B26555E648CA3307

Decrypted = 0AB40130303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303001

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000`

So do I understand correctly that I can choose between having my client crash on a NoneType dereference, or have my client crash on this assertion, when I receive these new encrypted messages?

It would be nice if yowsup could swallow these messages, report to the client that it received a message it could not decode, and move on with life...

bump, what can i do?

I encounter the same issue.
I solved some registration issues by implementing changed proposed by @jlguardi in his PR:
https://github.com/tgalal/yowsup/pull/1336/files

After these changes my environment is the following :

_MD5_CLASSES = "7UDPOXwpiLBvEjT8uNwsuA=="
    _KEY = "eQV5aq/Cg63Gsq1sshN9T3gh+UUp0wIw0xgHYT1bnCjEqOJQKCRrWxdAe2yvsDeCJL+Y4G3PRD2HUF7oUgiGo8vGlNJOaux26k+A2F3hj8A="

    _VERSION = "2.12.440"
    _OS_NAME = "Android"
    _OS_VERSION = "4.3"
    _DEVICE_NAME = "GalaxyS3"
    _AXOLOTL = True

And I keep getting this AssertionError: msg after login successfully with the /login command on yowsup-cli demos -y console.

I indeed wrote a message in a group in which my 'bot' is a participant.

In my pull request #1336 I've changed env from S40 to android for registration and running so group messages encryption is enabled.
Enable again S40 env for runtime and it will fix the issue. However someone should implement skmsg and pkmsg before the end of S40 support.
I'll try to por from chat-api but I think it's too hard for me.

Thanks @jlguardi for the answer. Unfortunately I still have the same error when I get back to S40 env like so :
in warerequest.py

from yowsup.env import S40YowsupEnv
CURRENT_ENV = S40YowsupEnv()

The file you need to edit is yowsup/env/init.py where default environment for normal use is defined.
Moreover, the message that is crashing the app is already sent to you so y will receive it until you send send ack. But you cannot send the ack due to the crash. So edit the cod to catch up exception and ack the message.

Thanks @jlguardi I figured this out. So when I use the current master version of Yowsup, with the S40 environment now I encounter this error while trying to receive a message from a group :

ERROR:yowsup.layers.axolotl.layer:Unknown version: 5

Here you have the log provided by the yowsup-cli demos in console mode, after logging successfully :

DEBUG:yowsup.layers.logger.layer:rx:
<ib from="s.whatsapp.net">
<offline count="0">
</offline>
</ib>

DEBUG:yowsup.layers.logger.layer:rx:
<message participant="[email protected]" notify="augustin lafanechere" from="[email protected]" type="text" id="65CB2575B2FB7F2FADAB1C74FF5CFC" t="1457686350">
<enc type="skmsg" v="2">
?\?AN??zD?dľo?qDFH???PzVm?,c?ƒv9j?f:?
HEX:3308dca882ca0410081a202280879b2906cca2b31bab9485c3301b94279514ae84e2f99fef20f6835850fc5c5e3ebaa065f7d3ebbd0daa8fafb10d93ef8f9c135c99414eb6d07a44119a646ccc8c6f8d71444648a1abc2501e7a561d6d892c1a63d8c28376396ac5663a84
</enc>
</message>

ERROR:yowsup.layers.axolotl.layer:Unknown version: 5
DEBUG:yowsup.layers.logger.layer:tx:
<receipt to="[email protected]" type="retry" id="65CB2575B2FB7F2FADAB1C74FF5CFC">
<retry count="1" v="2" t="1457686350" id="65CB2575B2FB7F2FADAB1C74FF5CFC">
</retry>
<registration>
D??K
HEX:44fc3f4b
</registration>
</receipt>

DEBUG:yowsup.layers.logger.layer:rx:
<ack type="retry" from="[email protected]" class="receipt" id="65CB2575B2FB7F2FADAB1C74FF5CFC">
</ack>

@jlguardi looks like tgalal is not pushing the port from chat-api.
Maybe it's time to fork off from yowsup and start merging PRs and implement
e2e encryption.
I guess i can look into porting this...

On Thu, Mar 10, 2016 at 9:16 PM, jlguardi [email protected] wrote:

In my pull request #1336 https://github.com/tgalal/yowsup/pull/1336
I've changed env from S40 to android for registration and running so group
messages encryption is enabled.
Enable again S40 env for runtime and it will fix the issue. However
someone should implement skmsg and pkmsg before the end of S40 support.
I'll try to por from chat-api but I think it's too hard for me.


Reply to this email directly or view it on GitHub
https://github.com/tgalal/yowsup/issues/898#issuecomment-195006515.

@msshapira I am working on it on wa16 branch

@tgalal
Thanks. Was getting worried you had forfieght the repo

On Mon, Mar 14, 2016 at 1:15 PM, Tarek [email protected] wrote:

@msshapira https://github.com/msshapira I am working on it on wa16
branch


Reply to this email directly or view it on GitHub
https://github.com/tgalal/yowsup/issues/898#issuecomment-196263109.

If i register a number with the new Android env and then run it on the S40 env it will work??
Also, you're talking about the end of S40 support... I already have some numbers which are already registered with S40 and working for a long time already... does that mean they will get blocked eventually???? do I need to re-register them as android?

Yes, i did it so
On Mar 17, 2016 12:16 PM, "yniv" [email protected] wrote:

If i register a number with the new Android env and then run it on the S40
env it will work??
Also, you're talking about the end of S40 support... I already have some
numbers which are already registered with S40 and working for a long time
already... does that mean they will get blocked eventually???? do I need to
re-register them as android?


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
https://github.com/tgalal/yowsup/issues/898#issuecomment-197829049

No, I've got some numbers registered with S40 but working with Android env. The Id is used for registration (Id differs from S40 and Android) but in all other operations but registering, just password is required and no check about architecture is made.
In summary, you can change from S40 env to Android env with problems but some encryption issues will appear due to unsupported API (WIP in branch wa16).
However, I'm still using S40 upon protocol 1.6 was implemented.

@jlguardi So the code you added in the last days are only for registering new numbers ?
after you register them you still run them with the S40 env?

@yniv Yes it is. I modified #1336 to use android at register time and S40 in the normal usage.

Was this page helpful?
0 / 5 - 0 ratings