Thursday, January 21, 2016

Encryption in World War 2: The Wheelset


Have you ever wondered how some of the German WWII ciphers worked? After reading a couple books on the subject I decided to write an encryption program based on the spirit of the WWII Tunny (fish) ciphers. This is modern interpretation based on the German Lorenz cipher machine, and I primarily did this to teach myself more about the process.


Tunny was a binary cipher, all input was converted to ones and zeros. It was also transmitted (in binary) using electronic machines. There were no human radio operators for Tunny which was unlike Enigma which was not binary and was transmitted by radio operators sending alphabetic characters.

Today's post is an introduction to the wheels and setting up a wheelset. The German machines had a series of wheels that rotated. Each wheel was covered with random bits, and that random data was combined with the letters producing encrypted messages. Each time a letter was enciphered one or more wheels changed locations which changed the random data.

Here is a simple two wheel example. Wheel A is set in location 2 which has a value of 149. Wheel B is set in location 4 which has a value of 203. As the wheels turn in a virtual way they change locations providing a combination of pseudo-random values.

Loc
Wheel A
Loc
Wheel B
0
93
0
11
1
27
1
41
->
2
149
2
165
3
161
3
76
4
30
->
4
203
5
89
6
54

 

A good question that I pondered was how many wheels to have. This is primarily for teaching, so I didn't feel like I need 12 wheels. The starting location of the wheels is a type of message key for the cipher. So it's useful to look at an example of how the number of wheels affects the strength of the message cipher.

Let's say that we have 120 numbers to partition out amongst an undecided number of wheels. If we created two wheels each one could have 60 numbers, if three wheels each could have 40 and so on. Below I built a table showing the number of possible starting key combinations for some example setups.

Number of wheels
Size of wheel
Key Combinations
1
120
120
2
60
3,600
3
40
64,000
4
30
810,000
5
24
7,962,624
10
12
61,917,364,224
20
6
3.65616E+15
60
2
1.15292E+18

 

As you can see, even though we cap the total numbers, choosing a higher number of wheels significantly increases the complexity of your key. For this example program I decided that 4 wheels would provide enough complexity to give some good examples. If I was a little more serious I would increase the wheel count to 8 and the number count to something larger like 240. Even then my program would not have a very powerful key, the security of the program would be less in the key, and more in the wheelset. As long as no one got the 240 numbers in your wheelset you would be relatively safe sending a lot of short messages.

With the original machine, the wheels were physical and had to be replaced to introduce a new set of random values, but with my program I can readily regenerate the wheelset when needed. But remember that both parties need to securely exchange the wheelset before they start sending messages.

Below is an example of the program. Notice that there are 4 wheels in the Daily Wheel Key. Each day all participants would set the starting value to a predetermined setting. Notice that this method requires the users to share keys and the wheels before they go their separate ways and start sending messages. In WWII there were hundreds of navel vessels and army outposts that all had matching codebooks with daily keys that had to be kept safe or the messages would be at risk.


Things to Try:

  • Enter a message and encrypt it. Copy the xml output to the input field and decrypt.
  • Change a key setting when decrypting and verify that you can't decrypt if the settings have changed.
  • Encrypt the message "pppppp" and notice that each letter translates to a completely different number. This is not a cryptogram where all letters map to the same thing.

Friday, January 1, 2016

All Books Review - 2015

Last years review of every book I read was seen by at least 5 people. I feel compelled by my past success to keep up the tradition.

Fiction

The Martian by Andy Weir - Exciting and funny. It reminds of Nel Stephenson or Michael Crighton in the scientific technical delight of the author.

All The Light We Cannot See by Anthony Doerr - How can one book contain so many characters that I care deeply about? Marie-Laure goes blind while every loss seems matched by a discovery of the world around her. Werner escapes poverty but loses himself in the Nazi’s. Frederick stands out unique to his core, and is brutally crushed for it. Etienne overcomes the demons of an older war and finds a reason to live again.

Life After Life by Kate Atkinson - Early on I struggled to understand the rules of this reincarnation tale. Then I got caught up in it and the nuanced portrait of Ursula’s family as you see them over and over. But in the end it fell flat. Ursala lives her life in a loop of minor (and major) variation, but do any of them make an impact?

Open City - A book of deep and philosophical boredom. Julius goes on long walks and thinks about stuff. About half way though you start hoping for an alien invasion, or maybe Julius could decide to hike Mount Kilimanjaro, or join a fight club, anything really.

Non-Fiction

Inside Box 1663 by Eleanor Jette - I bought this at the Los Alamos bookstore, it's a great little book about life for the families working on the manhattan project. Sometimes locally published books can be amazing.

Seizing the Enigma: The Race to Break the German U-boat Codes, 1933-1945 - Highly recommended if you like encryption and war books.

Code Breakers: The inside story of bletchley park - Each chapter is written by a different author about their experience cracking German and Japanese codes. It’s a great book, and shows the wide variety of people working on the project and how isolated some of their jobs were.

The Moffat Line: David Moffat’s Railroad Over and Under the Continental Divide - I really wanted this to be good, but sometimes locally published books can lack a coherent story.

River of Doubt - Theodore Roosevelt’s Darkest Journey by Candice Millard - There was  interesting material in this book, but there are other Roosevelt books to read first.

Saturday, June 20, 2015

A Father's Day wish for paternity leave


The first few years of having kids can be charitably described as an intense orientation. It’s taken me some time to process the experience, and I’m starting to feel a little more comfortable sharing some opinions on the topic. One opinion that has grown on me is that it is time to increase access to paid paternity and maternity leave.


Right now only about half of American workers qualify for the limited benefits of the Family Medical Leave Act. We fit into that breakdown fairly well, I qualified for FMLA and my wife didn’t. In conversations leading up to the birth of our girl I also came to realize that many people don’t understand that FMLA provides only unpaid time off. Like most couples we had to use a combination of vacation, sick time, and unpaid leave for our babies. In addition, my wife could have legally been fired for not showing up to work when she was recovering with the baby. Now we both kept our jobs and were financially ready for the event, but not everyone has that luxury. Many people deplete all vacation and sick time which limits their options for caring for needs that the baby might have in the coming months.


Even a lot of young and healthy mothers won’t have the capacity to work for a couple weeks leading up to the birth. Many are prohibited from walking up stairs for six weeks after a birth. You can have a great plan for the finances and timeline of having a baby, and that can all get thrown out of the window within five minutes of seeing a doctor. Starting a family and a financial crises at the same time can lead to years of debt and consequences. Why not take some steps that can keep young families out of financial crises.


I also think that it is important for fathers to take real time off. I remember the day before we went to the hospital someone trying to tell me that I was planning to take too much time off of work and pushing me to change my plans. On most days, an insensitive comment wouldn’t have affected me much. But I was really hurt by that at a time when I was under a lot of stress and uncertainty. I felt like I really stood out for taking more than two weeks off. Fathers should take time off, caring for a newborn and a mother is important. There are many in my generation that are spending more time playing and caring for their children, and that is something we should be proud of, and fight for.

Let’s get families started with a little less stress, and a little more financial backing. There are many countries that have figured out how ways of supporting paid leave, and we can put reasonable limits on the program. This is not going to drive companies out of business and it’s not going to lead us to socialism. I think it is time to make paid family leave a reality.

Monday, June 8, 2015

My husband is wise

My husband is wise.

We are celebrating 13 years of marriage and 18 years together. I love him. I adore him. I can't imagine my life without him and I am grateful to my 16 year old self for talking to him at a leadership conference.

We were recently talking to a friend at the beginning of a relationship. I put him on the spot and asked for his perspective on advice for relationships. Here's what he said:

1) Be with someone you like to do things with. 
A lot of life is doing things together, spending time together and talking. Find someone you like to talk to and want to spend time with. The best couples we know enjoy one another and the most awkward ones don't like to talk about the same things. It really helps if you enjoy some mutual hobbies and agree on where to spend some discretionary money. For example we both enjoy photography. If one of us didn't, it would be a lot more difficult to wake up early for the best light, take interesting diversions or spend $1000 on a lens. We both have our own things that take time, energy and money. We tend to bike and golf apart, but sometimes together. We like to travel. We like to eat out and try new places. We vacation similarly and don't like to sit around all day. Being comfortable with being together makes like easier.

2) Make life interesting.
Life is short. Don't be dull. Do interesting things. Go interesting places. Meet interesting people. Try new things.

3) Sometimes it won't be your turn, but do it anyway and do it without complaining.
Chores and household responsibilities will never be equal and they probably can't be.  With all sorts of responsibilities in life, it will not be your turn to do the dishes or change a diaper or go to a child who has awoken in the night. Do it anyway and don't complain. It will be more pleasant for everyone and make life better.

I am totally biased toward my husband, and I thought he summed these aspects of relationship up quite well. I hope some others find them useful.

And thanks, dear, for a wonderful, interesting life together. I'm so glad to have found such a wise and good partner.

Tuesday, January 6, 2015

All Books Review

Last year I decided to read more books. I think I'm a more interesting person when I read books, or at least I sound more interesting to myself as I'm yapping away. These are all the books I read with a brief review. For those who keep track 7,937 pages in total.


NON FICTION


The Guns of August - Barbara W. Tuchman
The folly of the opening month of the first World War. Highly recommended.
An Illustrated History of The First World War - John Keegan
Don’t look down on a good picture book.
The Great Influenza: The Story of the Deadliest Pandemic in History - John M. Barry
Full of interesting rich detail that resulted in me reading aloud to anyone nearby.
A Briefer History of Time - Stephen Hawking
One of the best science books that I have read. Hawking makes the case that the study of physics needs more ordinary people, philosophers, and religious leaders to discuss the meanings and implications of our understanding of the universe.
Quantum Theory A Graphic Guide
Until I find something better I will recommend this quick reference to quantum physics.
A short history of nuclear folly - Rudolph Herzog
A short and shocking book to destroy your belief in the likelihood of our continuing existence.
The Signal and the Noise - Nate Silver
I think Nate Silver was trying to write the next Freakonomics, instead he illustrated why some people should stick to writing a blog.
The Rise and Fall of Ancient Egypt - Toby Wilkinson
Ancient Egypt is often portrayed as a mystery. If you make it through this 600 page book you will see through the mysteries.
Manias, Panics and Crashes: A History of Financial Crises
This book jumps between events spread across continents and centuries. But it does reinforce that there is nothing new under the sun. Crisis and Government intervention/bailouts are very common.
The Hubble Wars - Eric J. Chaisson
Instead of trying to build a sense of wonder in our universe, Chaisson focuses on airing out his personal anger with NASA. Writing a book is not a replacement for a therapist.

FICTION

The Cuckoo’s Calling - Robert Galbraith
Rowling spins a top notch crime mystery. I was guessing down to the last page.  
The Silkworm - Robert Galbraith
Another great mystery, but a little heavy on the depravity.
We Have Always Lived in the Castle
A spooky classic that made me want to spend more time talking with literature critics.
Diamonds Are Forever - Ian Fleming
James Bond is a well written character, pour yourself a drink and dive in.
The Long Earth - Terry Pratchett and Stephen Baxter
This is good concept Sci-Fi, examining what would happen if suddenly everyone could easily move between a limitless series of worlds.
The Long War - Terry Pratchett and Stephen Baxter
A good follow-up, but the long war actually never happens.
Betrayal: Star Wars (Legacy of the Force)
Bloodlines: Star Wars (Legacy of the Force)
Tempest: Star Wars (Legacy of the Force)
Three Star Wars books, slightly amusing.
The Laughing Monsters - Denis Johnson
Apparently one of the best pieces of literature in 2014, I’m just not sure why.

Wednesday, December 3, 2014

Geeky thought of the week: an intense beam of light

I was reading about recent improvements in voice to text technology and the Government's ongoing goal to broadly track conversations from YouTube, government placed cameras, and other audio sources.
It occurred to me that there is a parallel with Heisenberg's Uncertainty Principle here. You might remember Heisenberg and his finding that you can't study something without changing it. He was speaking of quantum theory and atomic particles. The smaller the wavelength of light, the more energy it contains. To measure a subatomic particle you need a tiny wavelength with a corresponding powerful blast of energy that drastically affects the subject being studied. This finding has had philosophic implications from the start. Hawking cites the Uncertainty Principle when saying it is impossible for us to know the state of the Universe before the big bang, to know the conditions that precipitated it, or what higher power may have had a hand in its formation. This principle has also been used to show the logical shortcomings of our intelligence. Even with unlimited resources we can't know the state of the Universe, nor calculate its next steps.
A tool powerful enough to study every small conversation is not innocuous. The ray of observation affects us all, and it is impossible to say what results may come. It does not seem that outlandish to expect that many branches of communication will be affected and that ordinary people will change their habits and approach to securing communication. Quantum mechanics teaches us of the inherent difficulty in tracking complex systems, perhaps we should take that lesson to heart.