working encryption/decryption of text and files after GeneralActivity hands it over

This commit is contained in:
Thialfihar
2010-06-06 00:35:00 +00:00
parent 8c404d83d7
commit 26a500956f
7 changed files with 82 additions and 37 deletions

View File

@@ -110,6 +110,7 @@ public class Apg {
public static final String SELECT_SECRET_KEY = "org.thialfihar.android.apg.intent.SELECT_SECRET_KEY";
}
public static final String EXTRA_TEXT = "text";
public static final String EXTRA_DATA = "data";
public static final String EXTRA_STATUS = "status";
public static final String EXTRA_ERROR = "error";
@@ -1702,6 +1703,23 @@ public class Apg {
return returnData;
}
public static int getStreamContent(Context context, InputStream inStream)
throws IOException {
InputStream in = PGPUtil.getDecoderStream(inStream);
PGPObjectFactory pgpF = new PGPObjectFactory(in);
Object object = pgpF.nextObject();
while (object != null) {
if (object instanceof PGPPublicKeyRing ||
object instanceof PGPSecretKeyRing) {
return Id.content.keys;
} else if (object instanceof PGPEncryptedDataList) {
return Id.content.encrypted_data;
}
}
return Id.content.unknown;
}
// taken from ClearSignedFileProcessor in BC
private static int readInputLine(ByteArrayOutputStream bOut, InputStream fIn)
throws IOException {