I am ahving errors
C:\Documents and Settings\hariere\Desktop\testcrypto\testcrypto.cpp(67) : error C2065: 'PROV_RSA_AES' : undeclared identifier
C:\Documents and Settings\hariere\Desktop\testcrypto\testcrypto.cpp(101) : error C2065: 'CALG_AES_256' : undeclared identifier
Error executing cl.exe.
Please help where i am worng
error C2146: syntax error : missing ';' before identifier 'HRESULT'
0
The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.
One of a set of tools we're offering as a way of saying thank you for being a part of the community.
>>>> try adding
>>>> #include <windows.h>
>>>> before you include "wincrypt"
Hmmm. Isn't the windows.h already included in stdafx.h ? Note, a precompiled header like stdafx.h makes only sense if it does include some of the (rarely changing) big headers like windows.h and/or afx.h (MFC) respectively atlmfc.h (ATL and MFC since VC7). If not, you should remove it and switch off the Precompiled Header option which is in the C++ settings.
If your stdafx.h already includes windows.h your error may occur because you need to rebuild the precompiled header. Either compile stdafx.cpp for that or use 'rebuild all'.
If the error still exists you may have to set the _WIN32_WINNT preprocessor macro. Go to menu Project - Properties - Configuration Properties - C++ -Preprocessor and add _WIN32_WINNT=0x0500 to the list of preprocessor macros (use a semicolon ; as separator).
0
hp746Author Commented:
i did it still i have same problem btw i am using visual c++ 6.0 console application
and #include <windows.h> in stadfx.h
0
hp746Author Commented:
I wonder if vc++ 6.0 is support 'CALG_AES_256' alogrithms
>>>> I wonder if vc++ 6.0 is support 'CALG_AES_256' alogrithms
You are right. wincrypt.h supplied with VC6 doesn't offer the CALG_AES_256.
But you could try to add the missing definitions below wyncrypt.h. If the advapi32.dll on the target system is younger then 1998 (check your Windows\system32) it probably supports additional codes.
>>>> Defining these constants manually is not the usual way to go
No problem if it works. It is no code but only constants which were fully supported by any advapi32.dll younger than 2003.
>>>> update your SDK from
No, don't make updates which could spoil VC6. With VC7 MS made a major step towards .NET. That step is not compatible with VC6.
Defining the constants is a harmless thing. It either works or fails but won't make things worse. The SDK would bring an update which was made for later versions of C++ compiler and will change your VC6 environment. It is like to crack a nut with a sledgehammer and I highly recommend against it as long as you want to keep with VC6.
0
hp746Author Commented:
I have changed my code and i have few errors
// testcrypto.cpp : Defines the entry point for the console application.
//
Does it compile? If yes, does it call the function and what error (return) did you get?
Check both advapi32.dll and wincrypt.dll in system32 folder and tell me which create time they have.
Check all folders of your machine for elder versions of these dlls so that not the (old) ones coming with VC6 come to use.
0
hp746Author Commented:
advapi32.dll = Wednesday, August 04, 2004, 5:00:00 AM
and i have not seen wincrypt.dll in my system32 directory.
i am using wincrypt.h header file in my program
>>>>the constants MS_ENH_RSA_AES_PROV and PROV_RSA_AES
>>> I have defind in my program
Yes, but where do you know from that they were the right ones?
And what is the error you can retrieve by calling GetLastError()?
0
hp746Author Commented:
This i have get on online i am not if they are the right ones for the vc++ 6.0
I have to do encrypt/decrypt using CALG_AES_256 algorithim using VC++ 6.0
I am not sure if it is support vc++ 6.0
if it support please let me know how can i apporach to solve the problem or if you have any example in vc++ 6.0 using CALG_AES_256 that would be great
It definitively isn't supported by VC 6.0 (as proofed by the missing constant definitions). But there has been a chance that newer advapi32.dll and crypt32.dll could provide the needed functionality.
But you didn't tell what errors you have though I asked a few times. So it is difficult to help.
0
hp746Author Commented:
here is the error
error C2664: 'CryptAcquireContextA' : cannot convert parameter 4 from 'char [66]' to 'unsigned long'
here is my code snippet
// testcrypto.cpp : Defines the entry point for the console application.
//
You see, argument 2 and 3 are strings (long pointer to const T string, where T means single-byte - ANSI - if not a UNICODE project) while argument 4 is a DWORD (unsigned integer). But you were passing PROV_RSA_AES as 4th argument which is defined as a string.
#define PROV_RSA_AES "Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)"
The 4th argument is the 'provider type' while you were passing the 'provider name'.
If you check the definition of MS_ENH_RSA_AES_PROV which you were passing as 3rd argument, you see that it is the same string as for PROV_RSA_AES what obviously is false.
In my wincrypt.h I found
#define PROV_RSA_AES 24
You should check, whether your wincrypt.h already contains that definition. If yes, simply drop the above redefinition. If no, exchange the wrong definition of PROV_RSA_AES with the one above. You also could call
if (!CryptAcquireContext(&hProv, NULL, MS_ENH_RSA_AES_PROV ,24,CRYPT_VERIFYCONTEXT))
though that is less recommended.
0
hp746Author Commented:
if(!CryptCreateHash(hProv,CALG_AES_256, 0, 0, &hHash)) is failing
when i change to CALG_AES_128 i have not seen any issue .
The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.
One of a set of tools we're offering as a way of saying thank you for being a part of the community.