From 8991a1d03a9021d7d2e43acd2e9c526cc3e1555f Mon Sep 17 00:00:00 2001 From: Kushal Das Date: Wed, 19 Apr 2023 18:23:59 +0200 Subject: [PATCH] Fixes #74 detects key and Yubikey type --- changelog.md | 9 +++++++++ pyproject.toml | 2 +- src/tumpa/CardDetailsView.qml | 32 ++++++++++++++++---------------- src/tumpa/app.py | 17 ++++++++++++++--- 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/changelog.md b/changelog.md index 4da7eb7..0873e9a 100644 --- a/changelog.md +++ b/changelog.md @@ -2,8 +2,17 @@ ## Unreleased +## [0.10.0] - 2023-04-19 + +### Fixed + +- Fixed #74 detect key and Yubikey type before upload. +- Removes extra print statements. + ## [0.9.0] - 2023-04-18 +### Fixed + - Fixes key generation window color. - Cv25519 is the default key type. diff --git a/pyproject.toml b/pyproject.toml index 35a6f78..cfc1b0f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.briefcase] project_name = "tumpa" bundle = "in.kushaldas" -version = "0.9.0" +version = "0.10.0" url = "https://tumpa.rocks" license = "GNU General Public License v3 or later (GPLv3+)" author = 'Kushal Das' diff --git a/src/tumpa/CardDetailsView.qml b/src/tumpa/CardDetailsView.qml index c06db76..8d7ed9e 100644 --- a/src/tumpa/CardDetailsView.qml +++ b/src/tumpa/CardDetailsView.qml @@ -42,20 +42,20 @@ Rectangle { } } - ModalDangerButton { - id: formatKeyBtn - anchors { - bottom: root.bottom - right: root.right - rightMargin: 24 - bottomMargin: 24 - } - - labelString: qsTr("Reset smartcard") - - onClicked: { - // TODO: reset the smartcard - console.log("Reset smartcard button clicked") - } - } + // ModalDangerButton { + // id: formatKeyBtn + // anchors { + // bottom: root.bottom + // right: root.right + // rightMargin: 24 + // bottomMargin: 24 + // } + + // labelString: qsTr("Reset smartcard") + + // onClicked: { + // // TODO: reset the smartcard + // console.log("Reset smartcard button clicked") + // } + // } } diff --git a/src/tumpa/app.py b/src/tumpa/app.py index 654f4ee..83e3e68 100644 --- a/src/tumpa/app.py +++ b/src/tumpa/app.py @@ -286,7 +286,6 @@ def generateKey( whichsubkeys += 2 if authentication: whichsubkeys += 4 - print(f"{whichsubkeys=}") # Now feed in the data to the other thread self.kt.setup(uids, password, whichsubkeys, key_algo, expiry, canexpire) # Start the thread @@ -311,7 +310,6 @@ def removeKey(self, fingerprint): def get_subkey_types(self, fingerprint: str): key = self.ks.get_key(fingerprint) data = available_subkeys(key) - print(f"{data=}") e, s, a = data # TODO: the stupid hack to pass data to QML subkeytypes.e = e @@ -377,6 +375,20 @@ def uploadKey( ): # First get the key key = self.ks.get_key(fingerprint) + + # First check for the card to be accessable + if not rjce.is_smartcard_connected(): + return "Failed to find/access Yubikey. Plug it again if possible." + # Now check the version + version = rjce.get_card_version() + key_algos = rjce.get_key_cipher_details(key.keyvalue) + keytype = "RSA" + for key_details in key_algos: + if key_details[1] in ["EdDSA", "ECDH"]: + keytype = "Cv25519" + # Yubikey4 does not support Cv25519 keys + if keytype == "Cv25519" and version[0] < 5: + return "Please use Yubikey5 or above for Cv25519 Keys." try: # reset the yubikey result = rjce.reset_yubikey() @@ -449,7 +461,6 @@ def available_subkeys(key: Key) -> Tuple[bool, bool, bool]: got_auth = False # Loop over on the subkeys for subkey in subkeys_sorted: - print(subkey) if subkey["revoked"]: continue if not subkey["expiration"]: