Skip to content

Commit

Permalink
Rename StutteringInputStream to SlowInputStream.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 568190358
Change-Id: I5cb85e9570d40a126e976784fde4ac358e80cc23
  • Loading branch information
tholenst authored and copybara-github committed Sep 25, 2023
1 parent 7adaef2 commit 301ca97
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/google/crypto/tink/internal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -799,13 +799,13 @@ java_library(
)

android_library(
name = "stuttering_input_stream-android",
name = "slow_input_stream-android",
testonly = 1,
srcs = ["StutteringInputStream.java"],
srcs = ["SlowInputStream.java"],
)

java_library(
name = "stuttering_input_stream",
name = "slow_input_stream",
testonly = 1,
srcs = ["StutteringInputStream.java"],
srcs = ["SlowInputStream.java"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
* An implementation of ByteArrayInputStream which returns each element separately. Used for testing
* only.
*/
public final class StutteringInputStream extends InputStream {
public final class SlowInputStream extends InputStream {
private final byte[] result;
private int pos = 0;

private StutteringInputStream(byte[] b) {
private SlowInputStream(byte[] b) {
result = b;
}

public static StutteringInputStream copyFrom(byte[] b) {
return new StutteringInputStream(Arrays.copyOf(b, b.length));
public static SlowInputStream copyFrom(byte[] b) {
return new SlowInputStream(Arrays.copyOf(b, b.length));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.google.crypto.tink.Parameters;
import com.google.crypto.tink.aead.subtle.AesGcmSiv;
import com.google.crypto.tink.internal.KeyTypeManager;
import com.google.crypto.tink.internal.StutteringInputStream;
import com.google.crypto.tink.internal.SlowInputStream;
import com.google.crypto.tink.proto.AesGcmSivKey;
import com.google.crypto.tink.proto.AesGcmSivKeyFormat;
import com.google.crypto.tink.proto.KeyData.KeyMaterialType;
Expand Down Expand Up @@ -374,7 +374,7 @@ public void testCreateKeyFromRandomness_stuttering() throws Exception {
com.google.crypto.tink.aead.AesGcmSivKey key =
AesGcmSivKeyManager.createAesGcmSivKeyFromRandomness(
parameters,
StutteringInputStream.copyFrom(keyMaterial),
SlowInputStream.copyFrom(keyMaterial),
parameters.hasIdRequirement() ? 123 : null,
InsecureSecretKeyAccess.get());
byte[] truncatedKeyMaterial = Arrays.copyOf(keyMaterial, parameters.getKeySizeBytes());
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/google/crypto/tink/internal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,11 @@ java_test(
)

java_test(
name = "StutteringInputStreamTest",
name = "SlowInputStreamTest",
size = "small",
srcs = ["StutteringInputStreamTest.java"],
srcs = ["SlowInputStreamTest.java"],
deps = [
"//src/main/java/com/google/crypto/tink/internal:stuttering_input_stream",
"//src/main/java/com/google/crypto/tink/internal:slow_input_stream",
"@maven//:com_google_truth_truth",
"@maven//:junit_junit",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public final class StutteringInputStreamTest {
public final class SlowInputStreamTest {
@Test
public void testNoArgsRead_works() throws Exception {
byte[] b = new byte[] {(byte) 254, 0, (byte) 255};
StutteringInputStream s = StutteringInputStream.copyFrom(b);
SlowInputStream s = SlowInputStream.copyFrom(b);
assertThat(s.read()).isEqualTo(254);
assertThat(s.read()).isEqualTo(0);
assertThat(s.read()).isEqualTo(255);
Expand All @@ -37,7 +37,7 @@ public void testNoArgsRead_works() throws Exception {
@Test
public void testWithBuffer_works() throws Exception {
byte[] b = new byte[] {(byte) 254, 0, (byte) 255};
StutteringInputStream s = StutteringInputStream.copyFrom(b);
SlowInputStream s = SlowInputStream.copyFrom(b);

byte[] buffer = new byte[10];
assertThat(s.read(buffer, 0, 10)).isEqualTo(1);
Expand All @@ -52,7 +52,7 @@ public void testWithBuffer_works() throws Exception {
@Test
public void testWithBuffer_len0() throws Exception {
byte[] b = new byte[] {(byte) 254, 0, (byte) 255};
StutteringInputStream s = StutteringInputStream.copyFrom(b);
SlowInputStream s = SlowInputStream.copyFrom(b);
assertThat(s.read(b, 0, 0)).isEqualTo(0);
}
}

0 comments on commit 301ca97

Please sign in to comment.