@SuppressWarnings("UnusedException")
  public static SecretBytes readIntoSecretBytes(
      InputStream input, int length, SecretKeyAccess access) throws GeneralSecurityException {
    byte[] output = new byte[length];
    try {
      int len = output.length;
      int read;
      int readTotal = 0;
      while (readTotal < len) {
        read = input.read(output, readTotal, len - readTotal);
        if (read == -1) {
          throw new GeneralSecurityException("Not enough pseudorandomness provided");
        }
        readTotal += read;
      }
    } catch (IOException e) {
      throw new GeneralSecurityException("Reading pseudorandomness failed");
    }
    return SecretBytes.copyFrom(output, access);
  }
Reads {@code length} number of bytes from the {@code input} stream and returns it in a {@code
SecretBytes} object.

<p>Note that this method will not close the {@code input} stream.

@throws GeneralSecurityException when not enough randomness was provided in the {@code input}
    stream.
java_src/src/main/java/com/google/crypto/tink/internal/Util.java