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

Java UntrustedIdentityException类代码示例

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

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



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

示例1: decrypt

import org.whispersystems.libsignal.UntrustedIdentityException; //导入依赖的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: process

import org.whispersystems.libsignal.UntrustedIdentityException; //导入依赖的package包/类
/**
 * Build a new session from a {@link org.whispersystems.libsignal.protocol.KeyExchangeMessage}
 * received from a remote client.
 *
 * @param message The received KeyExchangeMessage.
 * @return The KeyExchangeMessage to respond with, or null if no response is necessary.
 * @throws InvalidKeyException if the received KeyExchangeMessage is badly formatted.
 */
public KeyExchangeMessage process(KeyExchangeMessage message)
    throws InvalidKeyException, UntrustedIdentityException, StaleKeyExchangeException
{
  synchronized (SessionCipher.SESSION_LOCK) {
    if (!identityKeyStore.isTrustedIdentity(remoteAddress, message.getIdentityKey())) {
      throw new UntrustedIdentityException(remoteAddress.getName(), message.getIdentityKey());
    }

    KeyExchangeMessage responseMessage = null;

    if (message.isInitiate()) responseMessage = processInitiate(message);
    else                      processResponse(message);

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


示例3: decrypt

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


示例4: process

import org.whispersystems.libsignal.UntrustedIdentityException; //导入依赖的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


示例5: processSending

import org.whispersystems.libsignal.UntrustedIdentityException; //导入依赖的package包/类
@Nullable
public AxolotlKey processSending(@NonNull byte[] outgoingMessage) {
	FingerprintStatus status = getTrust();
	if (status.isTrustedAndActive()) {
		try {
			CiphertextMessage ciphertextMessage = cipher.encrypt(outgoingMessage);
			return new AxolotlKey(ciphertextMessage.serialize(),ciphertextMessage.getType() == CiphertextMessage.PREKEY_TYPE);
		} catch (UntrustedIdentityException e) {
			return null;
		}
	} else {
		return null;
	}
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:15,代码来源:XmppAxolotlSession.java


示例6: processSending

import org.whispersystems.libsignal.UntrustedIdentityException; //导入依赖的package包/类
@Nullable
public AxolotlKey processSending(@NonNull byte[] outgoingMessage) {
    FingerprintStatus status = getTrust();
    if (status.isTrustedAndActive()) {
        try {
            CiphertextMessage ciphertextMessage = cipher.encrypt(outgoingMessage);
            return new AxolotlKey(ciphertextMessage.serialize(), ciphertextMessage.getType() == CiphertextMessage.PREKEY_TYPE);
        } catch (UntrustedIdentityException e) {
            return null;
        }
    } else {
        return null;
    }
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:15,代码来源:XmppAxolotlSession.java


示例7: if

import org.whispersystems.libsignal.UntrustedIdentityException; //导入依赖的package包/类
/**
 * Build a new session from a received {@link PreKeySignalMessage}.
 *
 * After a session is constructed in this way, the embedded {@link SignalMessage}
 * can be decrypted.
 *
 * @param message The received {@link PreKeySignalMessage}.
 * @throws org.whispersystems.libsignal.InvalidKeyIdException when there is no local
 *                                                             {@link org.whispersystems.libsignal.state.PreKeyRecord}
 *                                                             that corresponds to the PreKey ID in
 *                                                             the message.
 * @throws org.whispersystems.libsignal.InvalidKeyException when the message is formatted incorrectly.
 * @throws org.whispersystems.libsignal.UntrustedIdentityException when the {@link IdentityKey} of the sender is untrusted.
 */
/*package*/ Optional<Integer> process(SessionRecord sessionRecord, PreKeySignalMessage message)
    throws InvalidKeyIdException, InvalidKeyException, UntrustedIdentityException
{
  IdentityKey theirIdentityKey = message.getIdentityKey();

  if (!identityKeyStore.isTrustedIdentity(remoteAddress, theirIdentityKey)) {
    throw new UntrustedIdentityException(remoteAddress.getName(), theirIdentityKey);
  }

  Optional<Integer> unsignedPreKeyId = processV3(sessionRecord, message);

  identityKeyStore.saveIdentity(remoteAddress, theirIdentityKey);
  return unsignedPreKeyId;
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:29,代码来源:SessionBuilder.java


示例8: processV3

import org.whispersystems.libsignal.UntrustedIdentityException; //导入依赖的package包/类
private Optional<Integer> processV3(SessionRecord sessionRecord, PreKeySignalMessage message)
    throws UntrustedIdentityException, InvalidKeyIdException, InvalidKeyException
{

  if (sessionRecord.hasSessionState(message.getMessageVersion(), message.getBaseKey().serialize())) {
    Log.w(TAG, "We've already setup a session for this V3 message, letting bundled message fall through...");
    return Optional.absent();
  }

  ECKeyPair ourSignedPreKey = signedPreKeyStore.loadSignedPreKey(message.getSignedPreKeyId()).getKeyPair();

  BobSignalProtocolParameters.Builder parameters = BobSignalProtocolParameters.newBuilder();

  parameters.setTheirBaseKey(message.getBaseKey())
            .setTheirIdentityKey(message.getIdentityKey())
            .setOurIdentityKey(identityKeyStore.getIdentityKeyPair())
            .setOurSignedPreKey(ourSignedPreKey)
            .setOurRatchetKey(ourSignedPreKey);

  if (message.getPreKeyId().isPresent()) {
    parameters.setOurOneTimePreKey(Optional.of(preKeyStore.loadPreKey(message.getPreKeyId().get()).getKeyPair()));
  } else {
    parameters.setOurOneTimePreKey(Optional.<ECKeyPair>absent());
  }

  if (!sessionRecord.isFresh()) sessionRecord.archiveCurrentState();

  RatchetingSession.initializeSession(sessionRecord.getSessionState(), parameters.create());

  sessionRecord.getSessionState().setLocalRegistrationId(identityKeyStore.getLocalRegistrationId());
  sessionRecord.getSessionState().setRemoteRegistrationId(message.getRegistrationId());
  sessionRecord.getSessionState().setAliceBaseKey(message.getBaseKey().serialize());

  if (message.getPreKeyId().isPresent() && message.getPreKeyId().get() != Medium.MAX_VALUE) {
    return message.getPreKeyId();
  } else {
    return Optional.absent();
  }
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:40,代码来源:SessionBuilder.java


示例9: processReceiving

import org.whispersystems.libsignal.UntrustedIdentityException; //导入依赖的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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java HServerLoad类代码示例发布时间:2022-05-22
下一篇:
Java ConnectionOptions类代码示例发布时间: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