licel / jcardsim

https://jcardsim.org
224 stars 123 forks source link

Call of getDefaultKeyGenerationParameters() in getKeyGenerationParameters() (class ECKeyImpl) mixes KeyType with AlgorithmType #22

Closed licel closed 10 years ago

licel commented 11 years ago

From petermah...@gmail.com on October 01, 2013 21:36:13

when calling the function public KeyGenerationParameters getKeyGenerationParameters(SecureRandom rnd) from the class ECKeyImpl with an uninitialized Key, the function

getDefaultKeyGenerationParameters(type, size, rnd) gets called

where type is a constant from the keyBuilder ( http://www.win.tue.nl/pinpasjc/docs/apis/jc222/constant-values.html#javacard.security.KeyBuilder.TYPE_EC_FP_PRIVATE ).

in the called function getDefaultKeyGenerationParameters(byte algorithm, short keySize, SecureRandom rnd) { byte keyType = algorithm == KeyPair.ALG_EC_FP ? KeyBuilder.TYPE_EC_FP_PUBLIC : KeyBuilder.TYPE_EC_F2M_PUBLIC;

this type variable gets compared to constants from the KeyPair class ( http://www.win.tue.nl/pinpasjc/docs/apis/jc222/constant-values.html#javacard.security.KeyPair.ALG_EC_FP )

directly calling getDefaultsDomainParameters() from getKeyGenerationParameters() would solve the problem.

Original issue: http://code.google.com/p/jcardsim/issues/detail?id=22

licel commented 11 years ago

From petermah...@gmail.com on October 04, 2013 12:22:29

For a patch please see https://github.com/mali1/jCardSim/commit/72dd9349b1cb45fa9b2fda47e1ce06c71a3e6f65