mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-11 14:37:45 +00:00
clean
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
package org.session.libsignal.service.api.crypto;
|
||||
|
||||
public class InvalidCiphertextException extends Exception {
|
||||
public InvalidCiphertextException(Exception nested) {
|
||||
super(nested);
|
||||
}
|
||||
|
||||
public InvalidCiphertextException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
package org.session.libsignal.service.api.crypto;
|
||||
|
||||
|
||||
import org.session.libsignal.libsignal.util.ByteUtil;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.spec.GCMParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
public class UnidentifiedAccess {
|
||||
|
||||
private final byte[] unidentifiedAccessKey;
|
||||
|
||||
public UnidentifiedAccess(byte[] unidentifiedAccessKey)
|
||||
{
|
||||
this.unidentifiedAccessKey = unidentifiedAccessKey;
|
||||
}
|
||||
|
||||
public byte[] getUnidentifiedAccessKey() {
|
||||
return unidentifiedAccessKey;
|
||||
}
|
||||
|
||||
public static byte[] deriveAccessKeyFrom(byte[] profileKey) {
|
||||
try {
|
||||
byte[] nonce = new byte[12];
|
||||
byte[] input = new byte[16];
|
||||
|
||||
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(profileKey, "AES"), new GCMParameterSpec(128, nonce));
|
||||
|
||||
byte[] ciphertext = cipher.doFinal(input);
|
||||
|
||||
return ByteUtil.trim(ciphertext, 16);
|
||||
} catch (NoSuchAlgorithmException | InvalidKeyException | NoSuchPaddingException | InvalidAlgorithmParameterException | BadPaddingException | IllegalBlockSizeException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2014-2016 Open Whisper Systems
|
||||
*
|
||||
* Licensed according to the LICENSE file in this repository.
|
||||
*/
|
||||
|
||||
package org.session.libsignal.service.api.crypto;
|
||||
|
||||
import org.session.libsignal.libsignal.IdentityKey;
|
||||
|
||||
public class UntrustedIdentityException extends Exception {
|
||||
|
||||
private final IdentityKey identityKey;
|
||||
private final String e164number;
|
||||
|
||||
public UntrustedIdentityException(String s, String e164number, IdentityKey identityKey) {
|
||||
super(s);
|
||||
this.e164number = e164number;
|
||||
this.identityKey = identityKey;
|
||||
}
|
||||
|
||||
public IdentityKey getIdentityKey() {
|
||||
return identityKey;
|
||||
}
|
||||
|
||||
public String getE164Number() {
|
||||
return e164number;
|
||||
}
|
||||
|
||||
}
|
@@ -1,88 +0,0 @@
|
||||
package org.session.libsignal.service.api.messages;
|
||||
|
||||
|
||||
import org.session.libsignal.libsignal.IdentityKey;
|
||||
import org.session.libsignal.service.api.push.SignalServiceAddress;
|
||||
import org.session.libsignal.service.loki.api.SnodeAPI;
|
||||
|
||||
public class SendMessageResult {
|
||||
|
||||
private final SignalServiceAddress address;
|
||||
private final Success success;
|
||||
private final boolean networkFailure;
|
||||
private final boolean unregisteredFailure;
|
||||
private final IdentityFailure identityFailure;
|
||||
private final SnodeAPI.Error lokiAPIError;
|
||||
|
||||
public static SendMessageResult success(SignalServiceAddress address, boolean unidentified, boolean needsSync) {
|
||||
return new SendMessageResult(address, new Success(unidentified, needsSync), false, false, null, null);
|
||||
}
|
||||
|
||||
public static SendMessageResult lokiAPIError(SignalServiceAddress address, SnodeAPI.Error lokiAPIError) {
|
||||
return new SendMessageResult(address, null, false, false, null, lokiAPIError);
|
||||
}
|
||||
|
||||
public static SendMessageResult networkFailure(SignalServiceAddress address) {
|
||||
return new SendMessageResult(address, null, true, false, null, null);
|
||||
}
|
||||
|
||||
public SignalServiceAddress getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public Success getSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public boolean isNetworkFailure() {
|
||||
return networkFailure;
|
||||
}
|
||||
|
||||
public IdentityFailure getIdentityFailure() {
|
||||
return identityFailure;
|
||||
}
|
||||
|
||||
public SnodeAPI.Error getLokiAPIError() { return lokiAPIError; }
|
||||
|
||||
private SendMessageResult(SignalServiceAddress address, Success success, boolean networkFailure, boolean unregisteredFailure, IdentityFailure identityFailure, SnodeAPI.Error lokiAPIError) {
|
||||
this.address = address;
|
||||
this.success = success;
|
||||
this.networkFailure = networkFailure;
|
||||
this.unregisteredFailure = unregisteredFailure;
|
||||
this.identityFailure = identityFailure;
|
||||
this.lokiAPIError = lokiAPIError;
|
||||
}
|
||||
|
||||
public static class Success {
|
||||
private final boolean unidentified;
|
||||
private final boolean needsSync;
|
||||
|
||||
private Success(boolean unidentified, boolean needsSync) {
|
||||
this.unidentified = unidentified;
|
||||
this.needsSync = needsSync;
|
||||
}
|
||||
|
||||
public boolean isUnidentified() {
|
||||
return unidentified;
|
||||
}
|
||||
|
||||
public boolean isNeedsSync() {
|
||||
return needsSync;
|
||||
}
|
||||
}
|
||||
|
||||
public static class IdentityFailure {
|
||||
private final IdentityKey identityKey;
|
||||
|
||||
private IdentityFailure(IdentityKey identityKey) {
|
||||
this.identityKey = identityKey;
|
||||
}
|
||||
|
||||
public IdentityKey getIdentityKey() {
|
||||
return identityKey;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user