About CryptoApi and multithreading

  • Thread starter Thread starter Aleksey Rechinsky
  • Start date Start date
A

Aleksey Rechinsky

Hello!

I have to write a cryptographic service provider (CSP) for MS CryptoApi.
I read all of MSDN documentation about it but still can't understand if the
CSP must be multithread-safe.

I'll try to explain in details, i need answers for the following questions:

1) Should i expect that CPAcquireContext() may be called in different thread
contexts?
Namely, should i protect CSP internal handle table for HCRYPTPROV?

2) Should i expect that one HCRYPTPROV may be used in different thread
contexts?
For example is it normal to CryptoApi when one (main) user thread acquires
key context (receives HCRYPTPROV from CryptAcquireContext()) and then worker
threads do some job with it. For example, the first worker thread decrypts a
file, the second - encrypts a message and so on, but with the one
HCRYPTPROV.
In other words, should i protect CSP internal HCRYPTPROV representation from
multithreaded access?

3) All of above for HCRYPTKEY and HCRYPTHASH?

Thanks.
Aleksey.

PS: Sorry for my poor English, i have very small writing practice :-|
 
Back
Top