diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..0b1cef05 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "external/libsignal-service-java"] + path = external/libsignal-service-java + url = https://github.com/WhisperSystems/libsignal-service-java.git diff --git a/build.gradle b/build.gradle index 8cd7c6b4..995c9bf2 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,16 @@ repositories { maven { url 'https://jitpack.io' } } +allprojects { + project.ext { + // these are common variables used in */build.gradle + version_number="0.0.13" + group_info="haven" + signal_version="2.3.0" + } +} + + android { compileSdkVersion 25 buildToolsVersion '26.0.2' @@ -25,6 +35,11 @@ android { packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' + exclude 'META-INF/DEPENDENCIES' + exclude 'META-INF/NOTICE' + exclude 'META-INF/LICENSE' + exclude 'META-INF/LICENSE.txt' + exclude 'META-INF/NOTICE.txt' } defaultConfig { @@ -35,6 +50,8 @@ android { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } + multiDexEnabled true + } buildTypes { @@ -47,11 +64,12 @@ android { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } + } dependencies { - + compile project(':external:libsignal-service-java:java') compile 'com.android.support:support-v4:25.4.0' compile 'com.github.satyan:sugar:1.5' compile 'com.android.support:appcompat-v7:25.4.0' diff --git a/external/libsignal-service-java b/external/libsignal-service-java new file mode 160000 index 00000000..70a0b223 --- /dev/null +++ b/external/libsignal-service-java @@ -0,0 +1 @@ +Subproject commit 70a0b223b2732e1ceb01799edcd806ca70d0c489 diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..1cd4d145 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +include ':external:libsignal-service-java:java' + diff --git a/src/main/java/info/guardianproject/phoneypot/PhoneyPotApp.java b/src/main/java/info/guardianproject/phoneypot/PhoneyPotApp.java index b96cb894..034e504f 100644 --- a/src/main/java/info/guardianproject/phoneypot/PhoneyPotApp.java +++ b/src/main/java/info/guardianproject/phoneypot/PhoneyPotApp.java @@ -1,6 +1,7 @@ package info.guardianproject.phoneypot; import android.app.Application; +import android.support.multidex.MultiDexApplication; import com.facebook.drawee.backends.pipeline.Fresco; import com.orm.SugarApp; @@ -10,7 +11,7 @@ * Created by n8fr8 on 8/9/17. */ -public class PhoneyPotApp extends Application { +public class PhoneyPotApp extends MultiDexApplication { @Override public void onCreate() { diff --git a/src/main/java/info/guardianproject/phoneypot/service/signal/MySignalProtocolStore.java b/src/main/java/info/guardianproject/phoneypot/service/signal/MySignalProtocolStore.java new file mode 100644 index 00000000..2c28ac8f --- /dev/null +++ b/src/main/java/info/guardianproject/phoneypot/service/signal/MySignalProtocolStore.java @@ -0,0 +1,114 @@ +package info.guardianproject.phoneypot.service.signal; + +import org.whispersystems.libsignal.IdentityKey; +import org.whispersystems.libsignal.IdentityKeyPair; +import org.whispersystems.libsignal.InvalidKeyIdException; +import org.whispersystems.libsignal.SignalProtocolAddress; +import org.whispersystems.libsignal.state.IdentityKeyStore; +import org.whispersystems.libsignal.state.PreKeyRecord; +import org.whispersystems.libsignal.state.SessionRecord; +import org.whispersystems.libsignal.state.SignalProtocolStore; +import org.whispersystems.libsignal.state.SignedPreKeyRecord; + +import java.util.List; + +/** + * Created by n8fr8 on 11/1/17. + */ + +public class MySignalProtocolStore implements SignalProtocolStore { + @Override + public IdentityKeyPair getIdentityKeyPair() { + return null; + } + + @Override + public int getLocalRegistrationId() { + return 0; + } + + @Override + public boolean saveIdentity(SignalProtocolAddress address, IdentityKey identityKey) { + return false; + } + + @Override + public boolean isTrustedIdentity(SignalProtocolAddress address, IdentityKey identityKey, Direction direction) { + return false; + } + + @Override + public PreKeyRecord loadPreKey(int preKeyId) throws InvalidKeyIdException { + return null; + } + + @Override + public void storePreKey(int preKeyId, PreKeyRecord record) { + + } + + @Override + public boolean containsPreKey(int preKeyId) { + return false; + } + + @Override + public void removePreKey(int preKeyId) { + + } + + @Override + public SessionRecord loadSession(SignalProtocolAddress address) { + return null; + } + + @Override + public List getSubDeviceSessions(String name) { + return null; + } + + @Override + public void storeSession(SignalProtocolAddress address, SessionRecord record) { + + } + + @Override + public boolean containsSession(SignalProtocolAddress address) { + return false; + } + + @Override + public void deleteSession(SignalProtocolAddress address) { + + } + + @Override + public void deleteAllSessions(String name) { + + } + + @Override + public SignedPreKeyRecord loadSignedPreKey(int signedPreKeyId) throws InvalidKeyIdException { + return null; + } + + @Override + public List loadSignedPreKeys() { + return null; + } + + @Override + public void storeSignedPreKey(int signedPreKeyId, SignedPreKeyRecord record) { + + } + + @Override + public boolean containsSignedPreKey(int signedPreKeyId) { + return false; + } + + @Override + public void removeSignedPreKey(int signedPreKeyId) { + + } +} diff --git a/src/main/java/info/guardianproject/phoneypot/service/signal/SignalSender.java b/src/main/java/info/guardianproject/phoneypot/service/signal/SignalSender.java new file mode 100644 index 00000000..052a30d2 --- /dev/null +++ b/src/main/java/info/guardianproject/phoneypot/service/signal/SignalSender.java @@ -0,0 +1,78 @@ +package info.guardianproject.phoneypot.service.signal; + +import org.whispersystems.libsignal.IdentityKeyPair; +import org.whispersystems.libsignal.InvalidKeyException; +import org.whispersystems.libsignal.state.PreKeyRecord; +import org.whispersystems.libsignal.state.SignedPreKeyRecord; +import org.whispersystems.libsignal.util.KeyHelper; +import org.whispersystems.libsignal.util.guava.Optional; +import org.whispersystems.signalservice.api.SignalServiceAccountManager; +import org.whispersystems.signalservice.api.SignalServiceMessageSender; +import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; +import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage; +import org.whispersystems.signalservice.api.push.SignalServiceAddress; +import org.whispersystems.signalservice.api.push.TrustStore; + +import java.io.IOException; +import java.util.List; + +/** + * Created by n8fr8 on 10/31/17. + */ + +public class SignalSender { + + private final String URL = "https://my.signal.server.com"; + private final TrustStore TRUST_STORE = null;//new MyTrustStoreImpl(); + private final String USERNAME = "+14151231234"; + private final String PASSWORD = null;//generateRandomPassword(); + private final String USER_AGENT = "[FILL_IN]"; + + private SignalServiceAccountManager accountManager; + + public SignalSender () + { + accountManager = null; //new SignalServiceAccountManager(URL, TRUST_STORE, USERNAME, PASSWORD, USER_AGENT); + + + } + public void generateKeys () + { + + } + + public void register () throws IOException { + + accountManager.requestSmsVerificationCode(); + } + + public void verify (String receivedSmsVerificationCode) throws IOException, InvalidKeyException { + + // accountManager.verifyAccountWithCode(receivedSmsVerificationCode, generateRandomSignalingKey(), + // generateRandomInstallId(), false); + + int signedPreKeyId = 1; + + IdentityKeyPair identityKey = KeyHelper.generateIdentityKeyPair(); + List oneTimePreKeys = KeyHelper.generatePreKeys(0, 100); + SignedPreKeyRecord signedPreKeyRecord = KeyHelper.generateSignedPreKey(identityKey, signedPreKeyId); + + //accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID))); + accountManager.setPreKeys(identityKey.getPublicKey(), signedPreKeyRecord, oneTimePreKeys); + } + + public void sendMessage () throws IOException, UntrustedIdentityException { + SignalServiceMessageSender messageSender = null; + + /** + new SignalServiceMessageSender(URL, TRUST_STORE, USERNAME, PASSWORD, + new MySignalProtocolStore(), + USER_AGENT, Optional.absent()); + **/ + + messageSender.sendMessage(new SignalServiceAddress("+14159998888"), + SignalServiceDataMessage.newBuilder() + .withBody("Hello, world!") + .build()); + } +}