Java userspace test (contrib/external-tests/java)

Jason A. Donenfeld Jason at zx2c4.com
Tue Apr 18 03:54:44 CEST 2017


>From your code:

Blake2sMessageDigest blake2s = new Blake2sMessageDigest(preshared);
blake2s.update(theirPublic);
blake2s.update(buf.array(), 0, buf.position());
// Note: Blake2s returns 32 bytes, but we only use the first 16.
buf.put(blake2s.digest(), 0, 16);

The final length needs to be passed to Blake2sMessageDigest in the
constructor, because Blake2 encodes the final length into the initial
block. The implementation from here might work better:
https://github.com/Geal/android-wireguard/blob/master/app/src/main/java/com/southernstorm/noise/crypto/Blake2sMessageDigest.java


More information about the WireGuard mailing list