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

Simulator compatibility #23

Closed dufkan closed 2 years ago

dufkan commented 2 years ago

JCMathLib with newer versions of JCardSim fails to compute multiplication using the RSA trick correctly. Consequently, the computation of sqrt_FP gets stuck, as the computation enters an unbounded loop whose end condition depends on correct multiplication results.

Another issue with newer versions of JCardSim is that RSAPublicKey needs to be renewed in order to compute modular exponentiations correctly.

Lastly, point doubling on JCardSim via KeyAgreement fails (other values seem to work correctly).

This pull request avoids these issues by renewing the RSAPublicKey and using a pure software implementation of Bignat multiplication and ECPoint doubling when bIsSimulator flag is set.

petrs commented 2 years ago

@dufkan many thanks for the improvement!