DES has 16 weak keys. This method will check
if the given DES key material is weak or semi-weak.
Key material that is too short is regarded as weak.
See "Applied
Cryptography" by Bruce Schneier for more information.
if (key.length - offset < DES_KEY_LENGTH)
{
throw new IllegalArgumentException("key material too short.");
}
nextkey: for (int i = 0; i < N_DES_WEAK_KEYS; i++)
{
for (int j = 0; j < DES_KEY_LENGTH; j++)
{
if (key[j + offset] != DES_weak_keys[i * DES_KEY_LENGTH + j])
{
continue nextkey;
}
}
return true;
}
return false;