mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-30 12:32:17 -05:00
API update
This commit is contained in:
parent
224faa42ac
commit
2a0df5b75a
@ -22,10 +22,23 @@ import org.openintents.openpgp.OpenPgpError;
|
|||||||
interface IOpenPgpCallback {
|
interface IOpenPgpCallback {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CryptoSignatureResult is only returned if the Callback was used from decryptAndVerify
|
* onSuccess returns on successful OpenPGP operations.
|
||||||
*
|
*
|
||||||
|
* @param outputBytes
|
||||||
|
* contains resulting output bytes (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 byte[] outputBytes, in OpenPgpSignatureResult signatureResult);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
oneway void onError(in OpenPgpError error);
|
||||||
}
|
}
|
@ -27,57 +27,63 @@ interface IOpenPgpService {
|
|||||||
/**
|
/**
|
||||||
* Encrypt
|
* Encrypt
|
||||||
*
|
*
|
||||||
|
* After successful encryption, callback's onSuccess will contain the resulting output bytes.
|
||||||
|
*
|
||||||
* @param inputBytes
|
* @param inputBytes
|
||||||
* Byte array you want to encrypt
|
* Byte array you want to encrypt
|
||||||
* @param encryptionUserIds
|
* @param encryptionUserIds
|
||||||
* User Ids (emails) of recipients
|
* User Ids (emails) of recipients
|
||||||
* @param asciiArmor
|
* @param asciiArmor
|
||||||
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
* Encode result for ASCII (Radix-64, 33 percent overhead compared to binary)
|
||||||
* @param allowUserInteraction
|
* @param allowUserInteraction
|
||||||
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void encrypt(in byte[] inputBytes, in String[] encryptionUserIds,
|
oneway void encrypt(in byte[] inputBytes, in String[] encryptionUserIds, in boolean asciiArmor,
|
||||||
in boolean asciiArmor, in boolean allowUserInteraction, in IOpenPgpCallback callback);
|
in IOpenPgpCallback callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign
|
* Sign
|
||||||
*
|
*
|
||||||
|
* After successful signing, callback's onSuccess will contain the resulting output bytes.
|
||||||
|
*
|
||||||
* @param inputBytes
|
* @param inputBytes
|
||||||
* Byte array you want to encrypt
|
* Byte array you want to sign
|
||||||
* @param asciiArmor
|
* @param asciiArmor
|
||||||
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
* Encode result for ASCII (Radix-64, 33 percent overhead compared to binary)
|
||||||
* @param allowUserInteraction
|
* @param allowUserInteraction
|
||||||
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void sign(in byte[] inputBytes, in boolean asciiArmor, in boolean allowUserInteraction,
|
oneway void sign(in byte[] inputBytes, in boolean asciiArmor, in IOpenPgpCallback callback);
|
||||||
in IOpenPgpCallback callback);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign then encrypt
|
* Sign then encrypt
|
||||||
*
|
*
|
||||||
|
* After successful signing and encryption, callback's onSuccess will contain the resulting output bytes.
|
||||||
|
*
|
||||||
* @param inputBytes
|
* @param inputBytes
|
||||||
* Byte array you want to encrypt
|
* Byte array you want to sign and encrypt
|
||||||
* @param encryptionUserIds
|
* @param encryptionUserIds
|
||||||
* User Ids (emails) of recipients
|
* User Ids (emails) of recipients
|
||||||
* @param signatureUserId
|
|
||||||
* User Ids (email) of sender
|
|
||||||
* @param asciiArmor
|
* @param asciiArmor
|
||||||
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
* Encode result for ASCII (Radix-64, 33 percent overhead compared to binary)
|
||||||
* @param allowUserInteraction
|
* @param allowUserInteraction
|
||||||
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void signAndEncrypt(in byte[] inputBytes, in String[] encryptionUserIds,
|
oneway void signAndEncrypt(in byte[] inputBytes, in String[] encryptionUserIds, in boolean asciiArmor,
|
||||||
in boolean asciiArmor, in boolean allowUserInteraction, in IOpenPgpCallback callback);
|
in IOpenPgpCallback callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrypts and verifies given input bytes. If no signature is present this method
|
* Decrypts and verifies given input bytes. This methods handles encrypted-only, signed-and-encrypted,
|
||||||
* will only decrypt.
|
* and also signed-only inputBytes.
|
||||||
|
*
|
||||||
|
* 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
|
* @param inputBytes
|
||||||
* Byte array you want to decrypt and verify
|
* Byte array you want to decrypt and verify
|
||||||
@ -86,7 +92,8 @@ interface IOpenPgpService {
|
|||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void decryptAndVerify(in byte[] inputBytes, in boolean allowUserInteraction,
|
oneway void decryptAndVerify(in byte[] inputBytes, in IOpenPgpCallback callback);
|
||||||
in IOpenPgpCallback callback);
|
|
||||||
|
boolean isKeyAvailable(in String[] userIds);
|
||||||
|
|
||||||
}
|
}
|
@ -20,9 +20,13 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
public class OpenPgpSignatureResult implements Parcelable {
|
public class OpenPgpSignatureResult implements Parcelable {
|
||||||
|
// generic error on signature verification
|
||||||
public static final int SIGNATURE_ERROR = 0;
|
public static final int SIGNATURE_ERROR = 0;
|
||||||
|
// successfully verified signature, with trusted public key
|
||||||
public static final int SIGNATURE_SUCCESS_TRUSTED = 1;
|
public static final int SIGNATURE_SUCCESS_TRUSTED = 1;
|
||||||
public static final int SIGNATURE_UNKNOWN = 2;
|
// no public key was found for this signature verification
|
||||||
|
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;
|
public static final int SIGNATURE_SUCCESS_UNTRUSTED = 3;
|
||||||
|
|
||||||
int signatureStatus;
|
int signatureStatus;
|
||||||
|
@ -139,7 +139,7 @@ public class OpenPgpProviderActivity extends Activity {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
mCryptoServiceConnection.getService().encrypt(inputBytes,
|
mCryptoServiceConnection.getService().encrypt(inputBytes,
|
||||||
mEncryptUserIds.getText().toString().split(","), true, true, encryptCallback);
|
mEncryptUserIds.getText().toString().split(","), true, encryptCallback);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "CryptoProviderDemo", e);
|
Log.e(Constants.TAG, "CryptoProviderDemo", e);
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ public class OpenPgpProviderActivity extends Activity {
|
|||||||
byte[] inputBytes = mMessage.getText().toString().getBytes();
|
byte[] inputBytes = mMessage.getText().toString().getBytes();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mCryptoServiceConnection.getService().sign(inputBytes, true, true, encryptCallback);
|
mCryptoServiceConnection.getService().sign(inputBytes, true, encryptCallback);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "CryptoProviderDemo", e);
|
Log.e(Constants.TAG, "CryptoProviderDemo", e);
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ public class OpenPgpProviderActivity extends Activity {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
mCryptoServiceConnection.getService().signAndEncrypt(inputBytes,
|
mCryptoServiceConnection.getService().signAndEncrypt(inputBytes,
|
||||||
mEncryptUserIds.getText().toString().split(","), true, true, encryptCallback);
|
mEncryptUserIds.getText().toString().split(","), true, encryptCallback);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "CryptoProviderDemo", e);
|
Log.e(Constants.TAG, "CryptoProviderDemo", e);
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ public class OpenPgpProviderActivity extends Activity {
|
|||||||
byte[] inputBytes = mCiphertext.getText().toString().getBytes();
|
byte[] inputBytes = mCiphertext.getText().toString().getBytes();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mCryptoServiceConnection.getService().decryptAndVerify(inputBytes, true,
|
mCryptoServiceConnection.getService().decryptAndVerify(inputBytes,
|
||||||
decryptAndVerifyCallback);
|
decryptAndVerifyCallback);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "CryptoProviderDemo", e);
|
Log.e(Constants.TAG, "CryptoProviderDemo", e);
|
||||||
|
@ -25,7 +25,8 @@ interface IOpenPgpCallback {
|
|||||||
* onSuccess returns on successful OpenPGP operations.
|
* onSuccess returns on successful OpenPGP operations.
|
||||||
*
|
*
|
||||||
* @param outputBytes
|
* @param outputBytes
|
||||||
* contains resulting output bytes (decrypted content/content without signature)
|
* contains resulting output bytes (decrypted content (when input was encrypted)
|
||||||
|
* or content without signature (when input was signed-only))
|
||||||
* @param signatureResult
|
* @param signatureResult
|
||||||
* signatureResult is only non-null if decryptAndVerify() was called and the content
|
* signatureResult is only non-null if decryptAndVerify() was called and the content
|
||||||
* was encrypted or signed-and-encrypted.
|
* was encrypted or signed-and-encrypted.
|
||||||
|
@ -34,14 +34,14 @@ interface IOpenPgpService {
|
|||||||
* @param encryptionUserIds
|
* @param encryptionUserIds
|
||||||
* User Ids (emails) of recipients
|
* User Ids (emails) of recipients
|
||||||
* @param asciiArmor
|
* @param asciiArmor
|
||||||
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
* Encode result for ASCII (Radix-64, 33 percent overhead compared to binary)
|
||||||
* @param allowUserInteraction
|
* @param allowUserInteraction
|
||||||
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void encrypt(in byte[] inputBytes, in String[] encryptionUserIds,
|
oneway void encrypt(in byte[] inputBytes, in String[] encryptionUserIds, in boolean asciiArmor,
|
||||||
in boolean asciiArmor, in boolean allowUserInteraction, in IOpenPgpCallback callback);
|
in IOpenPgpCallback callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign
|
* Sign
|
||||||
@ -51,14 +51,13 @@ interface IOpenPgpService {
|
|||||||
* @param inputBytes
|
* @param inputBytes
|
||||||
* Byte array you want to sign
|
* Byte array you want to sign
|
||||||
* @param asciiArmor
|
* @param asciiArmor
|
||||||
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
* Encode result for ASCII (Radix-64, 33 percent overhead compared to binary)
|
||||||
* @param allowUserInteraction
|
* @param allowUserInteraction
|
||||||
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void sign(in byte[] inputBytes, in boolean asciiArmor, in boolean allowUserInteraction,
|
oneway void sign(in byte[] inputBytes, in boolean asciiArmor, in IOpenPgpCallback callback);
|
||||||
in IOpenPgpCallback callback);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign then encrypt
|
* Sign then encrypt
|
||||||
@ -70,14 +69,14 @@ interface IOpenPgpService {
|
|||||||
* @param encryptionUserIds
|
* @param encryptionUserIds
|
||||||
* User Ids (emails) of recipients
|
* User Ids (emails) of recipients
|
||||||
* @param asciiArmor
|
* @param asciiArmor
|
||||||
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
* Encode result for ASCII (Radix-64, 33 percent overhead compared to binary)
|
||||||
* @param allowUserInteraction
|
* @param allowUserInteraction
|
||||||
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void signAndEncrypt(in byte[] inputBytes, in String[] encryptionUserIds,
|
oneway void signAndEncrypt(in byte[] inputBytes, in String[] encryptionUserIds, in boolean asciiArmor,
|
||||||
in boolean asciiArmor, in boolean allowUserInteraction, in IOpenPgpCallback callback);
|
in IOpenPgpCallback callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrypts and verifies given input bytes. This methods handles encrypted-only, signed-and-encrypted,
|
* Decrypts and verifies given input bytes. This methods handles encrypted-only, signed-and-encrypted,
|
||||||
@ -93,7 +92,8 @@ interface IOpenPgpService {
|
|||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void decryptAndVerify(in byte[] inputBytes, in boolean allowUserInteraction,
|
oneway void decryptAndVerify(in byte[] inputBytes, in IOpenPgpCallback callback);
|
||||||
in IOpenPgpCallback callback);
|
|
||||||
|
boolean isKeyAvailable(in String[] userIds);
|
||||||
|
|
||||||
}
|
}
|
@ -456,15 +456,14 @@ public class OpenPgpService extends RemoteService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encrypt(final byte[] inputBytes, final String[] encryptionUserIds,
|
public void encrypt(final byte[] inputBytes, final String[] encryptionUserIds,
|
||||||
final boolean asciiArmor, final boolean allowUserInteraction,
|
final boolean asciiArmor, final IOpenPgpCallback callback) throws RemoteException {
|
||||||
final IOpenPgpCallback callback) throws RemoteException {
|
|
||||||
final AppSettings settings = getAppSettings();
|
final AppSettings settings = getAppSettings();
|
||||||
|
|
||||||
Runnable r = new Runnable() {
|
Runnable r = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
encryptAndSignSafe(inputBytes, encryptionUserIds, asciiArmor,
|
encryptAndSignSafe(inputBytes, encryptionUserIds, asciiArmor, true, callback,
|
||||||
allowUserInteraction, callback, settings, false);
|
settings, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -473,15 +472,14 @@ public class OpenPgpService extends RemoteService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void signAndEncrypt(final byte[] inputBytes, final String[] encryptionUserIds,
|
public void signAndEncrypt(final byte[] inputBytes, final String[] encryptionUserIds,
|
||||||
final boolean asciiArmor, final boolean allowUserInteraction,
|
final boolean asciiArmor, final IOpenPgpCallback callback) throws RemoteException {
|
||||||
final IOpenPgpCallback callback) throws RemoteException {
|
|
||||||
final AppSettings settings = getAppSettings();
|
final AppSettings settings = getAppSettings();
|
||||||
|
|
||||||
Runnable r = new Runnable() {
|
Runnable r = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
encryptAndSignSafe(inputBytes, encryptionUserIds, asciiArmor,
|
encryptAndSignSafe(inputBytes, encryptionUserIds, asciiArmor, true, callback,
|
||||||
allowUserInteraction, callback, settings, true);
|
settings, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -490,36 +488,41 @@ public class OpenPgpService extends RemoteService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sign(final byte[] inputBytes, boolean asciiArmor,
|
public void sign(final byte[] inputBytes, boolean asciiArmor,
|
||||||
final boolean allowUserInteraction, final IOpenPgpCallback callback)
|
|
||||||
throws RemoteException {
|
|
||||||
final AppSettings settings = getAppSettings();
|
|
||||||
|
|
||||||
Runnable r = new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
signSafe(inputBytes, allowUserInteraction, callback, settings);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
checkAndEnqueue(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void decryptAndVerify(final byte[] inputBytes, final boolean allowUserInteraction,
|
|
||||||
final IOpenPgpCallback callback) throws RemoteException {
|
final IOpenPgpCallback callback) throws RemoteException {
|
||||||
|
final AppSettings settings = getAppSettings();
|
||||||
|
|
||||||
|
Runnable r = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
signSafe(inputBytes, true, callback, settings);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
checkAndEnqueue(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void decryptAndVerify(final byte[] inputBytes, final IOpenPgpCallback callback)
|
||||||
|
throws RemoteException {
|
||||||
|
|
||||||
final AppSettings settings = getAppSettings();
|
final AppSettings settings = getAppSettings();
|
||||||
|
|
||||||
Runnable r = new Runnable() {
|
Runnable r = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
decryptAndVerifySafe(inputBytes, allowUserInteraction, callback, settings);
|
decryptAndVerifySafe(inputBytes, true, callback, settings);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
checkAndEnqueue(r);
|
checkAndEnqueue(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isKeyAvailable(String[] userIds) throws RemoteException {
|
||||||
|
// TODO
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user