HOWTO: Fast Diffie-Hellman on Xamarin.Android
On many Xamarin.Android platforms, our built-in managed Diffie-Hellman implementation is not fast enought, which causes an SSH or TLS negotiation with a 2048-bit Diffie-Hellman prime to take several seconds (or more for larger primes).
To work around this problem, we introduced the
DiffieHellmanNative class that uses Android's cryptographic API
via Xamarin.Android's Java interop, providing a big speed boost.
Rebex.Common.Native.dll assemblies can be found in "bin/xamarin.android" and "bin/xamarin.ios" subfolders of Rebex components install folder.
Alternatively, they are distributed as a NuGet package,
which also provides a compatible API for other mainstream platforms.
To enable fast Diffie-Hellman implementation for Xamarin.Android, add a reference to
Rebex.Common.Native assembly (or the NuGet package)
to your project, and enable the
using Rebex.Security.Cryptography; ... DiffieHellmanNative.Enable();
Once this is done, Rebex components will use
DiffieHellmanNative for Diffie-Hellman calculations.