# Nitrokey HSM 2: Encrypt data using AES-CBC

**URL:** <https://support.nitrokey.com/t/nitrokey-hsm-2-encrypt-data-using-aes-cbc/5829>\
**Category:** HSM\
**Created:** [January 10, 2024, 6:50am UTC](https://support.nitrokey.com/t/nitrokey-hsm-2-encrypt-data-using-aes-cbc/5829 "2024-01-10T06:50:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![phinho](https://support.nitrokey.com/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@phinho](https://support.nitrokey.com/u/phinho)\
**Post date:** [January 10, 2024, 6:50am UTC](https://support.nitrokey.com/t/nitrokey-hsm-2-encrypt-data-using-aes-cbc/5829/1 "2024-01-10T06:50:07Z")

</div>

Hi,  
I am trying to encrypt data using AES-CBC. As pointed out in [this comment](https://support.nitrokey.com/t/nitrokey-hsm-2-encrypt-with-aes/2663/4), I need to use sc-hsm-pkcs11 module to do this. However, it will fail to find a slot with an available token when using libsc-hsm-pkcs11.so module.

As shown in the picture below, no slot with a token was found(using libsc-hsm-pkcs11.so), while there is one slot with a present token using opensc-pkcs11.so.

 ![libsc-hsm-pkcs11-issue](https://support.nitrokey.com/uploads/default/original/2X/1/1fb1115f880de7834cae66ac3aa1bfb967b0d0e0.png)

The sc-hsm-embedded module installed in my machine is built from [source](https://github.com/CardContact/sc-hsm-embedded/releases/tag/V2.12) (v2.12).

Could someone help me to get sc-hsm-pkcs11 work with Nitrokey HSM 2?

---

<div class="post-metadata">

**Author:** ![saper](https://support.nitrokey.com/user_avatar/support.nitrokey.com/saper/32/493_2.png) [@saper](https://support.nitrokey.com/u/saper)\
**Post date:** [January 28, 2024, 3:30pm UTC](https://support.nitrokey.com/t/nitrokey-hsm-2-encrypt-data-using-aes-cbc/5829/2 "2024-01-28T15:30:48Z")

</div>

In principle, this should work, here is on my FreeBSD:

```plaintext
> pkcs11-tool --show-info --module /usr/local/lib/libsc-hsm-pkcs11.so
Cryptoki version 2.20
Manufacturer CardContact (www.cardcontact.de)
Library SmartCard-HSM via PC/SC (ver 2.11)
Using slot 1 with a present token (0x5)

```

(or after update)

```plaintext
> pkcs11-tool --show-info --module ./src/pkcs11/.libs/libsc-hsm-pkcs11.so
Cryptoki version 2.20
Manufacturer CardContact (www.cardcontact.de)
Library SmartCard-HSM via PC/SC (ver 2.12)
Using slot 1 with a present token (0x5)

```

What does `pkcs11-tool --module /usr/lib/opensc-pkcs11.so -T` say?
