Yes, I think it's better to deal with this before you call the methods in ByteArrayAccess class.
Your code snippet looks good.
Valerie

On 5/5/2016 1:16 AM, Wang Weijun wrote:
On May 5, 2016, at 11:06 AM, Wang Weijun<weijun.w...@oracle.com>  wrote:

So this assumes len % 4 == 0.

If you follow this, you might need to add Unsafe.putInt for the last 4 bytes.

On the other hand, if you think len % 8 == 0 should always be true, I can do 
some expand-and-shrink inside SHA5.java. My DRBG chanegset is not pushed yet.
I decided not to touch ByteArrayAccess.java. Instead, for SHA-512/224, I will 
use

int len = engineGetDigestLength();
if (len == 28) {
    // Special case for SHA-512/224
    l2bBig(state, 0, out, ofs, 24);
    i2bBig4((int)(state[3]>>  32), out, ofs + 24);
} else {
    l2bBig(state, 0, out, ofs, len);
}

Maybe we should add a check in l2bBig etc.

Thanks
Max

Reply via email to