aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2021-03-05 18:30:23 +0100
committerlaforge <laforge@osmocom.org>2021-03-05 20:38:50 +0000
commiteab8d2adf772e0da8c363ec0f68c155797675eca (patch)
treef3e68954f00f0e211cdf9a8261e66b45bd27feb2
parentb2edd1447520c884eff24aad6181da7199dad8d6 (diff)
fix TypeError in derive_milenage_opc()
In 4f6ca43e1f6726f00cfc91ff6d17db6878316c4d we started to use the bytearray type as 'b' type, but PyCrypto insists on getting a bytes type. This fixes the following Exception: TypeError: argument 1 must be read-only bytes-like object, not bytearray Change-Id: If2a727ed417ffd56c0f7d7b4e9f633d67fde5ced Closes: OS#5060
-rw-r--r--pySim/utils.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/pySim/utils.py b/pySim/utils.py
index 5320b59..13e62f0 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -244,9 +244,11 @@ def derive_milenage_opc(ki_hex, op_hex):
from pySim.utils import b2h
# We pass in hex string and now need to work on bytes
- aes = AES.new(h2b(ki_hex))
- opc_bytes = aes.encrypt(h2b(op_hex))
- return b2h(strxor(opc_bytes, h2b(op_hex)))
+ ki_bytes = bytes(h2b(ki_hex))
+ op_bytes = bytes(h2b(op_hex))
+ aes = AES.new(ki_bytes)
+ opc_bytes = aes.encrypt(op_bytes)
+ return b2h(strxor(opc_bytes, op_bytes))
def calculate_luhn(cc):
"""