dmrtd icon indicating copy to clipboard operation
dmrtd copied to clipboard

AESCipher decrypt error

Open Parzivalxx opened this issue 8 months ago • 11 comments

Hi, I am getting an error when using this package on PACE-enabled passports. The following shows the error logs:

I/flutter (22095): icc FINE: 2024-06-25 15:45:16.937965: Transceiving to ICC: C-APDU(CLA:10 INS:86 P1:00 P2:00 Le:256 Lc:2 Data:7c00)
I/flutter (22095): icc FINE: 2024-06-25 15:45:16.938715: Sending 8 byte(s) to ICC: data='10860000027c0000'
I/flutter (22095): icc FINE: 2024-06-25 15:45:17.109588: Received 38 byte(s) from ICC
I/flutter (22095): icc FINE: 2024-06-25 15:45:17.110085:  data='7c228020e99c8092a8c27b9f97a7d4ed2c5b1d318880c694208166623c0b7d57b31976e39000'
I/flutter (22095): icc FINE: 2024-06-25 15:45:17.110480: Received response from ICC: sw=9000 data_len=36
I/flutter (22095): icc FINE: 2024-06-25 15:45:17.110747:  data=7c228020e99c8092a8c27b9f97a7d4ed2c5b1d318880c694208166623c0b7d57b31976e3
I/flutter (22095): pace FINE: 2024-06-25 15:45:17.110950: Got PACE step 1 SUCCESSFUL response from ICC
I/flutter (22095): ResponseAPDUStep1Pace FINER: 2024-06-25 15:45:17.111158: ResponseAPDUStep1Pace data: 7c228020e99c8092a8c27b9f97a7d4ed2c5b1d318880c694208166623c0b7d57b31976e3
I/flutter (22095): ResponseAPDUStep1Pace FINER: 2024-06-25 15:45:17.111744: Pace.step1; Response data contains dynamic authentication data
I/flutter (22095): ResponseAPDUStep1Pace FINER: 2024-06-25 15:45:17.111960: Nonce: e99c8092a8c27b9f97a7d4ed2c5b1d318880c694208166623c0b7d57b31976e3
I/flutter (22095): pace FINE: 2024-06-25 15:45:17.112137: PACE.decryptNonce; Decrypting nonce ...
I/flutter (22095): pace FINER: 2024-06-25 15:45:17.112432: PACE.decryptNonce; Nonce: e99c8092a8c27b9f97a7d4ed2c5b1d318880c694208166623c0b7d57b31976e3, Pace protocol: OIEPaceProtocol: 0.4.0.127.0.7.2.2.4.2.4, id-PACE-ECDH-GM-AES-CBC-CMAC-256, [0, 4, 0, 127, 0, 7, 2, 2, 4, 2, 4], CipherAlgorithm: CipherAlgorithm.AES, KEY_LENGTH: KEY_LENGTH.s256, TOKEN_AGREEMENT_ALGO: TOKEN_AGREEMENT_ALGO.ECDH, MAPPING_TYPE: MAPPING_TYPE.GM
I/flutter (22095): AccessKey.DBAKeys FINE: 2024-06-25 15:45:17.114200: Calculating K-pi key ...
I/flutter (22095): AccessKey.DBAKeys FINE: 2024-06-25 15:45:17.114393: Seed: d61e9ad73e4eab753c6e477188229e2c21c6a41e, Key length: KEY_LENGTH.s256, Cipher algorithm: CipherAlgorithm.AES
I/flutter (22095): pace FINER: 2024-06-25 15:45:17.116219: PACE.decryptNonce; K-pi: 4a14104c5d366f406ebdcdddb4473e8a14c714fe6aa9f8788acba36479cbe124
I/flutter (22095): pace FINE: 2024-06-25 15:45:17.116455: PACE.decryptNonce; Cipher algorithm: AES
I/flutter (22095): AESChiperSelector FINER: 2024-06-25 15:45:17.116663: AES chiper with 128-bit key size selected.
I/flutter (22095): AESCipher FINEST: 2024-06-25 15:45:17.116876: AESCipher.decrypt; data size: 32, data: e99c8092a8c27b9f97a7d4ed2c5b1d318880c694208166623c0b7d57b31976e3
I/flutter (22095): AESCipher FINER: 2024-06-25 15:45:17.117092: AESCipher.decrypt; data: e99c8092a8c27b9f97a7d4ed2c5b1d318880c694208166623c0b7d57b31976e3, key size: 32, key: 4a14104c5d366f406ebdcdddb4473e8a14c714fe6aa9f8788acba36479cbe124
I/flutter (22095): AESCipher SEVERE: 2024-06-25 15:45:17.117352: AESCipher.decrypt; AES128 key length must be 128 bits.
I/flutter (22095): pace SEVERE: 2024-06-25 15:45:17.117689: PACE.decryptNonce; Failed: AESCipher.decrypt; AES128 key length must be 128 bits.
I/flutter (22095): pace SEVERE: 2024-06-25 15:45:17.117972: PACE(1); Failed: PACE.decryptNonce; Failed: AESCipher.decrypt; AES128 key length must be 128 bits.
I/flutter (22095): pace SEVERE: 2024-06-25 15:45:17.118253: PACE key establishment failed: PACE(1); Failed: PACE.decryptNonce; Failed: AESCipher.decrypt; AES128 key length must be 128 bits.
I/flutter (22095): mrtdeg.app SEVERE: 2024-06-25 15:45:17.118764: An exception was encountered while trying to read Passport: PACE key establishment failed: PACE(1); Failed: PACE.decryptNonce; Failed: AESCipher.decrypt; AES128 key length must be 128 bits.
I/flutter (22095): nfc.provider FINE: 2024-06-25 15:45:17.119230: Disconnecting

It works fine for BAC though

Parzivalxx avatar Jun 25 '24 08:06 Parzivalxx