OTP S / KEY One-Time Password - Folded Output MD5 Digest

I am trying to create a password generator for one phone. In RFC2289, it indicates that I should dump the MD5 output, I use bouncy castle MD5, and I cannot decide how to collapse the output of the byte array.

for (int i = 0; i < 8; i++)
{
    md5[i] ^= md5[i+8];
}

This is what I still have

+3
source share
1 answer

Perhaps you want this:

for (int i = 0; i < 8; ++i)
    md5[i] ^= md5[i + 8];
return Arrays.copyOf(md5, 8);

Thus, only the first 64 bits (which are used by OTP) are returned.

+1
source

Source: https://habr.com/ru/post/1733436/


All Articles