OpenCryptoProject / JCMathLib

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

Configuration of supported operations #24

Closed dufkan closed 2 years ago

dufkan commented 2 years ago

This pull request adds OperationSupport class that allows configuring the set of allowed operations. By default, only basic operations are allowed. When a disabled operation should be used, the library throws the exception SW_OPERATION_NOT_SUPPORTED.

To use JCMathLib in a simulator, add the following line in the constructor of your applet.

OperationSupport.getInstance().setCard(OperationSupport.SIMULATOR);

There are also pre-configured sets of supported operations for some cards.

If you want to enable some operations that are not included in the default set, you can do it in the following way.

OperationSupport.getInstance().ECDH_XY = true;

The last example line enables ECPoint multiplication via ALG_EC_SVDP_DH_PLAIN_XY key agreement. This is a new feature included in this pull request that results in almost native performance of scalar multiplication on cards that support it.

petrs commented 2 years ago

@dufkan Thank you a lot for the helpful addition which will help NOT to brick cards on non-standard operation!