0

I'm currently trying to build a custom battery pack for an electric bike.
The bike uses 36V batteries from Panasonic (also sold under OEM brands Victoria, Kalkhoff, Rahleigh, Flyer, Kettler).

We've already established that the battery speaks a custom UART protocol with the bike and the charger.
The protocol itself is easy to understand and we've already understood most of it.
There seems to be some sort of challenge-response authentication, though.

The packet format looks as follows:

2 byte preamble (always 2x FF)
1 byte length (not including preamble, length, command and checksum)
1 byte command
n byte payload data, varying length
1 byte checksum = ((0x100 - sum of data bytes) & 0xFF)

Example packets, charger sending Challenge-Response to battery:
Q: FF FF 14 B2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3A
R: FF FF 14 D2 F9 33 FF A6 C6 6B 39 26 EF 82 BB 6E DF 63 08 05 8E 96 96 D2 44

Q: FF FF 14 B2 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 39
R: FF FF 14 D2 AE F8 49 86 53 4C 41 87 2D 67 CD 74 5D 91 5E 72 79 6A CD C4 37

Q: FF FF 14 B2 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 96
R: FF FF 14 D2 58 3A EE ED C2 F5 C3 B3 95 72 F7 00 25 3A D7 4F 76 C1 2B 96 05

Q: FF FF 14 B2 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA F2
R: FF FF 14 D2 AB 01 C4 32 24 1D EF 96 57 5E 7F F0 8A 67 E8 71 7D 16 E3 E6 E8

As you can see, there is a 20 byte / 160 bit code in the challenge as well as in the response.
Single bit changes in the input lead to a completly different output.

We have asked the real battery with a lot of different challenges and logged the results.
Here is a .csv with ~200k challenge-response pairs:
https://tbspace.de/content/downloads/flyer_challenges_consecutive.csv.zip
(dump also contains shorter status information packets, these need to be ignored)

Unfortunately the entropy of the resulting data seems to be 1.0, which doesn't look too good.
Together with the 160bit data length, this might point to a cryptographic hash function like SHA1.

The battery uses a Renesas M37512 8-bit microcontroller (seems to be based on the 6502).

I'm out of ideas on how to figure out how this challenge-response system works.
Any ideas and suggestions are appreciated.

Thanks!

3
  • 1
    The 160 bits certainly seems to point to SHA-1, along with the high-entropy response. I've seen schemes like this where both parties have a hard-coded "key" that they pre-pend and/or append to the challenge, thus you still need the "key". Could also be something like HMAC-SHA1 with a pre-shared key. Probably need to get into the firmware on the 8-bit MCU to confirm. One easy thing to try is take the challenge and try pre-pending a byte 00-FF, see if that works. Also try appending 00-FF (one byte at a time). That's only 512 tries, test against your data set. Good luck! – Dan Apr 26 '20 at 16:11
  • I liked you investigator work very much and I have a practical question to you. From your description it looks like you separated cells from BMS and after that made BMS work again using pin T. Did I get that right? Because some BMS refuse to work after you separate cells. I'm afraid to work on my battery because not sure I can get BMS work again after replacing cells. Thanks! – ddddjj Feb 27 at 2:30
  • @ddddjj After cell replacement, the BMS will need to be connected to the charger to activate it again. It'll work fine after that. – Tobias Mädel Mar 7 at 0:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.