The InputStream.read() spec states:
The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned.
The current InputStreamDecrypter.read() currently behaves incorrectly as it returns signed ints which both:
- Breaks every implementation that relies on this behavior.
- Masks the -1 return value as it cannot be distinguished from 0xff.