25.2 Encryption and decryption with binary numbers 529
to a complete permutation algorithm, we would achieve most perfect scrambling. For
an eight-character or 56-bit codeword, the number of possible permutations is 56! =
7.1 × 10
74
, although with a sufficiently complex substitution algorithm, this approach
would seemingly yield undecipherable messages. But the drawback is that its key (the
scrambling algorithm) is fixed once and for all. No matter how complex, a fixed-key
cryptoalgorithm is, in fact, very vulnerable to attack. The key can be intercepted during
its communication (over the Internet, for instance) without the two parties being ever
aware of it. The key can be retrieved from the software used to encrypt or decrypt, should
one of the terminal computers be intruded by a t hird party. The alternative is to use a
different key (referred to as a one-time-pad cipher) for each new message. This means
that the two parties have agreed beforehand on a list of different keys (here, substitution
algorithms) to be used only once. This approach is not at all practical for any routine
use, such as in an army central command. If the list of keys is to be communicated over
the Internet (or any other wide-range transmission medium), or listed in a book (as in the
case of the Enigma machine), it is also extremely vulnerable. The solution to this issue,
which is not trivial, is to be addressed in the next two subsections. In the following, we
will prepare ourselves further by considering how secret keys can be used in the binar y
system.
In the binary system, a secret key is made of a single codeword of any desirable
length, which must remain known only to the two parties. In contrast, the encryption and
decryption algorithm can be known to anyone. If the secret key is to be memorized, so as
to leave no paper or computer-file trace of it, it must be plain English (or any language
for that matter); for instance, a “codeword,” a “passphrase” or even the first paragraph
or page of a book text commonly used and secretly agreed on. In the last case, the key
may simply be the page number of the book, which is easy to memorize. By itself, this
requirement of easy memorization or that the key be in plain English represents a built-in
weakness, because it exposes the cryptosystem to frequency analysis. Nowadays, this is
no longer an issue, since random binary keys are used. The remaining issue is how to
safely exchange and renew such keys, which is discussed later.
Mixing the secret key with the plaintext provides a means for both encryption and
decryption. Such mixing is performed by simple Boolean operations. In the binary
system, the four operations, called Boolean, are NO (logical inversion), AND (multi-
plication), OR (addition or subtraction), and XOR (exclusive OR). The rules of these
operations on one (NO) or two (AND, OR, XOR) bits or “operands” have been intro-
duced in Chapter 15. We note that with binary numbers, addition and subtraction are
thesame(1+ 1 = 1–1= 0, 1 + 0 = 1–0= 0 + 1 = 0 − 1). We also note that
XOR is the same as OR, except for the rule 1 + 1 = 0, which is similar to 9 + 1 = 0
in the ordinary digital system. The operators (NO, AND, OR, and XOR) are also noted
by mathematicians ¬, ∧, ∨, and ⊕, respectively. Thus NO a, a AND b, and a XOR b
are noted ¬a, a ∧ b, and a ⊕ b, respectively. The other basic Boolean operators are ≤
(noted →) and =(noted ↔). Thus, a → b is zero if a > b, and one otherwise. Similarly,
a ↔ b is zero if a = b, and one if a =b. I t is easily checked that the binary result of the
operation
(
a
→ b
)
∧
(
b ↔ c
)
is unity if and only if the condition a ≤ b = c is fulfilled.
In this chapter, we will not be concerned by Boolean logic other than just using XOR.