public static boolean isParityAdjusted(
        byte[]  key,
        int     offset)
    throws InvalidKeyException
	{
		if ((key.length - offset) < DES_KEY_LEN)
        {
            throw new InvalidKeyException("key material too short in DESKeySpec.isParityAdjusted");
        }

		for (int i = 0; i < DES_KEY_LEN; i++)
		{
            byte    keyByte = key[i + offset];
			int     count = 0;

            while (keyByte != 0)
			{
				/*
				 * we increment for every "on" bit
				 */
				if ((keyByte & 0x01) != 0)
				{
					count++;
				}

                keyByte >>>= 1;
			}

			if ((count & 1) == 1)
			{
				if ((key[i + offset] & 1) == 1)
				{
					return false;
				}
			}
			else if ((key[i + offset] & 1) != 1)
			{
				return false;
			}
		}

		return true;
	}