A key space, or keyspace, is the set of all valid, possible, distinct keys of a given cryptosystem.
Cryptosystems (also ciphers, algorithms) have a natural limit to the number of keys by nature of the rules in place. Using the example of a simple shift cipher, say ROT[X], it’s logical to consider that the key space is limited to the number of shifts in the alphabet being used or something close to it but something still workable.
Continuing in this example, the English alphabet is 26 characters, so it’s reasonable to assume the number of ROT (shifts) is somewhere between 0 and 26. It’s possible to give a ROT cipher a number into the thousands but such a rotation inevitably becomes equal to a smaller number, considering the rotations will continue and continue along the same 26 letter set. (It’s easy to visualize that the reason this is so is that it wraps around.) It’s invalid, however, to give the ROT a value equal to a fraction such as ¼ or 2 ¾ since it is incompatible with the cipher.
The security of a cryptosystem is proportional to the size of the key space. An intercepted message with a larger keyspace is more resistant to attackers’ decryption efforts since an attacker will try to brute force the message with all possible key combinations.
“An encryption system’s key space can range from a small number of combinations to millions. The larger the size of all possible permutations, the stronger the encryption system.”