Nitrokey HSM 2, encrypt with AES

The aes branch is pretty old and has already been integrated in the master branch. You can use the .msi installer to install the latest 2.11 version.

When working with the SmartCard-HSM you need to obtain an instance of the Crypto class using

var card = new Card(_scsh3.reader);
var sc = new SmartCardHSM(card);
var crypto = sc.getCrypto();

however this currently only works for asymmetric key, but not for AES keys. For AES you need to use the APDU interface instead, like in

var enc = sc.card.sendApdu(0x80, 0x78, key.getId(), 0x10, plain, [0x9000]);

with 0x10 for encryption, 0x11 for decryption and 0x18 for CMAC.

3 Likes