Project

General

Profile

Actions

Bug #5060

closed

mandatory Crypto module: pycrypto or pycryptodome?

Added by chertault about 3 years ago. Updated about 3 years ago.

Status:
Resolved
Priority:
High
Assignee:
Category:
-
Target version:
-
Start date:
03/05/2021
Due date:
% Done:

100%

Spec Reference:

Description

Hi,

With last master version, I have an issue regarding Crypto.AES when writing an USIM (with Ki and Op), using pycrypto or pycryptodome:

./pySim-prog.py -p 0 -a xxxx -x xxx -y xxx -i xxxx -s xxx --op=xxx -k xxxx --acc=xxx -n xxx

  • With pycrypto, the error is:
Card programming failed with an execption:
---------------------8<---------------------
Traceback (most recent call last):
  File "/tmp/pysim/pySim-prog.py", line 750, in <module>
    rc = process_card(opts, first, card_handler)
  File "/tmp/pysim/pySim-prog.py", line 673, in process_card
    cp = gen_parameters(opts)
  File "/tmp/pysim/pySim-prog.py", line 445, in gen_parameters
    opc = derive_milenage_opc(ki, opts.op)
  File "/tmp/pysim/pySim/utils.py", line 247, in derive_milenage_opc
    aes = AES.new(h2b(ki_hex))
  File "/home/vagrant/.virtualenvs/py3-ansible2.9/lib/python3.8/site-packages/Crypto/Cipher/AES.py", line 95, in new
    return AESCipher(key, *args, **kwargs)
  File "/home/vagrant/.virtualenvs/py3-ansible2.9/lib/python3.8/site-packages/Crypto/Cipher/AES.py", line 59, in __init__
    blockalgo.BlockAlgo.__init__(self, _AES, key, *args, **kwargs)
  File "/home/vagrant/.virtualenvs/py3-ansible2.9/lib/python3.8/site-packages/Crypto/Cipher/blockalgo.py", line 141, in __init__
    self._cipher = factory.new(key, *args, **kwargs)
TypeError: argument 1 must be read-only bytes-like object, not bytearray

  • With pycryptodome, the error is:
Ready for Programming: Insert card now (or CTRL-C to cancel)
Autodetected card type: sysmoUSIM-SJS1

Card programming failed with an execption:
---------------------8<---------------------
Traceback (most recent call last):
  File "/tmp/pysim/pySim-prog.py", line 750, in <module>
    rc = process_card(opts, first, card_handler)
  File "/tmp/pysim/pySim-prog.py", line 673, in process_card
    cp = gen_parameters(opts)
  File "/tmp/pysim/pySim-prog.py", line 445, in gen_parameters
    opc = derive_milenage_opc(ki, opts.op)
  File "/tmp/pysim/pySim/utils.py", line 247, in derive_milenage_opc
    aes = AES.new(h2b(ki_hex))
TypeError: new() missing 1 required positional argument: 'mode'
---------------------8<---------------------

Programming failed: Remove card from reader

In both case, it doesnt work !

Actions

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)