org.whispersystems.signalservice.api.crypto.DigestingOutputStream Java Examples

The following examples show how to use org.whispersystems.signalservice.api.crypto.DigestingOutputStream. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DigestingRequestBody.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void writeTo(BufferedSink sink) throws IOException {
  DigestingOutputStream outputStream = outputStreamFactory.createFor(new SkippingOutputStream(contentStart, sink.outputStream()));
  byte[]                buffer       = new byte[8192];

  int read;
  long total = 0;

  while ((read = inputStream.read(buffer, 0, buffer.length)) != -1) {
    if (cancelationSignal != null && cancelationSignal.isCanceled()) {
      throw new IOException("Canceled!");
    }

    outputStream.write(buffer, 0, read);
    total += read;

    if (progressListener != null) {
      progressListener.onAttachmentProgress(contentLength, total);
    }
  }

  outputStream.flush();
  digest = outputStream.getTransmittedDigest();
}
 
Example #2
Source File: DigestingRequestBody.java    From libsignal-service-java with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void writeTo(BufferedSink sink) throws IOException {
  DigestingOutputStream outputStream = outputStreamFactory.createFor(sink.outputStream());
  byte[]                buffer       = new byte[8192];

  int read;
  long total = 0;

  while ((read = inputStream.read(buffer, 0, buffer.length)) != -1) {
    outputStream.write(buffer, 0, read);
    total += read;

    if (progressListener != null) {
      progressListener.onAttachmentProgress(contentLength, total);
    }
  }

  outputStream.flush();
  digest = outputStream.getTransmittedDigest();
}
 
Example #3
Source File: DigestingRequestBody.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void writeTo(BufferedSink sink) throws IOException {
  DigestingOutputStream outputStream = outputStreamFactory.createFor(sink.outputStream());
  byte[]                buffer       = new byte[4096];

  int read;

  while ((read = inputStream.read(buffer, 0, buffer.length)) != -1) {
    outputStream.write(buffer, 0, read);
  }

  outputStream.flush();
  digest = outputStream.getTransmittedDigest();
}
 
Example #4
Source File: NoCipherOutputStreamFactory.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public DigestingOutputStream createFor(OutputStream wrap) {
  return new NoCipherOutputStream(wrap);
}
 
Example #5
Source File: AttachmentCipherOutputStreamFactory.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public DigestingOutputStream createFor(OutputStream wrap) throws IOException {
  return new AttachmentCipherOutputStream(key, iv, wrap);
}
 
Example #6
Source File: ProfileCipherOutputStreamFactory.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public DigestingOutputStream createFor(OutputStream wrap) throws IOException {
  return new ProfileCipherOutputStream(wrap, key);
}
 
Example #7
Source File: AttachmentCipherOutputStreamFactory.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public DigestingOutputStream createFor(OutputStream wrap) throws IOException {
  return new AttachmentCipherOutputStream(key, wrap);
}
 
Example #8
Source File: ProfileCipherOutputStreamFactory.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public DigestingOutputStream createFor(OutputStream wrap) throws IOException {
  return new ProfileCipherOutputStream(wrap, key);
}
 
Example #9
Source File: AttachmentCipherOutputStreamFactory.java    From libsignal-service-java with GNU General Public License v3.0 4 votes vote down vote up
@Override
public DigestingOutputStream createFor(OutputStream wrap) throws IOException {
  return new AttachmentCipherOutputStream(key, wrap);
}
 
Example #10
Source File: ProfileCipherOutputStreamFactory.java    From libsignal-service-java with GNU General Public License v3.0 4 votes vote down vote up
@Override
public DigestingOutputStream createFor(OutputStream wrap) throws IOException {
  return new ProfileCipherOutputStream(wrap, key);
}
 
Example #11
Source File: OutputStreamFactory.java    From mollyim-android with GNU General Public License v3.0 votes vote down vote up
public DigestingOutputStream createFor(OutputStream wrap) throws IOException; 
Example #12
Source File: OutputStreamFactory.java    From bcm-android with GNU General Public License v3.0 votes vote down vote up
public DigestingOutputStream createFor(OutputStream wrap) throws IOException; 
Example #13
Source File: OutputStreamFactory.java    From libsignal-service-java with GNU General Public License v3.0 votes vote down vote up
public DigestingOutputStream createFor(OutputStream wrap) throws IOException;