Browse Source

Add message sign with openkeychain

pull/125/head
世界 2 years ago
parent
commit
b1a9d29a1a
No known key found for this signature in database GPG Key ID: CD109927C34A63C4
  1. 18
      TMessagesProj/build.gradle
  2. 197
      TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java
  3. 13
      TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
  4. 40
      TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java
  5. 160
      TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java
  6. 75
      TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/PGPUtil.kt
  7. 7
      TMessagesProj/src/main/res/values/strings_nekox.xml
  8. 2
      build.gradle
  9. 33
      openpgp-api/.gitignore
  10. 16
      openpgp-api/build.gradle
  11. 7
      openpgp-api/src/main/AndroidManifest.xml
  12. 27
      openpgp-api/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl
  13. 30
      openpgp-api/src/main/aidl/org/openintents/openpgp/IOpenPgpService2.aidl
  14. 131
      openpgp-api/src/main/java/org/openintents/openpgp/AutocryptPeerUpdate.java
  15. 135
      openpgp-api/src/main/java/org/openintents/openpgp/OpenPgpDecryptionResult.java
  16. 116
      openpgp-api/src/main/java/org/openintents/openpgp/OpenPgpError.java
  17. 148
      openpgp-api/src/main/java/org/openintents/openpgp/OpenPgpMetadata.java
  18. 275
      openpgp-api/src/main/java/org/openintents/openpgp/OpenPgpSignatureResult.java
  19. 442
      openpgp-api/src/main/java/org/openintents/openpgp/util/OpenPgpApi.java
  20. 127
      openpgp-api/src/main/java/org/openintents/openpgp/util/OpenPgpServiceConnection.java
  21. 143
      openpgp-api/src/main/java/org/openintents/openpgp/util/OpenPgpUtils.java
  22. 87
      openpgp-api/src/main/java/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java
  23. 1
      settings.gradle

18
TMessagesProj/build.gradle

@ -42,8 +42,8 @@ configurations {
compile.exclude module: 'support-v4'
}
def okHttpVersion = '4.7.2'
def fcmVersion = '20.2.2'
def okHttpVersion = '4.8.0'
def fcmVersion = '20.2.3'
def crashlyticsVersion = '17.1.1'
def playCoreVersion = '1.7.3'
@ -63,6 +63,7 @@ buildscript {
repositories {
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
@ -92,17 +93,19 @@ dependencies {
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'org.osmdroid:osmdroid-android:6.1.6'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8'
implementation "com.squareup.okhttp3:okhttp:$okHttpVersion"
implementation "com.squareup.okhttp3:okhttp-dnsoverhttps:$okHttpVersion"
implementation 'dnsjava:dnsjava:3.2.1'
implementation 'dnsjava:dnsjava:3.2.2'
implementation 'org.dizitart:nitrite:3.4.2'
implementation 'cn.hutool:hutool-core:5.3.8'
implementation 'cn.hutool:hutool-crypto:5.3.8'
implementation 'cn.hutool:hutool-core:5.3.9'
implementation 'cn.hutool:hutool-crypto:5.3.9'
implementation 'org.tukaani:xz:1.8'
implementation project(":openpgp-api")
compileOnly files('libs/libv2ray.aar')
@ -271,14 +274,17 @@ android {
jniDebuggable false
minifyEnabled true
shrinkResources true
matchingFallbacks = ['debug']
}
release {
initWith releaseNoGcm
matchingFallbacks = ['debug']
}
foss {
initWith release
matchingFallbacks = ['debug']
}
}

197
TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java

@ -16,8 +16,11 @@ import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.ClipDescription;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
@ -48,6 +51,7 @@ import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextWatcher;
import android.text.style.ImageSpan;
import android.util.Log;
import android.util.Property;
import android.util.TypedValue;
import android.view.ActionMode;
@ -88,6 +92,8 @@ import androidx.core.view.inputmethod.InputContentInfoCompat;
import androidx.customview.widget.ExploreByTouchHelper;
import org.jetbrains.annotations.NotNull;
import org.openintents.openpgp.OpenPgpError;
import org.openintents.openpgp.util.OpenPgpApi;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
@ -122,6 +128,8 @@ import org.telegram.ui.GroupStickersActivity;
import org.telegram.ui.LaunchActivity;
import org.telegram.ui.StickersActivity;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
@ -129,12 +137,15 @@ import java.util.List;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicBoolean;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import kotlin.Unit;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.transtale.TranslateDb;
import tw.nekomimi.nekogram.transtale.Translator;
import tw.nekomimi.nekogram.transtale.TranslatorKt;
import tw.nekomimi.nekogram.utils.AlertUtil;
import tw.nekomimi.nekogram.utils.PGPUtil;
public class ChatActivityEnterView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate, SizeNotifierFrameLayout.SizeNotifierFrameLayoutDelegate, StickersAlert.StickersAlertDelegate {
@ -2968,64 +2979,95 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
});
sendPopupLayout.setShowedFromBotton(false);
for (int a = 0; a < 3; a++) {
if (a == 2 && (UserObject.isUserSelf(user) || slowModeTimer > 0 && !isInScheduleMode())) {
continue;
}
int num = a;
ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getContext());
if (num == 0) {
cell.setTextAndIcon(LocaleController.getString("Translate", R.string.Translate), R.drawable.ic_translate);
} else if (num == 1) {
if (UserObject.isUserSelf(user)) {
cell.setTextAndIcon(LocaleController.getString("SetReminder", R.string.SetReminder), R.drawable.baseline_date_range_24);
} else {
cell.setTextAndIcon(LocaleController.getString("ScheduleMessage", R.string.ScheduleMessage), R.drawable.baseline_date_range_24);
}
} else if (num == 2) {
cell.setTextAndIcon(LocaleController.getString("SendWithoutSound", R.string.SendWithoutSound), R.drawable.input_notify_off);
}
cell.setMinimumWidth(AndroidUtilities.dp(196));
sendPopupLayout.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 0, 48 * a, 0, 0));
int chatId;
if (chat != null) {
chatId = chat.id;
} else if (user != null) {
chatId = user.id;
} else {
chatId = -1;
}
int chatId;
if (chat != null) {
chatId = chat.id;
} else if (user != null) {
chatId = user.id;
} else {
chatId = -1;
}
int a = 0;
ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getContext());
if (StrUtil.isNotBlank(NekoConfig.openPGPApp)) {
cell.setTextAndIcon(LocaleController.getString("Sign", R.string.Sign), R.drawable.baseline_vpn_key_24);
cell.setOnClickListener(v -> {
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
sendPopupWindow.dismiss();
}
if (num == 0) {
translateComment(TranslateDb.getChatLanguage(chatId, TranslatorKt.getCode2Locale(NekoConfig.translateInputLang)));
signComment(NekoConfig.openPGPKeyId);
});
cell.setOnLongClickListener(v -> {
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
sendPopupWindow.dismiss();
}
if (num == 1) {
AlertsCreator.createScheduleDatePickerDialog(parentActivity, parentFragment.getDialogId(), this::sendMessageInternal);
} else if (num == 2) {
sendMessageInternal(false, 0);
signComment(1L);
return true;
});
cell.setMinimumWidth(AndroidUtilities.dp(196));
sendPopupLayout.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 0, 48 * a++, 0, 0));
cell = new ActionBarMenuSubItem(getContext());
}
cell.setTextAndIcon(LocaleController.getString("Translate", R.string.Translate), R.drawable.ic_translate);
cell.setOnClickListener(v -> {
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
sendPopupWindow.dismiss();
}
translateComment(TranslateDb.getChatLanguage(chatId, TranslatorKt.getCode2Locale(NekoConfig.translateInputLang)));
});
ActionBarMenuSubItem finalCell = cell;
cell.setOnLongClickListener(v -> {
Translator.showTargetLangSelect(finalCell, true, (locale) -> {
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
sendPopupWindow.dismiss();
}
translateComment(locale);
TranslateDb.saveChatLanguage(chatId, locale);
return Unit.INSTANCE;
});
cell.setOnLongClickListener(v -> {
if (num == 0) {
Translator.showTargetLangSelect(cell, true, (locale) -> {
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
sendPopupWindow.dismiss();
}
translateComment(locale);
TranslateDb.saveChatLanguage(chatId, locale);
return Unit.INSTANCE;
});
return true;
return true;
});
cell.setMinimumWidth(AndroidUtilities.dp(196));
sendPopupLayout.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 0, 48 * a++, 0, 0));
if (!UserObject.isUserSelf(user) && (slowModeTimer == 0 || !isInScheduleMode())) {
cell = new ActionBarMenuSubItem(getContext());
if (UserObject.isUserSelf(user)) {
cell.setTextAndIcon(LocaleController.getString("SetReminder", R.string.SetReminder), R.drawable.baseline_date_range_24);
} else {
cell.setTextAndIcon(LocaleController.getString("ScheduleMessage", R.string.ScheduleMessage), R.drawable.baseline_date_range_24);
}
cell.setOnClickListener(v -> {
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
sendPopupWindow.dismiss();
}
return false;
AlertsCreator.createScheduleDatePickerDialog(parentActivity, parentFragment.getDialogId(), this::sendMessageInternal);
});
cell.setMinimumWidth(AndroidUtilities.dp(196));
sendPopupLayout.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 0, 48 * a++, 0, 0));
}
cell = new ActionBarMenuSubItem(getContext());
cell.setTextAndIcon(LocaleController.getString("SendWithoutSound", R.string.SendWithoutSound), R.drawable.input_notify_off);
cell.setOnClickListener(v -> {
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
sendPopupWindow.dismiss();
}
AlertsCreator.createScheduleDatePickerDialog(parentActivity, parentFragment.getDialogId(), this::sendMessageInternal);
});
cell.setMinimumWidth(AndroidUtilities.dp(196));
sendPopupLayout.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 0, 48 * a++, 0, 0));
sendPopupWindow = new ActionBarPopupWindow(sendPopupLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT) {
@Override
public void dismiss() {
@ -3065,6 +3107,71 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
return false;
}
private void signComment(long signKeyId) {
if (parentActivity instanceof LaunchActivity) {
((LaunchActivity) parentActivity).callbacks.put(115, result -> {
long keyId = result.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, 0L);
if (signKeyId < 1L) NekoConfig.setOpenPGPKeyId(keyId);
signComment(keyId);
return Unit.INSTANCE;
});
}
Intent intent = new Intent(OpenPgpApi.ACTION_CLEARTEXT_SIGN);
if (signKeyId < 0L) intent.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, signKeyId);
ByteArrayInputStream is = IoUtil.toUtf8Stream(messageEditText.getText().toString());
ByteArrayOutputStream os = new ByteArrayOutputStream();
PGPUtil.post(() -> PGPUtil.api.executeApiAsync(intent, is, os, result -> {
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS: {
String str = StrUtil.utf8Str(os.toByteArray());
if (StrUtil.isNotBlank(str)) messageEditText.setText(str);
break;
}
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: {
PendingIntent pi = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
try {
parentActivity.startIntentSenderFromChild(parentActivity, pi.getIntentSender(),
115, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
Log.e(OpenPgpApi.TAG, "SendIntentException", e);
}
break;
}
case OpenPgpApi.RESULT_CODE_ERROR: {
OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
if (error.getMessage().contains("not found") && signKeyId < 0L) {
NekoConfig.setOpenPGPKeyId(0L);
signComment(0L);
} else {
AlertUtil.showToast(error.getMessage());
}
break;
}
}
}));
}
private void translateComment(Locale target) {
TranslateDb db = TranslateDb.forLocale(target);

13
TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java

@ -115,9 +115,11 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import kotlin.Unit;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.NekoXConfig;
import tw.nekomimi.nekogram.NekoXSettingActivity;
@ -2891,6 +2893,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
return rightActionBarLayout;
}
public HashMap<Integer, Function<Intent, Unit>> callbacks = new HashMap<>();
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (SharedConfig.passcodeHash.length() != 0 && SharedConfig.lastPauseTime != 0) {
@ -2901,6 +2905,15 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
UserConfig.getInstance(currentAccount).saveConfig(false);
}
super.onActivityResult(requestCode, resultCode, data);
if (callbacks.containsKey(requestCode)) {
callbacks.remove(requestCode).apply(data);
return;
}
ThemeEditorView editorView = ThemeEditorView.getInstance();
if (editorView != null) {
editorView.onActivityResult(requestCode, resultCode, data);

40
TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java

@ -3,6 +3,9 @@ package tw.nekomimi.nekogram;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BuildVars;
@ -21,7 +24,7 @@ public class NekoConfig {
public static final int TITLE_TYPE_ICON = 1;
public static final int TITLE_TYPE_MIX = 2;
private static SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
public static SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
public static boolean useIPv6;
@ -109,6 +112,27 @@ public class NekoConfig {
public static boolean proxyAutoSwitch;
public static boolean usePersianCalender;
public static String openPGPApp;
public static long openPGPKeyId;
public static String getOpenPGPAppName() {
if (StrUtil.isNotBlank(openPGPApp)) {
try {
PackageManager manager = ApplicationLoader.applicationContext.getPackageManager();
ApplicationInfo info = manager.getApplicationInfo(openPGPApp, PackageManager.GET_META_DATA);
return (String) manager.getApplicationLabel(info);
} catch (PackageManager.NameNotFoundException e) {
openPGPApp = "";
}
}
return LocaleController.getString("None",R.string.None);
}
public static String formatLang(String name) {
if (name == null) {
@ -215,6 +239,8 @@ public class NekoConfig {
proxyAutoSwitch = preferences.getBoolean("proxy_auto_switch", false);
usePersianCalender = preferences.getBoolean("usePersianCalender", false);
openPGPApp = preferences.getString("openPGPApp","");
openPGPKeyId = preferences.getLong("openPGPKeyId",0L);
}
@ -716,5 +742,17 @@ public class NekoConfig {
}
public static void setOpenPGPApp(String packageName) {
preferences.edit().putString("openPGPApp",openPGPApp = packageName).apply();
}
public static void setOpenPGPKeyId(long keyId) {
preferences.edit().putLong("openPGPKeyId",openPGPKeyId = keyId).apply();
}
}

160
TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java

@ -1,8 +1,14 @@
package tw.nekomimi.nekogram.settings;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.ResolveInfo;
import android.os.Build;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
@ -13,6 +19,8 @@ import android.widget.LinearLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.openintents.openpgp.OpenPgpError;
import org.openintents.openpgp.util.OpenPgpApi;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ContactsController;
import org.telegram.messenger.ImageLoader;
@ -42,6 +50,8 @@ import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.Components.UndoView;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import cn.hutool.core.util.StrUtil;
@ -49,10 +59,12 @@ import kotlin.Unit;
import tw.nekomimi.nekogram.BottomBuilder;
import tw.nekomimi.nekogram.EmojiProvider;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.PopupBuilder;
import tw.nekomimi.nekogram.transtale.Translator;
import tw.nekomimi.nekogram.transtale.TranslatorKt;
import tw.nekomimi.nekogram.utils.AlertUtil;
import tw.nekomimi.nekogram.utils.EnvUtil;
import tw.nekomimi.nekogram.PopupBuilder;
import tw.nekomimi.nekogram.utils.PGPUtil;
@SuppressLint("RtlHardcoded")
public class NekoGeneralSettingsActivity extends BaseFragment {
@ -76,6 +88,12 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
private int googleCloudTranslateKeyRow;
private int trans2Row;
private int openKeyChainRow;
private int pgpAppRow;
private int emailRow;
private int keyRow;
private int openKeyChain2Row;
private int dialogsRow;
private int sortMenuRow;
private int dialogs2Row;
@ -455,7 +473,52 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.usePersianCalender);
}
} else if (position == pgpAppRow) {
PopupBuilder builder = new PopupBuilder(view);
builder.addSubItem(0, LocaleController.getString("None", R.string.None));
LinkedList<String> appsMap = new LinkedList<>();
appsMap.add("");
Intent intent = new Intent(OpenPgpApi.SERVICE_INTENT_2);
List<ResolveInfo> resInfo = getParentActivity().getPackageManager().queryIntentServices(intent, 0);
if (resInfo != null) {
for (ResolveInfo resolveInfo : resInfo) {
if (resolveInfo.serviceInfo == null) {
continue;
}
String packageName = resolveInfo.serviceInfo.packageName;
String simpleName = String.valueOf(resolveInfo.serviceInfo.loadLabel(getParentActivity().getPackageManager()));
builder.addSubItem(appsMap.size(), simpleName);
appsMap.add(packageName);
}
}
builder.setDelegate((i) -> {
NekoConfig.setOpenPGPApp(appsMap.get(i));
NekoConfig.setOpenPGPKeyId(0L);
listAdapter.notifyItemChanged(pgpAppRow);
listAdapter.notifyItemChanged(keyRow);
if (i > 0) PGPUtil.recreateConnection();
});
builder.show();
} else if (position == keyRow) {
requestKey(new Intent(OpenPgpApi.ACTION_GET_SIGN_KEY_ID));
}
});
restartTooltip = new UndoView(context);
@ -465,6 +528,79 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
return fragmentView;
}
private void requestKey(Intent data) {
PGPUtil.post(() -> PGPUtil.api.executeApiAsync(data, null, null, result -> {
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS: {
long keyId = result.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, 0L);
NekoConfig.setOpenPGPKeyId(keyId);
listAdapter.notifyItemChanged(keyRow);
break;
}
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: {
PendingIntent pi = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
try {
Activity act = (Activity) getParentActivity();
act.startIntentSenderFromChild(
act, pi.getIntentSender(),
114, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
Log.e(OpenPgpApi.TAG, "SendIntentException", e);
}
break;
}
case OpenPgpApi.RESULT_CODE_ERROR: {
OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
AlertUtil.showToast(error.getMessage());
break;
}
}
}));
}
@Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
if (requestCode == 114 && resultCode == Activity.RESULT_OK) {
requestKey(data);
}
}
private static class OpenPgpProviderEntry {
private String packageName;
private String simpleName;
private Intent intent;
OpenPgpProviderEntry(String packageName, String simpleName) {
this.packageName = packageName;
this.simpleName = simpleName;
}
OpenPgpProviderEntry(String packageName, String simpleName, Intent intent) {
this(packageName, simpleName);
this.intent = intent;
}
@Override
public String toString() {
return simpleName;
}
}
private void showSortMenuAlert() {
if (getParentActivity() == null) {
return;
@ -568,6 +704,12 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
googleCloudTranslateKeyRow = rowCount++;
trans2Row = rowCount++;
openKeyChainRow = rowCount++;
pgpAppRow = rowCount++;
// emailRow = rowCount++;
keyRow = rowCount++;
openKeyChain2Row = rowCount++;
dialogsRow = rowCount++;
sortMenuRow = rowCount++;
dialogs2Row = rowCount++;
@ -737,7 +879,11 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
default:
value = "Unknown";
}
textCell.setTextAndValue(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), value, false);
textCell.setTextAndValue(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), value, true);
} else if (position == pgpAppRow) {
textCell.setTextAndValue(LocaleController.getString("OpenPGPApp", R.string.OpenPGPApp), NekoConfig.getOpenPGPAppName(), true);
} else if (position == keyRow) {
textCell.setTextAndValue(LocaleController.getString("OpenPGPKey", R.string.OpenPGPKey), NekoConfig.openPGPKeyId + "", true);
}
break;
}
@ -816,6 +962,8 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
headerCell.setText(LocaleController.getString("DialogsSettings", R.string.DialogsSettings));
} else if (position == privacyRow) {
headerCell.setText(LocaleController.getString("PrivacyTitle", R.string.PrivacyTitle));
} else if (position == openKeyChainRow) {
headerCell.setText(LocaleController.getString("OpenKayChain", R.string.OpenKayChain));
}
break;
}
@ -868,12 +1016,14 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
@Override
public int getItemViewType(int position) {
if (position == connection2Row || position == dialogs2Row || position == trans2Row || position == privacy2Row ||
position == general2Row || position == appearance2Row) {
position == general2Row || position == appearance2Row || position == openKeyChain2Row) {
return 1;
} else if (position == nameOrderRow || position == sortMenuRow || position == translateToLangRow || position == translateInputToLangRow ||
position == translationProviderRow || position == eventTypeRow || position == actionBarDecorationRow) {
position == translationProviderRow || position == eventTypeRow || position == actionBarDecorationRow ||
position == pgpAppRow || position == keyRow) {
return 2;
} else if (position == connectionRow || position == transRow || position == dialogsRow || position == privacyRow || position == generalRow || position == appearanceRow) {
} else if (position == connectionRow || position == transRow || position == dialogsRow ||
position == privacyRow || position == generalRow || position == appearanceRow || position == openKeyChainRow) {
return 4;
} else if (position == googleCloudTranslateKeyRow || position == cachePathRow) {
return 6;

75
TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/PGPUtil.kt

@ -0,0 +1,75 @@
package tw.nekomimi.nekogram.utils
import org.openintents.openpgp.IOpenPgpService2
import org.openintents.openpgp.util.OpenPgpApi
import org.openintents.openpgp.util.OpenPgpServiceConnection
import org.telegram.messenger.ApplicationLoader
import org.telegram.messenger.FileLog
import tw.nekomimi.nekogram.NekoConfig
object PGPUtil {
lateinit var serviceConnection: OpenPgpServiceConnection
lateinit var api: OpenPgpApi
@JvmStatic
fun recreateConnection() {
if (::serviceConnection.isInitialized) {
runCatching {
serviceConnection.unbindFromService()
}
}
serviceConnection = OpenPgpServiceConnection(
ApplicationLoader.applicationContext,
NekoConfig.openPGPApp
)
}
@JvmStatic
fun post(runnable: Runnable) {
if (!::serviceConnection.isInitialized) {
recreateConnection()
}
if (!serviceConnection.isBound) {
serviceConnection.bindToService(object : OpenPgpServiceConnection.OnBound {
override fun onBound(service: IOpenPgpService2) {
api = OpenPgpApi(ApplicationLoader.applicationContext, service)
runnable.run()
}
override fun onError(e: Exception) {
FileLog.e(e)
AlertUtil.showToast(e)
}
})
} else {
runnable.run()
}
}
}

7
TMessagesProj/src/main/res/values/strings_nekox.xml

@ -219,7 +219,12 @@
<string name="NekoXFaq">NekoX FAQ</string>
<string name="TransSite">Translate Platform</string>
<string name="NekoXTrans">Translate NekoX</string>
<string name="UsePersianCalender">Use Persian Calender</string>
<string name="OpenKayChain">OpenPGP Client</string>
<string name="OpenPGPApp">OpenPGP App</string>
<string name="OpenPGPKey">OpenPGP Key</string>
<string name="None">None</string>
<string name="Sign">Sign</string>
</resources>

2
build.gradle

@ -7,7 +7,7 @@ buildscript {
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'

33
openpgp-api/.gitignore

@ -0,0 +1,33 @@
#Android specific
bin
gen
obj
lint.xml
local.properties
release.properties
ant.properties
*.class
*.apk
#Gradle
.gradle
build
gradle.properties
#Maven
target
pom.xml.*
#Eclipse
.project
.classpath
.settings
.metadata
#IntelliJ IDEA
.idea
*.iml
#Lint output
lint-report.html
lint-report_files/*

16
openpgp-api/build.gradle

@ -0,0 +1,16 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
versionCode 9
versionName '13.0' // API-Version . minor
minSdkVersion 9
targetSdkVersion 28
}
lintOptions {
abortOnError false
}
}

7
openpgp-api/src/main/AndroidManifest.xml

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.openintents.openpgp">
<application/>
</manifest>

27
openpgp-api/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl

@ -0,0 +1,27 @@
/*
* Copyright (C) 2014-2015 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;
interface IOpenPgpService {
/**
* do NOT use this, data returned from the service through "output" may be truncated
* @deprecated
*/
Intent execute(in Intent data, in ParcelFileDescriptor input, in ParcelFileDescriptor output);
}

30
openpgp-api/src/main/aidl/org/openintents/openpgp/IOpenPgpService2.aidl

@ -0,0 +1,30 @@
/*
* Copyright (C) 2015 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;
interface IOpenPgpService2 {
/**
* see org.openintents.openpgp.util.OpenPgpApi for documentation
*/
ParcelFileDescriptor createOutputPipe(in int pipeId);
/**
* see org.openintents.openpgp.util.OpenPgpApi for documentation
*/
Intent execute(in Intent data, in ParcelFileDescriptor input, int pipeId);
}

131
openpgp-api/src/main/java/org/openintents/openpgp/AutocryptPeerUpdate.java

@ -0,0 +1,131 @@
/*
* Copyright (C) 2014-2015 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 java.util.Date;
import android.os.Parcel;
import android.os.Parcelable;
@SuppressWarnings("unused")
public class AutocryptPeerUpdate implements Parcelable {
/**
* Since there might be a case where new versions of the client using the library getting
* old versions of the protocol (and thus old versions of this class), we need a versioning
* system for the parcels sent between the clients and the providers.
*/
private static final int PARCELABLE_VERSION = 1;
private final byte[] keyData;
private final Date effectiveDate;
private final PreferEncrypt preferEncrypt;
private AutocryptPeerUpdate(byte[] keyData, Date effectiveDate, PreferEncrypt preferEncrypt) {
this.keyData = keyData;
this.effectiveDate = effectiveDate;
this.preferEncrypt = preferEncrypt;
}
private AutocryptPeerUpdate(Parcel source, int version) {
this.keyData = source.createByteArray();
this.effectiveDate = source.readInt() != 0 ? new Date(source.readLong()) : null;
this.preferEncrypt = PreferEncrypt.values()[source.readInt()];
}
public static AutocryptPeerUpdate createAutocryptPeerUpdate(byte[] keyData, Date timestamp) {
return new AutocryptPeerUpdate(keyData, timestamp, PreferEncrypt.NOPREFERENCE);
}
public byte[] getKeyData() {
return keyData;
}
public boolean hasKeyData() {
return keyData != null;
}
public Date getEffectiveDate() {
return effectiveDate;
}
public PreferEncrypt getPreferEncrypt() {
return preferEncrypt;
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel dest, int flags) {
/*
NOTE: When adding fields in the process of updating this API, make sure to bump
{@link #PARCELABLE_VERSION}.
*/
dest.writeInt(PARCELABLE_VERSION);
// Inject a placeholder that will store the parcel size from this point on
// (not including the size itself).
int sizePosition = dest.dataPosition();
dest.writeInt(0);
int startPosition = dest.dataPosition();
// version 1
dest.writeByteArray(keyData);
if (effectiveDate != null) {
dest.writeInt(1);
dest.writeLong(effectiveDate.getTime());
} else {
dest.writeInt(0);
}
dest.writeInt(preferEncrypt.ordinal());
// Go back and write the size
int parcelableSize = dest.dataPosition() - startPosition;
dest.setDataPosition(sizePosition);
dest.writeInt(parcelableSize);
dest.setDataPosition(startPosition + parcelableSize);
}
public static final Creator<AutocryptPeerUpdate> CREATOR = new Creator<AutocryptPeerUpdate>() {
public AutocryptPeerUpdate createFromParcel(final Parcel source) {
int version = source.readInt(); // parcelableVersion
int parcelableSize = source.readInt();
int startPosition = source.dataPosition();
AutocryptPeerUpdate vr = new AutocryptPeerUpdate(source, version);
// skip over all fields added in future versions of this parcel
source.setDataPosition(startPosition + parcelableSize);
return vr;
}
public AutocryptPeerUpdate[] newArray(final int size) {
return new AutocryptPeerUpdate[size];
}
};
public enum PreferEncrypt {
NOPREFERENCE, MUTUAL
}
}

135
openpgp-api/src/main/java/org/openintents/openpgp/OpenPgpDecryptionResult.java

@ -0,0 +1,135 @@
/*
* Copyright (C) 2015 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 java.util.Arrays;
import android.os.Parcel;
import android.os.Parcelable;
public class OpenPgpDecryptionResult implements Parcelable {
/**
* Since there might be a case where new versions of the client using the library getting
* old versions of the protocol (and thus old versions of this class), we need a versioning
* system for the parcels sent between the clients and the providers.
*/
public static final int PARCELABLE_VERSION = 2;
// content not encrypted
public static final int RESULT_NOT_ENCRYPTED = -1;
// insecure!
public static final int RESULT_INSECURE = 0;
// encrypted
public static final int RESULT_ENCRYPTED = 1;
private final int result;
private final byte[] sessionKey;
private final byte[] decryptedSessionKey;
public OpenPgpDecryptionResult(int result) {
this.result = result;
this.sessionKey = null;
this.decryptedSessionKey = null;
}
public OpenPgpDecryptionResult(int result, byte[] sessionKey, byte[] decryptedSessionKey) {
this.result = result;
if ((sessionKey == null) != (decryptedSessionKey == null)) {
throw new AssertionError("sessionkey must be null iff decryptedSessionKey is null");
}
this.sessionKey = sessionKey;
this.decryptedSessionKey = decryptedSessionKey;
}
public int getResult() {
return result;
}
public boolean hasDecryptedSessionKey() {
return sessionKey != null;
}
public byte[] getSessionKey() {
if (sessionKey == null) {
return null;
}
return Arrays.copyOf(sessionKey, sessionKey.length);
}
public byte[] getDecryptedSessionKey() {
if (sessionKey == null || decryptedSessionKey == null) {
return null;
}
return Arrays.copyOf(decryptedSessionKey, decryptedSessionKey.length);
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel dest, int flags) {
/*
NOTE: When adding fields in the process of updating this API, make sure to bump
{@link #PARCELABLE_VERSION}.
*/
dest.writeInt(PARCELABLE_VERSION);
// Inject a placeholder that will store the parcel size from this point on
// (not including the size itself).
int sizePosition = dest.dataPosition();
dest.writeInt(0);
int startPosition = dest.dataPosition();
// version 1
dest.writeInt(result);
// version 2
dest.writeByteArray(sessionKey);
dest.writeByteArray(decryptedSessionKey);
// Go back and write the size
int parcelableSize = dest.dataPosition() - startPosition;
dest.setDataPosition(sizePosition);
dest.writeInt(parcelableSize);
dest.setDataPosition(startPosition + parcelableSize);
}
public static final Creator<OpenPgpDecryptionResult> CREATOR = new Creator<OpenPgpDecryptionResult>() {
public OpenPgpDecryptionResult createFromParcel(final Parcel source) {
int version = source.readInt(); // parcelableVersion
int parcelableSize = source.readInt();
int startPosition = source.dataPosition();
int result = source.readInt();
byte[] sessionKey = version > 1 ? source.createByteArray() : null;
byte[] decryptedSessionKey = version > 1 ? source.createByteArray() : null;
OpenPgpDecryptionResult vr = new OpenPgpDecryptionResult(result, sessionKey, decryptedSessionKey);
// skip over all fields added in future versions of this parcel
source.setDataPosition(startPosition + parcelableSize);
return vr;
}
public OpenPgpDecryptionResult[] newArray(final int size) {
return new OpenPgpDecryptionResult[size];
}
};
@Override
public String toString() {
return "\nresult: " + result;
}
}

116
openpgp-api/src/main/java/org/openintents/openpgp/OpenPgpError.java

@ -0,0 +1,116 @@
/*
* Copyright (C) 2014-2015 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.os.Parcel;
import android.os.Parcelable;
public class OpenPgpError implements Parcelable {
/**
* Since there might be a case where new versions of the client using the library getting
* old versions of the protocol (and thus old versions of this class), we need a versioning
* system for the parcels sent between the clients and the providers.
*/
public static final int PARCELABLE_VERSION = 1;
// possible values for errorId
public static final int CLIENT_SIDE_ERROR = -1;
public static final int GENERIC_ERROR = 0;
public static final int INCOMPATIBLE_API_VERSIONS = 1;
public static final int NO_OR_WRONG_PASSPHRASE = 2;
public static final int NO_USER_IDS = 3;
public static final int OPPORTUNISTIC_MISSING_KEYS = 4;
int errorId;
String message;
public OpenPgpError() {
}
public OpenPgpError(int errorId, String message) {
this.errorId = errorId;
this.message = message;
}
public OpenPgpError(OpenPgpError b) {
this.errorId = b.errorId;
this.message = b.message;
}
public int getErrorId() {
return errorId;
}
public void setErrorId(int errorId) {
this.errorId = errorId;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel dest, int flags) {
/*
NOTE: When adding fields in the process of updating this API, make sure to bump
{@link #PARCELABLE_VERSION}.
*/
dest.writeInt(PARCELABLE_VERSION);
// Inject a placeholder that will store the parcel size from this point on
// (not including the size itself).
int sizePosition = dest.dataPosition();
dest.writeInt(0);
int startPosition = dest.dataPosition();
// version 1
dest.writeInt(errorId);
dest.writeString(message);
// Go back and write the size
int parcelableSize = dest.dataPosition() - startPosition;
dest.setDataPosition(sizePosition);
dest.writeInt(parcelableSize);
dest.setDataPosition(startPosition + parcelableSize);
}
public static final Creator<OpenPgpError> CREATOR = new Creator<OpenPgpError>() {
public OpenPgpError createFromParcel(final Parcel source) {
source.readInt(); // parcelableVersion
int parcelableSize = source.readInt();
int startPosition = source.dataPosition();
OpenPgpError error = new OpenPgpError();
error.errorId = source.readInt();
error.message = source.readString();
// skip over all fields added in future versions of this parcel
source.setDataPosition(startPosition + parcelableSize);
return error;
}
public OpenPgpError[] newArray(final int size) {
return new OpenPgpError[size];
}
};
}

148
openpgp-api/src/main/java/org/openintents/openpgp/OpenPgpMetadata.java

@ -0,0 +1,148 @@
/*
* Copyright (C) 2014-2015 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.os.Parcel;
import android.os.Parcelable;
public class OpenPgpMetadata implements Parcelable {
/**
* Since there might be a case where new versions of the client using the library getting
* old versions of the protocol (and thus old versions of this class), we need a versioning
* system for the parcels sent between the clients and the providers.
*/
public static final int PARCELABLE_VERSION = 2;
String filename;
String mimeType;
String charset;
long modificationTime;
long originalSize;
public String getFilename() {
return filename;
}
public String getMimeType() {
return mimeType;
}
public long getModificationTime() {
return modificationTime;
}
public long getOriginalSize() {
return originalSize;
}
public String getCharset() {
return charset;
}
public OpenPgpMetadata() {
}
public OpenPgpMetadata(String filename, String mimeType, long modificationTime,
long originalSize, String charset) {
this.filename = filename;
this.mimeType = mimeType;
this.modificationTime = modificationTime;
this.originalSize = originalSize;
this.charset = charset;
}
public OpenPgpMetadata(String filename, String mimeType, long modificationTime,
long originalSize) {
this.filename = filename;
this.mimeType = mimeType;
this.modificationTime = modificationTime;
this.originalSize = originalSize;
}
public OpenPgpMetadata(OpenPgpMetadata b) {
this.filename = b.filename;
this.mimeType = b.mimeType;
this.modificationTime = b.modificationTime;
this.originalSize = b.originalSize;
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel dest, int flags) {
/*
* NOTE: When adding fields in the process of updating this API, make sure to bump
* {@link #PARCELABLE_VERSION}.
*/
dest.writeInt(PARCELABLE_VERSION);
// Inject a placeholder that will store the parcel size from this point on
// (not including the size itself).
int sizePosition = dest.dataPosition();
dest.writeInt(0);
int startPosition = dest.dataPosition();
// version 1
dest.writeString(filename);
dest.writeString(mimeType);
dest.writeLong(modificationTime);
dest.writeLong(originalSize);
// version 2
dest.writeString(charset);
// Go back and write the size
int parcelableSize = dest.dataPosition() - startPosition;
dest.setDataPosition(sizePosition);
dest.writeInt(parcelableSize);
dest.setDataPosition(startPosition + parcelableSize);
}
public static final Creator<OpenPgpMetadata> CREATOR = new Creator<OpenPgpMetadata>() {
public OpenPgpMetadata createFromParcel(final Parcel source) {
int version = source.readInt(); // parcelableVersion
int parcelableSize = source.readInt();
int startPosition = source.dataPosition();
OpenPgpMetadata vr = new OpenPgpMetadata();
vr.filename = source.readString();
vr.mimeType = source.readString();
vr.modificationTime = source.readLong();
vr.originalSize = source.readLong();
if (version >= 2) {
vr.charset = source.readString();
}
// skip over all fields added in future versions of this parcel
source.setDataPosition(startPosition + parcelableSize);
return vr;
}
public OpenPgpMetadata[] newArray(final int size) {
return new OpenPgpMetadata[size];
}
};
@Override
public String toString() {
String out = "\nfilename: " + filename;
out += "\nmimeType: " + mimeType;
out += "\nmodificationTime: " + modificationTime;
out += "\noriginalSize: " + originalSize;
out += "\ncharset: " + charset;
return out;
}
}

275
openpgp-api/src/main/java/org/openintents/openpgp/OpenPgpSignatureResult.java

@ -0,0 +1,275 @@
/*
* Copyright (C) 2014-2015 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 java.util.Collections;
import java.util.Date;
import java.util.List;
import android.os.Parcel;
import android.os.Parcelable;
import org.openintents.openpgp.util.OpenPgpUtils;
@SuppressWarnings("unused")
public class OpenPgpSignatureResult implements Parcelable {
/**
* Since there might be a case where new versions of the client using the library getting
* old versions of the protocol (and thus old versions of this class), we need a versioning
* system for the parcels sent between the clients and the providers.
*/
private static final int PARCELABLE_VERSION = 5;
// content not signed
public static final int RESULT_NO_SIGNATURE = -1;
// invalid signature!
public static final int RESULT_INVALID_SIGNATURE = 0;
// successfully verified signature, with confirmed key
public static final int RESULT_VALID_KEY_CONFIRMED = 1;