This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BQ40Z50EVM-561: why does device and battery management studio give me different digest than open ssl.

Part Number: BQ40Z50EVM-561
Other Parts Discussed in Thread: BQ40Z80, BQ40Z50

How does the authentication work ?

I am getting a different dgest from opensll than from device and battery management software.

echo -n $chlg | openssl dgst -sha1 -mac HMAC -macopt hexkey:$skey

gives a different digest.

What algorithm is being used here?

  • Hi Preetam,

    It's SHA-1 as specified in the DS.

  • If its sha-1, then why is open ssl giving me a different digest? How does the Battery management studio generate the sha digest ? Does it use openssl or something else ?

  • Hi Preetam,

    It uses the SHA-1. The procedure is as follows, which we have in greater detail in the bq40z80 TRM.

    1. Generate 160-bit message M using a random number generator that meets approved random number
    generators described in FIPS PUB 140–2.
    2. Generate SHA-1 input block B1 of 512 bytes (total input = 128-bit authentication key KD + 160-bit
    message M + 1 + 159 0s + 100100000).
    3. Generate SHA-1 hash HMAC1 using B1.
    4. Generate SHA-1 input block B2 of 512 bytes (total input = 128-bit authentication key KD + 160-bit hash
    HMAC1 + 1 + 159 0s + 100100000).
    5. Generate SHA-1 hash HMAC2 using B2.
    6. With no active Authentication() data waiting, write 160-bit message M to Authentication() in the format:
    0xAABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTT, where AA is LSB.
    7. Wait 250 ms, then read Authentication() for HMAC3.
    8. Compare host HMAC2 with device HMAC3.

  • How did you verify steps 1 to 5 ? Did you use an open source or commercial tool ?

    You can substitute a known message and key for test purposes. How do you accomplish step 5? Opensll dgst is how it is done normally (I presume).

    That is not giving me a matching hash v/s the BQ40z50 or the Battery Management tool. Do you a set of commands where I can test the digest on my linux and cross verify it against the results from BMS ?

  • Hi Preetam,

    One of the known tools is hashcalc, https://www.slavasoft.com/hashcalc/. I don't have a procedure for you other than what was listed in the reply.