Monday 16 May 2016

Chapter Four. Late nights at Haertland Mathieu.


Back in the offices of Haertland Mathieu, with the blinds pulled firmly down, I stood on one side of the general manager’s desk and stared pointedly at Calloway. I think he was rather enjoying himself - he pointed the top of his head in my direction as he calmly and silently wrote out a grid of letters, and when he was finished he spun it round on the leather top, slid it in my direction, and said: “Well then.”

The grid looked like this:


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
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 A
C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
X Y ZA B C D E F G H I J K L M N O P Q R S T U V W
Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
Z 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

Calloway tapped the bottom corner, which I recognised as the origin of the fragment we had taken from Volkoff’s fireplace.

“This, Colonel,” he said, “is the Vigenere Cipher. It was known as the Unbreakable Cipher for four centuries. Fortunately, I think, brains like yours and mine should be able to crack it if we spend a few hours at it.” You could have bounced a sixpence off the surface of his self-confidence.

“Now, did you ever play around with secret ciphers when you were a boy?”

I hadn’t.

“This is the easiest. Caesar cipher, it’s called, after the man himself. You simply write out two alphabets, one offset just below the other, like this:

Clear: 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
Cipher: w x y  z a     b c d e f     g h  i  j  k        l  m n o p       q  r   s  t u     v

“Now, say you want to tell someone to MEET ME IN TRAFALGAR SQUARE. Just take each letter in turn, and write down the letter you see below it: iaap ia ej pnwbwhcwn omqwna. Or, to make it more difficult, you can run the letters together in groups of five, like our man’s mysterious correspondent did: iaapi aejpn wbwhc wnomq wna.

“This sort of cipher was the cleverest thing around in the Dark Ages, but it’s child’s play to break it now if you know the trick. The commonest letters in English are E T A - so you can simply take the commonest letters in your ciphered message and try each of them as E, T and A in turn.

“In our ciphered message here, there are four letter As, four Ws, two Ps, two Is and so on... the commonest letters in the cipher are A and W, so we can be fairly sure that one of those probably deciphers as E. It needn’t necessarily: if the message was “put all goods on sundial”, there would be no Es at all. But the longer the message, the more likely it is to follow the rule that E T A are the commonest letters in it. If we were to guess that W deciphered as e, and work from that, we get

Cipher: 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
Clear:   I J K L M N O P Q R S T U V W X Y Z A B C D E F G H

as our cipher key, and, taking each letter in the cipher and finding the one below it,
QIXXQ INRXV... as the deciphered message, which is obviously nonsense. Very well, we say, let’s guess that A deciphers as e instead...

Cipher: 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
Clear:     E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
and that gets us back to MEET ME IN TRAFALGAR SQUARE.”

I took a scrap of paper out of the furnace bag and tried it through for myself using the keys Calloway had written out. Once I’d worked my way back to the original message I nodded at him and he carried on.

“You can make life easier for yourself by looking at patterns of letters.There’s a double A in the ciphered message, and some letters are much more likely to be doubled in English than others; EE and TT and LL are common; CC and UU are less common (“access” and “vacuum”, but not many others); QQ and JJ and so on are unknown. Or if you happen to know that your message contains a certain word - what we call a crib - you can look for that: let’s say that you know that the message is about, oh, “Malabar”. Just look for something that follows that pattern - three letter As, each one letter apart, and that ABA will be very obvious - one letter, then the next one, then the first letter again - whether it ciphers as QRQ or DED or MNM or whatever.

“In any case, there are only twenty-six possible keys to the Caesar cipher - if you hit a complete dead end, you can just try each one in turn until it starts to look like English. Or French or German or whatever language the original is in; the letter frequencies are a little different in each language but the principle’s the same.

“Now, all of these things make the Caesar code completely inadequate for our purposes, or for the purposes of anyone out of short trousers. But what this grid -” he tapped the alphabet square again - “allows you to do is to change keys from one letter to the next. If you encipher the first letter using, say, the fifth column along as your cipher alphabet, then encipher the next letter in the sixth column, then back to the fifth and so on, you get something that’s a lot harder to break.You can’t count on the commonest letter in the cipher message being an enciphered E, because half the time you’ll cipher E as J and the rest of the time as K. You can’t look for double letters, because they’ll be enciphered as two different letters. And so on. And, of course, you don’t have to use just two alphabets alternately - you can use as many different alphabets as you like. If you pick a keyword, like KING, that means “encipher the first letter using the alphabet starting K, the second using the I alphabet, and so on” - at the fifth letter you go back to the K alphabet again.

“Take a message like this:
ONE BRIGADE AT YPRES FOUR BRIGADES AT ARRAS.
Encipher it using the keyword KING, and then I’ll show you how it can be broken as well.”
This took rather longer but eventually I came up with:

plaintext: ONE BRIGADE AT YPRES FOUR BRIGADES AT ARRAS
key letter: KIN GKINGKI  NG KINGK  INGK  INGKING    KI NGKIN
cipher:    YVR HBQTGNM NZ IXEKC NBAB JEOQIQKC IG GBZNY

“Now, you see,” Calloway went on, “we’ve repaired all the weaknesses of the Caesar cipher. We can’t look for patterns of letters. In fact, there’s a double letter there - GG, at the end - but that doesn’t mean a double in the message. It’s pure coincidence - the first G is an enciphered T and the second an enciphered A. And where we have a double letter in the message, as in ARRAS, it doesn’t encipher as a double; ARRAS becomes GBZNY. What’s more, we can’t just count up the commonest letter and assume it’s an enciphered E; an E could be enciphered as O or R or M or K, depending where it comes in the message and therefore which alphabet it’s enciphered with. And the same word can be enciphered as many ways as there are letters in the keyword; BRIGADE is in there twice, but the first time it’s HBQTGNM and the second it’s JEOQIQK.”

Calloway broke off and took a gulp of coffee, thoroughly enjoying himself.

“But it isn’t, you see, entirely unbreakable. An Englishman, a mathematician and a genius with machinery called Babbage, worked out how to get into it in the middle of the last century. Here’s how you open this particular oyster. Babbage realised that if you had a message that was simply a string of E’s, it would come out like this: OMRKOMRKOMRKOMRK and so on. Every four letters, you’re back to the start. Every letter can be enciphered four and only four ways. And the same is true of every word. However many times the word BRIGADE appears in the message, it can only ever be enciphered in four possible ways. The first letter has to be enciphered using the K alphabet, or the I, or the N, or the G. And the second letter has to be enciphered using the next letter in the key. So, if your message was a little longer, you might have something like this.”
He thought for a few seconds and then scribbled a few more words at the end, rapidly enciphering them.  

Clear: ONE BRIGADE AT YPRES FOUR BRIGADES AT ARRAS HQ AT YPRES
Key:    KIN GKINGKI   NG KINGK INGK   INGKINGK IN   GKING  KI  NG KINGK
Cipher:YVR HBQTGNM NZ IXEKC NBAB JEOQIQKC IG GBZNY RY NZ IXEKC

“See the pattern? As I said, BRIGADE comes into the message twice and is ciphered as two completely different words. But AT YPRES comes into the message at two places as well now, one 24 letters after the other. And because 24 is a multiple of 4, the keyword’s worked its way back round to the same place again - look how it matches up, you encipher AT YPRES with “ngkingk” both times - and so  AT YPRES comes out as NZIXEKC both times in the cipher. Your cipher-breaker can look at that and say ‘I don’t know what NZIXEKC means; I don’t know what the keyword is or even how long it is; but, whatever the keyword is, it must go into 24 an exact number of times, because in 24 letters it’s worked its way round a whole number of times.’ That doesn’t narrow it down too much, because he could have a keyword of 2, 3, 4, 6, 8, 12 or even 24 letters. But if it’s a long message and the gods are on his side, he’ll find a few other repeats as well, and he’ll work out that he’s dealing with a four-letter keyword. Then he writes the message out in four columns:

Y V R H
B Q T G
N M N Z
I X E K
C N B A
B J E O
Q I Q K
C I G G
B Z N Y
R Y N Z
I X E K
C.

Look, you can see the repeat there very clearly - two identical lines, the fourth from the top and the last but one. And if he takes the first column – which has the first letter of the ciphered message, the fifth letter, the ninth and so on - he knows that every letter in that was enciphered using the same alphabet, that of the first letter in the keyword.  And therefore he knows that the commonest letter, in the first column, will probably be an enciphered E. The same for the second column - the commonest letter will be different, but he can still be confident that it deciphers as E. Essentially he’s turned the problem from one unbreakable cipher into four very simple Caesar ciphers. He doesn’t even have to solve all four - if he works out that the first three letters of the keyword are K I N, he can have a guess at the fourth - the word’s either KING or KIND, or, I suppose, KINE or KINK. But finding those repeats is the break you need.”

“So our first step,” I said, “is to go through all this and look for where it starts to repeat itself.”
“Well, our first step would be to find the keyword written down somewhere,” Calloway said with a grin. “Cipher breaking is easiest when someone gives you the answer. But our man’s probably got that tucked away inside his head. He’d never carry that around with him - and, in any case, we know from his police file that when he was arrested two months ago he didn’t have anything that looked like a cipher key in his pockets; and there was nothing like it in his rooms for that matter. Not even the alphabet square. He must write that out afresh for each message and then burn it all once he’s finished deciphering. We were lucky, frankly, to find that little scrap to give us a lead.”

That was all very well. But three hours later Calloway and I - and a couple of other Haertland Mathieu clerks whom we had called in - looked up from our copies of the cipher and saw each other’s despairing faces.

“Sir, I don’t think this actually has any repeats at all,” the taller of the two clerks said eventually. “None we can spot, anyway. We’ve tried breaking it up into everything up to thirty columns to make the patterns easier to find - and nothing. Maybe it isn’t a Vigenere cipher after all - it’s something else?”

“Or else the keyword is even longer than thirty letters,” I suggested.

“But,” Calloway said, looking somewhat harrowed, “even if the damn thing is a hundred letters long, we should still see some repeats - this message is over two thousand letters long. And he’d have to remember the key! He can’t write it down! Do you think someone could reliably remember a hundred-letter key? Especially since he’s probably using a different key for each message, and it won’t necessarily be a plain German word - it’s much more likely to be a series of random letters. He’d have to learn and memorise a different key every few days. He’d have to be a wizard to remember a sequence of a hundred random letters. It’s too risky. Conspiracies are like firearms - the fewer moving parts the better.”
He pushed his hair back off his forehead.

“Or he’s written it down and hidden it?” I suggested. “Somewhere in his rooms, but we missed it? Or even on his person? The Swiss police can’t be infallible.”

“In that case,” said Calloway, “we really are sunk. Because if he’s using a long key - ideally a key as long as the message is itself - then what he has really is an unbreakable cipher. The wranglers will even tell you that it’s provably unbreakable, as long as the letters are truly random and you don’t re-use the key; we call it a one-time pad, because you’re issued the keys in the form of a pad of paper, like a notebook, with each page a new key. Once you use one, you tear out the page and burn it. And then there’s no way that even an entire college of geniuses could break into it, not if they kept at it until the Last Trump. There’s nothing to get a grip on - no repeats, no patterns. It’s completely flawless.”

“Why doesn’t everyone use them?” I asked. “Isn’t it rather perverse to use anything else if you’ve got a guaranteed unsinkable cipher?” Partly I was interested in this peculiar game of Calloway’s; partly I didn’t like to see the man despairing so publicly.

“Convenience, in the main,” Calloway said. “You need one page for every message. Imagine a corps headquarters trying to encipher every one of the hundreds of messages it sends every day; it would need trunks full of the pads. And so would everyone else who was on the other end of the signals. And you’d need to keep distributing new ones to all your outstations - and that’s risky and time-consuming. It’s not easy to produce lists of truly random letters, either. And the pads can be stolen - at which point everyone needs to replace them right away. And, which is worse from our point of view in this game, there’s absolutely no way of disguising a pad as anything else. If you find a man with a one-time pad, then he’s done for. All this cipher needs, on the other hand, is pencil and paper - and a keyword that can be memorised. One-time pads might be ideal to a wrangler but to us poor working men they’re worse than useless.”

“Couldn’t he have disguised the pad as a book?” I asked. “There must have been hundreds of them in his rooms.”

“Thought of that,” Calloway said, “or rather we didn’t think of exactly that but we checked all the books anyway on general principles. None of them had anything like that, and we checked them fairly thoroughly. No pages of random letters - nothing but perfectly normal German and Russian.”

“Well, maybe that’s the key,” I said. “Maybe he just takes a page of one of the books – one of the German ones, because of the alphabet - and starts off with the first word, using that as the key. Wouldn’t that work just as well as one of your one-time pads?”

“Doesn’t get us any further forward,” Calloway replied with a groan. “Two hundred books at least in German, four hundred pages or so in every book – eighty thousand possible keys and that’s assuming that he starts at the top of the page rather than the fifteenth word on the twelfth line or something. It’s still impossible. If we had a division of clerks here we could break it in a couple of weeks by exhausting every possibility in turn, but with four of us it would take years. And I suspect that the strategic situation surrounding this operation might have changed rather by 1920 or so. Not to mention that, remember, he deciphered this message on the spot in the Cafe Hirsch - so whatever the key-book was, he had a copy with him, and it’s perfectly likely that he wouldn’t have kept another copy at home. So the key-book might not be one of the ones on these shelves at all.” 

“No, wait,” said the previously-despairing Haertland clerk, his eyes brightening. “Let’s assume that Herr Kormann is right for the moment – surely there must be some way to exploit this even without the key-book. The key would be very predictable once we started to break it. If it’s using a German text as the key to encipher another German text, then maybe the letter frequencies would, added together…” he trailed off. 

His colleague, an older man with the beginnings of a highly respectable and burgerlich belly beneath his waistcoat, looked glum. “I actually doubt that would work, surely there would be too much variation…”

Calloway nodded. “But you’re right in principle, though – there should be some way to exploit that. It seems like such an obvious weakness.”

“If we knew the first word of the letter already,” the younger clerk said ruminatively, “we could derive the first word of the cipher key from that. Because we already have the enciphered version.”

“And where does that get us?”

“Well, we could guess at the second word of the cipher key and try that in turn. Or we might be lucky and have an overlap.”

He passed the coffee round again.

“Overlap?”

“Let’s say we knew the first word of the message should be ZURICH. And let’s say the first six letters of the ciphered letter were, er…” - he paused to scribble on yet more of Haertland Mathieu’s office stationery –  “RCVCPI. Then we can work out that the first six letters of the key must be SIEHAB. ‘Sie hab’. Then we can hazard a guess that the next two letters of the key are probably EN to complete ’Sie haben’ – we try that on the cipher and that gives us the first two letters of the next word in the message – perhaps we can guess at the rest of that word, and that in turn gives us the next few letters of the key, and so on. With a bit of luck and trial and error, we can jump from one to the other, from the key text to the message text and back again, like a man climbing a chimney and leaning first on one side and then on the other.”

The mental image seemed to startle him, and he paused briefly and looked suspiciously into his coffee cup. 

“But we don’t know what the first word of the message is.” 

“No,” said Calloway, “but we can guess what some of the words must be. ‘Zurich’ probably does appear in that letter somewhere. So will ‘polizei’, I should think, if I have our man to rights. And I wouldn’t be surprised to see ‘Russland’ or ‘Russische’. All we have to do is try to fit each of those into the message, and keep trying – and noting down what key we need to make each group of cipher letters translate as ‘Russland’. And if we’ve hit the right spot, then the key will be, well, something readable. Readable German. If we’re wrong it’ll be gibberish.”

“And,” I said, with a sudden inspiration, “we can save even more time. This cipher is thousands of letters long and trying ‘polizei’ at every letter in turn will take hours. We can have a damned good guess at the first few words of the letter. Our man’s correspondent – we know who he is, don’t we? From the handwriting and the notepaper? He’s the same man inside the German residency who’s been writing payment instructions to the fellow at the Cantonalbank, and been duped by Haertland Mathieu for the last ten months.”
Quiet smiles from the two clerks.

“We’ve got all the messages he sent to the bank chap, in plain German. Now, he may be a devil of an intelligence officer but he’s also a German and a civil servant, and those two things mean he is a creature of habit. He’ll have a routine and he’ll follow it. And I will stake a hundred of any currency you choose that he starts most of his letters to our bank clerk the same way – he’ll say ‘I have received your last letter’ or ‘yours of 26th to hand’ or some such - and that’s the way that this letter starts too. Let’s at least try that first - we’ll look at all the letters of his that we have, find any common features, and see if it gives us anything in the way of a comprehensible key.”

The rain had stopped hammering at the window, and a watery dawn sunshine was breaking through the clouds when we finally made the break into the message. The Boche intelligence officer’s instructions to our bank clerk all commenced with the same rubric, “An Arbeiter 66801” - “To Agent” and then the clerk’s code number. We tried ANARBEITER as the crib for the first few letters of the message and got nowhere. Not until we tried the crib a little further on in the message did we start to derive a meaningful key. Our intelligence officer had been a little crafty: he’d padded the start of the ciphered message with a meaningless word - probably as instructed to do in the Official Manual of Secret Code Writing. But after the padding word, “Rosengarten”, there was our crib and the start of the message itself, and the start of the key text along with it.

Somewhat to my surprise, the first words of the key text looked familiar: the German intelligence officer, it seemed, had enciphered this latest message using as a key a translation of Conan Doyle’s “The Hound of the Baskervilles”. I wondered whether he or the Russian had been the one to choose it… and as, on one sheet of paper, the story of Watson and Holmes’ desperate pursuit of the spectral hound across Dartmoor took shape, the other sheet filled up with Volkoff’s latest instructions from his German handler.

No comments:

Post a Comment