Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear experts
For educational purposes I'm trying to decrypt an encrypted text. This text is encrypted by .net using PasswordDeriveBytes with RijndaelManaged. Encrypted by .net means we have given:
    passPhrase
    saltValue
    hashAlgorithm (SHA in my case)
    passwordIterations
    initVector
    keySize

My target: I'm trying to decrypt the cipher text using only the basic W32 Api using pure c++ without any help the nice MS/VS support (decrypting the text by the help of full support of VS/.net is easy and works).

I'm facing now bigger problems especally with the "beast" "PasswordDeriveBytes". I have no idea what it is really doing, so I try to solve this part step by step. After googling hours my plan was/is:
I found
mono/PasswordDeriveBytes.cs at effa4c07ba850bedbe1ff54b2a5df281c058ebcb · mono/mono · GitHub[^]
the above link I hoped I found source code for "PasswordDeriveBytes" in c# which I can more or less easy transfer to c++.

But I stuck with an error message in "public override byte[] GetBytes(int cb)" line 243 (in the above link) with the message "Hash is not valid in the specified state.".

Finally my hope/question is, somebody has some similar experience in this and can give me a hint ir in best case a link for a c++ - "PasswordDeriveBytes" for dummies :)

I need to mention I' have no basic knowledge about this crypting stuff :(

Sorry for the cyrptic question and my english
Thank you in advance.
Regards

What I have tried:

Described above.。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
Posted
Updated 2-Feb-17 8:46am
v3

1 solution

This blog post[^] describes what the class is doing. It's essentially an implementation of PBKDF1, which might be a better search term to find a C++ implementation.

However, the documentation[^] says it's using an extension of PBKDF1. Without knowing exactly what that extension is, you'll probably struggle to match the output.

If you could switch the .NET code to use Rfc2898DeriveByes[^] instead, that would make your life simpler. It's a straight implementation of PBKDF2, with no extensions involved.

Alternatively, this StackOverflow answer[^] claims to be a working translation of the Mono code for PasswordDeriveBytes, albeit limited to the SHA1 algorithm.
 
Share this answer
 
Comments
[no name] 2-Feb-17 15:14pm    
Thank you very much for your answer and a 5 so far.
Most of the links you mentioned I recognize. But I think re read it again will be a good lesson for me to solve my request.
Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900