I have the following bits of (C++) code:
CkCrypt2 m_crypt; ... m_crypt.UnlockComponent("key"); ... m_crypt.AddPfxSourceData(cert, password); ... m_crypt.DecryptBytes(p7mData, decryptedData);
And it works just fine.
However, the class that m_crypt is a member of is used to decrypt more than one thing, and for security purposes I need to clear out the old certificates between decryptions. How can I accomplish this?
The CkCrypt2 destructor should take care of it. Write your code so that a new instance of CkCrypt2 is used each time. If the instance of CkCrypt2 is on the stack, then it is automatically destructed when it goes out of scope (such as if it's a local var in a method and the method returns).