crocs-muni / JCAlgTest

Automated testing tool for algorithms from JavaCard API supported by particular smart card. Performance testing of almost all available methods. The results for more than 100+ cards.
http://jcalgtest.org
MIT License
112 stars 44 forks source link

Incorrect key length used in KeyBuilder tests with TYPE_HMAC keys #259

Open nc-adnan opened 1 year ago

nc-adnan commented 1 year ago

According to the Java Card 3.0.5 API, the keyLength parameter passed to the KeyBuilder.buildKey method is the key size in bits.

In the KeyBuilder tests configs, the key sizes are specified in bytes for TYPE_HMAC keys (64/128) which leads to incorrect results:

see _JCAlgTest/AlgTestJClient/src/algtestjclient/SingleModeTest.java:

KEYBUILDER_TEST_CFGS.put("TYPE_HMAC_TRANSIENT_RESET#2.2.2", new KBTestCfg(JCConsts.KeyBuilder_TYPE_HMAC_TRANSIENT_RESET, (short) 64));
KEYBUILDER_TEST_CFGS.put("TYPE_HMAC_TRANSIENT_DESELECT#2.2.2", new KBTestCfg(JCConsts.KeyBuilder_TYPE_HMAC_TRANSIENT_DESELECT, (short) 64));
KEYBUILDER_TEST_CFGS.put("TYPE_HMAC LENGTH_HMAC_SHA_1_BLOCK_64#2.2.2", new KBTestCfg(JCConsts.KeyBuilder_TYPE_HMAC, (short) 64));
KEYBUILDER_TEST_CFGS.put("TYPE_HMAC LENGTH_HMAC_SHA_256_BLOCK_64#2.2.2", new KBTestCfg(JCConsts.KeyBuilder_TYPE_HMAC, (short) 64));
KEYBUILDER_TEST_CFGS.put("TYPE_HMAC LENGTH_HMAC_SHA_384_BLOCK_64#2.2.2", new KBTestCfg(JCConsts.KeyBuilder_TYPE_HMAC, (short) 128));
KEYBUILDER_TEST_CFGS.put("TYPE_HMAC LENGTH_HMAC_SHA_512_BLOCK_64#2.2.2", new KBTestCfg(JCConsts.KeyBuilder_TYPE_HMAC, (short) 128));
petrs commented 1 year ago

Thank you @nc-adnan for reporting, it will take longer to fix this issue due to need for re-measurement of existing results for these six values. So I'm leaving the issue open for now.

petrs commented 4 days ago

fixed by 6e01f83e311cb41a9ac6964a45279efbdd1235f3