mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 00:18:51 -05:00
Safeslinger: cleanup
This commit is contained in:
parent
b1c3bfa157
commit
7b51718c92
@ -56,9 +56,7 @@ import org.sufficientlysecure.keychain.util.QrCodeUtils;
|
|||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import edu.cmu.cylab.starslinger.exchange.ExchangeActivity;
|
import edu.cmu.cylab.starslinger.exchange.ExchangeActivity;
|
||||||
import edu.cmu.cylab.starslinger.exchange.ExchangeConfig;
|
import edu.cmu.cylab.starslinger.exchange.ExchangeConfig;
|
||||||
@ -252,19 +250,10 @@ public class ViewKeyShareFragment extends LoaderFragment implements
|
|||||||
case REQUEST_CODE_SAFESLINGER:
|
case REQUEST_CODE_SAFESLINGER:
|
||||||
switch (resultCode) {
|
switch (resultCode) {
|
||||||
case ExchangeActivity.RESULT_EXCHANGE_OK:
|
case ExchangeActivity.RESULT_EXCHANGE_OK:
|
||||||
// use newly exchanged data from 'theirSecrets'
|
// import exchanged keys
|
||||||
ArrayList<byte[]> theirSecrets = endExchange(data);
|
|
||||||
Intent importIntent = new Intent(getActivity(), ImportKeysActivity.class);
|
Intent importIntent = new Intent(getActivity(), ImportKeysActivity.class);
|
||||||
importIntent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY);
|
importIntent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY);
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
importIntent.putExtra(ImportKeysActivity.EXTRA_KEY_BYTES, getSlingedKeys(data));
|
||||||
for (byte[] t : theirSecrets) {
|
|
||||||
try {
|
|
||||||
out.write(t);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(Constants.TAG, "IOException", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
importIntent.putExtra(ImportKeysActivity.EXTRA_KEY_BYTES, out.toByteArray());
|
|
||||||
startActivity(importIntent);
|
startActivity(importIntent);
|
||||||
break;
|
break;
|
||||||
case ExchangeActivity.RESULT_EXCHANGE_CANCELED:
|
case ExchangeActivity.RESULT_EXCHANGE_CANCELED:
|
||||||
@ -277,11 +266,11 @@ public class ViewKeyShareFragment extends LoaderFragment implements
|
|||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<byte[]> endExchange(Intent data) {
|
private static byte[] getSlingedKeys(Intent data) {
|
||||||
ArrayList<byte[]> theirSecrets = new ArrayList<byte[]>();
|
ArrayList<byte[]> theirSecrets = new ArrayList<byte[]>();
|
||||||
Bundle extras = data.getExtras();
|
Bundle extras = data.getExtras();
|
||||||
if (extras != null) {
|
if (extras != null) {
|
||||||
byte[] d = null;
|
byte[] d;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
do {
|
do {
|
||||||
d = extras.getByteArray(ExchangeConfig.extra.MEMBER_DATA + i);
|
d = extras.getByteArray(ExchangeConfig.extra.MEMBER_DATA + i);
|
||||||
@ -291,7 +280,17 @@ public class ViewKeyShareFragment extends LoaderFragment implements
|
|||||||
}
|
}
|
||||||
} while (d != null);
|
} while (d != null);
|
||||||
}
|
}
|
||||||
return theirSecrets;
|
|
||||||
|
// concatenate keys
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
for (byte[] t : theirSecrets) {
|
||||||
|
try {
|
||||||
|
out.write(t);
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e(Constants.TAG, "IOException", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user