bcgit / bc-csharp

BouncyCastle.NET Cryptography Library (Mirror)
https://www.bouncycastle.org/csharp
MIT License
1.68k stars 558 forks source link

Allow extended keys in BlowfishEngine for interoperability #519

Open jpboivin opened 9 months ago

jpboivin commented 9 months ago

As discussed in https://github.com/bcgit/bc-csharp/issues/407, this is a proposal to support non-standard key sizes in the BlowfishEngine, for interoperability with other cryptographic libraries like OpenSSL and Nettle.

I want with an approach were by default, the key is still validated to be standard, but using the new BlowfishParameters, it is possible to lift the check for the engine to handle extended keys. If a key exceeds 576 bits, only the first 576 bits of the data will be used to compute the P box. This is in line with the OpenSSL and Nettle implementations.

I've generated test vectors using OpenSSL and Nettle. I couldn't find any online (even these libs do not seem to test larger keys): test_vectors.cpp.txt