本文整理汇总了Java中org.whispersystems.libaxolotl.InvalidKeyIdException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidKeyIdException类的具体用法?Java InvalidKeyIdException怎么用?Java InvalidKeyIdException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvalidKeyIdException类属于org.whispersystems.libaxolotl包,在下文中一共展示了InvalidKeyIdException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: decrypt
import org.whispersystems.libaxolotl.InvalidKeyIdException; //导入依赖的package包/类
public IncomingEncryptedMessage decrypt(Context context, IncomingPreKeyBundleMessage message)
throws InvalidVersionException, InvalidMessageException, DuplicateMessageException,
UntrustedIdentityException, LegacyMessageException
{
try {
Recipients recipients = RecipientFactory.getRecipientsFromString(context, message.getSender(), false);
byte[] decoded = transportDetails.getDecodedMessage(message.getMessageBody().getBytes());
PreKeyWhisperMessage preKeyMessage = new PreKeyWhisperMessage(decoded);
SessionCipher sessionCipher = new SessionCipher(axolotlStore, recipients.getPrimaryRecipient().getRecipientId(), 1);
byte[] padded = sessionCipher.decrypt(preKeyMessage);
byte[] plaintext = transportDetails.getStrippedPaddingMessageBody(padded);
return new IncomingEncryptedMessage(message, new String(plaintext));
} catch (RecipientFormattingException | IOException | InvalidKeyException | InvalidKeyIdException e) {
throw new InvalidMessageException(e);
}
}
开发者ID:redcracker,项目名称:TextSecure,代码行数:18,代码来源:SmsCipher.java
示例2: generateLastResortKey
import org.whispersystems.libaxolotl.InvalidKeyIdException; //导入依赖的package包/类
public static PreKeyRecord generateLastResortKey(Context context, MasterSecret masterSecret) {
PreKeyStore preKeyStore = new TextSecurePreKeyStore(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 = Curve25519.generateKeyPair();
PreKeyRecord record = new PreKeyRecord(Medium.MAX_VALUE, keyPair);
preKeyStore.storePreKey(Medium.MAX_VALUE, record);
return record;
}
开发者ID:redcracker,项目名称:TextSecure,代码行数:20,代码来源:PreKeyUtil.java
示例3: decrypt
import org.whispersystems.libaxolotl.InvalidKeyIdException; //导入依赖的package包/类
public TextSecureMessage decrypt(TextSecureEnvelope envelope)
throws InvalidVersionException, InvalidMessageException, InvalidKeyException,
DuplicateMessageException, InvalidKeyIdException, UntrustedIdentityException,
LegacyMessageException, NoSessionException
{
try {
byte[] paddedMessage;
if (envelope.isPreKeyWhisperMessage()) {
paddedMessage = sessionCipher.decrypt(new PreKeyWhisperMessage(envelope.getMessage()));
} else if (envelope.isWhisperMessage()) {
paddedMessage = sessionCipher.decrypt(new WhisperMessage(envelope.getMessage()));
} else if (envelope.isPlaintext()) {
paddedMessage = envelope.getMessage();
} else {
throw new InvalidMessageException("Unknown type: " + envelope.getType());
}
PushTransportDetails transportDetails = new PushTransportDetails(sessionCipher.getSessionVersion());
PushMessageContent content = PushMessageContent.parseFrom(transportDetails.getStrippedPaddingMessageBody(paddedMessage));
return createTextSecureMessage(envelope, content);
} catch (InvalidProtocolBufferException e) {
throw new InvalidMessageException(e);
}
}
开发者ID:redcracker,项目名称:TextSecure,代码行数:27,代码来源:TextSecureCipher.java
示例4: loadSignedPreKey
import org.whispersystems.libaxolotl.InvalidKeyIdException; //导入依赖的package包/类
@Override
public SignedPreKeyRecord loadSignedPreKey(final int signedPreKeyId) throws InvalidKeyIdException {
try {
final SignedPreKeyRecord record = SignedPreKeyTable.getInstance().loadKey(signedPreKeyId);
if (record == null) {
LOGGER.debug("Tried to fetch SignedPreKeyRecord for the invalid key ID [{}].", signedPreKeyId);
throw new InvalidKeyIdException("Key id " + signedPreKeyId + " has no associated PreKeyRecord.");
}
return SignedPreKeyTable.getInstance().loadKey(signedPreKeyId);
} catch (final SQLException e) {
LOGGER.error("Signed pre key could not be fetched from database.", e);
Errors.showError(translate("unexpected_quit"));
Errors.stopApplication();
throw new UnreachableCodeException();
}
}
开发者ID:connorlanigan,项目名称:norvos,代码行数:17,代码来源:SignedPreKeyStore.java
示例5: decrypt
import org.whispersystems.libaxolotl.InvalidKeyIdException; //导入依赖的package包/类
public TextSecureSMPMessage decrypt(TextSecureEnvelope envelope) throws InvalidVersionException,
InvalidMessageException, InvalidKeyException, DuplicateMessageException, InvalidKeyIdException, UntrustedIdentityException, LegacyMessageException, NoSessionException {
try {
AxolotlAddress e = new AxolotlAddress(envelope.getSource(), envelope.getSourceDevice());
SessionCipher sessionCipher = new SessionCipher(this.axolotlStore, e);
byte[] paddedMessage;
if(envelope.isPreKeyWhisperMessage()) {
paddedMessage = sessionCipher.decrypt(new PreKeyWhisperMessage(envelope.getMessage()));
} else {
if(!envelope.isWhisperMessage()) {
throw new InvalidMessageException("Unknown type: " + envelope.getType());
}
paddedMessage = sessionCipher.decrypt(new WhisperMessage(envelope.getMessage()));
}
PushTransportDetails transportDetails = new PushTransportDetails(sessionCipher.getSessionVersion());
PushMessageProtos.PushMessageContent content = PushMessageProtos.PushMessageContent.parseFrom(transportDetails.getStrippedPaddingMessageBody(paddedMessage));
return this.createTextSecureSMPMessage(envelope, content);
} catch (InvalidProtocolBufferException var7) {
throw new InvalidMessageException(var7);
}
}
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:24,代码来源:TextSecureSMPCipher.java
示例6: generateLastResortKey
import org.whispersystems.libaxolotl.InvalidKeyIdException; //导入依赖的package包/类
public static PreKeyRecord generateLastResortKey(Context context, MasterSecret masterSecret) {
PreKeyStore preKeyStore = new TextSecurePreKeyStore(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:Agilitum,项目名称:TextSecureSMP,代码行数:20,代码来源:PreKeyUtil.java
示例7: encrypt
import org.whispersystems.libaxolotl.InvalidKeyIdException; //导入依赖的package包/类
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:Securecom,项目名称:Securecom-Messaging,代码行数:24,代码来源:GroupCipher.java
示例8: decrypt
import org.whispersystems.libaxolotl.InvalidKeyIdException; //导入依赖的package包/类
public byte[] decrypt(byte[] senderKeyMessageBytes)
throws LegacyMessageException, InvalidMessageException, DuplicateMessageException
{
synchronized (LOCK) {
try {
SenderKeyRecord record = senderKeyStore.loadSenderKey(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());
senderKeyStore.storeSenderKey(senderKeyId, record);
return plaintext;
} catch (org.whispersystems.libaxolotl.InvalidKeyException | InvalidKeyIdException e) {
throw new InvalidMessageException(e);
}
}
}
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:24,代码来源:GroupCipher.java
示例9: loadPreKey
import org.whispersystems.libaxolotl.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:xavierle,项目名称:messengerxmpp,代码行数:16,代码来源:SQLiteAxolotlStore.java
示例10: loadSignedPreKey
import org.whispersystems.libaxolotl.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:xavierle,项目名称:messengerxmpp,代码行数:16,代码来源:SQLiteAxolotlStore.java
示例11: loadPreKey
import org.whispersystems.libaxolotl.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:redcracker,项目名称:TextSecure,代码行数:12,代码来源:TextSecurePreKeyStore.java
示例12: loadSignedPreKey
import org.whispersystems.libaxolotl.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:redcracker,项目名称:TextSecure,代码行数:12,代码来源:TextSecurePreKeyStore.java
示例13: onRun
import org.whispersystems.libaxolotl.InvalidKeyIdException; //导入依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret) throws IOException {
try {
SignedPreKeyStore signedPreKeyStore = signedPreKeyStoreFactory.create(masterSecret);
SignedPreKeyEntity currentSignedPreKey = accountManager.getSignedPreKey();
if (currentSignedPreKey == null) return;
SignedPreKeyRecord currentRecord = signedPreKeyStore.loadSignedPreKey(currentSignedPreKey.getKeyId());
List<SignedPreKeyRecord> allRecords = signedPreKeyStore.loadSignedPreKeys();
LinkedList<SignedPreKeyRecord> oldRecords = removeRecordFrom(currentRecord, allRecords);
Collections.sort(oldRecords, new SignedPreKeySorter());
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 >= TimeUnit.DAYS.toMillis(ARCHIVE_AGE_DAYS)) {
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:redcracker,项目名称:TextSecure,代码行数:35,代码来源:CleanPreKeysJob.java
示例14: loadPreKey
import org.whispersystems.libaxolotl.InvalidKeyIdException; //导入依赖的package包/类
@Override
public PreKeyRecord loadPreKey(final int preKeyId) throws InvalidKeyIdException {
try {
final PreKeyRecord record = PreKeyTable.getInstance().getKey(preKeyId);
if (record == null) {
throw new InvalidKeyIdException("Key id " + preKeyId + " has no associated PreKeyRecord.");
}
return PreKeyTable.getInstance().getKey(preKeyId);
} catch (final SQLException e) {
LOGGER.error("PreKey could not be fetched from database.", e);
Errors.showError(translate("unexpected_quit"));
Errors.stopApplication();
throw new UnreachableCodeException();
}
}
开发者ID:connorlanigan,项目名称:norvos,代码行数:16,代码来源:PreKeyStore.java
示例15: loadPreKey
import org.whispersystems.libaxolotl.InvalidKeyIdException; //导入依赖的package包/类
@Test
public void loadPreKey() throws InvalidKeyIdException {
final PreKeyRecord preKey = KeyHelper.generatePreKeys(0, ANY_NUMBER).get(0);
store.storePreKey(preKey.getId(), preKey);
final PreKeyRecord newKey = store.loadPreKey(preKey.getId());
assertArrayEquals(preKey.serialize(), newKey.serialize());
}
开发者ID:connorlanigan,项目名称:norvos,代码行数:8,代码来源:AxolotlStoreTest.java
示例16: signedPreKey
import org.whispersystems.libaxolotl.InvalidKeyIdException; //导入依赖的package包/类
@Test
public void signedPreKey() throws InvalidKeyException, InvalidKeyIdException {
final Random r = new Random();
final IdentityKeyPair identityKey = KeyHelper.generateIdentityKeyPair();
final SignedPreKeyRecord key = KeyHelper.generateSignedPreKey(identityKey, r.nextInt(Integer.MAX_VALUE));
store.storeSignedPreKey(key.getId(), key);
assertTrue(store.containsSignedPreKey(key.getId()));
assertFalse(store.containsSignedPreKey(key.getId() + 1));
assertArrayEquals(key.serialize(), store.loadSignedPreKey(key.getId()).serialize());
store.removeSignedPreKey(key.getId());
assertFalse(store.containsSignedPreKey(key.getId()));
}
开发者ID:connorlanigan,项目名称:norvos,代码行数:16,代码来源:AxolotlStoreTest.java
示例17: getSenderKeyState
import org.whispersystems.libaxolotl.InvalidKeyIdException; //导入依赖的package包/类
public SenderKeyState getSenderKeyState() throws InvalidKeyIdException {
if (!senderKeyStates.isEmpty()) {
return senderKeyStates.get(0);
} else {
throw new InvalidKeyIdException("No key state in record!");
}
}
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:8,代码来源:SenderKeyRecord.java
示例18: loadPreKey
import org.whispersystems.libaxolotl.InvalidKeyIdException; //导入依赖的package包/类
@Override
public PreKeyRecord loadPreKey(int preKeyId) throws InvalidKeyIdException {
try {
if (!store.containsKey(preKeyId)) {
throw new InvalidKeyIdException("No such prekeyrecord!");
}
return new PreKeyRecord(store.get(preKeyId));
} catch (IOException e) {
throw new AssertionError(e);
}
}
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:13,代码来源:InMemoryPreKeyStore.java
示例19: loadSignedPreKey
import org.whispersystems.libaxolotl.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:Securecom,项目名称:Securecom-Messaging,代码行数:13,代码来源:InMemorySignedPreKeyStore.java
示例20: loadPreKey
import org.whispersystems.libaxolotl.InvalidKeyIdException; //导入依赖的package包/类
@Override
public PreKeyRecord loadPreKey(int preKeyId) throws InvalidKeyIdException {
return preKeyStore.loadPreKey(preKeyId);
}
开发者ID:redcracker,项目名称:TextSecure,代码行数:5,代码来源:TextSecureAxolotlStore.java
注:本文中的org.whispersystems.libaxolotl.InvalidKeyIdException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论