login about faq

I have the following bits of (C++) code:

CkCrypt2 m_crypt;
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?

asked Jan 29 '13 at 17:23

mightyshortadam's gravatar image


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).


answered Jan 29 '13 at 17:29

chilkat's gravatar image

chilkat ♦♦

I've refactored the code to make it work this way, and it works fine. Thanks! Out of curiosity, can you explain why CkCrypt2 seems designed specifically to not be reusable?

(Jan 30 '13 at 11:46) mightyshortadam

I wouldn't say that it's not reusable in a general sense. It's only that the reverse of AddPfxSourceFile/AddPfxSourceData is not implemented.

(Jan 30 '13 at 18:08) chilkat ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Jan 29 '13 at 17:23

Seen: 7,992 times

Last updated: Jan 30 '13 at 18:08

powered by OSQA