Sie sind auf Seite 1von 16

Fall 2003

Chris Christensen
Class notes

Affine Ciphers
Cryptography
Combining the two processes of the Caesar cipher and the multiplicative
cipher results in a transformation of the form C mP b . This is called an
affine cipher.
affine (adjective): via French, from Latin ad "to, at," and finis
"boundary, border," of unknown prior origin. Although the original
meaning of the Latin adjective affinis was "neighboring, adjacent," the
most common meaning eventually became "related by marriage." The
notion of kinship or affinity was carried into French, and from there to
English. In mathematics, the affine transformations include
translation [and] stretching [multiplication] .
Affine transformations maintain a "kinship" between the original
object and the transformed object. For example, in the plane, a pair of
parallel lines is transformed into a pair of parallel lines.
The Number of Possible Keys
Now we have two parts to the key an additive part b (the shift) and a
multiplicative part m (the decimation interval). As there are for Caesar
ciphers, there are 26 choices for b. For each of those choices, there are (as
there are for multiplicative ciphers) 12 possible choices for m. Therefore,
there are 26 12 312 possible affine ciphers. Of course, one of these does
nothing the cipher with b = 0 and m = 1 yields C = P, the plaintext
alphabet. This would obviously not be a good choice for encryption.
The 312 affine ciphers include the 26 Caesar ciphers (the affine ciphers with
m = 1; C = P + b) and the multiplicative ciphers (the affine ciphers with b =
0, C = mP).

Here is an example of an affine cipher with additive key 5 and multiplicative


key 7.
Affine cipher
Multiplicative key = 7 and additive key = 5
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

12
19
26
7
14
21
2
9
16
23
4
11
18
25
6
13
20
1
8
15
22
3
10
17
24
5

L
S
Z
G
N
U
B
I
P
W
D
K
R
Y
F
M
T
A
H
O
V
C
J
Q
X
E

Cryptanalysis
Recognition and Cryptanalysis
Just like the multiplicative cipher, an affine cipher with m 1 decimates the
alphabet but if b 0 there is also a shift. We can recognize an affine cipher
from its frequency chart if we can spot a decimation and a shift.
Here is a frequency chart transformed by the affine cipher with additive key
5 and multiplicative key 7.
Frequencies
Additive key = 5 and Multiplicative key = 7
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z

11111111
11
1

1111111
1111
111111
1111
11
1111
1111111
111
1111111111111
111111111
1111111
111
1
111
111
11
11111111
111

If b 0 , unlike the multiplicative cipher, ciphertext Z will not correspond to


plaintext z. It is much more difficult to determine the decimation interval.
Notice that in this case cipher E corresponds to plaintext z. Counting
backwards from E in intervals of 7 we find
E
X
Q
J
C
V

(low)
(low)
(low)
(low)
(low)
(not high)

which from b = 5 and m = 7.


Another Cryptanalysis by Frequency Analysis
If we knew or had reason to suspect that we were dealing with an affine
cipher, we might use the following method of cryptanalysis.
Recall that for a Caesar cipher C = P + b we need only one plaintextciphertext letter correspondence to determine the shift b and for a
multiplicative cipher C = mP we need only one plaintext-ciphertext letter
correspondence to determine the multiplier m. On way of cryptanalyzing
those ciphers is to assume that the most common ciphertext letter
corresponded to the plaintext e. (If that turned out to be an incorrect choice,
we assumed that another high frequency plaintext letter corresponded to e,
and we continued this process until the correct key was determined.)
For an affine cipher, we need to determine two keys b and m. We need two
ciphertext-plaintext correspondences to do that.
Example 7.1
Here is a ciphertext
OINRFHORXHONAPFVHLHMNZOFUOINANGRLZI
PYNJLHOINMKVBLYGMKVBSFLAGLAALYBNRNY
OVHNGSXPO
4

and here is a frequency analysis of the ciphertext


A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z

11111
111

1111
1111
111111
1111
1
11
1111111
111
1111111111
11111111
111
1111
11
1
1111
11
1111
11

Let us assume that an affine cipher was used. We need two plaintextciphertext correspondences. We might begin by assuming the most frequent
ciphertext letter N corresponds to plaintext e and the second most frequent
ciphertext letter O corresponds to plaintext t.
This would give us two equations to solve modulo 26.
C mP b mod 26
If ciphertext N(C = 14) corresponds to plaintext e (P = 5),
14 m5 b mod 26 .

If ciphertext O (C = 15) corresponds to plaintext t (P = 20),


15 m20 b mod 26 .

We have a system of equations to solve modulo 26.


14 5m b mod 26

15 20m b mod 26
Here is a solution. We begin by subtracting the first congruence from the
second.
1 15m mod 26
m 151 mod 26
m 7 mod 26
m = 7. Now substitute this into one of the congruences, say the first.
14 5 7 b mod 26
14 35 b mod 26
b 21mod 26
b 5mod 26
b = 5.
If we were correct in our assumptions that ciphertext letter N corresponds to
plaintext letter e and ciphertext letter O corresponds to plaintext letter t, then
the affine cipher has additive key 5 and multiplicative key 7.
Use the key given above to decipher the ciphertext.

Brute Force
Although it would not be pleasant to do by hand (however, you might be
willing to do that if the security of the free world depended upon it), it would
not be hard for a computer to print out the 312 plaintext messages which
result in this ciphertext. Then, we just need to find the one that makes sense.
Another Approach
We could search through the ciphertext for an enciphered version of the.
Here are the 312 affine ciphers of the.
Enciphered the

Multiplicative key

ACJ
ACR
ADJ
AEF
AGB
AOL
AQH
ASD
AUZ
AWV
AXP
AYR
BDK
BDS
BEK
BFG
BHC
BPM
BRI
BTE
BVA
BXW
BYQ
BZS
CAT
CEL

15
23
21
17
19
1
3
5
7
9
25
11
15
23
21
17
19
1
3
5
7
9
25
11
11
15

Additive key
13
15
25
25
11
7
19
5
17
3
22
15
14
16
0
0
12
8
20
6
18
4
23
16
17
15

CET
CFL
CGH
CID
CQN
CSJ
CUF
CWB
CYX
CZR
DAS
DBU
DFM
DFU
DGM
DHI
DJE
DRO
DTK
DVG
DXC
DZY
EAZ
EBT
ECU
EGN
EGU
EHN
EIJ
EKF
ESP
EUL
EWH
EYD
FBA
FCU
FDW
FHO
FHW
FIO
FJK
FLG
FTQ

23
21
17
19
1
3
5
7
9
25
25
11
15
23
21
17
19
1
3
5
7
9
9
25
11
15
23
21
17
19
1
3
5
7
9
25
11
15
23
21
17
19
1

17
1
1
13
9
21
7
19
5
24
25
18
16
18
2
2
14
10
22
8
20
6
7
0
19
17
19
3
3
15
11
23
9
21
8
1
20
18
20
4
4
16
12

FVM
FXI
FZE
GAF
GCB
GDV
GEX
GIP
GIX
GJP
GKL
GMH
GUR
GWN
GYI
HBG
HDC
HEW
HFY
HJQ
HJY
HKQ
HLM
HNI
HUS
HXO
HZK
IAL
ICH
IED
IFX
IGZ
IKR
IKZ
ILR
IMN
IOJ
IWT
IYP
JBM
JDI
JFE
JGY

3
5
7
7
9
25
11
15
23
21
17
19
1
3
5
7
9
25
11
15
23
21
17
19
1
3
5
5
7
9
25
11
15
23
21
17
19
1
3
5
7
9
25

24
10
22
23
9
2
21
19
21
5
5
17
13
25
11
24
10
3
22
20
22
6
6
18
14
0
12
13
25
11
4
23
21
23
7
7
19
15
1
14
0
12
5

10

JHA
JLA
JLS
JMS
JNO
JPK
JXU
JZQ
KAR
KCN
KEJ
KGF
KHZ
KIB
KMB
KMT
KNT
KOP
KQL
KYV
LBS
LDO
LFK
LHG
LIA
LJC
LNC
LNU
LOU
LPQ
LRM
LZW
MAX
MCT
MEP
MGL
MIH
MJB
MKD
MOD
MOV
MPV
MQR

11
23
15
21
17
19
1
3
3
5
7
9
25
11
23
15
21
17
19
1
3
5
7
9
25
11
23
15
21
17
19
1
1
3
5
7
9
25
11
23
15
21
17

24
24
22
8
8
20
16
2
3
15
1
13
6
25
25
23
9
9
21
17
4
16
2
14
7
0
0
24
10
10
22
18
19
5
17
3
15
8
1
1
25
11
11

11

MSN
NBY
NDU
NFQ
NHM
NJI
NKC
NLE
NPE
NPW
NQW
NRS
NTO
OCZ
OEU
OGR
OIN
OKJ
OLD
OMF
OQF
OQX
ORX
OST
OUP
PDA
PFW
PHS
PJO
PLK
PME
PNG
PRG
PRY
PSY
PTU
PVQ
QEB
QGX
QIT
QKP
QML
QNF

19
1
3
5
7
9
25
11
23
15
21
17
19
1
3
5
7
9
25
11
23
15
21
17
19
1
3
5
7
9
25
11
23
15
21
17
19
1
3
5
7
9
25

23
20
6
18
4
16
9
2
2
0
12
12
24
21
7
19
5
17
10
3
3
1
13
13
25
22
8
20
6
18
11
4
4
2
14
14
0
23
9
21
7
19
12

12

QOH
QSH
QSZ
QTZ
QUV
QWR
RFC
RHY
RJU
RLQ
RNM
ROG
RPI
RTA
RTI
RUA
RVW
RXS
SGD
SIZ
SKV
SMR
SON
SPH
SQJ
SUB
SUJ
SVB
SWX
SYT
THE
TJA
TLW
TNS
TPO
TQI
TRK
TVC
TVK
TWC
TXY
TZU
UAV

11
23
15
21
17
19
1
3
5
7
9
25
11
15
23
21
17
19
1
3
5
7
9
25
11
15
23
21
17
19
1
3
5
7
9
25
11
15
23
21
17
19
19

5
5
3
15
15
1
24
10
22
8
20
13
6
4
6
16
16
2
25
11
23
9
21
14
7
5
7
17
17
3
0
12
24
10
22
15
8
6
8
18
18
4
5

13

UIF
UKB
UMX
UOT
UQP
URJ
USL
UWD
UWL
UXD
UYZ
VBW
VJG
VLC
VNY
VPU
VRQ
VSK
VTM
VXE
VXM
VYE
VZA
WAB
WCX
WKH
WMD
WOZ
WQV
WSR
WTL
WUN
WYF
WYN
WZF
XAG
XBC
XDY
XLI
XNE
XPA
XRW
XTS

1
3
5
7
9
25
11
15
23
21
17
19
1
3
5
7
9
25
11
15
23
21
17
17
19
1
3
5
7
9
25
11
15
23
21
21
17
19
1
3
5
7
9

1
13
25
11
23
16
9
7
9
19
19
6
2
14
0
12
24
17
10
8
10
20
20
21
7
3
15
1
13
25
18
11
9
11
21
22
22
8
4
16
2
14
0

14

XUM
XVO
XZG
XZO
YAH
YAP
YBH
YCD
YEZ
YMJ
YOF
YQB
YSX
YUT
YVN
YWP
ZBI
ZBQ
ZCI
ZDE
ZFA
ZNK
ZPG
ZRC
ZTY
ZVU
ZWO
ZXQ

25
11
15
23
15
23
21
17
19
1
3
5
7
9
25
11
15
23
21
17
19
1
3
5
7
9
25
11

19
12
10
12
11
13
23
23
9
5
17
3
15
1
20
13
12
14
24
24
10
6
18
4
16
2
21
14

It could be an unpleasant experience to compare one-by-one all of the


trigraphs of the ciphertext against the table, but we luck out. The very first
trigraph OIN appears in the table as the enciphered version of the when the
multiplicative key is 7 and the additive key is 5.

15

Exercises
1. Construct a plaintext-ciphertext correspondence for an affine cipher
with multiplicative key 11 and additive key 16.
2. Encipher the following message using an affine cipher with
multiplicative key 11 and additive key 16.
TheRussiansandGermansalsosolvedPURPLE.

3. Use frequency analysis to cryptanalyze the following ciphertext:


EJURBIOJMRXGEMHHUBXWTWJZMQEJURBISUS
BWQEIQVGZWNBCIVGZMJUYWUSBJWMQSWHWEB
JIZGEMHHUBIOWZWJMBWMBXGJNYWUSBJWMQ

4. Search through the ciphertext in exercise 3 for an enciphered version


of the. Then determine the multiplicative and additive keys and recover
the plaintext.

16