• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java LegacyMessageException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.whispersystems.libsignal.LegacyMessageException的典型用法代码示例。如果您正苦于以下问题:Java LegacyMessageException类的具体用法?Java LegacyMessageException怎么用?Java LegacyMessageException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LegacyMessageException类属于org.whispersystems.libsignal包,在下文中一共展示了LegacyMessageException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: decrypt

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
private byte[] decrypt(SignalServiceEnvelope envelope, byte[] ciphertext)
    throws InvalidVersionException, InvalidMessageException, InvalidKeyException,
           DuplicateMessageException, InvalidKeyIdException, UntrustedIdentityException,
           LegacyMessageException, NoSessionException
{
  SignalProtocolAddress sourceAddress = new SignalProtocolAddress(envelope.getSource(), envelope.getSourceDevice());
  SessionCipher         sessionCipher = new SessionCipher(signalProtocolStore, sourceAddress);

  byte[] paddedMessage;

  if (envelope.isPreKeySignalMessage()) {
    paddedMessage = sessionCipher.decrypt(new PreKeySignalMessage(ciphertext));
  } else if (envelope.isSignalMessage()) {
    paddedMessage = sessionCipher.decrypt(new SignalMessage(ciphertext));
  } else {
    throw new InvalidMessageException("Unknown type: " + envelope.getType());
  }

  PushTransportDetails transportDetails = new PushTransportDetails(sessionCipher.getSessionVersion());
  return transportDetails.getStrippedPaddingMessageBody(paddedMessage);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-lib,代码行数:22,代码来源:SignalServiceCipher.java


示例2: tryFetchLatestMessage

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
@WorkerThread
private IncomingMessage tryFetchLatestMessage() throws TimeoutException {
    if (this.messagePipe == null) {
        this.messagePipe = messageReceiver.createMessagePipe();
    }

    try {
        final SignalServiceEnvelope envelope = messagePipe.read(INCOMING_MESSAGE_TIMEOUT, TimeUnit.SECONDS);
        return decryptIncomingSignalServiceEnvelope(envelope);
    } catch (final TimeoutException ex) {
        throw new TimeoutException(ex.getMessage());
    } catch (final IllegalStateException | InvalidKeyException | InvalidKeyIdException | DuplicateMessageException | InvalidVersionException | LegacyMessageException | InvalidMessageException | NoSessionException | org.whispersystems.libsignal.UntrustedIdentityException | IOException e) {
        LogUtil.exception(getClass(), "Error while fetching latest message", e);
    }
    return null;
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:17,代码来源:SofaMessageReceiver.java


示例3: handleIncomingSofaMessage

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
private IncomingMessage handleIncomingSofaMessage(final SignalServiceEnvelope envelope) throws InvalidVersionException, InvalidMessageException, InvalidKeyException, DuplicateMessageException, InvalidKeyIdException, org.whispersystems.libsignal.UntrustedIdentityException, LegacyMessageException, NoSessionException {
    final SignalServiceAddress localAddress = new SignalServiceAddress(this.wallet.getOwnerAddress());
    final SignalServiceCipher cipher = new SignalServiceCipher(localAddress, this.protocolStore);
    final SignalServiceContent content = cipher.decrypt(envelope);
    final String messageSource = envelope.getSource();

    if (isUserBlocked(messageSource)) {
        LogUtil.i(getClass(), "A blocked user is trying to send a message");
        return null;
    }

    if (content.getDataMessage().isPresent()) {
        final SignalServiceDataMessage dataMessage = content.getDataMessage().get();
        if (dataMessage.isGroupUpdate()) return taskGroupUpdate.run(messageSource, dataMessage);
        else return taskHandleMessage.run(messageSource, dataMessage);
    }
    return null;
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:19,代码来源:SofaMessageReceiver.java


示例4: decrypt

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
public IncomingTextMessage decrypt(Context context, IncomingTextMessage message)
    throws LegacyMessageException, InvalidMessageException,
           DuplicateMessageException, NoSessionException
{
  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);
  }
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:21,代码来源:SmsCipher.java


示例5: process

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
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);
  }
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:23,代码来源:SmsCipher.java


示例6: ReceiveKeyDialog

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
public ReceiveKeyDialog(@NonNull Context context,
                        @NonNull MasterSecret masterSecret,
                        @NonNull MessageRecord messageRecord)
{
  super(context);

  try{
    final IncomingKeyExchangeMessage message = getMessage(messageRecord);
    final IdentityKey identityKey = getIdentityKey(message);

    if (isTrusted(masterSecret, identityKey, messageRecord.getIndividualRecipient())){
      setMessage(context.getString(R.string.ReceiveKeyActivity_the_signature_on_this_key_exchange_is_trusted_but));
    } else {
      setUntrustedText(messageRecord, identityKey);
    }

    setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.receive_key_activity__complete), new AcceptListener(masterSecret, messageRecord, message, identityKey));
    setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(android.R.string.cancel), new CancelListener());

  } catch (InvalidKeyException | InvalidVersionException | InvalidMessageException | LegacyMessageException e) {
    throw new AssertionError(e);
  }

}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:25,代码来源:ReceiveKeyDialog.java


示例7: getMessage

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
private static IncomingKeyExchangeMessage getMessage(MessageRecord messageRecord)
    throws InvalidKeyException, InvalidVersionException,
           InvalidMessageException, LegacyMessageException
{
  IncomingTextMessage message = new IncomingTextMessage(messageRecord.getIndividualRecipient().getNumber(),
                                                        messageRecord.getRecipientDeviceId(),
                                                        System.currentTimeMillis(),
                                                        messageRecord.getBody().getBody());

  if (messageRecord.isBundleKeyExchange()) {
    return new IncomingPreKeyBundleMessage(message, message.getMessageBody());
  } else if (messageRecord.isIdentityUpdate()) {
    return new IncomingIdentityUpdateMessage(message, message.getMessageBody());
  } else {
    return new IncomingKeyExchangeMessage(message, message.getMessageBody());
  }
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:18,代码来源:ReceiveKeyDialog.java


示例8: getIdentityKey

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
private static IdentityKey getIdentityKey(IncomingKeyExchangeMessage message)
        throws InvalidKeyException, InvalidVersionException,
        InvalidMessageException, LegacyMessageException
{
  try {
    if (message.isIdentityUpdate()) {
      return new IdentityKey(Base64.decodeWithoutPadding(message.getMessageBody()), 0);
    } else if (message.isPreKeyBundle()) {
      return new PreKeySignalMessage(Base64.decodeWithoutPadding(message.getMessageBody())).getIdentityKey();
    } else {
      return new KeyExchangeMessage(Base64.decodeWithoutPadding(message.getMessageBody())).getIdentityKey();
    }
  } catch (IOException e) {
    throw new AssertionError(e);
  }
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:17,代码来源:ReceiveKeyDialog.java


示例9: testNoSession

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
public void testNoSession() throws InvalidMessageException, LegacyMessageException, NoSessionException, DuplicateMessageException {
    InMemorySenderKeyStore aliceStore = new InMemorySenderKeyStore();
    InMemorySenderKeyStore bobStore   = new InMemorySenderKeyStore();

    GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore);
    GroupSessionBuilder bobSessionBuilder   = new GroupSessionBuilder(bobStore);

    GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, GROUP_SENDER);
    GroupCipher bobGroupCipher   = new GroupCipher(bobStore, GROUP_SENDER);

    SenderKeyDistributionMessage sentAliceDistributionMessage     = aliceSessionBuilder.create(GROUP_SENDER);
    SenderKeyDistributionMessage receivedAliceDistributionMessage = new SenderKeyDistributionMessage(sentAliceDistributionMessage.serialize());

//    bobSessionBuilder.process(GROUP_SENDER, receivedAliceDistributionMessage);

    byte[] ciphertextFromAlice = aliceGroupCipher.encrypt("smert ze smert".getBytes());
    try {
      byte[] plaintextFromAlice  = bobGroupCipher.decrypt(ciphertextFromAlice);
      throw new AssertionError("Should be no session!");
    } catch (NoSessionException e) {
      // good
    }
  }
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:24,代码来源:GroupCipherTest.java


示例10: testBasicEncryptDecrypt

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
public void testBasicEncryptDecrypt()
    throws LegacyMessageException, DuplicateMessageException, InvalidMessageException, NoSessionException
{
  InMemorySenderKeyStore aliceStore = new InMemorySenderKeyStore();
  InMemorySenderKeyStore bobStore   = new InMemorySenderKeyStore();

  GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore);
  GroupSessionBuilder bobSessionBuilder   = new GroupSessionBuilder(bobStore);

  GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, GROUP_SENDER);
  GroupCipher bobGroupCipher   = new GroupCipher(bobStore, GROUP_SENDER);

  SenderKeyDistributionMessage sentAliceDistributionMessage     = aliceSessionBuilder.create(GROUP_SENDER);
  SenderKeyDistributionMessage receivedAliceDistributionMessage = new SenderKeyDistributionMessage(sentAliceDistributionMessage.serialize());
  bobSessionBuilder.process(GROUP_SENDER, receivedAliceDistributionMessage);

  byte[] ciphertextFromAlice = aliceGroupCipher.encrypt("smert ze smert".getBytes());
  byte[] plaintextFromAlice  = bobGroupCipher.decrypt(ciphertextFromAlice);

  assertTrue(new String(plaintextFromAlice).equals("smert ze smert"));
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:22,代码来源:GroupCipherTest.java


示例11: testLargeMessages

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
public void testLargeMessages() throws InvalidMessageException, LegacyMessageException, NoSessionException, DuplicateMessageException {
  InMemorySenderKeyStore aliceStore = new InMemorySenderKeyStore();
  InMemorySenderKeyStore bobStore   = new InMemorySenderKeyStore();

  GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore);
  GroupSessionBuilder bobSessionBuilder   = new GroupSessionBuilder(bobStore);

  GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, GROUP_SENDER);
  GroupCipher bobGroupCipher   = new GroupCipher(bobStore, GROUP_SENDER);

  SenderKeyDistributionMessage sentAliceDistributionMessage     = aliceSessionBuilder.create(GROUP_SENDER);
  SenderKeyDistributionMessage receivedAliceDistributionMessage = new SenderKeyDistributionMessage(sentAliceDistributionMessage.serialize());
  bobSessionBuilder.process(GROUP_SENDER, receivedAliceDistributionMessage);

  byte[] plaintext = new byte[1024 * 1024];
  new Random().nextBytes(plaintext);

  byte[] ciphertextFromAlice = aliceGroupCipher.encrypt(plaintext);
  byte[] plaintextFromAlice  = bobGroupCipher.decrypt(ciphertextFromAlice);

  assertTrue(Arrays.equals(plaintext, plaintextFromAlice));
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:23,代码来源:GroupCipherTest.java


示例12: decryptIncomingSignalServiceEnvelope

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
private IncomingMessage decryptIncomingSignalServiceEnvelope(final SignalServiceEnvelope envelope) throws InvalidVersionException, InvalidMessageException, InvalidKeyException, DuplicateMessageException, InvalidKeyIdException, org.whispersystems.libsignal.UntrustedIdentityException, LegacyMessageException, NoSessionException {
       // ToDo -- When do we need to create new keys?
/*       if (envelope.getType() == SignalServiceProtos.Envelope.Type.PREKEY_BUNDLE_VALUE) {
           // New keys need to be registered with the server.
           registerWithServer();
           return;
       }*/
       return handleIncomingSofaMessage(envelope);
   }
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:10,代码来源:SofaMessageReceiver.java


示例13: KeyExchangeMessage

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
public KeyExchangeMessage(byte[] serialized)
    throws InvalidMessageException, InvalidVersionException, LegacyMessageException
{
  try {
    byte[][] parts        = ByteUtil.split(serialized, 1, serialized.length - 1);
    this.version          = ByteUtil.highBitsToInt(parts[0][0]);
    this.supportedVersion = ByteUtil.lowBitsToInt(parts[0][0]);

    if (this.version < CiphertextMessage.CURRENT_VERSION) {
      throw new LegacyMessageException("Unsupported legacy version: " + this.version);
    }

    if (this.version > CiphertextMessage.CURRENT_VERSION) {
      throw new InvalidVersionException("Unknown version: " + this.version);
    }

    SignalProtos.KeyExchangeMessage message = SignalProtos.KeyExchangeMessage.parseFrom(parts[1]);

    if (!message.hasId()           || !message.hasBaseKey()     ||
        !message.hasRatchetKey()   || !message.hasIdentityKey() ||
        !message.hasBaseKeySignature())
    {
      throw new InvalidMessageException("Some required fields missing!");
    }

    this.sequence         = message.getId() >> 5;
    this.flags            = message.getId() & 0x1f;
    this.serialized       = serialized;
    this.baseKey          = Curve.decodePoint(message.getBaseKey().toByteArray(), 0);
    this.baseKeySignature = message.getBaseKeySignature().toByteArray();
    this.ratchetKey       = Curve.decodePoint(message.getRatchetKey().toByteArray(), 0);
    this.identityKey      = new IdentityKey(message.getIdentityKey().toByteArray(), 0);
  } catch (InvalidKeyException | IOException e) {
    throw new InvalidMessageException(e);
  }
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:37,代码来源:KeyExchangeMessage.java


示例14: handleSecureMessage

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
private void handleSecureMessage(MasterSecret masterSecret, long messageId, long threadId,
                                 IncomingTextMessage message)
    throws NoSessionException, DuplicateMessageException,
    InvalidMessageException, LegacyMessageException
{
  EncryptingSmsDatabase database  = DatabaseFactory.getEncryptingSmsDatabase(context);
  SmsCipher             cipher    = new SmsCipher(new SilenceSignalProtocolStore(context, masterSecret));
  IncomingTextMessage   plaintext = cipher.decrypt(context, message);

  database.updateMessageBody(masterSecret, messageId, plaintext.getMessageBody());

  if (message.isEndSession()) SecurityEvent.broadcastSecurityUpdateEvent(context, threadId);
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:14,代码来源:SmsDecryptJob.java


示例15: handleXmppExchangeMessage

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
private void handleXmppExchangeMessage(MasterSecret masterSecret, long messageId, long threadId,
                                       IncomingXmppExchangeMessage message)
   throws NoSessionException, DuplicateMessageException, InvalidMessageException, LegacyMessageException
{
  EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
  database.markAsXmppExchange(messageId);
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:8,代码来源:SmsDecryptJob.java


示例16: processReceiving

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
@Nullable
public byte[] processReceiving(AxolotlKey encryptedKey) throws CryptoFailedException {
	byte[] plaintext;
	FingerprintStatus status = getTrust();
	if (!status.isCompromised()) {
		try {
			if (encryptedKey.prekey) {
				PreKeySignalMessage preKeySignalMessage = new PreKeySignalMessage(encryptedKey.key);
				Optional<Integer> optionalPreKeyId = preKeySignalMessage.getPreKeyId();
				IdentityKey identityKey = preKeySignalMessage.getIdentityKey();
				if (!optionalPreKeyId.isPresent()) {
					throw new CryptoFailedException("PreKeyWhisperMessage did not contain a PreKeyId");
				}
				preKeyId = optionalPreKeyId.get();
				if (this.identityKey != null && !this.identityKey.equals(identityKey)) {
					throw new CryptoFailedException("Received PreKeyWhisperMessage but preexisting identity key changed.");
				}
				this.identityKey = identityKey;
				plaintext = cipher.decrypt(preKeySignalMessage);
			} else {
				SignalMessage signalMessage = new SignalMessage(encryptedKey.key);
				plaintext = cipher.decrypt(signalMessage);
				preKeyId = null; //better safe than sorry because we use that to do special after prekey handling
			}
		} catch (InvalidVersionException | InvalidKeyException | LegacyMessageException | InvalidMessageException | DuplicateMessageException | NoSessionException | InvalidKeyIdException | UntrustedIdentityException e) {
			if (!(e instanceof DuplicateMessageException)) {
				e.printStackTrace();
			}
			throw new CryptoFailedException("Error decrypting WhisperMessage " + e.getClass().getSimpleName() + ": " + e.getMessage());
		}
		if (!status.isActive()) {
			setTrust(status.toActive());
		}
	} else {
		throw new CryptoFailedException("not encrypting omemo message from fingerprint "+getFingerprint()+" because it was marked as compromised");
	}
	return plaintext;
}
 
开发者ID:siacs,项目名称:Conversations,代码行数:39,代码来源:XmppAxolotlSession.java


示例17: decrypt

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
/**
 * Decrypt a SenderKey group message.
 *
 * @param senderKeyMessageBytes The received ciphertext.
 * @param callback   A callback that is triggered after decryption is complete,
 *                    but before the updated session state has been committed to the session
 *                    DB.  This allows some implementations to store the committed plaintext
 *                    to a DB first, in case they are concerned with a crash happening between
 *                    the time the session state is updated but before they're able to store
 *                    the plaintext to disk.
 * @return Plaintext
 * @throws LegacyMessageException
 * @throws InvalidMessageException
 * @throws DuplicateMessageException
 */
public byte[] decrypt(byte[] senderKeyMessageBytes, DecryptionCallback callback)
    throws LegacyMessageException, InvalidMessageException, DuplicateMessageException,
           NoSessionException
{
  synchronized (LOCK) {
    try {
      SenderKeyRecord record = senderKeyStore.loadSenderKey(senderKeyId);

      if (record.isEmpty()) {
        throw new NoSessionException("No sender key for: " + senderKeyId);
      }

      SenderKeyMessage senderKeyMessage = new SenderKeyMessage(senderKeyMessageBytes);
      SenderKeyState   senderKeyState   = record.getSenderKeyState(senderKeyMessage.getKeyId());

      senderKeyMessage.verifySignature(senderKeyState.getSigningKeyPublic());

      SenderMessageKey senderKey = getSenderKey(senderKeyState, senderKeyMessage.getIteration());

      byte[] plaintext = getPlainText(senderKey.getIv(), senderKey.getCipherKey(), senderKeyMessage.getCipherText());

      callback.handlePlaintext(plaintext);

      senderKeyStore.storeSenderKey(senderKeyId, record);

      return plaintext;
    } catch (org.whispersystems.libsignal.InvalidKeyException | InvalidKeyIdException e) {
      throw new InvalidMessageException(e);
    }
  }
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:47,代码来源:GroupCipher.java


示例18: SenderKeyDistributionMessage

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
public SenderKeyDistributionMessage(byte[] serialized) throws LegacyMessageException, InvalidMessageException {
  try {
    byte[][] messageParts = ByteUtil.split(serialized, 1, serialized.length - 1);
    byte     version      = messageParts[0][0];
    byte[]   message      = messageParts[1];

    if (ByteUtil.highBitsToInt(version) < CiphertextMessage.CURRENT_VERSION) {
      throw new LegacyMessageException("Legacy message: " + ByteUtil.highBitsToInt(version));
    }

    if (ByteUtil.highBitsToInt(version) > CURRENT_VERSION) {
      throw new InvalidMessageException("Unknown version: " + ByteUtil.highBitsToInt(version));
    }

    SignalProtos.SenderKeyDistributionMessage distributionMessage = SignalProtos.SenderKeyDistributionMessage.parseFrom(message);

    if (!distributionMessage.hasId()        ||
        !distributionMessage.hasIteration() ||
        !distributionMessage.hasChainKey()  ||
        !distributionMessage.hasSigningKey())
    {
      throw new InvalidMessageException("Incomplete message.");
    }

    this.serialized   = serialized;
    this.id           = distributionMessage.getId();
    this.iteration    = distributionMessage.getIteration();
    this.chainKey     = distributionMessage.getChainKey().toByteArray();
    this.signatureKey = Curve.decodePoint(distributionMessage.getSigningKey().toByteArray(), 0);
  } catch (InvalidProtocolBufferException | InvalidKeyException e) {
    throw new InvalidMessageException(e);
  }
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:34,代码来源:SenderKeyDistributionMessage.java


示例19: PreKeySignalMessage

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
public PreKeySignalMessage(byte[] serialized)
    throws InvalidMessageException, InvalidVersionException
{
  try {
    this.version = ByteUtil.highBitsToInt(serialized[0]);

    if (this.version > CiphertextMessage.CURRENT_VERSION) {
      throw new InvalidVersionException("Unknown version: " + this.version);
    }

    if (this.version < CiphertextMessage.CURRENT_VERSION) {
      throw new LegacyMessageException("Legacy version: " + this.version);
    }

    SignalProtos.PreKeySignalMessage preKeyWhisperMessage
        = SignalProtos.PreKeySignalMessage.parseFrom(ByteString.copyFrom(serialized, 1,
                                                                         serialized.length-1));

    if (!preKeyWhisperMessage.hasSignedPreKeyId()  ||
        !preKeyWhisperMessage.hasBaseKey()         ||
        !preKeyWhisperMessage.hasIdentityKey()     ||
        !preKeyWhisperMessage.hasMessage())
    {
      throw new InvalidMessageException("Incomplete message.");
    }

    this.serialized     = serialized;
    this.registrationId = preKeyWhisperMessage.getRegistrationId();
    this.preKeyId       = preKeyWhisperMessage.hasPreKeyId() ? Optional.of(preKeyWhisperMessage.getPreKeyId()) : Optional.<Integer>absent();
    this.signedPreKeyId = preKeyWhisperMessage.hasSignedPreKeyId() ? preKeyWhisperMessage.getSignedPreKeyId() : -1;
    this.baseKey        = Curve.decodePoint(preKeyWhisperMessage.getBaseKey().toByteArray(), 0);
    this.identityKey    = new IdentityKey(Curve.decodePoint(preKeyWhisperMessage.getIdentityKey().toByteArray(), 0));
    this.message        = new SignalMessage(preKeyWhisperMessage.getMessage().toByteArray());
  } catch (InvalidProtocolBufferException | InvalidKeyException | LegacyMessageException e) {
    throw new InvalidMessageException(e);
  }
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:38,代码来源:PreKeySignalMessage.java


示例20: SenderKeyMessage

import org.whispersystems.libsignal.LegacyMessageException; //导入依赖的package包/类
public SenderKeyMessage(byte[] serialized) throws InvalidMessageException, LegacyMessageException {
  try {
    byte[][] messageParts = ByteUtil.split(serialized, 1, serialized.length - 1 - SIGNATURE_LENGTH, SIGNATURE_LENGTH);
    byte     version      = messageParts[0][0];
    byte[]   message      = messageParts[1];
    byte[]   signature    = messageParts[2];

    if (ByteUtil.highBitsToInt(version) < 3) {
      throw new LegacyMessageException("Legacy message: " + ByteUtil.highBitsToInt(version));
    }

    if (ByteUtil.highBitsToInt(version) > CURRENT_VERSION) {
      throw new InvalidMessageException("Unknown version: " + ByteUtil.highBitsToInt(version));
    }

    SignalProtos.SenderKeyMessage senderKeyMessage = SignalProtos.SenderKeyMessage.parseFrom(message);

    if (!senderKeyMessage.hasId() ||
        !senderKeyMessage.hasIteration() ||
        !senderKeyMessage.hasCiphertext())
    {
      throw new InvalidMessageException("Incomplete message.");
    }

    this.serialized     = serialized;
    this.messageVersion = ByteUtil.highBitsToInt(version);
    this.keyId          = senderKeyMessage.getId();
    this.iteration      = senderKeyMessage.getIteration();
    this.ciphertext     = senderKeyMessage.getCiphertext().toByteArray();
  } catch (InvalidProtocolBufferException | ParseException e) {
    throw new InvalidMessageException(e);
  }
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:34,代码来源:SenderKeyMessage.java



注:本文中的org.whispersystems.libsignal.LegacyMessageException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VirtualMachineRelocateSpec类代码示例发布时间:2022-05-22
下一篇:
Java ServiceType类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap