HmacSha256.apply narrows the key length to I32 and hands it to HMAC:
@HMAC(@EVP_sha256(), key.cpointer(), key.size().i32(),
data.cpointer(), data.size(), arr.cpointer(), Pointer[U32])
HMAC takes an int for the key length, so the declaration is right. Nothing checks that the key's size fits in one.
A key of 2^32 + 5 bytes narrows to 5. HMAC reads the first five bytes of it and returns a MAC for a key the caller never passed. Nothing raises.
A key between 2^31 and 2^32 bytes narrows to a negative length. HMAC returns NULL and writes nothing.
data.size() is passed as a USize and does not narrow. Only the key does.
apply takes a ByteSeq, which admits both sizes.
HmacSha256.applynarrows the key length toI32and hands it toHMAC:HMACtakes anintfor the key length, so the declaration is right. Nothing checks that the key's size fits in one.A key of
2^32 + 5bytes narrows to 5.HMACreads the first five bytes of it and returns a MAC for a key the caller never passed. Nothing raises.A key between
2^31and2^32bytes narrows to a negative length.HMACreturns NULL and writes nothing.data.size()is passed as aUSizeand does not narrow. Only the key does.applytakes aByteSeq, which admits both sizes.