|
|
Comments and Discussions
|
|
 |
|

|
So much simpler and more logical compared to the approach outlined in MSDN. The first question that came to my mind after reading the MSDN article was why we can't just decrypt the key using the private key? And you answered that well (I did not think about the 12 byte header). Thanks for the post. It will benefit a lot of people.
|
|
|
|

|
Hi,
In your example you are using keypair of the current user. That will work only if the user has private key. What if i want to encrypt for another user. I can get public key and encrypt using cryptexportkey.
How do i get decrypted key
|
|
|
|

|
I got the answer.
|
|
|
|

|
hello,
I am using Windows2000,VC6++. I setted all the information but couldn't include wincrypt.h.
This is:
: error C2146: syntax error : missing ';' before identifier 'HRESULT'
:fatal error C1004: unexpected end of file found
When I click in the error, I get:
typedef LONG HRESULT;
So, what should I do?? I don't undertand!!!!!!!!!
Thank you so much
|
|
|
|

|
Add in C++/Preprocessor definitions:
_WIN32_WINNT=0x0500, _CRYPT32_(WIN2K) or _WIN32_WINNT=0x0400, _CRYPT32_(NT4)
And Link this library crypt32.lib
Raphael Amorim Dantas Leite
VC++, Java and C# programmer. Win32 and PocketPC enviroments
|
|
|
|

|
First of all, thanks for the code example, I've been looking for this.
Bug:
the last loop should be :
for ( c = 0; c < SESSION_KEY_SIZE ; c++)
not c--
Suggestion:
You could use CryptGenKey( hCryptProv, AT_KEYEXCHANGE, 0, &hExchangeKeyPair) instead of CryptGetUserKey. CryptGetUserKey fails for me(probably because I don't have a userkey).
JC.
|
|
|
|

|
Good Idea
Raphael Amorim Dantas Leite
VC++, Java and C# programmer. Win32 and PocketPC enviroments
|
|
|
|

|
Why CryptGetUserKey returned the same key every time called at one machine?
If so,all programs run at one machine will have the same RSA key exchange pairs? Then how to keep secret?
--I am a silent programmers.
|
|
|
|

|
Depends on your CryptAcquireContext call
Raphael Amorim Dantas Leite
VC++, Java and C# programmer. Win32 and PocketPC enviroments
|
|
|
|

|
oh,yes.
Maybe.
Now I know if u want a different key, use CryptGenKey
--programmers,lucky!
|
|
|
|

|
Hi,
Does anyone know why the generated encrypted text under windows XP different from those generated from Windows 2000.
|
|
|
|
|

|
You should try to encrypt this key using CryptEncrypt. After that pick the encrypted buffer and build a SIMPLEBLOB buffer, MSDN covers this format. This way you should be able to import the key using CryptImportKey.
Raphael Amorim Dantas Leite
VC++, VB, Java, .NET and eMbedded Programmer
|
|
|
|

|
Can you help to use the CAPI in a vc++ app to encrypt text and files?
==================================================
The Eclypse
|
|
|
|

|
Come on! there's a god damn sample in MSDN!
|
|
|
|

|
1) He mentioned the MSDN example.
2) His method is different.
3) Posting anonymously should be banned on this site.
4) There was really no reason to use profanity.
5) How many articles have *you* posted?
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|

|
There's no reason for this behavior!!
Come on, "Mr. Anonymous", all I want is to help this site to get better and better. Is kinda a way of payback all the doubts I took off by reading articles from here. And no one will hinder us of keep doing this.
Thanks for the defense John...and Eclypse! I'll send to you a sample code of
my authorship and another one from MSDN( yes! there's a sample there again, so what? ). I've got messages from MSDN requesting authorization to publish this article I think is a good thing for the Code Project Team and for me of course.
And stay cool!!!
Raphael Amorim
VC++,Delphi,VB,C++ Builder,BP and eMbedded Programmer
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
Generally it's very important to obtain the value of session keys. However, the Microsoft Cryptographic Providers (Base and Enhanced) do not support this feature. CryptExportKey() and CryptImportKey() require a valid key handle to encrypt and decrypt the session key, respectively.
| Type | Article |
| Licence | MIT |
| First Posted | 10 Dec 2001 |
| Views | 108,665 |
| Downloads | 1,165 |
| Bookmarked | 38 times |
|
|