aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/org/openintents
diff options
context:
space:
mode:
Diffstat (limited to 'OpenPGP-Keychain/src/org/openintents')
-rw-r--r--OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpCallback.aidl7
-rw-r--r--OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpKeyIdsCallback.aidl39
-rw-r--r--OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpService.aidl110
-rw-r--r--OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpData.aidl20
-rw-r--r--OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpData.java125
-rw-r--r--OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpSignatureResult.java51
6 files changed, 297 insertions, 55 deletions
diff --git a/OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpCallback.aidl b/OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpCallback.aidl
index ca00c8ce1..ba41de1ba 100644
--- a/OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpCallback.aidl
+++ b/OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpCallback.aidl
@@ -16,6 +16,7 @@
package org.openintents.openpgp;
+import org.openintents.openpgp.OpenPgpData;
import org.openintents.openpgp.OpenPgpSignatureResult;
import org.openintents.openpgp.OpenPgpError;
@@ -24,14 +25,14 @@ interface IOpenPgpCallback {
/**
* onSuccess returns on successful OpenPGP operations.
*
- * @param outputBytes
- * contains resulting output bytes (decrypted content (when input was encrypted)
+ * @param output
+ * contains resulting output (decrypted content (when input was encrypted)
* or content without signature (when input was signed-only))
* @param signatureResult
* signatureResult is only non-null if decryptAndVerify() was called and the content
* was encrypted or signed-and-encrypted.
*/
- oneway void onSuccess(in byte[] outputBytes, in OpenPgpSignatureResult signatureResult);
+ oneway void onSuccess(in OpenPgpData output, in OpenPgpSignatureResult signatureResult);
/**
* onError returns on errors or when allowUserInteraction was set to false, but user interaction
diff --git a/OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpKeyIdsCallback.aidl b/OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpKeyIdsCallback.aidl
new file mode 100644
index 000000000..4ca356fad
--- /dev/null
+++ b/OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpKeyIdsCallback.aidl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2013 Dominik Schürmann <dominik@dominikschuermann.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openintents.openpgp;
+
+import org.openintents.openpgp.OpenPgpError;
+
+interface IOpenPgpKeyIdsCallback {
+
+ /**
+ * onSuccess returns on successful getKeyIds operations.
+ *
+ * @param keyIds
+ * returned key ids
+ */
+ oneway void onSuccess(in long[] keyIds);
+
+ /**
+ * onError returns on errors or when allowUserInteraction was set to false, but user interaction
+ * was required execute an OpenPGP operation.
+ *
+ * @param error
+ * See OpenPgpError class for more information.
+ */
+ oneway void onError(in OpenPgpError error);
+} \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpService.aidl b/OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpService.aidl
index ab7ec8b1a..69a608dc6 100644
--- a/OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpService.aidl
+++ b/OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpService.aidl
@@ -16,7 +16,9 @@
package org.openintents.openpgp;
+import org.openintents.openpgp.OpenPgpData;
import org.openintents.openpgp.IOpenPgpCallback;
+import org.openintents.openpgp.IOpenPgpKeyIdsCallback;
/**
* All methods are oneway, which means they are asynchronous and non-blocking.
@@ -29,54 +31,76 @@ interface IOpenPgpService {
*
* After successful encryption, callback's onSuccess will contain the resulting output bytes.
*
- * @param inputBytes
- * Byte array you want to encrypt
- * @param encryptionUserIds
- * User Ids (emails) of recipients
- * @param asciiArmor
- * Encode result for ASCII (Radix-64, 33 percent overhead compared to binary)
- * @param allowUserInteraction
- * Allows the OpenPGP Provider to handle missing keys by showing activities
+ * @param input
+ * OpenPgpData object containing String, byte[], ParcelFileDescriptor, or Uri
+ * @param output
+ * Request output format by defining OpenPgpData object
+ *
+ * new OpenPgpData(OpenPgpData.TYPE_STRING)
+ * Returns as String
+ * (OpenPGP Radix-64, 33 percent overhead compared to binary, see http://tools.ietf.org/html/rfc4880#page-53)
+ * new OpenPgpData(OpenPgpData.TYPE_BYTE_ARRAY)
+ * Returns as byte[]
+ * new OpenPgpData(uri)
+ * Writes output to given Uri
+ * new OpenPgpData(fileDescriptor)
+ * Writes output to given ParcelFileDescriptor
+ * @param keyIds
+ * Key Ids of recipients. Can be retrieved with getKeyIds()
* @param callback
* Callback where to return results
*/
- oneway void encrypt(in byte[] inputBytes, in String[] encryptionUserIds, in boolean asciiArmor,
- in IOpenPgpCallback callback);
+ oneway void encrypt(in OpenPgpData input, in OpenPgpData output, in long[] keyIds, in IOpenPgpCallback callback);
/**
* Sign
*
* After successful signing, callback's onSuccess will contain the resulting output bytes.
*
- * @param inputBytes
- * Byte array you want to sign
- * @param asciiArmor
- * Encode result for ASCII (Radix-64, 33 percent overhead compared to binary)
- * @param allowUserInteraction
- * Allows the OpenPGP Provider to handle missing keys by showing activities
+ * @param input
+ * OpenPgpData object containing String, byte[], ParcelFileDescriptor, or Uri
+ * @param output
+ * Request output format by defining OpenPgpData object
+ *
+ * new OpenPgpData(OpenPgpData.TYPE_STRING)
+ * Returns as String
+ * (OpenPGP Radix-64, 33 percent overhead compared to binary, see http://tools.ietf.org/html/rfc4880#page-53)
+ * new OpenPgpData(OpenPgpData.TYPE_BYTE_ARRAY)
+ * Returns as byte[]
+ * new OpenPgpData(uri)
+ * Writes output to given Uri
+ * new OpenPgpData(fileDescriptor)
+ * Writes output to given ParcelFileDescriptor
* @param callback
* Callback where to return results
*/
- oneway void sign(in byte[] inputBytes, in boolean asciiArmor, in IOpenPgpCallback callback);
+ oneway void sign(in OpenPgpData input, in OpenPgpData output, in IOpenPgpCallback callback);
/**
* Sign then encrypt
*
* After successful signing and encryption, callback's onSuccess will contain the resulting output bytes.
*
- * @param inputBytes
- * Byte array you want to sign and encrypt
- * @param encryptionUserIds
- * User Ids (emails) of recipients
- * @param asciiArmor
- * Encode result for ASCII (Radix-64, 33 percent overhead compared to binary)
- * @param allowUserInteraction
- * Allows the OpenPGP Provider to handle missing keys by showing activities
+ * @param input
+ * OpenPgpData object containing String, byte[], ParcelFileDescriptor, or Uri
+ * @param output
+ * Request output format by defining OpenPgpData object
+ *
+ * new OpenPgpData(OpenPgpData.TYPE_STRING)
+ * Returns as String
+ * (OpenPGP Radix-64, 33 percent overhead compared to binary, see http://tools.ietf.org/html/rfc4880#page-53)
+ * new OpenPgpData(OpenPgpData.TYPE_BYTE_ARRAY)
+ * Returns as byte[]
+ * new OpenPgpData(uri)
+ * Writes output to given Uri
+ * new OpenPgpData(fileDescriptor)
+ * Writes output to given ParcelFileDescriptor
+ * @param keyIds
+ * Key Ids of recipients. Can be retrieved with getKeyIds()
* @param callback
* Callback where to return results
*/
- oneway void signAndEncrypt(in byte[] inputBytes, in String[] encryptionUserIds, in boolean asciiArmor,
- in IOpenPgpCallback callback);
+ oneway void signAndEncrypt(in OpenPgpData input, in OpenPgpData output, in long[] keyIds, in IOpenPgpCallback callback);
/**
* Decrypts and verifies given input bytes. This methods handles encrypted-only, signed-and-encrypted,
@@ -85,15 +109,35 @@ interface IOpenPgpService {
* After successful decryption/verification, callback's onSuccess will contain the resulting output bytes.
* The signatureResult in onSuccess is only non-null if signed-and-encrypted or signed-only inputBytes were given.
*
- * @param inputBytes
- * Byte array you want to decrypt and verify
- * @param allowUserInteraction
- * Allows the OpenPGP Provider to handle missing keys by showing activities
+ * @param input
+ * OpenPgpData object containing String, byte[], ParcelFileDescriptor, or Uri
+ * @param output
+ * Request output format by defining OpenPgpData object
+ *
+ * new OpenPgpData(OpenPgpData.TYPE_STRING)
+ * Returns as String
+ * (OpenPGP Radix-64, 33 percent overhead compared to binary, see http://tools.ietf.org/html/rfc4880#page-53)
+ * new OpenPgpData(OpenPgpData.TYPE_BYTE_ARRAY)
+ * Returns as byte[]
+ * new OpenPgpData(uri)
+ * Writes output to given Uri
+ * new OpenPgpData(fileDescriptor)
+ * Writes output to given ParcelFileDescriptor
* @param callback
* Callback where to return results
*/
- oneway void decryptAndVerify(in byte[] inputBytes, in IOpenPgpCallback callback);
+ oneway void decryptAndVerify(in OpenPgpData input, in OpenPgpData output, in IOpenPgpCallback callback);
- boolean isKeyAvailable(in String[] userIds);
+ /**
+ * Get available key ids based on given user ids
+ *
+ * @param ids
+ * User Ids (emails) of recipients OR key ids
+ * @param allowUserInteraction
+ * Enable user interaction to lookup and import unknown keys
+ * @param callback
+ * Callback where to return results (different type than callback in other functions!)
+ */
+ oneway void getKeyIds(in String[] ids, in boolean allowUserInteraction, in IOpenPgpKeyIdsCallback callback);
} \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpData.aidl b/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpData.aidl
new file mode 100644
index 000000000..3711e4fb4
--- /dev/null
+++ b/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpData.aidl
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2013 Dominik Schürmann <dominik@dominikschuermann.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openintents.openpgp;
+
+// Declare OpenPgpData so AIDL can find it and knows that it implements the parcelable protocol.
+parcelable OpenPgpData; \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpData.java b/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpData.java
new file mode 100644
index 000000000..064df0f1e
--- /dev/null
+++ b/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpData.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2013 Dominik Schürmann <dominik@dominikschuermann.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openintents.openpgp;
+
+import android.net.Uri;
+import android.os.Parcel;
+import android.os.ParcelFileDescriptor;
+import android.os.Parcelable;
+
+public class OpenPgpData implements Parcelable {
+ public static final int TYPE_STRING = 0;
+ public static final int TYPE_BYTE_ARRAY = 1;
+ public static final int TYPE_FILE_DESCRIPTOR = 2;
+ public static final int TYPE_URI = 3;
+
+ int type;
+
+ String string;
+ byte[] bytes = new byte[0];
+ ParcelFileDescriptor fileDescriptor;
+ Uri uri;
+
+ public int getType() {
+ return type;
+ }
+
+ public String getString() {
+ return string;
+ }
+
+ public byte[] getBytes() {
+ return bytes;
+ }
+
+ public ParcelFileDescriptor getFileDescriptor() {
+ return fileDescriptor;
+ }
+
+ public Uri getUri() {
+ return uri;
+ }
+
+ public OpenPgpData() {
+
+ }
+
+ /**
+ * Not a real constructor. This can be used to define requested output type.
+ *
+ * @param type
+ */
+ public OpenPgpData(int type) {
+ this.type = type;
+ }
+
+ public OpenPgpData(String string) {
+ this.string = string;
+ this.type = TYPE_STRING;
+ }
+
+ public OpenPgpData(byte[] bytes) {
+ this.bytes = bytes;
+ this.type = TYPE_BYTE_ARRAY;
+ }
+
+ public OpenPgpData(ParcelFileDescriptor fileDescriptor) {
+ this.fileDescriptor = fileDescriptor;
+ this.type = TYPE_FILE_DESCRIPTOR;
+ }
+
+ public OpenPgpData(Uri uri) {
+ this.uri = uri;
+ this.type = TYPE_URI;
+ }
+
+ public OpenPgpData(OpenPgpData b) {
+ this.string = b.string;
+ this.bytes = b.bytes;
+ this.fileDescriptor = b.fileDescriptor;
+ this.uri = b.uri;
+ }
+
+ public int describeContents() {
+ return 0;
+ }
+
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(string);
+ dest.writeInt(bytes.length);
+ dest.writeByteArray(bytes);
+ dest.writeParcelable(fileDescriptor, 0);
+ dest.writeParcelable(uri, 0);
+ }
+
+ public static final Creator<OpenPgpData> CREATOR = new Creator<OpenPgpData>() {
+ public OpenPgpData createFromParcel(final Parcel source) {
+ OpenPgpData vr = new OpenPgpData();
+ vr.string = source.readString();
+ vr.bytes = new byte[source.readInt()];
+ source.readByteArray(vr.bytes);
+ vr.fileDescriptor = source.readParcelable(ParcelFileDescriptor.class.getClassLoader());
+ vr.fileDescriptor = source.readParcelable(Uri.class.getClassLoader());
+ return vr;
+ }
+
+ public OpenPgpData[] newArray(final int size) {
+ return new OpenPgpData[size];
+ }
+ };
+
+}
diff --git a/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpSignatureResult.java b/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpSignatureResult.java
index 4446614dd..829f8f8cf 100644
--- a/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpSignatureResult.java
+++ b/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpSignatureResult.java
@@ -25,40 +25,50 @@ public class OpenPgpSignatureResult implements Parcelable {
// successfully verified signature, with trusted public key
public static final int SIGNATURE_SUCCESS_TRUSTED = 1;
// no public key was found for this signature verification
+ // you can retrieve the key with
+ // getKeys(new String[] {String.valueOf(signatureResult.getKeyId)}, true, callback)
public static final int SIGNATURE_UNKNOWN_PUB_KEY = 2;
// successfully verified signature, but with untrusted public key
public static final int SIGNATURE_SUCCESS_UNTRUSTED = 3;
- int signatureStatus;
- String signatureUserId;
+ int status;
boolean signatureOnly;
+ String userId;
+ long keyId;
- public int getSignatureStatus() {
- return signatureStatus;
- }
-
- public String getSignatureUserId() {
- return signatureUserId;
+ public int getStatus() {
+ return status;
}
public boolean isSignatureOnly() {
return signatureOnly;
}
+ public String getUserId() {
+ return userId;
+ }
+
+ public long getKeyId() {
+ return keyId;
+ }
+
public OpenPgpSignatureResult() {
}
- public OpenPgpSignatureResult(int signatureStatus, String signatureUserId, boolean signatureOnly) {
- this.signatureStatus = signatureStatus;
- this.signatureUserId = signatureUserId;
+ public OpenPgpSignatureResult(int signatureStatus, String signatureUserId,
+ boolean signatureOnly, long keyId) {
+ this.status = signatureStatus;
this.signatureOnly = signatureOnly;
+ this.userId = signatureUserId;
+ this.keyId = keyId;
}
public OpenPgpSignatureResult(OpenPgpSignatureResult b) {
- this.signatureStatus = b.signatureStatus;
- this.signatureUserId = b.signatureUserId;
+ this.status = b.status;
+ this.userId = b.userId;
this.signatureOnly = b.signatureOnly;
+ this.keyId = b.keyId;
}
public int describeContents() {
@@ -66,17 +76,19 @@ public class OpenPgpSignatureResult implements Parcelable {
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(signatureStatus);
- dest.writeString(signatureUserId);
+ dest.writeInt(status);
dest.writeByte((byte) (signatureOnly ? 1 : 0));
+ dest.writeString(userId);
+ dest.writeLong(keyId);
}
public static final Creator<OpenPgpSignatureResult> CREATOR = new Creator<OpenPgpSignatureResult>() {
public OpenPgpSignatureResult createFromParcel(final Parcel source) {
OpenPgpSignatureResult vr = new OpenPgpSignatureResult();
- vr.signatureStatus = source.readInt();
- vr.signatureUserId = source.readString();
+ vr.status = source.readInt();
vr.signatureOnly = source.readByte() == 1;
+ vr.userId = source.readString();
+ vr.keyId = source.readLong();
return vr;
}
@@ -88,9 +100,10 @@ public class OpenPgpSignatureResult implements Parcelable {
@Override
public String toString() {
String out = new String();
- out += "\nsignatureStatus: " + signatureStatus;
- out += "\nsignatureUserId: " + signatureUserId;
+ out += "\nstatus: " + status;
+ out += "\nuserId: " + userId;
out += "\nsignatureOnly: " + signatureOnly;
+ out += "\nkeyId: " + keyId;
return out;
}