[gnome-keysign: 40/65] avahi and bluetooth return only the data and not the code
- From: Gitlab System User <gitlab src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keysign: 40/65] avahi and bluetooth return only the data and not the code
- Date: Tue, 3 Oct 2017 11:40:15 +0000 (UTC)
commit c9b665fbd2f545b5cc239764e3a17cac708db48b
Author: RyuzakiKK <aasonykk gmail com>
Date: Mon Aug 21 11:41:18 2017 +0200
avahi and bluetooth return only the data and not the code
The return of the code was initially used because the code was the one
to display to the user as the "security code". But now with bluetooth we
only add the "data" in the QR, so his "code" is never used.
keysign/avahioffer.py | 4 ++--
keysign/bluetoothoffer.py | 9 ++++++---
keysign/send.py | 5 ++---
tests/test_bluetooth.py | 6 ++++--
4 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/keysign/avahioffer.py b/keysign/avahioffer.py
index ecc2c0d..4b2f749 100755
--- a/keysign/avahioffer.py
+++ b/keysign/avahioffer.py
@@ -39,7 +39,7 @@ if __name__ == "__main__" and __package__ is None:
from .__init__ import __version__
from .gpgmh import get_usable_keys, get_public_key_data
from .i18n import _
-from .util import mac_generate, format_fingerprint
+from .util import mac_generate
from . import Keyserver
log = logging.getLogger(__name__)
@@ -64,7 +64,7 @@ class AvahiHTTPOffer:
log.info("Requesting to start")
self.keyserver.start()
- return format_fingerprint(self.key.fingerprint), discovery_info
+ return discovery_info
def stop(self):
"Stops offering the key"
diff --git a/keysign/bluetoothoffer.py b/keysign/bluetoothoffer.py
index c802b0d..8a3df72 100644
--- a/keysign/bluetoothoffer.py
+++ b/keysign/bluetoothoffer.py
@@ -78,7 +78,7 @@ class BluetoothOffer:
else:
log.error("An unexpected error occurred %s", e.get_dbus_name())
self.code = None
- return None, None
+ return None
if self.server_socket is None:
self.server_socket = BluetoothSocket(RFCOMM)
self.server_socket.bind(("", 0))
@@ -88,7 +88,7 @@ class BluetoothOffer:
port = self.server_socket.getsockname()[1]
log.info("BT Code: %s %s", code, port)
bt_data = "BT={0};PT={1}".format(code, port)
- return code, bt_data
+ return bt_data
def stop(self):
log.debug("Stopping bt receive")
@@ -121,8 +121,11 @@ def main(args):
file_key_data = get_public_key_data(key.fingerprint)
hmac = mac_generate(key.fingerprint.encode('ascii'), file_key_data)
offer = BluetoothOffer(key)
- code, data = offer.allocate_code()
+ data = offer.allocate_code()
if data:
+ # getting the code from "BT=code;...."
+ code = data.split("=", 1)[1]
+ code = code.split(";", 1)[0]
port = data.rsplit("=", 1)[1]
offer.start().addCallback(_received)
print("Offering key: {}".format(key))
diff --git a/keysign/send.py b/keysign/send.py
index 771845b..94f416d 100755
--- a/keysign/send.py
+++ b/keysign/send.py
@@ -92,13 +92,12 @@ class SendApp:
# Start network services
discovery_list = []
self.a_offer = AvahiHTTPOffer(self.key)
- a_info = self.a_offer.start()
- code, a_data = a_info
+ a_data = self.a_offer.start()
discovery_list.append(a_data)
bt_data = None
if BluetoothOffer:
self.bt_offer = BluetoothOffer(self.key)
- _, bt_data = self.bt_offer.allocate_code()
+ bt_data = self.bt_offer.allocate_code()
if bt_data:
discovery_list.append(bt_data)
discovery_data = ";".join(discovery_list)
diff --git a/tests/test_bluetooth.py b/tests/test_bluetooth.py
index dbe2829..4c3b3fb 100644
--- a/tests/test_bluetooth.py
+++ b/tests/test_bluetooth.py
@@ -45,8 +45,10 @@ def test_bt():
hmac = mac_generate(key.fingerprint.encode('ascii'), file_key_data)
# Start offering the key
offer = BluetoothOffer(key)
- info = yield offer.allocate_code()
- code, data = info
+ data = yield offer.allocate_code()
+ # getting the code from "BT=code;...."
+ code = data.split("=", 1)[1]
+ code = code.split(";", 1)[0]
port = int(data.rsplit("=", 1)[1])
offer.start()
receive = BluetoothReceive(port)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]