From d0c6981410a234734b24e15ec2e9dfd3d0e071fd Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Mon, 31 Jan 2022 19:25:36 -0800 Subject: [PATCH] use bytes.fromhex instead... --- lora_comms.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lora_comms.py b/lora_comms.py index 10e291c..e757e1a 100644 --- a/lora_comms.py +++ b/lora_comms.py @@ -25,7 +25,6 @@ import os import unittest -from binascii import a2b_hex from ctypes import Structure, POINTER, CFUNCTYPE, pointer, sizeof from ctypes import c_uint8, c_uint16, c_ssize_t, c_size_t, c_uint64, c_int from ctypes import CDLL @@ -233,16 +232,16 @@ class TestX25519(unittest.TestCase): def test_rfc7748_6_1(self): # KAT from https://datatracker.ietf.org/doc/html/rfc7748#section-6.1 - apriv = a2b_hex('77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a') + apriv = bytes.fromhex('77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a') akey = X25519(apriv) - self.assertEqual(akey.getpub(), a2b_hex('8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a')) + self.assertEqual(akey.getpub(), bytes.fromhex('8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a')) - bpriv = a2b_hex('5dab087e624a8a4b79e17f8b83800ee66f3bb1292618b6fd1c2f8b27ff88e0eb') + bpriv = bytes.fromhex('5dab087e624a8a4b79e17f8b83800ee66f3bb1292618b6fd1c2f8b27ff88e0eb') bkey = X25519(bpriv) - self.assertEqual(bkey.getpub(), a2b_hex('de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f')) + self.assertEqual(bkey.getpub(), bytes.fromhex('de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f')) - ss = a2b_hex('4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742') + ss = bytes.fromhex('4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742') self.assertEqual(akey.dh(bkey.getpub()), ss) self.assertEqual(bkey.dh(akey.getpub()), ss)