Encrypt Decrypt data

Hello,
I am trying encrypt and decrypt data using function CryptEncrypt(..) and CryptDecrypt(..) these are MFC function it compile and deploy fine. But this function parameter hkey is null when i debug it then when // Get the handle to the default provider. CryptAcquireContext(&hCryptProv, this hCryptProv is also null i think therefore it not created hKey.
May i know is this CryptEncrypt(..) and CryptDecrypt(..) function are compatibel or any other function there for cryptography. Please help me out this condition.

Dear @yogeshindigen@outlook.com,

Could you quickly check this link : https://www.codeproject.com/Articles/1658/Obtain-the-plain-text-session-key-using-CryptoAPI and let us know, is it helps you?

Please wait for a day, let me search in WinCE code base and get back you tomorrow. Thank you.

ok, Its work fine on Desktop windows 10 but, How about wince toradex platform.

Dear @yogeshindigen@outlook.com,

We never tested these functions but there are samples available from the WinCE code base.

  • \WINCE600\PRIVATE\DIRECTX\DSHOW\FILTERS\DVR\DVRENGINEMPEG\ENCRYPTER\encrypter.cpp
  • \WINCE600\PUBLIC\COMMON\SDK\SAMPLES\SCWCSP\CSP\context.cpp

Could you install WinCE platform builder and take a look at those codes, we should not share the code here.

If possible, could you share the reproducible demo project that will help us to debug it quickly?

Yes sure,
in this code attached only i commented

  1. Advapi32.lib at line 12 as commente name //YogeshJadhav
  2. 35 and 36 line
  3. And put path for encrypt file at 39 and 40

SmartEnDecrypt.zip

Dear @yogeshindigen@outlook.com,

Maybe certain crypto functionality not supported on Window Embedded Compact. Could you check the Microsoft documentation here: https://csrc.nist.gov/csrc/media/projects/cryptographic-module-validation-program/documents/security-policies/140sp825.pdf. Sorry we don’t have experience on this, you would also consider getting help from MSDN forum: https://social.msdn.microsoft.com/Forums/en-US/home?forum=winembplatdev

Below sample code is working on WinCE

if (!CryptAcquireContext(	&m_hProv,
								L"mycontainer",			// Default key container
								NULL,					// Default provider
								PROV_RSA_AES,
								CRYPT_NEWKEYSET | CRYPT_SILENT))

please share demo code.

Dear @yogeshindigen@outlook.com,

Sorry, we should not share the Microsoft sample code over the public forum. Could you install WinCE6 or WinCE7 platform builder with private(shared) code there can find the samples?