From 4412da173e7137adecf033f9cfeca3ad9cc87f18 Mon Sep 17 00:00:00 2001 From: Henry Jalonen Date: Thu, 21 Sep 2023 01:05:18 -0700 Subject: [PATCH] Copybara import of the project: -- 5c8e998bbba385b1c611cde77bcd600e006e3357 by Henry Jalonen : Make InputStreamDecrypter.read() InputStream compliant Convert the read signed integer to unsigned before returning it, because it is the behavior defined in the InputStream interface. It also makes it possible to distinguish between errors and successful read operations. Fixes #10. PiperOrigin-RevId: 567219401 Change-Id: Ie6f2726e2a5bfd71015022c24463d7bd41357d16 --- .../google/crypto/tink/streamingaead/InputStreamDecrypter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/google/crypto/tink/streamingaead/InputStreamDecrypter.java b/src/main/java/com/google/crypto/tink/streamingaead/InputStreamDecrypter.java index 2778a3396..df3d77150 100644 --- a/src/main/java/com/google/crypto/tink/streamingaead/InputStreamDecrypter.java +++ b/src/main/java/com/google/crypto/tink/streamingaead/InputStreamDecrypter.java @@ -121,7 +121,7 @@ public synchronized int available() throws IOException { public synchronized int read() throws IOException { byte[] oneByte = new byte[1]; if (read(oneByte) == 1) { - return oneByte[0]; + return oneByte[0] & 0xff; } return -1; }