Discuss this help topic in SecureBlackbox Forum
Use hardware keys for symmetric encryption
Besides files and database records, persistent symmetric keys can be stored on hardware cryptographic tokens. You can use such keys to encrypt or decrypt data with TElSymmetricCrypto in exactly the same way as you do with the in-memory keys. The only difference is in obtaining the corresponding TElSymmetricKeyMaterial object.
To obtain the key object from the device, perform the following steps. This procedure of obtaining a key object from the device is similar to accessing hardware-based certificates and private keys:
TElPKCS11CertStorage storage = new TElPKCS11CertStorage();
storage.DLLName = "mypkcs11.dll";
storage.Open();
TElPKCS11SessionInfo session = storage.OpenSession(0, true);
session.Login(SBPKCS11Base.Unit.utUser, "1111");
TElSymmetricKeyMaterial km = null;
for (int i = 0; i < storage.KeyCount; i++)
{
if (storage.get_Keys(i) is TElSymmetricKeyMaterial)
{
km = storage.get_Keys(i);
break;
}
}
km.IV = iv;
crypto.KeyMaterial = km;
That's it. Now you can proceed to encryption or decryption as usual.