zeromq / netmq

A 100% native C# implementation of ZeroMQ for .NET
Other
2.95k stars 744 forks source link

Wrap LibSodium to yield better performance when using encrypted connections #923

Closed dxdjgl closed 2 years ago

dxdjgl commented 4 years ago

Would it not be possible to implement a encryption plugin architecture in NetMQ. Then you could plugin LibSodium-net for improved performance. In case no plugin was found, or they are missing something then fallback to NaCl.net? I have been looking into improving the performance on NaCl.net I am afraid that it is not going to be easy to come nowwhere near the performance of LibSodium

dxdjgl commented 4 years ago

I already have a rough skeleton, where this is working. I have created small NetMQ security assembly. It contains the interface that must be implemented, and the annotation which I have decided to decorate the implementing class with. In my skeleton 1 class from Nacl.net has been modified, I just decorated it with the annotation and added the interface. Inside NetMQ the code has been modified ~12-15 places the declaration. If the libsodium dll is missing then it reverts back to NaCl.net. NetMQ itself would remain 100 % dotnet. See performance measurements https://github.com/somdoron/NaCl.net/pull/7#issuecomment-659623329

danielcrenna commented 4 years ago

@dxdjgl I created a similar skeleton, though it uses NetMQ's preferred crypto by default. The crypto implementation can be changed at runtime by replacing delegates to a base class that by default forwards to NaCL.net. It's likely preferred not to default to libsodium.

dxdjgl commented 4 years ago

@dxdjgl I created a similar skeleton, though it uses NetMQ's preferred crypto by default. The crypto implementation can be changed at runtime by replacing delegates to a base class that by default forwards to NaCL.net. It's likely preferred not to default to libsodium.

If "NetMQ"libsodium is not there it will fallback to the default crypto. If "NetMQ"libsodium is there it is because you want improved performance in my scenario.

danielcrenna commented 4 years ago

If "NetMQ"libsodium is not there it will fallback to the default crypto. If "NetMQ"libsodium is there it is because you want improved performance in my scenario.

Is it a one-time check? In cases where the default NetMQ is used, probably don't want to spend cycles looking for a library that will never be there. Totally reasonable, your approach, just my two cents about making it more of an opt-in, triggered by code.

dxdjgl commented 4 years ago

@danielcrenna it is a one time check. I think if you have chosen to include the NetMQ"libsodium package then you want to use it. So no need for any code.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had activity for 365 days. It will be closed if no further activity occurs within 56 days. Thank you for your contributions.