Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -764,8 +764,9 @@
|
|||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<!-- OpenPGP Remote API, this service has explicitly no permission requirements
|
<!-- DEPRECATED service,
|
||||||
because we are using our own package based allow/disallow system -->
|
using this service may lead to truncated data being returned to the caller
|
||||||
|
-->
|
||||||
<service
|
<service
|
||||||
android:name=".remote.OpenPgpService"
|
android:name=".remote.OpenPgpService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
@@ -777,6 +778,19 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<!-- OpenPGP Remote API, this service has explicitly no permission requirements
|
||||||
|
because we are using our own package based allow/disallow system -->
|
||||||
|
<service
|
||||||
|
android:name=".remote.OpenPgpService2"
|
||||||
|
android:enabled="true"
|
||||||
|
android:exported="true"
|
||||||
|
android:process=":remote_api_2"
|
||||||
|
tools:ignore="ExportedService">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="org.openintents.openpgp.IOpenPgpService2" />
|
||||||
|
</intent-filter>
|
||||||
|
</service>
|
||||||
|
|
||||||
<!-- Contact Sync services -->
|
<!-- Contact Sync services -->
|
||||||
<service
|
<service
|
||||||
android:name=".service.DummyAccountService"
|
android:name=".service.DummyAccountService"
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import android.net.Uri;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import org.openintents.openpgp.IOpenPgpService;
|
import org.openintents.openpgp.IOpenPgpService;
|
||||||
@@ -65,8 +66,10 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class OpenPgpService extends RemoteService {
|
public class OpenPgpService extends RemoteService {
|
||||||
|
|
||||||
@@ -812,19 +815,14 @@ public class OpenPgpService extends RemoteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// version code is required and needs to correspond to version code of service!
|
// version code is required and needs to correspond to version code of service!
|
||||||
// History of versions in org.openintents.openpgp.util.OpenPgpApi
|
// History of versions in openpgp-api's CHANGELOG.md
|
||||||
// we support 3, 4, 5, 6
|
List<Integer> supportedVersions = Arrays.asList(3, 4, 5, 6, 7, 8, 9);
|
||||||
if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) != 3
|
if (!supportedVersions.contains(data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1))) {
|
||||||
&& data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) != 4
|
|
||||||
&& data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) != 5
|
|
||||||
&& data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) != 6
|
|
||||||
&& data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) != 7
|
|
||||||
&& data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) != 8) {
|
|
||||||
Intent result = new Intent();
|
Intent result = new Intent();
|
||||||
OpenPgpError error = new OpenPgpError
|
OpenPgpError error = new OpenPgpError
|
||||||
(OpenPgpError.INCOMPATIBLE_API_VERSIONS, "Incompatible API versions!\n"
|
(OpenPgpError.INCOMPATIBLE_API_VERSIONS, "Incompatible API versions!\n"
|
||||||
+ "used API version: " + data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) + "\n"
|
+ "used API version: " + data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) + "\n"
|
||||||
+ "supported API versions: 3-8");
|
+ "supported API versions: " + supportedVersions.toString());
|
||||||
result.putExtra(OpenPgpApi.RESULT_ERROR, error);
|
result.putExtra(OpenPgpApi.RESULT_ERROR, error);
|
||||||
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
|
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
|
||||||
return result;
|
return result;
|
||||||
@@ -842,67 +840,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
private final IOpenPgpService.Stub mBinder = new IOpenPgpService.Stub() {
|
private final IOpenPgpService.Stub mBinder = new IOpenPgpService.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public Intent execute(Intent data, ParcelFileDescriptor input, ParcelFileDescriptor output) {
|
public Intent execute(Intent data, ParcelFileDescriptor input, ParcelFileDescriptor output) {
|
||||||
try {
|
Log.w(Constants.TAG, "You are using a deprecated service which may lead to truncated data on return, please use IOpenPgpService2!");
|
||||||
Intent errorResult = checkRequirements(data);
|
return executeInternal(data, input, output);
|
||||||
if (errorResult != null) {
|
|
||||||
return errorResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
String action = data.getAction();
|
|
||||||
switch (action) {
|
|
||||||
case OpenPgpApi.ACTION_CLEARTEXT_SIGN: {
|
|
||||||
return signImpl(data, input, output, true);
|
|
||||||
}
|
|
||||||
case OpenPgpApi.ACTION_SIGN: {
|
|
||||||
// DEPRECATED: same as ACTION_CLEARTEXT_SIGN
|
|
||||||
Log.w(Constants.TAG, "You are using a deprecated API call, please use ACTION_CLEARTEXT_SIGN instead of ACTION_SIGN!");
|
|
||||||
return signImpl(data, input, output, true);
|
|
||||||
}
|
|
||||||
case OpenPgpApi.ACTION_DETACHED_SIGN: {
|
|
||||||
return signImpl(data, input, output, false);
|
|
||||||
}
|
|
||||||
case OpenPgpApi.ACTION_ENCRYPT: {
|
|
||||||
return encryptAndSignImpl(data, input, output, false);
|
|
||||||
}
|
|
||||||
case OpenPgpApi.ACTION_SIGN_AND_ENCRYPT: {
|
|
||||||
return encryptAndSignImpl(data, input, output, true);
|
|
||||||
}
|
|
||||||
case OpenPgpApi.ACTION_DECRYPT_VERIFY: {
|
|
||||||
return decryptAndVerifyImpl(data, input, output, false);
|
|
||||||
}
|
|
||||||
case OpenPgpApi.ACTION_DECRYPT_METADATA: {
|
|
||||||
return decryptAndVerifyImpl(data, input, output, true);
|
|
||||||
}
|
|
||||||
case OpenPgpApi.ACTION_GET_SIGN_KEY_ID: {
|
|
||||||
return getSignKeyIdImpl(data);
|
|
||||||
}
|
|
||||||
case OpenPgpApi.ACTION_GET_KEY_IDS: {
|
|
||||||
return getKeyIdsImpl(data);
|
|
||||||
}
|
|
||||||
case OpenPgpApi.ACTION_GET_KEY: {
|
|
||||||
return getKeyImpl(data);
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
// always close input and output file descriptors even in error cases
|
|
||||||
if (input != null) {
|
|
||||||
try {
|
|
||||||
input.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(Constants.TAG, "IOException when closing input ParcelFileDescriptor", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (output != null) {
|
|
||||||
try {
|
|
||||||
output.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(Constants.TAG, "IOException when closing output ParcelFileDescriptor", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -912,4 +851,68 @@ public class OpenPgpService extends RemoteService {
|
|||||||
return mBinder;
|
return mBinder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected Intent executeInternal(Intent data, ParcelFileDescriptor input, ParcelFileDescriptor output) {
|
||||||
|
try {
|
||||||
|
Intent errorResult = checkRequirements(data);
|
||||||
|
if (errorResult != null) {
|
||||||
|
return errorResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
String action = data.getAction();
|
||||||
|
switch (action) {
|
||||||
|
case OpenPgpApi.ACTION_CLEARTEXT_SIGN: {
|
||||||
|
return signImpl(data, input, output, true);
|
||||||
|
}
|
||||||
|
case OpenPgpApi.ACTION_SIGN: {
|
||||||
|
// DEPRECATED: same as ACTION_CLEARTEXT_SIGN
|
||||||
|
Log.w(Constants.TAG, "You are using a deprecated API call, please use ACTION_CLEARTEXT_SIGN instead of ACTION_SIGN!");
|
||||||
|
return signImpl(data, input, output, true);
|
||||||
|
}
|
||||||
|
case OpenPgpApi.ACTION_DETACHED_SIGN: {
|
||||||
|
return signImpl(data, input, output, false);
|
||||||
|
}
|
||||||
|
case OpenPgpApi.ACTION_ENCRYPT: {
|
||||||
|
return encryptAndSignImpl(data, input, output, false);
|
||||||
|
}
|
||||||
|
case OpenPgpApi.ACTION_SIGN_AND_ENCRYPT: {
|
||||||
|
return encryptAndSignImpl(data, input, output, true);
|
||||||
|
}
|
||||||
|
case OpenPgpApi.ACTION_DECRYPT_VERIFY: {
|
||||||
|
return decryptAndVerifyImpl(data, input, output, false);
|
||||||
|
}
|
||||||
|
case OpenPgpApi.ACTION_DECRYPT_METADATA: {
|
||||||
|
return decryptAndVerifyImpl(data, input, output, true);
|
||||||
|
}
|
||||||
|
case OpenPgpApi.ACTION_GET_SIGN_KEY_ID: {
|
||||||
|
return getSignKeyIdImpl(data);
|
||||||
|
}
|
||||||
|
case OpenPgpApi.ACTION_GET_KEY_IDS: {
|
||||||
|
return getKeyIdsImpl(data);
|
||||||
|
}
|
||||||
|
case OpenPgpApi.ACTION_GET_KEY: {
|
||||||
|
return getKeyImpl(data);
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// always close input and output file descriptors even in error cases
|
||||||
|
if (input != null) {
|
||||||
|
try {
|
||||||
|
input.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e(Constants.TAG, "IOException when closing input ParcelFileDescriptor", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (output != null) {
|
||||||
|
try {
|
||||||
|
output.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e(Constants.TAG, "IOException when closing output ParcelFileDescriptor", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.sufficientlysecure.keychain.remote;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Binder;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.os.ParcelFileDescriptor;
|
||||||
|
|
||||||
|
import org.openintents.openpgp.IOpenPgpService2;
|
||||||
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class OpenPgpService2 extends OpenPgpService {
|
||||||
|
|
||||||
|
private Map<Long, ParcelFileDescriptor> mOutputPipeMap = new HashMap<Long, ParcelFileDescriptor>();
|
||||||
|
|
||||||
|
private long createKey(int id) {
|
||||||
|
int callingPid = Binder.getCallingPid();
|
||||||
|
return ((long) callingPid << 32) | ((long) id & 0xFFFFFFFL);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final IOpenPgpService2.Stub mBinder = new IOpenPgpService2.Stub() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ParcelFileDescriptor createOutputPipe(int outputPipeId) {
|
||||||
|
try {
|
||||||
|
ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
|
||||||
|
mOutputPipeMap.put(createKey(outputPipeId), pipe[1]);
|
||||||
|
return pipe[0];
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e(Constants.TAG, "IOException in OpenPgpService2", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Intent execute(Intent data, ParcelFileDescriptor input, int outputPipeId) {
|
||||||
|
long key = createKey(outputPipeId);
|
||||||
|
ParcelFileDescriptor output = mOutputPipeMap.get(key);
|
||||||
|
mOutputPipeMap.remove(key);
|
||||||
|
return executeInternal(data, input, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBinder onBind(Intent intent) {
|
||||||
|
return mBinder;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1526,8 +1526,8 @@
|
|||||||
<string name="error_loading_keys">"Error loading keys!"</string>
|
<string name="error_loading_keys">"Error loading keys!"</string>
|
||||||
<string name="error_empty_log">"(error, empty log)"</string>
|
<string name="error_empty_log">"(error, empty log)"</string>
|
||||||
<string name="error_reading_text">"Could not read input to decrypt!"</string>
|
<string name="error_reading_text">"Could not read input to decrypt!"</string>
|
||||||
<string name="filename_unknown"><![CDATA[<no filename>]]></string>
|
<string name="filename_unknown">Unknown filename (click to open)</string>
|
||||||
<string name="filename_unknown_text"><![CDATA[<plain text data>]]></string>
|
<string name="filename_unknown_text">Text (click to show)</string>
|
||||||
<string name="intent_show">Show Signed/Encrypted Content</string>
|
<string name="intent_show">Show Signed/Encrypted Content</string>
|
||||||
<string name="view_internal">"View in OpenKeychain"</string>
|
<string name="view_internal">"View in OpenKeychain"</string>
|
||||||
<string name="error_preparing_data">"Error preparing data!"</string>
|
<string name="error_preparing_data">"Error preparing data!"</string>
|
||||||
|
|||||||
2
extern/openpgp-api-lib
vendored
2
extern/openpgp-api-lib
vendored
Submodule extern/openpgp-api-lib updated: a5240bebf4...13492ba19f
Reference in New Issue
Block a user