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

The following examples show how to use org.whispersystems.signalservice.api.crypto.ProfileCipherOutputStream. 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: SignalServiceAccountManager.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
public Optional<String> setProfileAvatar(ProfileKey key, StreamDetails avatar)
    throws IOException
{
  if (FeatureFlags.DISALLOW_OLD_PROFILE_SETTING) {
    throw new AssertionError();
  }

  ProfileAvatarData profileAvatarData = null;

  if (avatar != null) {
    profileAvatarData = new ProfileAvatarData(avatar.getStream(),
                                              ProfileCipherOutputStream.getCiphertextLength(avatar.getLength()),
                                              avatar.getContentType(),
                                              new ProfileCipherOutputStreamFactory(key));
  }

  return this.pushServiceSocket.setProfileAvatar(profileAvatarData);
}
 
Example #2
Source File: SignalServiceAccountManager.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @return The avatar URL path, if one was written.
 */
public Optional<String> setVersionedProfile(UUID uuid, ProfileKey profileKey, String name, StreamDetails avatar)
    throws IOException
{
  if (name == null) name = "";

  byte[]            ciphertextName    = new ProfileCipher(profileKey).encryptName(name.getBytes(StandardCharsets.UTF_8), ProfileCipher.NAME_PADDED_LENGTH);
  boolean           hasAvatar         = avatar != null;
  ProfileAvatarData profileAvatarData = null;

  if (hasAvatar) {
    profileAvatarData = new ProfileAvatarData(avatar.getStream(),
                                              ProfileCipherOutputStream.getCiphertextLength(avatar.getLength()),
                                              avatar.getContentType(),
                                              new ProfileCipherOutputStreamFactory(profileKey));
  }

  return this.pushServiceSocket.writeProfile(new SignalServiceProfileWrite(profileKey.getProfileKeyVersion(uuid).serialize(),
                                                                           ciphertextName,
                                                                           hasAvatar,
                                                                           profileKey.getCommitment(uuid).serialize()),
                                                                           profileAvatarData);
}
 
Example #3
Source File: SignalServiceAccountManager.java    From libsignal-service-java with GNU General Public License v3.0 5 votes vote down vote up
public void setProfileAvatar(byte[] key, StreamDetails avatar)
    throws IOException
{
  ProfileAvatarData profileAvatarData = null;

  if (avatar != null) {
    profileAvatarData = new ProfileAvatarData(avatar.getStream(),
                                              ProfileCipherOutputStream.getCiphertextLength(avatar.getLength()),
                                              avatar.getContentType(),
                                              new ProfileCipherOutputStreamFactory(key));
  }

  this.pushServiceSocket.setProfileAvatar(profileAvatarData);
}
 
Example #4
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 #5
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 #6
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);
}