OpenCryptoProject / JCMathLib

Implementation of mathematical operations with big numbers and elliptic curve points for smart cards with JavaCard platform.
MIT License
83 stars 27 forks source link

EC scalar_Point Multiplication and EC Point Double fails with 0xff05 (SW_NullPointerException) #12

Closed petrs closed 4 years ago

petrs commented 4 years ago

EC scalar_Point Multiplication: cardMngr.transmit(new CommandAPDU(hexStringToByteArray("B043200061201A1C4AA2D77D116F1730C186AF4F1BAA617FB82670D074AE24CD40457F59DD046B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C2964FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5"))); static byte[] failedCommand = {(byte) 0xb0, (byte) 0x43, (byte) 0x20, (byte) 0x0, (byte) 0x61, (byte) 0x20, (byte) 0x1a, (byte) 0x1c, (byte) 0x4a, (byte) 0xa2, (byte) 0xd7, (byte) 0x7d, (byte) 0x11, (byte) 0x6f, (byte) 0x17, (byte) 0x30, (byte) 0xc1, (byte) 0x86, (byte) 0xaf, (byte) 0x4f, (byte) 0x1b, (byte) 0xaa, (byte) 0x61, (byte) 0x7f, (byte) 0xb8, (byte) 0x26, (byte) 0x70, (byte) 0xd0, (byte) 0x74, (byte) 0xae, (byte) 0x24, (byte) 0xcd, (byte) 0x40, (byte) 0x45, (byte) 0x7f, (byte) 0x59, (byte) 0xdd, (byte) 0x4, (byte) 0x6b, (byte) 0x17, (byte) 0xd1, (byte) 0xf2, (byte) 0xe1, (byte) 0x2c, (byte) 0x42, (byte) 0x47, (byte) 0xf8, (byte) 0xbc, (byte) 0xe6, (byte) 0xe5, (byte) 0x63, (byte) 0xa4, (byte) 0x40, (byte) 0xf2, (byte) 0x77, (byte) 0x3, (byte) 0x7d, (byte) 0x81, (byte) 0x2d, (byte) 0xeb, (byte) 0x33, (byte) 0xa0, (byte) 0xf4, (byte) 0xa1, (byte) 0x39, (byte) 0x45, (byte) 0xd8, (byte) 0x98, (byte) 0xc2, (byte) 0x96, (byte) 0x4f, (byte) 0xe3, (byte) 0x42, (byte) 0xe2, (byte) 0xfe, (byte) 0x1a, (byte) 0x7f, (byte) 0x9b, (byte) 0x8e, (byte) 0xe7, (byte) 0xeb, (byte) 0x4a, (byte) 0x7c, (byte) 0xf, (byte) 0x9e, (byte) 0x16, (byte) 0x2b, (byte) 0xce, (byte) 0x33, (byte) 0x57, (byte) 0x6b, (byte) 0x31, (byte) 0x5e, (byte) 0xce, (byte) 0xcb, (byte) 0xb6, (byte) 0x40, (byte) 0x68, (byte) 0x37, (byte) 0xbf, (byte) 0x51, (byte) 0xf5};

EC Point Double: cardMngr.transmit(new CommandAPDU(hexStringToByteArray("B041000041044BA5A6CD62B7DAACDC2467B74D30D546FBCFF4002481A3C29867C03D39CBE0CF5EAF576F6DC24FD4DE1754A4E97E4DC4B7A18B3C18C62BC8A7057E653E8FA896"))); static byte[] failedCommand = {(byte) 0xb0, (byte) 0x41, (byte) 0x0, (byte) 0x0, (byte) 0x41, (byte) 0x4, (byte) 0x4b, (byte) 0xa5, (byte) 0xa6, (byte) 0xcd, (byte) 0x62, (byte) 0xb7, (byte) 0xda, (byte) 0xac, (byte) 0xdc, (byte) 0x24, (byte) 0x67, (byte) 0xb7, (byte) 0x4d, (byte) 0x30, (byte) 0xd5, (byte) 0x46, (byte) 0xfb, (byte) 0xcf, (byte) 0xf4, (byte) 0x0, (byte) 0x24, (byte) 0x81, (byte) 0xa3, (byte) 0xc2, (byte) 0x98, (byte) 0x67, (byte) 0xc0, (byte) 0x3d, (byte) 0x39, (byte) 0xcb, (byte) 0xe0, (byte) 0xcf, (byte) 0x5e, (byte) 0xaf, (byte) 0x57, (byte) 0x6f, (byte) 0x6d, (byte) 0xc2, (byte) 0x4f, (byte) 0xd4, (byte) 0xde, (byte) 0x17, (byte) 0x54, (byte) 0xa4, (byte) 0xe9, (byte) 0x7e, (byte) 0x4d, (byte) 0xc4, (byte) 0xb7, (byte) 0xa1, (byte) 0x8b, (byte) 0x3c, (byte) 0x18, (byte) 0xc6, (byte) 0x2b, (byte) 0xc8, (byte) 0xa7, (byte) 0x5, (byte) 0x7e, (byte) 0x65, (byte) 0x3e, (byte) 0x8f, (byte) 0xa8, (byte) 0x96};

petrs commented 4 years ago

False issue, tested on the card without KeyAgreement.getInstance(ALG_EC_SVDP_DH_PLAIN, false); algorithm.

Better reporting if the card is good fit for JCMathLib shall be developed