Question

My C++ program is using a standard blowfish.

My C# program is using the Blowfish encryption algorithm from here.

Both applications (TCP Clients) do the same thing: receive a packet, encrypt it and then send it back. If the server recognises the packet as normal - it sends another packet, otherwise it closes the socket. I followed all functions in C++ and C# and everything is the same except the encryption.

In the C++ file I have only one encryption. However, in the C# Blowfish I have

  • BlowfishCBC
  • BlowfishCFB
  • BlowfishECB
  • BlowfishSimple

I didn't know which one is the one in my C++ project, so I randomly picked BlowfishECB. But it doesn't work, the server (I don't have access to it) doesn't recognize the packet as encrypted.

My question: Is there a standard Blowfish for C# or if this is the only one, how do I solve this problem? EDIT:

The C++ blowfish code can be seen here.

Was it helpful?

Solution

No, there is not a standard blowfish for C#. It will use whichever you tell it to. (Edit: I think I misunderstood. If you want a standards compliant blowfish for C#, I would recommend Bouncy Castle Crypto. It is a port from Java and contains most documented RFC standards. Take a look at the unit tests for examples of how to use the classes. Whenever I used it last the documentation was lacking, but the unit tests are pretty good examples of how things fit together.)

The question you want to ask is which flavour of Blowfish your C++ application is using. What library are you using in the C++ application to do your encryption? Once you know that, then you can make the correct choice in your C# application.

I personally encounter CBC the most. "Simple" would probably be worth trying to.

You will also have to deal with things like making sure your initialization vector matches up depending on which one you use.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top