Java Code Examples for org.whispersystems.libsignal.InvalidMessageException
The following examples show how to use
org.whispersystems.libsignal.InvalidMessageException. These examples are extracted from open source projects.
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 Project: mollyim-android Source File: SignalServiceMessageReceiver.java License: GNU General Public License v3.0 | 6 votes |
/** * Retrieves a {@link SignalServiceStickerManifest}. * * @param packId The 16-byte packId that identifies the sticker pack. * @param packKey The 32-byte packKey that decrypts the sticker pack. * @return The {@link SignalServiceStickerManifest} representing the sticker pack. * @throws IOException * @throws InvalidMessageException */ public SignalServiceStickerManifest retrieveStickerManifest(byte[] packId, byte[] packKey) throws IOException, InvalidMessageException { byte[] manifestBytes = socket.retrieveStickerManifest(packId); InputStream cipherStream = AttachmentCipherInputStream.createForStickerData(manifestBytes, packKey); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Util.copy(cipherStream, outputStream); StickerProtos.Pack pack = StickerProtos.Pack.parseFrom(outputStream.toByteArray()); List<SignalServiceStickerManifest.StickerInfo> stickers = new ArrayList<>(pack.getStickersCount()); SignalServiceStickerManifest.StickerInfo cover = pack.hasCover() ? new SignalServiceStickerManifest.StickerInfo(pack.getCover().getId(), pack.getCover().getEmoji()) : null; for (StickerProtos.Pack.Sticker sticker : pack.getStickersList()) { stickers.add(new SignalServiceStickerManifest.StickerInfo(sticker.getId(), sticker.getEmoji())); } return new SignalServiceStickerManifest(pack.getTitle(), pack.getAuthor(), cover, stickers); }
Example 2
Source Project: mollyim-android Source File: SignalServiceGroupContext.java License: GNU General Public License v3.0 | 6 votes |
public static SignalServiceGroupContext create(SignalServiceGroup groupV1, SignalServiceGroupV2 groupV2) throws InvalidMessageException { if (groupV1 == null && groupV2 == null) { return null; } if (groupV1 != null && groupV2 != null) { throw new InvalidMessageException("Message cannot have both V1 and V2 group contexts."); } if (groupV1 != null) { return new SignalServiceGroupContext(groupV1); } else { return new SignalServiceGroupContext(groupV2); } }
Example 3
Source Project: mollyim-android Source File: AttachmentCipherTest.java License: GNU General Public License v3.0 | 6 votes |
public void test_attachment_decryptFailOnBadKey() throws IOException{ File cipherFile = null; boolean hitCorrectException = false; try { byte[] key = Util.getSecretBytes(64); byte[] plaintextInput = "Gwen Stacy".getBytes(); EncryptResult encryptResult = encryptData(plaintextInput, key); byte[] badKey = new byte[64]; cipherFile = writeToFile(encryptResult.ciphertext); AttachmentCipherInputStream.createForAttachment(cipherFile, plaintextInput.length, badKey, encryptResult.digest); } catch (InvalidMessageException e) { hitCorrectException = true; } finally { if (cipherFile != null) { cipherFile.delete(); } } assertTrue(hitCorrectException); }
Example 4
Source Project: mollyim-android Source File: AttachmentCipherTest.java License: GNU General Public License v3.0 | 6 votes |
public void test_attachment_decryptFailOnBadDigest() throws IOException{ File cipherFile = null; boolean hitCorrectException = false; try { byte[] key = Util.getSecretBytes(64); byte[] plaintextInput = "Mary Jane Watson".getBytes(); EncryptResult encryptResult = encryptData(plaintextInput, key); byte[] badDigest = new byte[32]; cipherFile = writeToFile(encryptResult.ciphertext); AttachmentCipherInputStream.createForAttachment(cipherFile, plaintextInput.length, key, badDigest); } catch (InvalidMessageException e) { hitCorrectException = true; } finally { if (cipherFile != null) { cipherFile.delete(); } } assertTrue(hitCorrectException); }
Example 5
Source Project: mollyim-android Source File: AttachmentCipherTest.java License: GNU General Public License v3.0 | 6 votes |
public void test_attachment_decryptFailOnNullDigest() throws IOException{ File cipherFile = null; boolean hitCorrectException = false; try { byte[] key = Util.getSecretBytes(64); byte[] plaintextInput = "Aunt May".getBytes(); EncryptResult encryptResult = encryptData(plaintextInput, key); cipherFile = writeToFile(encryptResult.ciphertext); AttachmentCipherInputStream.createForAttachment(cipherFile, plaintextInput.length, key, null); } catch (InvalidMessageException e) { hitCorrectException = true; } finally { if (cipherFile != null) { cipherFile.delete(); } } assertTrue(hitCorrectException); }
Example 6
Source Project: Silence Source File: MmsDatabase.java License: GNU General Public License v3.0 | 6 votes |
private @Nullable String getDecryptedBody(@NonNull MasterSecret masterSecret, @Nullable String body, long outboxType) { try { if (!TextUtils.isEmpty(body) && Types.isSymmetricEncryption(outboxType)) { MasterCipher masterCipher = new MasterCipher(masterSecret); return masterCipher.decryptBody(body); } else { return body; } } catch (InvalidMessageException e) { Log.w(TAG, e); } return null; }
Example 7
Source Project: mollyim-android Source File: AttachmentCipherTest.java License: GNU General Public License v3.0 | 6 votes |
public void test_sticker_decryptFailOnBadKey() throws IOException{ boolean hitCorrectException = false; try { byte[] packKey = Util.getSecretBytes(32); byte[] plaintextInput = "Gwen Stacy".getBytes(); EncryptResult encryptResult = encryptData(plaintextInput, expandPackKey(packKey)); byte[] badPackKey = new byte[32]; AttachmentCipherInputStream.createForStickerData(encryptResult.ciphertext, badPackKey); } catch (InvalidMessageException e) { hitCorrectException = true; } assertTrue(hitCorrectException); }
Example 8
Source Project: mollyim-android Source File: StickerPackPreviewRepository.java License: GNU General Public License v3.0 | 6 votes |
@WorkerThread private Optional<StickerManifestResult> getManifestRemote(@NonNull String packId, @NonNull String packKey) { try { byte[] packIdBytes = Hex.stringToBytes(packId); byte[] packKeyBytes = Hex.stringToBytes(packKey); SignalServiceStickerManifest remoteManifest = receiver.retrieveStickerManifest(packIdBytes, packKeyBytes); StickerManifest localManifest = new StickerManifest(packId, packKey, remoteManifest.getTitle(), remoteManifest.getAuthor(), toOptionalSticker(packId, packKey, remoteManifest.getCover()), Stream.of(remoteManifest.getStickers()) .map(s -> toSticker(packId, packKey, s)) .toList()); return Optional.of(new StickerManifestResult(localManifest, false)); } catch (IOException | InvalidMessageException e) { Log.w(TAG, "Failed to retrieve pack manifest.", e); } return Optional.absent(); }
Example 9
Source Project: mollyim-android Source File: AttachmentDownloadJob.java License: GNU General Public License v3.0 | 6 votes |
private void retrieveAttachment(long messageId, final AttachmentId attachmentId, final Attachment attachment) throws IOException { AttachmentDatabase database = DatabaseFactory.getAttachmentDatabase(context); File attachmentFile = database.getOrCreateTransferFile(attachmentId); try { SignalServiceMessageReceiver messageReceiver = ApplicationDependencies.getSignalServiceMessageReceiver(); SignalServiceAttachmentPointer pointer = createAttachmentPointer(attachment); InputStream stream = messageReceiver.retrieveAttachment(pointer, attachmentFile, MAX_ATTACHMENT_SIZE, (total, progress) -> EventBus.getDefault().postSticky(new PartProgressEvent(attachment, PartProgressEvent.Type.NETWORK, total, progress))); database.insertAttachmentsForPlaceholder(messageId, attachmentId, stream); } catch (InvalidPartException | NonSuccessfulResponseCodeException | InvalidMessageException | MmsException | MissingConfigurationException e) { Log.w(TAG, "Experienced exception while trying to download an attachment.", e); markFailed(messageId, attachmentId); } }
Example 10
Source Project: Silence Source File: SmsCipher.java License: GNU General Public License v3.0 | 6 votes |
public IncomingTextMessage decrypt(Context context, IncomingTextMessage message) throws LegacyMessageException, InvalidMessageException, DuplicateMessageException, NoSessionException, UntrustedIdentityException { try { byte[] decoded = transportDetails.getDecodedMessage(message.getMessageBody().getBytes()); SignalMessage signalMessage = new SignalMessage(decoded); SessionCipher sessionCipher = new SessionCipher(signalProtocolStore, new SignalProtocolAddress(message.getSender(), 1)); byte[] padded = sessionCipher.decrypt(signalMessage); byte[] plaintext = transportDetails.getStrippedPaddingMessageBody(padded); if (message.isEndSession() && "TERMINATE".equals(new String(plaintext))) { signalProtocolStore.deleteSession(new SignalProtocolAddress(message.getSender(), 1)); } return message.withMessageBody(new String(plaintext)); } catch (IOException | IllegalArgumentException | NullPointerException e) { throw new InvalidMessageException(e); } }
Example 11
Source Project: bcm-android Source File: PushDecryptJob.java License: GNU General Public License v3.0 | 6 votes |
private void handleUntrustedIdentityMessage(@NonNull SignalServiceProtos.Envelope envelope) { ALog.i(TAG, "handleUntrustedIdentityMessage"); try { PrivateChatRepo chatRepo = repository.getChatRepo(); Address sourceAddress = Address.from(accountContext, envelope.getSource()); byte[] serialized = envelope.hasLegacyMessage() ? envelope.getLegacyMessage().toByteArray() : envelope.getContent().toByteArray(); PreKeySignalMessage whisperMessage = new PreKeySignalMessage(serialized); String encoded = Base64.encodeBytes(serialized); IncomingTextMessage textMessage = new IncomingTextMessage(sourceAddress, envelope.getSourceDevice(), envelope.getTimestamp(), encoded, Optional.absent(), 0); IncomingPreKeyBundleMessage bundleMessage = new IncomingPreKeyBundleMessage(textMessage, encoded, envelope.hasLegacyMessage()); chatRepo.insertIncomingTextMessage(bundleMessage); } catch (InvalidMessageException | InvalidVersionException e) { throw new AssertionError(e); } }
Example 12
Source Project: bcm-android Source File: MmsDatabase.java License: GNU General Public License v3.0 | 6 votes |
private DisplayRecord.Body getBody(Cursor cursor) { try { String body = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.BODY)); long box = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.MESSAGE_BOX)); if (!TextUtils.isEmpty(body) && masterCipher != null && Types.isSymmetricEncryption(box)) { return new DisplayRecord.Body(masterCipher.decryptBody(body), true); } else if (!TextUtils.isEmpty(body) && masterCipher == null && Types.isSymmetricEncryption(box)) { return new DisplayRecord.Body(body, false); } else if (!TextUtils.isEmpty(body) && Types.isAsymmetricEncryption(box)) { return new DisplayRecord.Body(body, false); } else { return new DisplayRecord.Body(body == null ? "" : body, true); } } catch (InvalidMessageException e) { Log.w("MmsDatabase", e); return new DisplayRecord.Body(context.getString(R.string.MmsDatabase_error_decrypting_message), true); } }
Example 13
Source Project: Silence Source File: SmsCipher.java License: GNU General Public License v3.0 | 6 votes |
public IncomingEncryptedMessage decrypt(Context context, IncomingPreKeyBundleMessage message) throws InvalidVersionException, InvalidMessageException, DuplicateMessageException, UntrustedIdentityException, LegacyMessageException { try { byte[] decoded = transportDetails.getDecodedMessage(message.getMessageBody().getBytes()); PreKeySignalMessage preKeyMessage = new PreKeySignalMessage(decoded); SessionCipher sessionCipher = new SessionCipher(signalProtocolStore, new SignalProtocolAddress(message.getSender(), 1)); byte[] padded = sessionCipher.decrypt(preKeyMessage); byte[] plaintext = transportDetails.getStrippedPaddingMessageBody(padded); return new IncomingEncryptedMessage(message, new String(plaintext)); } catch (IOException | InvalidKeyException | InvalidKeyIdException e) { throw new InvalidMessageException(e); } }
Example 14
Source Project: bcm-android Source File: MasterCipher.java License: GNU General Public License v3.0 | 6 votes |
private byte[] verifyMacBody(@NonNull Mac hmac, @NonNull byte[] encryptedAndMac) throws InvalidMessageException { if (encryptedAndMac.length < hmac.getMacLength()) { throw new InvalidMessageException("length(encrypted body + MAC) < length(MAC)"); } byte[] encrypted = new byte[encryptedAndMac.length - hmac.getMacLength()]; System.arraycopy(encryptedAndMac, 0, encrypted, 0, encrypted.length); byte[] remoteMac = new byte[hmac.getMacLength()]; System.arraycopy(encryptedAndMac, encryptedAndMac.length - remoteMac.length, remoteMac, 0, remoteMac.length); byte[] localMac = hmac.doFinal(encrypted); if (!Arrays.equals(remoteMac, localMac)) throw new InvalidMessageException("MAC doesen't match."); return encrypted; }
Example 15
Source Project: Silence Source File: AsymmetricMasterCipher.java License: GNU General Public License v3.0 | 6 votes |
public String decryptBody(String body) throws IOException, InvalidMessageException { try { byte[] combined = Base64.decode(body); byte[][] parts = Util.split(combined, PublicKey.KEY_SIZE, combined.length - PublicKey.KEY_SIZE); PublicKey theirPublicKey = new PublicKey(parts[0], 0); ECPrivateKey ourPrivateKey = asymmetricMasterSecret.getPrivateKey(); byte[] secret = Curve.calculateAgreement(theirPublicKey.getKey(), ourPrivateKey); MasterCipher masterCipher = getMasterCipherForSecret(secret); byte[] decryptedBody = masterCipher.decryptBytes(parts[1]); return new String(decryptedBody); } catch (InvalidKeyException | InvalidMessageException ike) { throw new InvalidMessageException(ike); } }
Example 16
Source Project: bcm-android Source File: TextSecurePreKeyStore.java License: GNU General Public License v3.0 | 6 votes |
private byte[] loadSerializedRecord(File recordFile) throws IOException, InvalidMessageException { FileInputStream fin = new FileInputStream(recordFile); int recordVersion = readInteger(fin); try { if (recordVersion > CURRENT_VERSION_MARKER) { throw new AssertionError("Invalid version: " + recordVersion); } byte[] serializedRecord = readBlob(fin); if (recordVersion < PLAINTEXT_VERSION && masterSecret != null) { MasterCipher masterCipher = new MasterCipher(masterSecret); serializedRecord = masterCipher.decryptBytes(serializedRecord); } else if (recordVersion < PLAINTEXT_VERSION) { throw new AssertionError("Migration didn't happen! " + recordFile.getAbsolutePath() + ", " + recordVersion); } fin.close(); return serializedRecord; } catch (AssertionError e) { Logger.e(e, "loadSerializedRecord failed"); throw new IOException(e); } }
Example 17
Source Project: bcm-android Source File: EncryptingJobSerializer.java License: GNU General Public License v3.0 | 6 votes |
@Override public Job deserialize(EncryptionKeys keys, boolean encrypted, String serialized) throws IOException { try { String plaintext; if (encrypted) { MasterSecret masterSecret = ParcelUtil.deserialize(keys.getEncoded(), MasterSecret.CREATOR); MasterCipher masterCipher = new MasterCipher(masterSecret); plaintext = masterCipher.decryptBody(serialized); } else { plaintext = serialized; } return delegate.deserialize(keys, encrypted, plaintext); } catch (InvalidMessageException e) { throw new IOException(e); } }
Example 18
Source Project: libsignal-service-java Source File: SignalServiceCipher.java License: GNU General Public License v3.0 | 6 votes |
private SignalServiceTypingMessage createTypingMessage(Metadata metadata, TypingMessage content) throws ProtocolInvalidMessageException { SignalServiceTypingMessage.Action action; if (content.getAction() == TypingMessage.Action.STARTED) action = SignalServiceTypingMessage.Action.STARTED; else if (content.getAction() == TypingMessage.Action.STOPPED) action = SignalServiceTypingMessage.Action.STOPPED; else action = SignalServiceTypingMessage.Action.UNKNOWN; if (content.hasTimestamp() && content.getTimestamp() != metadata.getTimestamp()) { throw new ProtocolInvalidMessageException(new InvalidMessageException("Timestamps don't match: " + content.getTimestamp() + " vs " + metadata.getTimestamp()), metadata.getSender().getIdentifier(), metadata.getSenderDevice()); } return new SignalServiceTypingMessage(action, content.getTimestamp(), content.hasGroupId() ? Optional.of(content.getGroupId().toByteArray()) : Optional.<byte[]>absent()); }
Example 19
Source Project: libsignal-service-java Source File: AttachmentCipherTest.java License: GNU General Public License v3.0 | 6 votes |
public void test_attachment_decryptFailOnBadKey() throws IOException{ File cipherFile = null; boolean hitCorrectException = false; try { byte[] key = Util.getSecretBytes(64); byte[] plaintextInput = "Gwen Stacy".getBytes(); EncryptResult encryptResult = encryptData(plaintextInput, key); byte[] badKey = new byte[64]; cipherFile = writeToFile(encryptResult.ciphertext); AttachmentCipherInputStream.createForAttachment(cipherFile, plaintextInput.length, badKey, encryptResult.digest); } catch (InvalidMessageException e) { hitCorrectException = true; } finally { if (cipherFile != null) { cipherFile.delete(); } } assertTrue(hitCorrectException); }
Example 20
Source Project: libsignal-service-java Source File: AttachmentCipherTest.java License: GNU General Public License v3.0 | 6 votes |
public void test_attachment_decryptFailOnBadDigest() throws IOException{ File cipherFile = null; boolean hitCorrectException = false; try { byte[] key = Util.getSecretBytes(64); byte[] plaintextInput = "Mary Jane Watson".getBytes(); EncryptResult encryptResult = encryptData(plaintextInput, key); byte[] badDigest = new byte[32]; cipherFile = writeToFile(encryptResult.ciphertext); AttachmentCipherInputStream.createForAttachment(cipherFile, plaintextInput.length, key, badDigest); } catch (InvalidMessageException e) { hitCorrectException = true; } finally { if (cipherFile != null) { cipherFile.delete(); } } assertTrue(hitCorrectException); }
Example 21
Source Project: Silence Source File: SmsCipher.java License: GNU General Public License v3.0 | 6 votes |
public OutgoingKeyExchangeMessage process(Context context, IncomingKeyExchangeMessage message) throws UntrustedIdentityException, StaleKeyExchangeException, InvalidVersionException, LegacyMessageException, InvalidMessageException { try { Recipients recipients = RecipientFactory.getRecipientsFromString(context, message.getSender(), false); SignalProtocolAddress signalProtocolAddress = new SignalProtocolAddress(message.getSender(), 1); KeyExchangeMessage exchangeMessage = new KeyExchangeMessage(transportDetails.getDecodedMessage(message.getMessageBody().getBytes())); SessionBuilder sessionBuilder = new SessionBuilder(signalProtocolStore, signalProtocolAddress); KeyExchangeMessage response = sessionBuilder.process(exchangeMessage); if (response != null) { byte[] serializedResponse = transportDetails.getEncodedMessage(response.serialize()); return new OutgoingKeyExchangeMessage(recipients, new String(serializedResponse), message.getSubscriptionId()); } else { return null; } } catch (IOException | InvalidKeyException e) { throw new InvalidMessageException(e); } }
Example 22
Source Project: libsignal-service-java Source File: AttachmentCipherTest.java License: GNU General Public License v3.0 | 6 votes |
public void test_sticker_decryptFailOnBadMac() throws IOException { boolean hitCorrectException = false; try { byte[] packKey = Util.getSecretBytes(32); byte[] plaintextInput = "Uncle Ben".getBytes(); EncryptResult encryptResult = encryptData(plaintextInput, expandPackKey(packKey)); byte[] badMacCiphertext = Arrays.copyOf(encryptResult.ciphertext, encryptResult.ciphertext.length); badMacCiphertext[badMacCiphertext.length - 1] = 0; AttachmentCipherInputStream.createForStickerData(badMacCiphertext, packKey); } catch (InvalidMessageException e) { hitCorrectException = true; } assertTrue(hitCorrectException); }
Example 23
Source Project: Silence Source File: SilencePreKeyStore.java License: GNU General Public License v3.0 | 5 votes |
@Override public SignedPreKeyRecord loadSignedPreKey(int signedPreKeyId) throws InvalidKeyIdException { synchronized (FILE_LOCK) { try { return new SignedPreKeyRecord(loadSerializedRecord(getSignedPreKeyFile(signedPreKeyId))); } catch (IOException | InvalidMessageException e) { Log.w(TAG, e); throw new InvalidKeyIdException(e); } } }
Example 24
Source Project: mollyim-android Source File: SignalServiceAttachmentRemoteId.java License: GNU General Public License v3.0 | 5 votes |
public static SignalServiceAttachmentRemoteId from(AttachmentPointer attachmentPointer) throws ProtocolInvalidMessageException { switch (attachmentPointer.getAttachmentIdentifierCase()) { case CDNID: return new SignalServiceAttachmentRemoteId(attachmentPointer.getCdnId()); case CDNKEY: return new SignalServiceAttachmentRemoteId(attachmentPointer.getCdnKey()); case ATTACHMENTIDENTIFIER_NOT_SET: throw new ProtocolInvalidMessageException(new InvalidMessageException("AttachmentPointer CDN location not set"), null, 0); } return null; }
Example 25
Source Project: mollyim-android Source File: AttachmentCipherTest.java License: GNU General Public License v3.0 | 5 votes |
public void test_attachment_encryptDecrypt() throws IOException, InvalidMessageException { byte[] key = Util.getSecretBytes(64); byte[] plaintextInput = "Peter Parker".getBytes(); EncryptResult encryptResult = encryptData(plaintextInput, key); File cipherFile = writeToFile(encryptResult.ciphertext); InputStream inputStream = AttachmentCipherInputStream.createForAttachment(cipherFile, plaintextInput.length, key, encryptResult.digest); byte[] plaintextOutput = readInputStreamFully(inputStream); assertTrue(Arrays.equals(plaintextInput, plaintextOutput)); cipherFile.delete(); }
Example 26
Source Project: mollyim-android Source File: AttachmentCipherTest.java License: GNU General Public License v3.0 | 5 votes |
public void test_attachment_encryptDecryptEmpty() throws IOException, InvalidMessageException { byte[] key = Util.getSecretBytes(64); byte[] plaintextInput = "".getBytes(); EncryptResult encryptResult = encryptData(plaintextInput, key); File cipherFile = writeToFile(encryptResult.ciphertext); InputStream inputStream = AttachmentCipherInputStream.createForAttachment(cipherFile, plaintextInput.length, key, encryptResult.digest); byte[] plaintextOutput = readInputStreamFully(inputStream); assertTrue(Arrays.equals(plaintextInput, plaintextOutput)); cipherFile.delete(); }
Example 27
Source Project: Silence Source File: SilencePreKeyStore.java License: GNU General Public License v3.0 | 5 votes |
private byte[] loadSerializedRecord(File recordFile) throws IOException, InvalidMessageException { MasterCipher masterCipher = new MasterCipher(masterSecret); FileInputStream fin = new FileInputStream(recordFile); int recordVersion = readInteger(fin); if (recordVersion != CURRENT_VERSION_MARKER) { throw new AssertionError("Invalid version: " + recordVersion); } return masterCipher.decryptBytes(readBlob(fin)); }
Example 28
Source Project: mollyim-android Source File: AttachmentCipherTest.java License: GNU General Public License v3.0 | 5 votes |
public void test_sticker_encryptDecryptEmpty() throws IOException, InvalidMessageException { byte[] packKey = Util.getSecretBytes(32); byte[] plaintextInput = "".getBytes(); EncryptResult encryptResult = encryptData(plaintextInput, expandPackKey(packKey)); InputStream inputStream = AttachmentCipherInputStream.createForStickerData(encryptResult.ciphertext, packKey); byte[] plaintextOutput = readInputStreamFully(inputStream); assertTrue(Arrays.equals(plaintextInput, plaintextOutput)); }
Example 29
Source Project: Silence Source File: SilencePreKeyStore.java License: GNU General Public License v3.0 | 5 votes |
@Override public PreKeyRecord loadPreKey(int preKeyId) throws InvalidKeyIdException { synchronized (FILE_LOCK) { try { return new PreKeyRecord(loadSerializedRecord(getPreKeyFile(preKeyId))); } catch (IOException | InvalidMessageException e) { Log.w(TAG, e); throw new InvalidKeyIdException(e); } } }
Example 30
Source Project: mollyim-android Source File: StickerRemoteUriFetcher.java License: GNU General Public License v3.0 | 5 votes |
@Override public void loadData(@NonNull Priority priority, @NonNull DataCallback<? super InputStream> callback) { try { byte[] packIdBytes = Hex.stringToBytes(stickerUri.getPackId()); byte[] packKeyBytes = Hex.stringToBytes(stickerUri.getPackKey()); InputStream stream = receiver.retrieveSticker(packIdBytes, packKeyBytes, stickerUri.getStickerId()); callback.onDataReady(stream); } catch (IOException | InvalidMessageException e) { callback.onLoadFailed(e); } }