Quick Links: Downloads, Wiki, Support, Translations, Contributing, Research Paper, Project Website
- /safeslinger-exchange Contains the library project you can add to your own Android applications. Both the safeslinger-demo and safeslinger-messenger application projects utilize this library to execute the exchange.
- /safeslinger-demo Contains the simple SafeSlinger Exchange Developer's App application project which shows the minimum requirements to run a safeslinger secure exchange.
- /safeslinger-messenger Contains the full application project source for the SafeSlinger Messenger application. This project is a very rich implementation of a safeslinger secure exchange if you want an example of how to use the exchange to verify public keys in your own applications.
- /sha3 Contains only the Keccak portions of the sphlib 3.0 library.
- /android-vcard This is a modified version of the android-vcard library.
Developer's App Requirements:
- Must be installed on a minimum of 2 devices.
- An Internet connection must be active.
- 'Server Host Name' can be your own server, OR use ours:
slinger-dev.appspot.com
- 'My Secret' can be any information.
Modify your AndroidManifest.xml
to include required permissions.
...
<uses-permission android:name="android.permission.INTERNET" />
...
Modify your AndroidManifest.xml
to include required activities.
...
<!-- we must include all activities declared by library manifests as well: -->
<activity
android:name="edu.cmu.cylab.starslinger.exchange.ExchangeActivity"
android:label="@string/lib_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="edu.cmu.cylab.starslinger.exchange.GroupingActivity"
android:label="@string/lib_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="edu.cmu.cylab.starslinger.exchange.VerifyActivity"
android:label="@string/lib_name"
android:screenOrientation="portrait" >
</activity>
...
Modify your Activity
that starts the exchange to import Bundle
string extras for convenience and to avoid potential refactoring of names in future versions of the library.
...
import edu.cmu.cylab.starslinger.exchange.ExchangeActivity;
import edu.cmu.cylab.starslinger.exchange.ExchangeConfig;
public class MainActivity extends Activity {
private static final int RESULT_EXCHANGE = 1;
...
Call the ExchangeActivity
with required extras USER_DATA
and HOST_NAME
. The UX will ask for the number of users, grouping number, and 3-word phrase.
private void beginExchange(String hostName, byte[] mySecret) {
Intent intent = new Intent(getActivity(), ExchangeActivity.class);
intent.putExtra(ExchangeConfig.extra.USER_DATA, mySecret);
intent.putExtra(ExchangeConfig.extra.HOST_NAME, hostName);
startActivityForResult(intent, RESULT_EXCHANGE);
}
Optionally, you may pass in the number of users using the NUM_USERS
extra. The UX will ask for the grouping number and 3-word phrase only.
private void beginExchange(String hostName, byte[] mySecret, int numUsersIn) {
Intent intent = new Intent(getActivity(), ExchangeActivity.class);
intent.putExtra(ExchangeConfig.extra.USER_DATA, mySecret);
intent.putExtra(ExchangeConfig.extra.HOST_NAME, hostName);
intent.putExtra(ExchangeConfig.extra.NUM_USERS, numUsersIn);
startActivityForResult(intent, RESULT_EXCHANGE);
}
Handle the ExchangeActivity
results.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case RESULT_EXCHANGE:
switch (resultCode) {
case ExchangeActivity.RESULT_EXCHANGE_OK:
// use newly exchanged data from 'theirSecrets'
ArrayList<byte[]> theirSecrets = endExchange(data);
// ...
break;
case ExchangeActivity.RESULT_EXCHANGE_CANCELED:
// handle canceled result
// ...
break;
}
break;
}
super.onActivityResult(requestCode, resultCode, data);
}
private static ArrayList<byte[]> endExchange(Intent data) {
ArrayList<byte[]> theirSecrets = new ArrayList<byte[]>();
Bundle extras = data.getExtras();
if (extras != null) {
byte[] d = null;
int i = 0;
do {
d = extras.getByteArray(ExchangeConfig.extra.MEMBER_DATA + i);
if (d != null) {
theirSecrets.add(d);
i++;
}
} while (d != null);
}
return theirSecrets;
}
The MIT License (MIT)
Copyright (c) 2010-2015 Carnegie Mellon University
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.