# PKCS#11. Possibility of performing Ecryption/Decryption in hardware [closed]

Cheers. I'm dealing with HSM via PKCS#11 C/Python interface. I'm wondering is it possible to do some C_Encrypt/C_Decrypt in hardware. By saying "in hardware" I mean encryption/decryption without exposing the result to the caller space. This is mostly aboud decryption as I want to call C_Decrypt and leave the result inside the HSM as arbitrary data to do some other transformations on that data later, saying re-encrypting it on some other key. Thank you in advance.

## closed as off-topic by Maarten Bodewes♦, e-sushiNov 16 '18 at 2:55

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Programming questions are off-topic even if you are writing or debugging cryptographic code. Unless your question is specifically about how the cryptographic algorithm, protocol or side-channel (mitigation) works, you should look into asking on Stack Overflow instead." – Maarten Bodewes, e-sushi
If this question can be reworded to fit the rules in the help center, please edit the question.

• I believe this suits more into StackExchange. – kelalaka Nov 14 '18 at 9:10
• If you'd use CTR mode encryption then you could encrypt the data with a temporary key, then decrypt the data with the decryption key. You could do the same thing once you know the new key. I don't see how you could use C_Decrypt to a data object on the HSM, as the function expects a pointer to a byte array. – Maarten Bodewes Nov 14 '18 at 16:43
• This question has been reposted on SO. While I don't necessarily see this as off-topic here (see e.g. this recent meta thread), we should still preferably keep all the answers in one place. – Ilmari Karonen Nov 14 '18 at 16:58
• @IlmariKaronen, sorry, I just thougth this question suits better for this resource. I'm closing it. – Henadzi Matuts Nov 15 '18 at 7:53
• @HenadziMatuts I’ve closed it for your convenience. – e-sushi Nov 16 '18 at 2:55