Change in pysim[master]: fix TypeError in derive_milenage_opc()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Fri Mar 5 20:39:12 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/23258 )

Change subject: fix TypeError in derive_milenage_opc()
......................................................................

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
---
M pySim/utils.py
1 file changed, 5 insertions(+), 3 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



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 @@
 	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):
 	"""

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/23258
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: If2a727ed417ffd56c0f7d7b4e9f633d67fde5ced
Gerrit-Change-Number: 23258
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210305/267a7ef1/attachment.htm>


More information about the gerrit-log mailing list