Hoernchen uploaded patch set #2 to this change.

View Change

GP: fix kcb for non block aligned keys

how encrypt_key() pads a kcv:
len(key) % blocksize bytes
what it should do to actually do it right:
blocksize - len(key) % blocksize
so the plaintext handed to the cipher was only block aligned by luck as
long as the key length happened to be a multiple of half the block size.

And of course decrypt_key() did not invert encrypt_key() at all,
the clear text length of GP CardSpec v2.3 Table 11-70 precedes the
ENCRYPTED kcv, but it was parsed out of the DECRYPTED data, and the
length byte itself was fed to the cipher along with the cryptogram.

Fix this up with a helper and tests so it is actually usable.

Change-Id: I02b4f2ed948c31e1741e40f0226fb49757fa2570
---
M pySim/global_platform/scp.py
M tests/unittests/test_globalplatform.py
2 files changed, 48 insertions(+), 6 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/00/43200/2

To view, visit change 43200. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I02b4f2ed948c31e1741e40f0226fb49757fa2570
Gerrit-Change-Number: 43200
Gerrit-PatchSet: 2
Gerrit-Owner: Hoernchen <ewild@sysmocom.de>
Gerrit-CC: Jenkins Builder