Encyption compatability with C++ EncrypionAPI calls?

  • Thread starter Thread starter Morris Neuman
  • Start date Start date
M

Morris Neuman

Is there a System.Security.Cryptography class or method that is compatable
with the C++ CryptoProvider MS_ENHANCED_PROV. So I can then enc/decrypt in
C# Windows form files that were encrypted in c++ with CryptoProvider
MS_ENHANCED_PROV?

I have encrypted a file in a C++ program using:

CryptAcquireContext(&hCryptProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL,
0))
'
'
'
(CryptCreateHash(hCryptProv, CALG_MD5, 0, 0, &hHash))
.....
etc.

as per the documentation on Win 32 and Com Deve. - CryptAcquireContext()

I don't see The MS Enhanced Crypto Provider in the
System.Security.Cryptography class. Is this doable? Do I have to use only
the C++ Crypto Provider to decrypt the file ?
 
Is there a System.Security.Cryptography class or method that is
compatable with the C++ CryptoProvider MS_ENHANCED_PROV. So I can
then enc/decrypt in C# Windows form files that were encrypted in c++
with CryptoProvider MS_ENHANCED_PROV?

Do you know what algorithm(s) MS_ENHANCED_PROV uses in the code in
question? Once you find the algorithm, you can look for an analog in C#.

I am not familiar with the Windows call, but you can look at PInvoke for
a direct call to the Windows API for encryption at worst case. More
likely, you can find the algorithm used and then code with it. I would
guess RSA for asym and AES for sym. In either case, you would need the
"secret" (passphrase or key) to encrypt/decrypt.

If this is running against a windows machine and the C++ supplies no
keys, look into the default server keys on the windows machine. I forget
the name of the machine key method, so a bit of Googling is in order, if
that is the methodology used.

NOTE: If the code uses the built in keys in windows, the implementation
can change depending on what server, as the "best" encryption method has
changed over time. If you have a mixed farm with older Windows machines
alongside newer windows machines, one may not be able to decrypt
another's message (using defaults, not explicit) even if you ship keys
from one machine to another.

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Thanks that helped.

--
Thanks
Morris


Gregory A. Beamer said:
Do you know what algorithm(s) MS_ENHANCED_PROV uses in the code in
question? Once you find the algorithm, you can look for an analog in C#.

I am not familiar with the Windows call, but you can look at PInvoke for
a direct call to the Windows API for encryption at worst case. More
likely, you can find the algorithm used and then code with it. I would
guess RSA for asym and AES for sym. In either case, you would need the
"secret" (passphrase or key) to encrypt/decrypt.

If this is running against a windows machine and the C++ supplies no
keys, look into the default server keys on the windows machine. I forget
the name of the machine key method, so a bit of Googling is in order, if
that is the methodology used.

NOTE: If the code uses the built in keys in windows, the implementation
can change depending on what server, as the "best" encryption method has
changed over time. If you have a mixed farm with older Windows machines
alongside newer windows machines, one may not be able to decrypt
another's message (using defaults, not explicit) even if you ship keys
from one machine to another.

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Morris Neuman said:
Is there a System.Security.Cryptography class or method that is compatable
with the C++ CryptoProvider MS_ENHANCED_PROV. So I can then enc/decrypt
in
C# Windows form files that were encrypted in c++ with CryptoProvider
MS_ENHANCED_PROV?

I have encrypted a file in a C++ program using:

CryptAcquireContext(&hCryptProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL,
0))
'
'
'
(CryptCreateHash(hCryptProv, CALG_MD5, 0, 0, &hHash))
....
etc.

as per the documentation on Win 32 and Com Deve. - CryptAcquireContext()

I don't see The MS Enhanced Crypto Provider in the
System.Security.Cryptography class. Is this doable? Do I have to use
only
the C++ Crypto Provider to decrypt the file ?

MD5 is MD5 is MD5. Every provider implements the same hash function, though
some may use hardware acceleration, use initialization vectors generated by
hardware rng, (for real crypto) use keys stored in hardware, etc, or even a
different algorithm to get there (lookup tables vs bit shifts for the actual
steps, etc). But if it generates a different result for the same IV and
same data (and for crypto, same key), it's not MD5.
--
Thanks
Morris

__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4512 (20091015) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4512 (20091015) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
Back
Top