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

Java InvalidKeyIdException类代码示例

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

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



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

示例1: generateLastResortKey

import org.whispersystems.libsignal.InvalidKeyIdException; //导入依赖的package包/类
public static PreKeyRecord generateLastResortKey(Context context) {
  PreKeyStore preKeyStore = new TextSecurePreKeyStore(context);

  if (preKeyStore.containsPreKey(Medium.MAX_VALUE)) {
    try {
      return preKeyStore.loadPreKey(Medium.MAX_VALUE);
    } catch (InvalidKeyIdException e) {
      Log.w("PreKeyUtil", e);
      preKeyStore.removePreKey(Medium.MAX_VALUE);
    }
  }

  ECKeyPair    keyPair = Curve.generateKeyPair();
  PreKeyRecord record  = new PreKeyRecord(Medium.MAX_VALUE, keyPair);

  preKeyStore.storePreKey(Medium.MAX_VALUE, record);

  return record;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:20,代码来源:PreKeyUtil.java


示例2: decrypt

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


示例3: tryFetchLatestMessage

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


示例4: handleIncomingSofaMessage

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


示例5: registerKeys

import org.whispersystems.libsignal.InvalidKeyIdException; //导入依赖的package包/类
public Completable registerKeys(final ProtocolStore protocolStore) {
    try {
        return registerKeys(
                protocolStore.getIdentityKeyPair().getPublicKey(),
                protocolStore.getLastResortKey(),
                protocolStore.getPassword(),
                protocolStore.getLocalRegistrationId(),
                protocolStore.getSignalingKey(),
                protocolStore.getSignedPreKey(),
                protocolStore.getPreKeys()
        );
    } catch (final IOException | InvalidKeyIdException | InvalidKeyException ex) {
        LogUtil.e(getClass(), "ERROR!" + ex.toString());
        return Completable.error(ex);
    }
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:17,代码来源:ChatService.java


示例6: generateLastResortKey

import org.whispersystems.libsignal.InvalidKeyIdException; //导入依赖的package包/类
public static PreKeyRecord generateLastResortKey(Context context) {
    PreKeyStore preKeyStore = new SignalPreKeyStore();

    if (preKeyStore.containsPreKey(Medium.MAX_VALUE)) {
        try {
            return preKeyStore.loadPreKey(Medium.MAX_VALUE);
        } catch (InvalidKeyIdException e) {
            LogUtil.w("PreKeyUtil", e.toString());
            preKeyStore.removePreKey(Medium.MAX_VALUE);
        }
    }

    ECKeyPair    keyPair = Curve.generateKeyPair();
    PreKeyRecord record  = new PreKeyRecord(Medium.MAX_VALUE, keyPair);

    preKeyStore.storePreKey(Medium.MAX_VALUE, record);

    return record;
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:20,代码来源:PreKeyUtil.java


示例7: decrypt

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


示例8: generateLastResortKey

import org.whispersystems.libsignal.InvalidKeyIdException; //导入依赖的package包/类
public static PreKeyRecord generateLastResortKey(Context context, MasterSecret masterSecret) {
  PreKeyStore preKeyStore = new SilencePreKeyStore(context, masterSecret);

  if (preKeyStore.containsPreKey(Medium.MAX_VALUE)) {
    try {
      return preKeyStore.loadPreKey(Medium.MAX_VALUE);
    } catch (InvalidKeyIdException e) {
      Log.w("PreKeyUtil", e);
      preKeyStore.removePreKey(Medium.MAX_VALUE);
    }
  }

  ECKeyPair    keyPair = Curve.generateKeyPair();
  PreKeyRecord record  = new PreKeyRecord(Medium.MAX_VALUE, keyPair);

  preKeyStore.storePreKey(Medium.MAX_VALUE, record);

  return record;
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:20,代码来源:PreKeyUtil.java


示例9: create

import org.whispersystems.libsignal.InvalidKeyIdException; //导入依赖的package包/类
/**
 * Construct a group session for sending messages.
 *
 * @param senderKeyName The (groupId, senderId, deviceId) tuple.  In this case, 'senderId' should be the caller.
 * @return A SenderKeyDistributionMessage that is individually distributed to each member of the group.
 */
public SenderKeyDistributionMessage create(SenderKeyName senderKeyName) {
  synchronized (GroupCipher.LOCK) {
    try {
      SenderKeyRecord senderKeyRecord = senderKeyStore.loadSenderKey(senderKeyName);

      if (senderKeyRecord.isEmpty()) {
        senderKeyRecord.setSenderKeyState(KeyHelper.generateSenderKeyId(),
                                          0,
                                          KeyHelper.generateSenderKey(),
                                          KeyHelper.generateSenderSigningKey());
        senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord);
      }

      SenderKeyState state = senderKeyRecord.getSenderKeyState();

      return new SenderKeyDistributionMessage(state.getKeyId(),
                                              state.getSenderChainKey().getIteration(),
                                              state.getSenderChainKey().getSeed(),
                                              state.getSigningKeyPublic());

    } catch (InvalidKeyIdException | InvalidKeyException e) {
      throw new AssertionError(e);
    }
  }
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:32,代码来源:GroupSessionBuilder.java


示例10: encrypt

import org.whispersystems.libsignal.InvalidKeyIdException; //导入依赖的package包/类
/**
 * Encrypt a message.
 *
 * @param paddedPlaintext The plaintext message bytes, optionally padded.
 * @return Ciphertext.
 * @throws NoSessionException
 */
public byte[] encrypt(byte[] paddedPlaintext) throws NoSessionException {
  synchronized (LOCK) {
    try {
      SenderKeyRecord  record         = senderKeyStore.loadSenderKey(senderKeyId);
      SenderKeyState   senderKeyState = record.getSenderKeyState();
      SenderMessageKey senderKey      = senderKeyState.getSenderChainKey().getSenderMessageKey();
      byte[]           ciphertext     = getCipherText(senderKey.getIv(), senderKey.getCipherKey(), paddedPlaintext);

      SenderKeyMessage senderKeyMessage = new SenderKeyMessage(senderKeyState.getKeyId(),
                                                               senderKey.getIteration(),
                                                               ciphertext,
                                                               senderKeyState.getSigningKeyPrivate());

      senderKeyState.setSenderChainKey(senderKeyState.getSenderChainKey().getNext());

      senderKeyStore.storeSenderKey(senderKeyId, record);

      return senderKeyMessage.serialize();
    } catch (InvalidKeyIdException e) {
      throw new NoSessionException(e);
    }
  }
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:31,代码来源:GroupCipher.java


示例11: loadPreKey

import org.whispersystems.libsignal.InvalidKeyIdException; //导入依赖的package包/类
@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);
    }
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:12,代码来源:TextSecurePreKeyStore.java


示例12: loadSignedPreKey

import org.whispersystems.libsignal.InvalidKeyIdException; //导入依赖的package包/类
@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);
    }
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:12,代码来源:TextSecurePreKeyStore.java


示例13: onRun

import org.whispersystems.libsignal.InvalidKeyIdException; //导入依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret) throws IOException {
  try {
    Log.w(TAG, "Cleaning prekeys...");

    int                activeSignedPreKeyId = PreKeyUtil.getActiveSignedPreKeyId(context);
    SignedPreKeyStore  signedPreKeyStore    = signedPreKeyStoreFactory.create();

    if (activeSignedPreKeyId < 0) return;

    SignedPreKeyRecord             currentRecord = signedPreKeyStore.loadSignedPreKey(activeSignedPreKeyId);
    List<SignedPreKeyRecord>       allRecords    = signedPreKeyStore.loadSignedPreKeys();
    LinkedList<SignedPreKeyRecord> oldRecords    = removeRecordFrom(currentRecord, allRecords);

    Collections.sort(oldRecords, new SignedPreKeySorter());

    Log.w(TAG, "Active signed prekey: " + activeSignedPreKeyId);
    Log.w(TAG, "Old signed prekey record count: " + oldRecords.size());

    boolean foundAgedRecord = false;

    for (SignedPreKeyRecord oldRecord : oldRecords) {
      long archiveDuration = System.currentTimeMillis() - oldRecord.getTimestamp();

      if (archiveDuration >= ARCHIVE_AGE) {
        if (!foundAgedRecord) {
          foundAgedRecord = true;
        } else {
          Log.w(TAG, "Removing signed prekey record: " + oldRecord.getId() + " with timestamp: " + oldRecord.getTimestamp());
          signedPreKeyStore.removeSignedPreKey(oldRecord.getId());
        }
      }
    }
  } catch (InvalidKeyIdException e) {
    Log.w(TAG, e);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:38,代码来源:CleanPreKeysJob.java


示例14: loadPreKey

import org.whispersystems.libsignal.InvalidKeyIdException; //导入依赖的package包/类
/**
 * Load a local PreKeyRecord.
 *
 * @param preKeyId the ID of the local PreKeyRecord.
 * @return the corresponding PreKeyRecord.
 * @throws InvalidKeyIdException when there is no corresponding PreKeyRecord.
 */
@Override
public PreKeyRecord loadPreKey(int preKeyId) throws InvalidKeyIdException {
	PreKeyRecord record = mXmppConnectionService.databaseBackend.loadPreKey(account, preKeyId);
	if (record == null) {
		throw new InvalidKeyIdException("No such PreKeyRecord: " + preKeyId);
	}
	return record;
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:16,代码来源:SQLiteAxolotlStore.java


示例15: loadSignedPreKey

import org.whispersystems.libsignal.InvalidKeyIdException; //导入依赖的package包/类
/**
 * Load a local SignedPreKeyRecord.
 *
 * @param signedPreKeyId the ID of the local SignedPreKeyRecord.
 * @return the corresponding SignedPreKeyRecord.
 * @throws InvalidKeyIdException when there is no corresponding SignedPreKeyRecord.
 */
@Override
public SignedPreKeyRecord loadSignedPreKey(int signedPreKeyId) throws InvalidKeyIdException {
	SignedPreKeyRecord record = mXmppConnectionService.databaseBackend.loadSignedPreKey(account, signedPreKeyId);
	if (record == null) {
		throw new InvalidKeyIdException("No such SignedPreKeyRecord: " + signedPreKeyId);
	}
	return record;
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:16,代码来源:SQLiteAxolotlStore.java


示例16: decryptIncomingSignalServiceEnvelope

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


示例17: getSignedPreKey

import org.whispersystems.libsignal.InvalidKeyIdException; //导入依赖的package包/类
public SignedPreKeyRecord getSignedPreKey() throws InvalidKeyIdException, InvalidKeyException {
    final int signedPreKeyId = SignalPreferences.getSignedPreKeyId();
    if (signedPreKeyId == -1) {
        return generateSignedPreKey();
    }

    final SignedPreKeyRecord signedPreKey = loadSignedPreKey(signedPreKeyId);
    if (signedPreKey == null) {
        return generateSignedPreKey();
    }
    return signedPreKey;
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:13,代码来源:ProtocolStore.java


示例18: loadPreKey

import org.whispersystems.libsignal.InvalidKeyIdException; //导入依赖的package包/类
@Override
public PreKeyRecord loadPreKey(int preKeyId) throws InvalidKeyIdException {
    synchronized (FILE_LOCK) {
        try {
            return new PreKeyRecord(loadSerializedRecord(getPreKeyFile(preKeyId)));
        } catch (IOException | InvalidMessageException e) {
            LogUtil.w(getClass(), e.getMessage());
            throw new InvalidKeyIdException(e);
        }
    }
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:12,代码来源:SignalPreKeyStore.java


示例19: loadSignedPreKey

import org.whispersystems.libsignal.InvalidKeyIdException; //导入依赖的package包/类
@Override
public SignedPreKeyRecord loadSignedPreKey(int signedPreKeyId) throws InvalidKeyIdException {
    synchronized (FILE_LOCK) {
        try {
            return new SignedPreKeyRecord(loadSerializedRecord(getSignedPreKeyFile(signedPreKeyId)));
        } catch (IOException | InvalidMessageException e) {
            LogUtil.w(getClass(), e.getMessage());
            throw new InvalidKeyIdException(e);
        }
    }
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:12,代码来源:SignalPreKeyStore.java


示例20: loadSignedPreKey

import org.whispersystems.libsignal.InvalidKeyIdException; //导入依赖的package包/类
@Override
public SignedPreKeyRecord loadSignedPreKey(int signedPreKeyId) throws InvalidKeyIdException {
    try {
        if (!store.containsKey(signedPreKeyId)) {
            throw new InvalidKeyIdException("No such signedprekeyrecord! " + signedPreKeyId);
        }

        return new SignedPreKeyRecord(store.get(signedPreKeyId));
    } catch (IOException e) {
        throw new AssertionError(e);
    }
}
 
开发者ID:AsamK,项目名称:signal-cli,代码行数:13,代码来源:JsonSignedPreKeyStore.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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