From f712a26ab68eb0f978722cfa69a7e9b5d05c80ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 8 Jan 2015 14:40:58 +0100 Subject: API for detached signatures --- src/org/openintents/openpgp/util/OpenPgpApi.java | 40 ++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/org/openintents/openpgp/util/OpenPgpApi.java b/src/org/openintents/openpgp/util/OpenPgpApi.java index 3e18ab0..f140af1 100644 --- a/src/org/openintents/openpgp/util/OpenPgpApi.java +++ b/src/org/openintents/openpgp/util/OpenPgpApi.java @@ -67,14 +67,42 @@ public class OpenPgpApi { */ /** - * Sign only + * DEPRECATED + * Same as ACTION_CLEARTEXT_SIGN *

* optional extras: - * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for output) + * boolean EXTRA_REQUEST_ASCII_ARMOR (DEPRECATED: this makes no sense here) * String EXTRA_PASSPHRASE (key passphrase) */ public static final String ACTION_SIGN = "org.openintents.openpgp.action.SIGN"; + /** + * Sign text resulting in a cleartext signature + * Some magic pre-processing of the text is done to convert it to a format usable for + * cleartext signatures per RFC 4880 before the text is actually signed: + * - end cleartext with newline + * - remove whitespaces on line endings + *

+ * optional extras: + * String EXTRA_PASSPHRASE (key passphrase) + */ + public static final String ACTION_CLEARTEXT_SIGN = "org.openintents.openpgp.action.CLEARTEXT_SIGN"; + + /** + * Sign text or binary data resulting in a detached signature. + * OutputStream returns exactly the InputStream. + * No magic pre-processing is done like in ACTION_CLEARTEXT_SIGN. + * The detached signature is returned separately in RESULT_DETACHED_SIGNATURE. + *

+ * optional extras: + * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for detached signature) + * String EXTRA_PASSPHRASE (key passphrase) + *

+ * returned extras: + * byte[] RESULT_DETACHED_SIGNATURE + */ + public static final String ACTION_DETACHED_SIGN = "org.openintents.openpgp.action.DETACHED_SIGN"; + /** * Encrypt *

@@ -114,6 +142,7 @@ public class OpenPgpApi { *

* optional extras: * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for output) + * byte[] EXTRA_DETACHED_SIGNATURE (detached signature) *

* returned extras: * OpenPgpSignatureResult RESULT_SIGNATURE @@ -159,11 +188,14 @@ public class OpenPgpApi { public static final String EXTRA_ACCOUNT_NAME = "account_name"; - // SIGN, ENCRYPT, SIGN_AND_ENCRYPT, DECRYPT_VERIFY + // ACTION_DETACHED_SIGN, ENCRYPT, SIGN_AND_ENCRYPT, DECRYPT_VERIFY // request ASCII Armor for output // OpenPGP Radix-64, 33 percent overhead compared to binary, see http://tools.ietf.org/html/rfc4880#page-53) public static final String EXTRA_REQUEST_ASCII_ARMOR = "ascii_armor"; + // ACTION_DETACHED_SIGN + public static final String RESULT_DETACHED_SIGNATURE = "detached_signature"; + // ENCRYPT, SIGN_AND_ENCRYPT public static final String EXTRA_USER_IDS = "user_ids"; public static final String EXTRA_KEY_IDS = "key_ids"; @@ -195,6 +227,8 @@ public class OpenPgpApi { public static final String RESULT_INTENT = "intent"; // DECRYPT_VERIFY + public static final String EXTRA_DETACHED_SIGNATURE = "detached_signature"; + public static final String RESULT_SIGNATURE = "signature"; public static final String RESULT_METADATA = "metadata"; -- cgit v1.2.3