diff options
author | David Hook <dgh@bouncycastle.org> | 2021-05-31 08:54:59 +1000 |
---|---|---|
committer | David Hook <dgh@bouncycastle.org> | 2021-05-31 08:54:59 +1000 |
commit | 1d0f6346030e5c01a69e6e3659c3238ab7e5e857 (patch) | |
tree | 9fb63c33eabcaeebcd790f1734a97f95b2fdded8 /crypto/src | |
parent | github #83 - correct digest name fetch to check enc oid (diff) | |
download | BouncyCastle.NET-ed25519-1d0f6346030e5c01a69e6e3659c3238ab7e5e857.tar.xz |
github #172 - added blowfish init check on key size
Diffstat (limited to 'crypto/src')
-rw-r--r-- | crypto/src/crypto/engines/BlowfishEngine.cs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/crypto/src/crypto/engines/BlowfishEngine.cs b/crypto/src/crypto/engines/BlowfishEngine.cs index e38f4e8f6..1b3dd9743 100644 --- a/crypto/src/crypto/engines/BlowfishEngine.cs +++ b/crypto/src/crypto/engines/BlowfishEngine.cs @@ -421,7 +421,12 @@ namespace Org.BouncyCastle.Crypto.Engines private void SetKey(byte[] key) { - /* + if (key.Length < 4 || key.Length > 56) + { + throw new ArgumentException("key length must be in range 32 to 448 bits"); + } + + /* * - comments are from _Applied Crypto_, Schneier, p338 * please be careful comparing the two, AC numbers the * arrays from 1, the enclosed code from 0. @@ -430,7 +435,7 @@ namespace Org.BouncyCastle.Crypto.Engines * Initialise the S-boxes and the P-array, with a fixed string * This string contains the hexadecimal digits of pi (3.141...) */ - Array.Copy(KS0, 0, S0, 0, SBOX_SK); + Array.Copy(KS0, 0, S0, 0, SBOX_SK); Array.Copy(KS1, 0, S1, 0, SBOX_SK); Array.Copy(KS2, 0, S2, 0, SBOX_SK); Array.Copy(KS3, 0, S3, 0, SBOX_SK); |