1

I'm working on an application in which user will enter encryption key via GUI and my app will fetch that encryption key. Now i need to store that received key into Microsoft key container. I got this and this as a starting point and i know that i have to use this only. I am able to create key inside the container but i don't want to use this key. I have to store user entered key inside the container for later use in encryption/decryption process. Help highly appreciated. Thank you.

liveforFun
  • 5
  • 1
  • 5

1 Answers1

1

I think the link you provided above is one off--check here instead, which covers key import (what you need to start with). In short, you'll invoke BCryptImportKey or BCryptImportKeyPair, depending on if you're dealing with symmetric or asymmetric keys.

Once imported, use the various functions provided in CNG, probably starting with BCryptDecrypt and BCryptEncrypt.

jth
  • 726
  • 6
  • 10
  • Thanks for your comment. I tried to use this [example](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376234(v=vs.85).aspx#encrypting_data_example) but it returned me 'BCryptOpenAlgorithmProvider@24' not declared. After lots of googling i come to know that to use this function required lib is crypt32.lib. I linked that lib file even though getting same error. Now i want to know whether it's possible to do what i want to do. I want to save my own key in to key container. is it possible? If yes can you explain some what in detail? I as stucked here since last 10 days. Help me. – liveforFun Mar 18 '15 at 06:55