laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/35800?usp=email )


Change subject: global_platform: Fix --key-id argument
......................................................................

global_platform: Fix --key-id argument

The key-id is actually a 7-bit integer and on the wire the 8th bit
has a special meaning which can be derived automatically.

Let's unburden the user from explicitly encoding that 8th bit and
instead set it automatically.

Change-Id: I8da37aa8fd064e6d35ed29a70f5d7a0e9060be3a
---
M pySim/global_platform/__init__.py
1 file changed, 21 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/00/35800/1

diff --git a/pySim/global_platform/__init__.py 
b/pySim/global_platform/__init__.py
index e32b47e..848adba 100644
--- a/pySim/global_platform/__init__.py
+++ b/pySim/global_platform/__init__.py
@@ -522,12 +522,12 @@
             See GlobalPlatform CardSpecification v2.3 Section 11.8 for details.

             Example (SCP80 KIC/KID/KIK):
-                put_key --key-version-nr 1 --key-id 0x81    --key-type aes 
--key-data 000102030405060708090a0b0c0d0e0f
+                put_key --key-version-nr 1 --key-id 0x01    --key-type aes 
--key-data 000102030405060708090a0b0c0d0e0f
                                                             --key-type aes 
--key-data 101112131415161718191a1b1c1d1e1f
                                                             --key-type aes 
--key-data 202122232425262728292a2b2c2d2e2f

             Example (SCP81 TLS-PSK/KEK):
-                put_key --key-version-nr 0x40 --key-id 0x81 --key-type tls_psk 
--key-data 303132333435363738393a3b3c3d3e3f
+                put_key --key-version-nr 0x40 --key-id 0x01 --key-type tls_psk 
--key-data 303132333435363738393a3b3c3d3e3f
                                                             --key-type des 
--key-data 404142434445464748494a4b4c4d4e4f

             """
@@ -540,7 +540,10 @@
                 else:
                     kcv = ''
                 kdb.append({'key_type': opts.key_type[i], 'kcb': 
opts.key_data[i], 'kcv': kcv})
-            self.put_key(opts.old_key_version_nr, opts.key_version_nr, 
opts.key_id, kdb)
+            p2 = opts.key_id
+            if len(opts.key_type) > 1:
+                p2 |= 0x80
+            self.put_key(opts.old_key_version_nr, opts.key_version_nr, p2, kdb)

         # Table 11-68: Key Data Field - Format 1 (Basic Format)
         KeyDataBasic = GreedyRange(Struct('key_type'/KeyType,

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35800?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I8da37aa8fd064e6d35ed29a70f5d7a0e9060be3a
Gerrit-Change-Number: 35800
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <[email protected]>
Gerrit-MessageType: newchange

Reply via email to