From bbe238519cf3750ed8affc5b6802149c09ec9c89 Mon Sep 17 00:00:00 2001
From: Marten Rebane <54431068+martenrebane@users.noreply.github.com>
Date: Tue, 13 Aug 2024 17:52:07 +0300
Subject: [PATCH 1/7] Fix expired message displaying
---
MoppApp/MoppApp/LandingViewController.swift | 18 ------------------
MoppApp/MoppApp/NFCSignature.swift | 16 +++++++++++-----
2 files changed, 11 insertions(+), 23 deletions(-)
diff --git a/MoppApp/MoppApp/LandingViewController.swift b/MoppApp/MoppApp/LandingViewController.swift
index e20bb09a2..a27cdbc71 100644
--- a/MoppApp/MoppApp/LandingViewController.swift
+++ b/MoppApp/MoppApp/LandingViewController.swift
@@ -135,7 +135,6 @@ class LandingViewController : UIViewController, NativeShare, ContainerActions
presentButtons([.signTab, .cryptoTab, .myeIDTab])
selectTabButton(.signTab)
- NotificationCenter.default.addObserver(self, selector: #selector(receiveErrorNotification), name: .errorNotificationName, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(receiveStartImportingFilesWithDocumentPickerNotification), name: .startImportingFilesWithDocumentPickerNotificationName, object: nil)
LandingViewController.onDataFileAddedAccessibility = {
NotificationCenter.default.addObserver(
@@ -227,23 +226,6 @@ class LandingViewController : UIViewController, NativeShare, ContainerActions
controller.tabBarItem.image = image
controller.tabBarItem.selectedImage = selectedImage
}
-
- @objc func receiveErrorNotification(_ notification: Notification) {
- guard let userInfo = notification.userInfo else { return }
- let error = userInfo[kErrorKey] as? NSError
- var errorMessage = error?.userInfo[NSLocalizedDescriptionKey] as? String ??
- userInfo[kErrorMessage] as? String
- guard let strongErrorMessage = errorMessage else { return }
- errorMessage = MoppLib_LocalizedString(strongErrorMessage)
- let alert = UIAlertController(
- title: L(.errorAlertTitleGeneral),
- message: errorMessage,
- preferredStyle: .alert)
-
- presentedViewController?.dismiss(animated: false, completion: nil)
- alert.addAction(UIAlertAction(title: L(.actionOk), style: .default, handler: nil))
- present(alert, animated: true)
- }
@objc func receiveStartImportingFilesWithDocumentPickerNotification(_ notification: Notification) {
fileImportIntent = notification.userInfo![kKeyFileImportIntent] as? MoppApp.FileImportIntent
diff --git a/MoppApp/MoppApp/NFCSignature.swift b/MoppApp/MoppApp/NFCSignature.swift
index 9313d509e..63c1131ef 100644
--- a/MoppApp/MoppApp/NFCSignature.swift
+++ b/MoppApp/MoppApp/NFCSignature.swift
@@ -52,6 +52,7 @@ class NFCSignature : NSObject, NFCTagReaderSessionDelegate {
var ksEnc: Bytes?
var ksMac: Bytes?
var SSC: Bytes?
+ var invalidateWithError: Bool = false
func createNFCSignature(can: String, pin: String, containerPath: String, hashType: String, roleData: MoppLibRoleAddressData?) -> Void {
guard NFCTagReaderSession.readingAvailable else {
@@ -61,6 +62,7 @@ class NFCSignature : NSObject, NFCTagReaderSessionDelegate {
CAN = can
PIN = pin
self.containerPath = containerPath
+ invalidateWithError = false
session = NFCTagReaderSession(pollingOption: .iso14443, delegate: self)
session?.alertMessage = L(.nfcHoldNear)
session?.begin()
@@ -76,6 +78,8 @@ class NFCSignature : NSObject, NFCTagReaderSessionDelegate {
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
@Sendable func setSessionMessage(_ msg: String, invalidate: Bool = false) -> Void {
+ invalidateWithError = invalidate
+
if invalidate {
session.invalidate(errorMessage: msg)
} else {
@@ -200,11 +204,13 @@ class NFCSignature : NSObject, NFCTagReaderSessionDelegate {
}
func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: Error) {
- if let readerError = error as? NFCReaderError,
- readerError.code == .readerSessionInvalidationErrorUserCanceled {
- CancelUtil.handleCancelledRequest(errorMessageDetails: "User cancelled NFC signing")
- } else {
- CancelUtil.handleCancelledRequest(errorMessageDetails: "Session Invalidated")
+ if !invalidateWithError {
+ if let readerError = error as? NFCReaderError,
+ readerError.code == .readerSessionInvalidationErrorUserCanceled {
+ CancelUtil.handleCancelledRequest(errorMessageDetails: "User cancelled NFC signing")
+ } else {
+ CancelUtil.handleCancelledRequest(errorMessageDetails: "Session Invalidated")
+ }
}
self.session = nil
}
From bae90c3cc8b4bb4c32fddedfd20ca9c20c241c1a Mon Sep 17 00:00:00 2001
From: Marten Rebane <54431068+martenrebane@users.noreply.github.com>
Date: Tue, 13 Aug 2024 18:15:51 +0300
Subject: [PATCH 2/7] Add better NFC translations
---
MoppApp/MoppApp/en.lproj/Localizable.strings | 10 ++++-----
MoppApp/MoppApp/et.lproj/Localizable.strings | 22 ++++++++++----------
MoppApp/MoppApp/ru.lproj/Localizable.strings | 20 +++++++++---------
3 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/MoppApp/MoppApp/en.lproj/Localizable.strings b/MoppApp/MoppApp/en.lproj/Localizable.strings
index 59ce739dc..86df49f53 100755
--- a/MoppApp/MoppApp/en.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/en.lproj/Localizable.strings
@@ -230,11 +230,11 @@
"smart-id-country-latvia" = "Latvia";
"smart-id-challenge-title" = "Sign with Smart-ID";
"smart-id-sign-help-title" = "Make sure control code matches with one in phone screen and enter Smart-ID PIN2 code";
-"nfc-title" = "Enter your ID-card access number and PIN2 code to sign with ID-card";
-"nfc-can-title" = "ID-card access number";
-"nfc-device-no-support" = "This device does not support NFC.";
+"nfc-title" = "Enter your ID-card access number (CAN) and PIN2 code to sign with ID-card";
+"nfc-can-title" = "ID-card access number (CAN)";
+"nfc-device-no-support" = "This device does not support contactless connection or NFC is turned off.";
"nfc-hold-near" = "Hold your phone near the ID-card";
-"nfc-multiple-cards" = "More than 1 NFC tag is detected, please remove all NFC tags and try again";
+"nfc-multiple-cards" = "More than 1 NFC tag is detected. Please remove all NFC tags and try again.";
"nfc-invalid-tag" = "Invalid NFC tag";
"nfc-unable-connect" = "Unable to connect to NFC tag";
"nfc-auth" = "Authenticating with ID-card";
@@ -243,7 +243,7 @@
"nfc-sign-done" = "Signing done";
"nfc-auth-failed" = "Failed to authenticate with ID-card";
"nfc-sign-failed" = "Failed to sign document with ID-card";
-"nfc-pin-locked" = "Locked PIN";
+"nfc-pin-locked" = "PIN2 has been blocked";
"role-and-address" = "Role and address";
"role-and-address-title" = "Enter your role and address info";
"role-and-address-role-title" = "Role / resolution";
diff --git a/MoppApp/MoppApp/et.lproj/Localizable.strings b/MoppApp/MoppApp/et.lproj/Localizable.strings
index e0b428b5b..099fe40c1 100755
--- a/MoppApp/MoppApp/et.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/et.lproj/Localizable.strings
@@ -231,20 +231,20 @@
"smart-id-country-latvia" = "Läti";
"smart-id-challenge-title" = "Allkirjasta Smart-IDga";
"smart-id-sign-help-title" = "Veendu kontrollkoodi õigsuses ja sisesta nutiseadmes Smart-ID PIN2-kood";
-"nfc-title" = "ID-kaardiga allkirjastamiseks sisesta oma ID-kaardi ligipääsu number ja PIN2-kood";
-"nfc-can-title" = "ID-kaardi ligipääsu number";
-"nfc-device-no-support" = "See seade ei toeta NFC-d";
-"nfc-hold-near" = "Hoidke ID-kaarti telefoni lähedal";
-"nfc-multiple-cards" = "Rohkem kui 1 NFC märgis on tuvastatud, eemaldage kõik NFC-märgisega esemed ja proovige uuesti";
-"nfc-invalid-tag" = "Kehtetu NFC-märgis";
-"nfc-unable-connect" = "NFC-ega ei saa ühendust luua";
-"nfc-auth" = "Isikutuvastus ID-kaardiga";
+"nfc-title" = "ID-kaardiga allkirjastamiseks sisesta oma ID-kaardi ligipääsu number (CAN) ja PIN2 kood";
+"nfc-can-title" = "ID-kaardi ligipääsu number (CAN)";
+"nfc-device-no-support" = "See seade ei toeta kontaktivaba ühendust või NFC on välja lülitatud.";
+"nfc-hold-near" = "Hoia ID-kaarti telefoni lähedal";
+"nfc-multiple-cards" = "Tuvastatud on rohkem kui üks NFC-element. Eemalda kõik NFC-elemendiga esemed ja proovi uuesti.";
+"nfc-invalid-tag" = "Kehtetu NFC-element";
+"nfc-unable-connect" = "Kontaktivaba ühendust ei saa luua";
+"nfc-auth" = "ID-kaardiga kontaktivaba ühenduse loomine";
"nfc-reading-cert" = "Sertifikaadi lugemine";
-"nfc-sign-doc" = "Allkirjasta dokument";
+"nfc-sign-doc" = "Ümbriku allkirjastamine";
"nfc-sign-done" = "Allkiri lisatud";
"nfc-auth-failed" = "Isikutuvastus ID-kaardiga ebaõnnestus";
-"nfc-sign-failed" = "Failed to sign document with ID-card";
-"nfc-pin-locked" = "Locked PIN";
+"nfc-sign-failed" = "Ümbriku allkirjastamine ebaõnnestus";
+"nfc-pin-locked" = "PIN2 on blokeeritud";
"role-and-address" = "Roll ja aadress";
"role-and-address-title" = "Sisesta oma roll ja aadress";
"role-and-address-role-title" = "Roll / resolutsioon";
diff --git a/MoppApp/MoppApp/ru.lproj/Localizable.strings b/MoppApp/MoppApp/ru.lproj/Localizable.strings
index 27848c134..cd4d02631 100644
--- a/MoppApp/MoppApp/ru.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/ru.lproj/Localizable.strings
@@ -231,20 +231,20 @@
"smart-id-country-latvia" = "Латвия";
"smart-id-challenge-title" = "Подписать с помощью приложения Smart-ID";
"smart-id-sign-help-title" = "Убедитесь в правильности контрольного кода и введите PIN2-код для Smart-ID";
-"nfc-title" = "Введите номер доступа к карте и PIN2-код для подписи с помощью ID-карты";
-"nfc-can-title" = "Номер доступа к карте";
-"nfc-device-no-support" = "Это устройство не поддерживает NFC";
-"nfc-hold-near" = "Держите телефон рядом с ID-картой";
-"nfc-multiple-cards" = "Обнаружено более одной NFC-метки, пожалуйста, удалите все NFC-метки и повторите попытку";
+"nfc-title" = "Чтобы подписать с помощью ID-карты, введите ее номер доступа (CAN) и PIN2-код";
+"nfc-can-title" = "Номер доступа ID-карты (CAN)";
+"nfc-device-no-support" = "Данное устройство не поддерживает бесконтактное соединение или NFC отключен";
+"nfc-hold-near" = "Удерживайте ID-карту рядом с телефоном";
+"nfc-multiple-cards" = "Обнаружено более одной NFC-метки. Удалите все объекты с NFC-элементом (NFC-метки) и попробуйте снова.";
"nfc-invalid-tag" = "Недействительная NFC-метка";
-"nfc-unable-connect" = "Невозможно подключиться к NFC-метке";
-"nfc-auth" = "Идентификация личности по карте";
+"nfc-unable-connect" = "Бесконтактное соединение не может быть установлено";
+"nfc-auth" = "Создание бесконтактного соединения с ID-картой";
"nfc-reading-cert" = "Считывание сертификата";
-"nfc-sign-doc" = "Подписать документ";
+"nfc-sign-doc" = "Подписание конверта";
"nfc-sign-done" = "Подпись добавлена";
"nfc-auth-failed" = "Идентификация личности по карте не удалась";
-"nfc-sign-failed" = "Failed to sign document with ID-card";
-"nfc-pin-locked" = "Locked PIN";
+"nfc-sign-failed" = "Не удалось подписать контейнер";
+"nfc-pin-locked" = "PIN2 заблокирован";
"role-and-address" = "Роль и адрес";
"role-and-address-title" = "Введите свою роль и адрес";
"role-and-address-role-title" = "Роль / pезолюция";
From 95e7dd6ec89f3ba0ab27c0d0093e5c54c15f364b Mon Sep 17 00:00:00 2001
From: Marten Rebane <54431068+martenrebane@users.noreply.github.com>
Date: Tue, 27 Aug 2024 17:24:06 +0300
Subject: [PATCH 3/7] Make blocked PIN texts shorter
---
MoppApp/MoppApp/en.lproj/Localizable.strings | 4 ++--
MoppApp/MoppApp/et.lproj/Localizable.strings | 4 ++--
MoppApp/MoppApp/ru.lproj/Localizable.strings | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/MoppApp/MoppApp/en.lproj/Localizable.strings b/MoppApp/MoppApp/en.lproj/Localizable.strings
index 86df49f53..284f2c851 100755
--- a/MoppApp/MoppApp/en.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/en.lproj/Localizable.strings
@@ -289,8 +289,8 @@
"wrong-pin1-single" = "Wrong PIN1. You have 1 attempt left until your PIN1 is blocked.";
"pin2-textfield-label" = "Enter PIN2";
"pin1-textfield-label" = "Enter PIN1";
-"pin2-blocked-alert" = "PIN2 blocked. The PIN code can be unlocked on the My eID page.";
-"pin1-blocked-alert" = "PIN1 blocked. The PIN code can be unlocked on the My eID page.";
+"pin2-blocked-alert" = "PIN2 has been blocked";
+"pin1-blocked-alert" = "PIN1 has been blocked";
"generic-error-message" = "Something went wrong. Please try again.";
"decryption-error-message" = "Something went wrong with decryption. Please try again.";
"signing-aborted-message" = "Signing process aborted";
diff --git a/MoppApp/MoppApp/et.lproj/Localizable.strings b/MoppApp/MoppApp/et.lproj/Localizable.strings
index 099fe40c1..1c185d3d2 100755
--- a/MoppApp/MoppApp/et.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/et.lproj/Localizable.strings
@@ -285,8 +285,8 @@
"card-reader-state-initial" = "Ühenda kaardilugeja nutiseadmega ja sisesta ID-kaart lugejasse.";
"pin2-textfield-label" = "Sisesta PIN2";
"pin1-textfield-label" = "Sisesta PIN1";
-"pin2-blocked-alert" = "PIN2 on lukus. PIN-koodi saab lukust avada Minu eID lehel.";
-"pin1-blocked-alert" = "PIN1 on lukus. PIN-koodi saab lukust avada Minu eID lehel.";
+"pin2-blocked-alert" = "PIN2 on blokeeritud";
+"pin1-blocked-alert" = "PIN1 on blokeeritud";
"generic-error-message" = "Midagi läks valesti. Palun proovi uuesti.";
"decryption-error-message" = "Midagi läks dekrüpteerimisel valesti. Palun proovi uuesti.";
"signing-error-too-many-requests" = "Sinu %@ tasuta allkirjade kuulimiit on ületatud. https://www.id.ee/artikkel/asutustele-kus-allkirjastatakse-digidoc4-kliendi-kaudu-suuremates-kogustes-dokumente/";
diff --git a/MoppApp/MoppApp/ru.lproj/Localizable.strings b/MoppApp/MoppApp/ru.lproj/Localizable.strings
index cd4d02631..6ba88e800 100644
--- a/MoppApp/MoppApp/ru.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/ru.lproj/Localizable.strings
@@ -290,8 +290,8 @@
"wrong-pin1-single" = "Неверный PIN1. У Вас осталась 1 попытка до блокировки Вашего PIN1.";
"pin2-textfield-label" = "Введите PIN2";
"pin1-textfield-label" = "Введите PIN1";
-"pin2-blocked-alert" = "PIN2 заблокирован. PIN-код можно разблокировать на странице Mой eID.";
-"pin1-blocked-alert" = "PIN1 заблокирован. PIN-код можно разблокировать на странице Mой eID.";
+"pin2-blocked-alert" = "PIN2 заблокирован";
+"pin1-blocked-alert" = "PIN1 заблокирован";
"generic-error-message" = "Что-то пошло не так. Пожалуйста, попробуйте снова.";
"decryption-error-message" = "Что-то пошло не так с дешифрованием. Пожалуйста, попробуйте снова.";
"signing-aborted-message" = "Процесс подписания прерван";
From 1766b22a819df6c09f66c03214a978d558bdf271 Mon Sep 17 00:00:00 2001
From: Marten Rebane <54431068+martenrebane@users.noreply.github.com>
Date: Mon, 2 Sep 2024 23:31:42 +0300
Subject: [PATCH 4/7] Fix saving encrypted CAN number
---
MoppApp/MoppApp/EncryptedDataUtil.swift | 5 ++---
MoppApp/MoppApp/KeychainUtil.swift | 21 ++++++++++++++++++---
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/MoppApp/MoppApp/EncryptedDataUtil.swift b/MoppApp/MoppApp/EncryptedDataUtil.swift
index 8be34e7c0..dafcb96f9 100644
--- a/MoppApp/MoppApp/EncryptedDataUtil.swift
+++ b/MoppApp/MoppApp/EncryptedDataUtil.swift
@@ -77,13 +77,12 @@ struct EncryptedDataUtil {
}
static func decryptSecret(_ data: Data, with symmetricKey: SymmetricKey) -> String? {
- guard let sealedBox = try? ChaChaPoly.SealedBox(combined: data) else { return nil }
-
do {
+ let sealedBox = try ChaChaPoly.SealedBox(combined: data)
let decryptedData = try ChaChaPoly.open(sealedBox, using: symmetricKey)
return String(data: decryptedData, encoding: .utf8)
} catch {
- printLog("Unable to decrypt secret: \(error.localizedDescription)")
+ printLog("Unable to decrypt encrypted secret: \(error.localizedDescription)")
return nil
}
}
diff --git a/MoppApp/MoppApp/KeychainUtil.swift b/MoppApp/MoppApp/KeychainUtil.swift
index 7a68ef5ba..054e0da75 100644
--- a/MoppApp/MoppApp/KeychainUtil.swift
+++ b/MoppApp/MoppApp/KeychainUtil.swift
@@ -27,17 +27,32 @@ import Security
class KeychainUtil {
static func save(key: String, info: Data, withPasscodeSetOnly: Bool = false) -> Bool {
guard let bundleIdentifier = Bundle.main.bundleIdentifier else { return false }
+
let query: [CFString: Any] = [
kSecClass: kSecClassGenericPassword,
kSecAttrService: bundleIdentifier,
kSecAttrAccount: "\(bundleIdentifier).\(key)",
+ ]
+
+ let attributes: [CFString: Any] = [
kSecValueData: info,
kSecAttrAccessible: withPasscodeSetOnly ? kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly : kSecAttrAccessibleWhenUnlockedThisDeviceOnly
]
- SecItemDelete(query as CFDictionary)
- let status = SecItemAdd(query as CFDictionary, nil)
+
+ let status = SecItemUpdate(query as CFDictionary, attributes as CFDictionary)
- return status == errSecSuccess
+ if status == errSecSuccess {
+ return true
+ } else if status == errSecItemNotFound {
+ // Item does not exist yet, add it
+ let queryWithAttributes = query.merging(attributes) { (_, new) in new }
+
+ let addStatus = SecItemAdd(queryWithAttributes as CFDictionary, nil)
+ return addStatus == errSecSuccess
+ } else {
+ printLog("Unable to save \(key): \(status)")
+ return false
+ }
}
static func retrieve(key: String) -> Data? {
From 189f30d55ddb401ac101e7fe5f6dee7c80c67a17 Mon Sep 17 00:00:00 2001
From: Marten Rebane <54431068+martenrebane@users.noreply.github.com>
Date: Tue, 3 Sep 2024 22:32:23 +0300
Subject: [PATCH 5/7] Fix PIN2 limits
---
MoppApp/MoppApp/IdCardViewController.swift | 6 +++++-
MoppApp/MoppApp/et.lproj/Localizable.strings | 4 ++--
MoppApp/MoppApp/ru.lproj/Localizable.strings | 4 ++--
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/MoppApp/MoppApp/IdCardViewController.swift b/MoppApp/MoppApp/IdCardViewController.swift
index 788421b85..1b618aa85 100644
--- a/MoppApp/MoppApp/IdCardViewController.swift
+++ b/MoppApp/MoppApp/IdCardViewController.swift
@@ -119,7 +119,11 @@ class IdCardViewController : MoppViewController, TokenFlowSigning {
@objc func editingChanged(sender: UITextField) {
let count = (sender.text?.count ?? 0)
- actionButton.isEnabled = count >= 4 && count <= 6
+ if self.isActionDecryption {
+ actionButton.isEnabled = count >= 4 && count <= 12
+ } else {
+ actionButton.isEnabled = count >= 5 && count <= 12
+ }
if !actionButton.isEnabled {
actionButton.backgroundColor = UIColor.moppBackgroundDark
}
diff --git a/MoppApp/MoppApp/et.lproj/Localizable.strings b/MoppApp/MoppApp/et.lproj/Localizable.strings
index f1bf24b7f..490bafa28 100755
--- a/MoppApp/MoppApp/et.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/et.lproj/Localizable.strings
@@ -243,9 +243,9 @@
"nfc-sign-doc" = "Allkirjasta dokument";
"nfc-sign-done" = "Allkiri lisatud";
"nfc-auth-failed" = "Isikutuvastus ID-kaardiga ebaõnnestus";
-"nfc-sign-failed" = "Failed to sign document with ID-card";
+"nfc-sign-failed" = "Ümbriku allkirjastamine ebaõnnestus";
"nfc-pin-locked" = "Locked PIN";
-"nfc-cert-parse-failed" = "Certificate parsing failed";
+"nfc-cert-parse-failed" = "Viga sertifikaadi parsimisel";
"nfc-cert-expired" = "Aegunud sertifikaati ei saa kasutada allkirjastamiseks";
"role-and-address" = "Roll ja aadress";
"role-and-address-title" = "Sisesta oma roll ja aadress";
diff --git a/MoppApp/MoppApp/ru.lproj/Localizable.strings b/MoppApp/MoppApp/ru.lproj/Localizable.strings
index 3b2be72ed..5b809c1af 100644
--- a/MoppApp/MoppApp/ru.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/ru.lproj/Localizable.strings
@@ -243,9 +243,9 @@
"nfc-sign-doc" = "Подписать документ";
"nfc-sign-done" = "Подпись добавлена";
"nfc-auth-failed" = "Идентификация личности по карте не удалась";
-"nfc-sign-failed" = "Failed to sign document with ID-card";
+"nfc-sign-failed" = "Не удалось подписать контейнер";
"nfc-pin-locked" = "Locked PIN";
-"nfc-cert-parse-failed" = "Certificate parsing failed";
+"nfc-cert-parse-failed" = "Ошибка при анализе сертификата";
"nfc-cert-expired" = "Сертификат с истекшим сроком действия не может быть использован для подписи";
"role-and-address" = "Роль и адрес";
"role-and-address-title" = "Введите свою роль и адрес";
From a1ae10d3ef15a78fe4ed2f0f7fa84079d4de07b1 Mon Sep 17 00:00:00 2001
From: Marten Rebane <54431068+martenrebane@users.noreply.github.com>
Date: Mon, 9 Sep 2024 15:54:54 +0300
Subject: [PATCH 6/7] Update translations
---
MoppApp/MoppApp/LocalizationKeys.swift | 2 ++
MoppApp/MoppApp/NFCSignature.swift | 2 +-
MoppApp/MoppApp/en.lproj/Localizable.strings | 2 ++
MoppApp/MoppApp/et.lproj/Localizable.strings | 2 ++
MoppApp/MoppApp/ru.lproj/Localizable.strings | 2 ++
5 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/MoppApp/MoppApp/LocalizationKeys.swift b/MoppApp/MoppApp/LocalizationKeys.swift
index d5a751ef2..a04ee79e7 100644
--- a/MoppApp/MoppApp/LocalizationKeys.swift
+++ b/MoppApp/MoppApp/LocalizationKeys.swift
@@ -183,6 +183,8 @@ enum LocKey : String
case nfcPinLocked = "nfc-pin-locked"
case nfcCertParseFailed = "nfc-cert-parse-failed"
case nfcCertExpired = "nfc-cert-expired"
+ case nfcWrongPin1 = "nfc-wrong-pin1"
+ case nfcWrongPin2 = "nfc-wrong-pin2"
case containerSignTitle = "container-sign-title"
case containerEncryptionTitle = "container-encryption-title"
case containerDecryptionTitle = "container-decryption-title"
diff --git a/MoppApp/MoppApp/NFCSignature.swift b/MoppApp/MoppApp/NFCSignature.swift
index 63c1131ef..9c21072ea 100644
--- a/MoppApp/MoppApp/NFCSignature.swift
+++ b/MoppApp/MoppApp/NFCSignature.swift
@@ -188,7 +188,7 @@ class NFCSignature : NSObject, NFCTagReaderSessionDelegate {
switch error.attemptsLeft {
case 0: setSessionMessage(L(.pin2BlockedAlert), invalidate: true)
case 1: setSessionMessage(L(.wrongPin2Single), invalidate: true)
- default: setSessionMessage(L(.wrongPin2, [error.attemptsLeft]), invalidate: true)
+ default: setSessionMessage(L(.nfcWrongPin2, [error.attemptsLeft]), invalidate: true)
}
} catch let error as RuntimeError {
printLog("\nRIA.NFC - RuntimeError \(error.msg)")
diff --git a/MoppApp/MoppApp/en.lproj/Localizable.strings b/MoppApp/MoppApp/en.lproj/Localizable.strings
index ca5006af8..bc728804b 100755
--- a/MoppApp/MoppApp/en.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/en.lproj/Localizable.strings
@@ -246,6 +246,8 @@
"nfc-pin-locked" = "Locked PIN";
"nfc-cert-parse-failed" = "Certificate parsing failed";
"nfc-cert-expired" = "An expired certificate cannot be used for signing";
+"nfc-wrong-pin2" = "Wrong PIN2. Remaining attempts: %d";
+"nfc-wrong-pin1" = "Wrong PIN1. Remaining attempts: %d";
"role-and-address" = "Role and address";
"role-and-address-title" = "Enter your role and address info";
"role-and-address-role-title" = "Role / resolution";
diff --git a/MoppApp/MoppApp/et.lproj/Localizable.strings b/MoppApp/MoppApp/et.lproj/Localizable.strings
index 490bafa28..4923d63cd 100755
--- a/MoppApp/MoppApp/et.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/et.lproj/Localizable.strings
@@ -247,6 +247,8 @@
"nfc-pin-locked" = "Locked PIN";
"nfc-cert-parse-failed" = "Viga sertifikaadi parsimisel";
"nfc-cert-expired" = "Aegunud sertifikaati ei saa kasutada allkirjastamiseks";
+"nfc-wrong-pin2" = "Vale PIN2. Katseid jäänud: %d";
+"nfc-wrong-pin1" = "Vale PIN1. Katseid jäänud: %d";
"role-and-address" = "Roll ja aadress";
"role-and-address-title" = "Sisesta oma roll ja aadress";
"role-and-address-role-title" = "Roll / resolutsioon";
diff --git a/MoppApp/MoppApp/ru.lproj/Localizable.strings b/MoppApp/MoppApp/ru.lproj/Localizable.strings
index 5b809c1af..e8585d97d 100644
--- a/MoppApp/MoppApp/ru.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/ru.lproj/Localizable.strings
@@ -247,6 +247,8 @@
"nfc-pin-locked" = "Locked PIN";
"nfc-cert-parse-failed" = "Ошибка при анализе сертификата";
"nfc-cert-expired" = "Сертификат с истекшим сроком действия не может быть использован для подписи";
+"nfc-wrong-pin2" = "Неверный PIN2-код. Оставшиеся попытки: %d";
+"nfc-wrong-pin1" = "Неверный PIN1-код. Оставшиеся попытки: %d";
"role-and-address" = "Роль и адрес";
"role-and-address-title" = "Введите свою роль и адрес";
"role-and-address-role-title" = "Роль / pезолюция";
From fbf9d161025b702fb62065f3453122182486b9b0 Mon Sep 17 00:00:00 2001
From: Marten Rebane <54431068+martenrebane@users.noreply.github.com>
Date: Wed, 4 Sep 2024 01:05:30 +0300
Subject: [PATCH 7/7] Add NFC CAN number message
---
.../xcschemes/xcschememanagement.plist | 4 +-
MoppApp/MoppApp/LocalizationKeys.swift | 2 +
MoppApp/MoppApp/NFCEditViewController.swift | 42 ++++++++++++++++---
MoppApp/MoppApp/TokenFlow.storyboard | 18 ++++----
MoppApp/MoppApp/en.lproj/Localizable.strings | 2 +
MoppApp/MoppApp/et.lproj/Localizable.strings | 4 +-
MoppApp/MoppApp/ru.lproj/Localizable.strings | 2 +
.../xcschemes/xcschememanagement.plist | 2 +-
8 files changed, 57 insertions(+), 19 deletions(-)
diff --git a/CryptoLib/CryptoLib.xcodeproj/xcuserdata/martenr.xcuserdatad/xcschemes/xcschememanagement.plist b/CryptoLib/CryptoLib.xcodeproj/xcuserdata/martenr.xcuserdatad/xcschemes/xcschememanagement.plist
index 70305072b..0ea84e679 100644
--- a/CryptoLib/CryptoLib.xcodeproj/xcuserdata/martenr.xcuserdatad/xcschemes/xcschememanagement.plist
+++ b/CryptoLib/CryptoLib.xcodeproj/xcuserdata/martenr.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -7,12 +7,12 @@
CryptoLib.xcscheme_^#shared#^_
orderHint
- 4
+ 6
cdoc.xcscheme_^#shared#^_
orderHint
- 5
+ 4
diff --git a/MoppApp/MoppApp/LocalizationKeys.swift b/MoppApp/MoppApp/LocalizationKeys.swift
index e049054d7..d890cfc6e 100644
--- a/MoppApp/MoppApp/LocalizationKeys.swift
+++ b/MoppApp/MoppApp/LocalizationKeys.swift
@@ -169,6 +169,8 @@ enum LocKey : String
case nfcTitle = "nfc-title"
case nfcCANTitle = "nfc-can-title"
case nfcDeviceNoSupport = "nfc-device-no-support"
+ case nfcCanLocation = "nfc-can-location"
+ case nfcIncorrectLength = "nfc-incorrect-length"
case nfcHoldNear = "nfc-hold-near"
case nfcMultipleCards = "nfc-multiple-cards"
case nfcInvalidTag = "nfc-invalid-tag"
diff --git a/MoppApp/MoppApp/NFCEditViewController.swift b/MoppApp/MoppApp/NFCEditViewController.swift
index 1c0973b8a..8902dda47 100644
--- a/MoppApp/MoppApp/NFCEditViewController.swift
+++ b/MoppApp/MoppApp/NFCEditViewController.swift
@@ -35,7 +35,7 @@ class NFCEditViewController : MoppViewController, TokenFlowSigning {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var canTextLabel: UILabel!
@IBOutlet weak var pinTextLabel: UILabel!
- @IBOutlet weak var canTextErrorLabel: UILabel!
+ @IBOutlet weak var canTextInfoLabel: ScaledLabel!
@IBOutlet weak var pinTextErrorLabel: UILabel!
@IBOutlet weak var cancelButton: MoppButton!
@IBOutlet weak var signButton: MoppButton!
@@ -56,8 +56,8 @@ class NFCEditViewController : MoppViewController, TokenFlowSigning {
pinTextLabel.text = L(.pin2TextfieldLabel)
pinTextLabel.isHidden = notAvailable
- canTextErrorLabel.text = ""
- canTextErrorLabel.isHidden = true
+ setCANDefaultText()
+
pinTextErrorLabel.text = ""
pinTextErrorLabel.isHidden = true
@@ -84,6 +84,20 @@ class NFCEditViewController : MoppViewController, TokenFlowSigning {
tapGR.addTarget(self, action: #selector(cancelAction))
view.addGestureRecognizer(tapGR)
}
+
+ override func viewDidAppear(_ animated: Bool) {
+ super.viewDidAppear(animated)
+
+ if let canNumber = canTextField.text {
+ if !canNumber.isEmpty && canNumber.count != 6 {
+ setCANErrorText()
+ } else {
+ setCANDefaultText()
+ }
+ } else {
+ setCANDefaultText()
+ }
+ }
@objc func dismissKeyboard(_ notification: NSNotification) {
pinTextField.resignFirstResponder()
@@ -196,6 +210,18 @@ class NFCEditViewController : MoppViewController, TokenFlowSigning {
override func keyboardWillHide(notification: NSNotification) {
hideKeyboard(scrollView: scrollView)
}
+
+ func setCANDefaultText() {
+ canTextInfoLabel.text = L(.nfcCanLocation)
+ canTextInfoLabel.isHidden = false
+ canTextInfoLabel.textColor = UIColor.moppText
+ }
+
+ func setCANErrorText() {
+ canTextInfoLabel.text = L(.nfcIncorrectLength)
+ canTextInfoLabel.isHidden = false
+ canTextInfoLabel.textColor = UIColor.moppError
+ }
}
extension NFCEditViewController : UITextFieldDelegate {
@@ -226,12 +252,17 @@ extension NFCEditViewController : UITextFieldDelegate {
func textFieldDidEndEditing(_ textField: UITextField) {
if textField.accessibilityIdentifier == "nfcCanField" {
if let can = textField.text {
+ if !can.isEmpty && can.count != 6 {
+ setCANErrorText()
+ } else {
+ setCANDefaultText()
+ }
do {
let symKey = try EncryptedDataUtil.getSymmetricKey(fileName: NFCEditViewController.nfcCANKeyFilename)
if let encryptedKey = EncryptedDataUtil.encryptSecret(can, with: symKey) {
_ = KeychainUtil.save(key: NFCEditViewController.nfcCANKey, info: encryptedKey, withPasscodeSetOnly: true)
} else {
- printLog("Encryption failed for 'can' string")
+ printLog("Encryption failed for 'CAN' string")
}
} catch {
do {
@@ -249,8 +280,7 @@ extension NFCEditViewController : UITextFieldDelegate {
}
} else {
KeychainUtil.remove(key: NFCEditViewController.nfcCANKey)
- canTextErrorLabel.text = ""
- canTextErrorLabel.isHidden = true
+ setCANDefaultText()
removeViewBorder(view: textField)
UIAccessibility.post(notification: .layoutChanged, argument: canTextField)
}
diff --git a/MoppApp/MoppApp/TokenFlow.storyboard b/MoppApp/MoppApp/TokenFlow.storyboard
index ca025fa8c..7b45bda3f 100644
--- a/MoppApp/MoppApp/TokenFlow.storyboard
+++ b/MoppApp/MoppApp/TokenFlow.storyboard
@@ -3,7 +3,7 @@
-
+
@@ -1418,7 +1418,7 @@
-
+
-
+
diff --git a/MoppApp/MoppApp/en.lproj/Localizable.strings b/MoppApp/MoppApp/en.lproj/Localizable.strings
index 284f2c851..164e2e911 100755
--- a/MoppApp/MoppApp/en.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/en.lproj/Localizable.strings
@@ -233,6 +233,8 @@
"nfc-title" = "Enter your ID-card access number (CAN) and PIN2 code to sign with ID-card";
"nfc-can-title" = "ID-card access number (CAN)";
"nfc-device-no-support" = "This device does not support contactless connection or NFC is turned off.";
+"nfc-can-location" = "The 6-digit number is located under the document photo";
+"nfc-incorrect-length" = "CAN-code must be 6 digits long";
"nfc-hold-near" = "Hold your phone near the ID-card";
"nfc-multiple-cards" = "More than 1 NFC tag is detected. Please remove all NFC tags and try again.";
"nfc-invalid-tag" = "Invalid NFC tag";
diff --git a/MoppApp/MoppApp/et.lproj/Localizable.strings b/MoppApp/MoppApp/et.lproj/Localizable.strings
index 1c185d3d2..15dfd0ccb 100755
--- a/MoppApp/MoppApp/et.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/et.lproj/Localizable.strings
@@ -234,8 +234,10 @@
"nfc-title" = "ID-kaardiga allkirjastamiseks sisesta oma ID-kaardi ligipääsu number (CAN) ja PIN2 kood";
"nfc-can-title" = "ID-kaardi ligipääsu number (CAN)";
"nfc-device-no-support" = "See seade ei toeta kontaktivaba ühendust või NFC on välja lülitatud.";
+"nfc-can-location" = "6-kohaline number asub dokumendil foto all";
+"nfc-incorrect-length" = "Ligipääsu number (CAN) peab olema 6-kohaline";
"nfc-hold-near" = "Hoia ID-kaarti telefoni lähedal";
-"nfc-multiple-cards" = "Tuvastatud on rohkem kui üks NFC-element. Eemalda kõik NFC-elemendiga esemed ja proovi uuesti.";
+"nfc-multiple-cards" = "Tuvastatud on rohkem kui üks NFC-element. Eemalda kõik NFC-elemendiga esemed ja proovi uuesti.";
"nfc-invalid-tag" = "Kehtetu NFC-element";
"nfc-unable-connect" = "Kontaktivaba ühendust ei saa luua";
"nfc-auth" = "ID-kaardiga kontaktivaba ühenduse loomine";
diff --git a/MoppApp/MoppApp/ru.lproj/Localizable.strings b/MoppApp/MoppApp/ru.lproj/Localizable.strings
index 6ba88e800..41be69aff 100644
--- a/MoppApp/MoppApp/ru.lproj/Localizable.strings
+++ b/MoppApp/MoppApp/ru.lproj/Localizable.strings
@@ -234,6 +234,8 @@
"nfc-title" = "Чтобы подписать с помощью ID-карты, введите ее номер доступа (CAN) и PIN2-код";
"nfc-can-title" = "Номер доступа ID-карты (CAN)";
"nfc-device-no-support" = "Данное устройство не поддерживает бесконтактное соединение или NFC отключен";
+"nfc-can-location" = "6-значный номер находится под фотографией на документе";
+"nfc-incorrect-length" = "Номер доступа (CAN) должен состоять из 6-цифр";
"nfc-hold-near" = "Удерживайте ID-карту рядом с телефоном";
"nfc-multiple-cards" = "Обнаружено более одной NFC-метки. Удалите все объекты с NFC-элементом (NFC-метки) и попробуйте снова.";
"nfc-invalid-tag" = "Недействительная NFC-метка";
diff --git a/SkSigningLib/SkSigningLib.xcodeproj/xcuserdata/martenr.xcuserdatad/xcschemes/xcschememanagement.plist b/SkSigningLib/SkSigningLib.xcodeproj/xcuserdata/martenr.xcuserdatad/xcschemes/xcschememanagement.plist
index c136c2ca3..41438bc41 100644
--- a/SkSigningLib/SkSigningLib.xcodeproj/xcuserdata/martenr.xcuserdatad/xcschemes/xcschememanagement.plist
+++ b/SkSigningLib/SkSigningLib.xcodeproj/xcuserdata/martenr.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -7,7 +7,7 @@
SkSigningLib.xcscheme_^#shared#^_
orderHint
- 4
+ 5