This behavior only occurs with random messages that are not multiples of 4 bytes.
It can be mitigated if one does a msg1.clamp() right after creation of the random message.
I have the feeling that the library should .clamp() the result from WordArray.random() to avoid inconsistent behavior.
What do you think?
I am not super sure if this is really a bug, but please judge by the following example:
What is this code doing?
msg1
and compute an HMAC of it, store that inhmac1
msg2
(assume I would transmit my message here)hmac2
What would I expect here?
I would expect
hmac1 == hmac2
What is actually happening?
While the messages are equal, the HMAC isn't. See an example output for the snippet above:
What is the root cause?
This behavior only occurs with random messages that are not multiples of 4 bytes. It can be mitigated if one does a
msg1.clamp()
right after creation of the random message.I have the feeling that the library should
.clamp()
the result fromWordArray.random()
to avoid inconsistent behavior. What do you think?