diff --git a/android/app/build.gradle b/android/app/build.gradle index 43d415d..814c26f 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -32,7 +32,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion 30 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -46,7 +46,7 @@ android { defaultConfig { applicationId "com.marinbasic.yapgp" minSdkVersion 18 - targetSdkVersion 28 + targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/android/app/src/main/kotlin/com/marinbasic/yapgp/MainActivity.java b/android/app/src/main/kotlin/com/marinbasic/yapgp/MainActivity.java index 419d1da..e982ec3 100644 --- a/android/app/src/main/kotlin/com/marinbasic/yapgp/MainActivity.java +++ b/android/app/src/main/kotlin/com/marinbasic/yapgp/MainActivity.java @@ -1,20 +1,19 @@ package com.marinbasic.yapgp; import androidx.annotation.NonNull; + import com.google.android.gms.tasks.Tasks; -import com.proton.gopenpgp.crypto.Crypto; -import com.proton.gopenpgp.crypto.Identity; -import com.proton.gopenpgp.crypto.Key; -import com.proton.gopenpgp.helper.Helper; -import org.json.JSONException; -import org.json.JSONObject; +import org.json.JSONObject; import java.util.concurrent.Callable; -import java.util.concurrent.Executor; import java.util.concurrent.Executors; +import crypto.Crypto; +import crypto.Key; +import crypto.UserInfo; +import helper.Helper; import io.flutter.embedding.android.FlutterActivity; import io.flutter.embedding.engine.FlutterEngine; import io.flutter.plugin.common.MethodChannel; @@ -55,9 +54,11 @@ public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { return resultJSON; case "Encrypt": - String pgpMessage = Helper.encryptMessageArmored( - call.argument("pubKey"), - call.argument("message") + String pgpMessage = Helper.encryptSignMessageArmored( + call.argument("pubKey").toString(), + call.argument("privKey").toString(), + call.argument("passphrase").toString().getBytes(), + call.argument("message").toString() ); resultJSON.put("message", pgpMessage); @@ -80,10 +81,10 @@ public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { return resultJSON; case "Identity": Key pubKey; - Identity id; + UserInfo id; try{ pubKey = Crypto.newKeyFromArmored(call.argument("pubKey")); - id = pubKey.identity(); + id = pubKey.primaryIdentity(); }catch (Exception e) { resultJSON.put("error", "Invalid PGP public key"); return resultJSON; @@ -97,13 +98,14 @@ public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { return resultJSON; case "Import": Key privateKey; - Identity identity; + UserInfo identity; String password = call.argument("passphrase"); if(password == null) { password = ""; } try { privateKey = Crypto.newKeyFromArmored(call.argument("privKey")); + if(privateKey.isLocked() && password.isEmpty()) { resultJSON.put("error", "Private key locked with password"); return resultJSON; @@ -113,7 +115,7 @@ public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { resultJSON.put("error", "Invalid password"); return resultJSON; } - identity = privateKey.identity(); + identity = privateKey.primaryIdentity(); resultJSON.put("publicKey", privateKey.getArmoredPublicKey()); resultJSON.put("privateKey", privateKey.armor()); @@ -133,9 +135,7 @@ public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { call.argument("message"), Crypto.getUnixTime() ); - Long time = Helper.createdCleartextMessageArmored(call.argument("message")); resultJSON.put("msg", msg); - resultJSON.put("time", time); }catch (Exception e) { resultJSON.put("error", "Contact key does not match PGP signed message"); return resultJSON; @@ -154,6 +154,7 @@ public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { resultJSON.put("time", Crypto.getUnixTime()); }catch (Exception e) { + e.printStackTrace(); resultJSON.put("error", "Cannot create signature"); return resultJSON; } diff --git a/android/gopenpgp/gopenpgp.aar b/android/gopenpgp/gopenpgp.aar index 1426daf..420a7ab 100644 Binary files a/android/gopenpgp/gopenpgp.aar and b/android/gopenpgp/gopenpgp.aar differ diff --git a/android/gradle.properties b/android/gradle.properties index ca7c63c..6bd1be0 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx1536M -android.enableR8=true android.useAndroidX=true android.enableJetifier=true android.bundle.enableUncompressedNativeLibs=false +android.enableR8=true diff --git a/lib/models/signature.dart b/lib/models/signature.dart index 5df4170..85818ac 100644 --- a/lib/models/signature.dart +++ b/lib/models/signature.dart @@ -1,19 +1,15 @@ class Signature { String message; - DateTime datetime; - Signature({this.message, this.datetime}); + Signature({this.message}); Signature.fromJson(Map json) { message = json['msg']; - datetime = new DateTime.fromMillisecondsSinceEpoch(json['time'] * 1000); - print(json['time']); } Map toJson() { final Map data = new Map(); data['msg'] = this.message; - data['time'] = this.datetime; return data; } } diff --git a/lib/services/pgp_service.dart b/lib/services/pgp_service.dart index 8231e21..fc03469 100644 --- a/lib/services/pgp_service.dart +++ b/lib/services/pgp_service.dart @@ -13,8 +13,8 @@ class PGPService { return PGP.fromJson(jsonDecode(result)); } - Future encrypt(String msg, PGP key) async { - String result = await ch.invokeMethod("Encrypt", {"pubKey": key.publicKey, "message": msg}); + Future encrypt(String msg, PGP key, PGP contact) async { + String result = await ch.invokeMethod("Encrypt", {"pubKey": contact.publicKey,"privKey": key.privateKey,"passphrase": key.passphrase, "message": msg}); var json = jsonDecode(result); return json["message"]; } diff --git a/lib/views/encrypt.dart b/lib/views/encrypt.dart index 3ba0fa1..6f7a33c 100644 --- a/lib/views/encrypt.dart +++ b/lib/views/encrypt.dart @@ -75,7 +75,7 @@ class EncryptState extends State { .toString(); PGP mykey = _keys.where((element) => element.privateKey == privKey).first; - _service.encrypt(message, mykey).then((value) { + _service.encrypt(message, mykey, contact).then((value) { setState(() { isLoading = false; _controller.text = value; diff --git a/lib/views/import_key.dart b/lib/views/import_key.dart index 551e220..8eace3c 100644 --- a/lib/views/import_key.dart +++ b/lib/views/import_key.dart @@ -71,7 +71,7 @@ class ImportKeyState extends State { privKey, _fbKey.currentState.value["password"].toString(), ) - .then((value) { + .then(Store.addKey).then((value) { Navigator.pop(context, value); }).catchError((e) { _utils.showSnackbar(builderContext, e.message); diff --git a/lib/views/verify_sign.dart b/lib/views/verify_sign.dart index ebda79a..64d5f5b 100644 --- a/lib/views/verify_sign.dart +++ b/lib/views/verify_sign.dart @@ -100,17 +100,6 @@ class VerifySignatureState extends State { ], ), ), - Card( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - title: Text('Signed at'), - subtitle: Text(sig.datetime.toString()), - ), - ], - ), - ), ], ) : FormBuilder( diff --git a/pubspec.lock b/pubspec.lock index 0072be6..db53ab8 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -28,7 +28,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.2" + version: "2.5.0-nullsafety.1" basic_utils: dependency: transitive description: @@ -42,21 +42,21 @@ packages: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0-nullsafety.3" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.2.0-nullsafety.1" clipboard_manager: dependency: "direct main" description: @@ -70,14 +70,14 @@ packages: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.1.0-nullsafety.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.15.0-nullsafety.3" convert: dependency: transitive description: @@ -126,7 +126,14 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" file: dependency: transitive description: @@ -145,7 +152,7 @@ packages: name: flutter_chips_input url: "https://pub.dartlang.org" source: hosted - version: "1.9.1" + version: "1.9.5" flutter_colorpicker: dependency: transitive description: @@ -159,28 +166,42 @@ packages: name: flutter_form_builder url: "https://pub.dartlang.org" source: hosted - version: "3.13.2" + version: "3.14.1" flutter_keyboard_visibility: dependency: transitive description: name: flutter_keyboard_visibility url: "https://pub.dartlang.org" source: hosted - version: "3.2.1" + version: "4.0.2" + flutter_keyboard_visibility_platform_interface: + dependency: transitive + description: + name: flutter_keyboard_visibility_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + flutter_keyboard_visibility_web: + dependency: transitive + description: + name: flutter_keyboard_visibility_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "1.0.8" + version: "1.0.11" flutter_secure_storage: dependency: "direct main" description: name: flutter_secure_storage url: "https://pub.dartlang.org" source: hosted - version: "3.3.3" + version: "3.3.5" flutter_test: dependency: "direct dev" description: flutter @@ -199,7 +220,7 @@ packages: name: flutter_typeahead url: "https://pub.dartlang.org" source: hosted - version: "1.8.7" + version: "1.9.3" flutter_web_plugins: dependency: transitive description: flutter @@ -232,21 +253,21 @@ packages: name: image_picker url: "https://pub.dartlang.org" source: hosted - version: "0.6.7+4" + version: "0.6.7+21" image_picker_for_web: dependency: transitive description: name: image_picker_for_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.0+1" + version: "0.1.0+2" image_picker_platform_interface: dependency: transitive description: name: image_picker_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" intl: dependency: transitive description: @@ -281,21 +302,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.10-nullsafety.1" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0-nullsafety.3" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.1" path_provider_linux: dependency: transitive description: @@ -309,7 +330,14 @@ packages: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.4" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.4+3" pedantic: dependency: transitive description: @@ -330,7 +358,7 @@ packages: name: phone_number url: "https://pub.dartlang.org" source: hosted - version: "0.6.2+4" + version: "0.6.3" platform: dependency: transitive description: @@ -344,7 +372,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.3" pointycastle: dependency: transitive description: @@ -379,7 +407,7 @@ packages: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.8" + version: "0.5.12+4" shared_preferences_linux: dependency: transitive description: @@ -408,6 +436,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.2+7" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.1+3" signature: dependency: transitive description: @@ -426,49 +461,49 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.5" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0-nullsafety.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.2.19-nullsafety.2" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0-nullsafety.3" validators: dependency: transitive description: @@ -482,7 +517,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0-nullsafety.3" vin_decoder: dependency: transitive description: @@ -490,6 +525,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.2" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.4" xdg_directories: dependency: transitive description: @@ -505,5 +547,5 @@ packages: source: hosted version: "4.2.0" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" - flutter: ">=1.12.13+hotfix.6 <2.0.0" + dart: ">=2.10.0-110 <2.11.0" + flutter: ">=1.22.0 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 0f72704..c8355c4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,16 +15,16 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.2+4 +version: 1.0.3+5 environment: sdk: ">=2.7.0 <3.0.0" dependencies: clipboard_manager: ^0.0.4 - shared_preferences: ^0.5.7+3 + shared_preferences: ^0.5.12+4 flutter_form_builder: ^3.13.2 - flutter_secure_storage: ^3.3.3 + flutter_secure_storage: ^3.3.5 flutter: sdk: flutter