Hi Qian Hong, I'm not convinced that a failed call to CryptDecrypt actually resets the key state. It's also possible that CryptDecrypt returns FALSE before even trying to decrypt if data length is invalid. To check it, you would need to change the key state by (successfully) calling CryptDecrypt with Final=FALSE before your test. Could you add such test? Regards, Daniel
2013/6/28, Qian Hong fracting@gmail.com:
Hi Daniel,
On Fri, Jun 28, 2013 at 3:43 AM, Daniel Jeliński djelinski1@gmail.com wrote:
It is definitely valid to call CryptDecrypt multiple times with the same key. Calls with Final = FALSE change the internal state of the key, calls with Final = TRUE restore the initial state. Subsequent calls with Final = TRUE should return the same result.
Your testcase fails because CryptDecrypt changes the value of dwLen, which you do not restore before calling the function again.
Thanks a lot of the hint, with your help I finally resolve it! I've improved my test and submit two rsaenh patches, would you mind help to review them?
Thanks again!
-- Regards, Qian Hong