{"action":"created","issue":{"url":"https://api.github.com/repos/martinpaljak/GlobalPlatformPro/issues/56","repository_url":"https://api.github.com/repos/martinpaljak/GlobalPlatformPro","labels_url":"https://api.github.com/repos/martinpaljak/GlobalPlatformPro/issues/56/labels{/name}","comments_url":"https://api.github.com/repos/martinpaljak/GlobalPlatformPro/issues/56/comments","events_url":"https://api.github.com/repos/martinpaljak/GlobalPlatformPro/issues/56/events","html_url":"https://github.com/martinpaljak/GlobalPlatformPro/issues/56","id":191201724,"number":56,"title":"Bug with host cryptogram calculation in SCP02","user":{"login":"minkyn","id":1875412,"avatar_url":"https://avatars.githubusercontent.com/u/1875412?v=3","gravatar_id":"","url":"https://api.github.com/users/minkyn","html_url":"https://github.com/minkyn","followers_url":"https://api.github.com/users/minkyn/followers","following_url":"https://api.github.com/users/minkyn/following{/other_user}","gists_url":"https://api.github.com/users/minkyn/gists{/gist_id}","starred_url":"https://api.github.com/users/minkyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minkyn/subscriptions","organizations_url":"https://api.github.com/users/minkyn/orgs","repos_url":"https://api.github.com/users/minkyn/repos","events_url":"https://api.github.com/users/minkyn/events{/privacy}","received_events_url":"https://api.github.com/users/minkyn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-23T07:12:43Z","updated_at":"2016-12-07T03:35:05Z","closed_at":null,"body":"I have my custom keyset of ENC, MAC, KEK running under SCP02:\r\n```\r\ngp -d -v --scp 2 --key-enc XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --key-mac YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY --key-kek ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ --list\r\n```\r\n\r\nI got the command output:\r\n```\r\nGlobalPlatformPro v0.3.9-24-g7e62155\r\nRunning on Mac OS X 10.12.1 x86_64, Java 1.8.0_60 by Oracle Corporation\r\nUnlimited crypto policy is NOT installed!\r\nATTENTION: Overriding default keys ...\r\n[DEBUG] PlaintextKeys - static keys: \r\nENC: Ver:0 ID:0 Type:DES3 Len:16 Value:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX KCV: D3A661\r\nMAC: Ver:0 ID:0 Type:DES3 Len:16 Value:YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY KCV: AEE3F5\r\nKEK: Ver:0 ID:0 Type:DES3 Len:16 Value:ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ KCV: FC6828\r\n# Detected readers from JNA2PCSC\r\n[*] ACS ACR 38U-CCID\r\nSCardConnect(\"ACS ACR 38U-CCID\", T=*) -> T=0, 3B9F95801FC78031E073FE2113671192004001000118\r\nSCardBeginTransaction(\"ACS ACR 38U-CCID\")\r\nReader: ACS ACR 38U-CCID\r\nATR: 3B9F95801FC78031E073FE2113671192004001000118\r\nMore information about your card:\r\n    http://smartcard-atr.appspot.com/parse?ATR=3B9F95801FC78031E073FE2113671192004001000118\r\n\r\nA>> T=0 (4+0000) 00A40400 00 \r\nA<< (0017+2) (17ms) 6F0F8407A0000001510000A5049F6501FF 9000\r\n[DEBUG] GlobalPlatform - Auto-detected ISD AID: A0000001510000\r\n[DEBUG] GlobalPlatform - Auto-detected block size: 255\r\nA>> T=0 (4+0008) 80500000 08 2E07ADE6502DC607 00\r\nA<< (0028+2) (15ms) 0000C6D86A1CB20214132002000DFBC91D4F0C9E68060E82EA5C814B 9000\r\n[DEBUG] GlobalPlatform - Host challenge: 2E07ADE6502DC607\r\n[DEBUG] GlobalPlatform - Card challenge: 000DFBC91D4F0C9E\r\n[DEBUG] GlobalPlatform - Card reports SCP02 with version 32 keys\r\n[DEBUG] PlaintextKeys - session keys: \r\nENC: Ver:0 ID:0 Type:DES3 Len:16 Value:AD24EAD378F1365E333FCBE909F3E6D2 KCV: 99BDEA\r\nMAC: Ver:0 ID:0 Type:DES3 Len:16 Value:DCB288C75E7B4970E840FCB56A139507 KCV: 24138C\r\nKEK: Ver:0 ID:0 Type:DES3 Len:16 Value:9E0E9B5D4B76B102ED0FCB6A1E3F0166 KCV: 4B590A\r\n[DEBUG] GlobalPlatform - Verified card cryptogram: 68060E82EA5C814B\r\n[DEBUG] GlobalPlatform - Calculated host cryptogram: 9C650864521157D8\r\nA>> T=0 (4+0016) 84820100 10 9C650864521157D8126595F7B75ABC18\r\nA<< (0000+2) (8ms) 6982\r\npro.javacard.gp.GPException: External authenticate failed SW: 6982\r\n\tat pro.javacard.gp.GPException.check(GPException.java:66)\r\n\tat pro.javacard.gp.GlobalPlatform.openSecureChannel(GlobalPlatform.java:602)\r\n\tat pro.javacard.gp.GPTool.main(GPTool.java:465)\r\nExternal authenticate failed SW: 6982\r\n```\r\n\r\nI ran with other tools (e.g. GPShell) and there is nothing wrong with the external authentication. I'm 100% sure of the correctness of my keyset, because when I manually changed that, I would get:\r\n```\r\n!!! DO NOT RE-TRY THE SAME COMMAND/KEYS OR YOU MAY BRICK YOUR CARD !!!\r\n\tat pro.javacard.gp.GlobalPlatform.giveStrictWarning(GlobalPlatform.java:207)\r\n\tat pro.javacard.gp.GlobalPlatform.openSecureChannel(GlobalPlatform.java:583)\r\n\tat pro.javacard.gp.GPTool.main(GPTool.java:465)\r\nSTRICT WARNING: Card cryptogram invalid!\r\n```\r\n\r\nCan you double check the host cryptogram logic please?"},"comment":{"url":"https://api.github.com/repos/martinpaljak/GlobalPlatformPro/issues/comments/265346547","html_url":"https://github.com/martinpaljak/GlobalPlatformPro/issues/56#issuecomment-265346547","issue_url":"https://api.github.com/repos/martinpaljak/GlobalPlatformPro/issues/56","id":265346547,"user":{"login":"minkyn","id":1875412,"avatar_url":"https://avatars.githubusercontent.com/u/1875412?v=3","gravatar_id":"","url":"https://api.github.com/users/minkyn","html_url":"https://github.com/minkyn","followers_url":"https://api.github.com/users/minkyn/followers","following_url":"https://api.github.com/users/minkyn/following{/other_user}","gists_url":"https://api.github.com/users/minkyn/gists{/gist_id}","starred_url":"https://api.github.com/users/minkyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minkyn/subscriptions","organizations_url":"https://api.github.com/users/minkyn/orgs","repos_url":"https://api.github.com/users/minkyn/repos","events_url":"https://api.github.com/users/minkyn/events{/privacy}","received_events_url":"https://api.github.com/users/minkyn/received_events","type":"User","site_admin":false},"created_at":"2016-12-07T03:35:05Z","updated_at":"2016-12-07T03:35:05Z","body":"Looks like it's the card that has transient errors. It is working now ...."}}
{"actor":{"display_login":"minkyn"}}