While not strictly necessary, replacing the two ASCII tab characters in the markdown copyright comment makes it easier to detect problematic TAB indentation within markdown files. After this commit, only 90 markdown files have leading ASCII TAB characters. And again, while not strictly necessary, we can consider running expand on those 90 markdown files to see what effect that might have on the HTML files they produce. Replace leading ASCII TAB characters with multiples of 8 ASCII SPACE characters (the default action of the `expand(1)` tool) might have an negative effect on some HTML formatting where **hack-a-round** formatting was attempted to fix broken indentation caused by problematic ASCII TAB characters. Think of this as a baseline for evaluating leading TAB characters within markdown files. TODO: Consider either using `expand(1)` to replace leading ASCII TAB characters with multiples of 8 ASCII SPACE characters AND/OR modifying the appropriate `bin` tool to convert leading ASCII TAB characters into multiples of 8 ASCII SPACE characters.
1199 lines
62 KiB
HTML
1199 lines
62 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||
<!-- START: two lines up starts content from: inc/top.default.html -->
|
||
|
||
<!-- END: this line ends content from: inc/top.default.html -->
|
||
<!-- START: this line starts content from: inc/head.default.html -->
|
||
|
||
<head>
|
||
<link rel="stylesheet" href="../../ioccc.css">
|
||
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@100..900&display=swap" rel="stylesheet">
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
||
<title>2020/ferguson2 - Most enigmatic</title>
|
||
<link rel="icon" type="image/x-icon" href="../../favicon.ico">
|
||
<meta name="description" content="2020 IOCCC entry ferguson2 - Most enigmatic">
|
||
<meta name="keywords" content="IOCCC, 2020, IOCCC 2020, IOCCC entry, ferguson2, Most enigmatic">
|
||
</head>
|
||
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
|
||
<!-- END: this line ends content from: inc/head.default.html -->
|
||
|
||
<!-- -->
|
||
<!-- This web page was formed via the tool: bin/readme2index.sh -->
|
||
<!-- The content of main section of this web page came from: 2020/ferguson2/README.md -->
|
||
<!-- -->
|
||
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2020/ferguson2/README.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2020/ferguson2/README.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2020/ferguson2/README.md !!! -->
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
|
||
<!-- Markdown content was converted into HTML via the tool: bin/md2html.sh -->
|
||
|
||
<!-- START: this line starts content from: inc/body.default.html -->
|
||
|
||
<body>
|
||
|
||
<!-- END: this line ends content from: inc/body.default.html -->
|
||
<!-- START: this line starts content from: inc/topbar.default.html -->
|
||
|
||
<div class="theader">
|
||
<nav class="topbar">
|
||
<div class="container">
|
||
<div class="logo">
|
||
<a href="../../index.html" class="logo-link">
|
||
IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="topbar-items">
|
||
<div class="item">
|
||
<span class="item-header">
|
||
Entries
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
<div class="outfit-font">
|
||
<a href="../../years.html" class="sub-item-link">
|
||
Winning Entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../authors.html" class="sub-item-link">
|
||
Winning Authors
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../location.html" class="sub-item-link">
|
||
Location of winning authors
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../bugs.html" class="sub-item-link">
|
||
Bugs and (mis)features
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<span class="item-header">
|
||
Status
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
<div class="outfit-font">
|
||
<a href="../../news.html" class="sub-item-link">
|
||
IOCCC News
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../status.html" class="sub-item-link">
|
||
Contest status
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../next/index.html" class="sub-item-link">
|
||
Rules and Guidelines
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<span class="item-header">
|
||
FAQ
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html" class="sub-item-link">
|
||
FAQ
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#submit" class="sub-item-link">
|
||
How to enter the IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_an_entry" class="sub-item-link">
|
||
Fixing IOCCC entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_web_site" class="sub-item-link">
|
||
Fixing the website
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_author" class="sub-item-link">
|
||
Updating author info
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<span class="item-header">
|
||
About
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
<div class="outfit-font">
|
||
<a href="../../index.html" class="sub-item-link">
|
||
IOCCC Home
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../judges.html" class="sub-item-link">
|
||
The IOCCC Judges
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../contact.html" class="sub-item-link">
|
||
Contacting the IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../thanks-for-help.html" class="sub-item-link">
|
||
Thanks for the help
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../markdown.html" class="sub-item-link">
|
||
IOCCC markdown guidelines
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
|
||
<div class="header-mobile-menu">
|
||
<noscript>
|
||
<a href="../../nojs-menu.html" class="topbar-js-label">
|
||
Please Enable JavaScript
|
||
</a>
|
||
</noscript>
|
||
|
||
<button id="header-open-menu-button" class="topbar-mobile-menu">
|
||
<img
|
||
src="../../png/hamburger-icon-open.png"
|
||
alt="hamburger style menu icon - open state"
|
||
width=48
|
||
height=48>
|
||
</button>
|
||
|
||
<button id="header-close-menu-button" class="hide-content">
|
||
<img
|
||
src="../../png/hamburger-icon-closed.png"
|
||
alt="hamburger style menu icon - closed state"
|
||
width=48
|
||
height=48>
|
||
</button>
|
||
|
||
<div id="mobile-menu-panel" class="hide-content">
|
||
<div class="mobile-menu-container">
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
<div class="mobile-menu-item">
|
||
Entries
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../years.html">
|
||
Winning Entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../authors.html">
|
||
Authors of winning IOCCC entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../location.html">
|
||
Location of authors
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../bugs.html">
|
||
Bugs and (mis)features
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
|
||
<div class="mobile-menu-item">
|
||
Status
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../status.html">
|
||
Contest status
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../next/index.html">
|
||
Rules and Guidelines
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../news.html">
|
||
IOCCC News
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
<div class="mobile-menu-item">
|
||
FAQ
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html">
|
||
Frequently Asked Questions
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#submit">
|
||
How to enter the IOCCC
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_an_entry">
|
||
Fixing IOCCC entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_web_site">
|
||
Fixing the website
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_author">
|
||
Fixing author info
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
<div class="mobile-menu-item">
|
||
About
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../index.html">
|
||
IOCCC Home
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../judges.html">
|
||
The IOCCC Judges
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../contact.html">
|
||
Contacting the IOCCC
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../thanks-for-help.html">
|
||
Thanks for the help
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<script>
|
||
var headerOpenMenuButton = document.getElementById("header-open-menu-button");
|
||
var headerCloseMenuButton = document.getElementById("header-close-menu-button");
|
||
var mobileMenuPanel = document.getElementById("mobile-menu-panel");
|
||
|
||
headerOpenMenuButton.addEventListener("click", () => {
|
||
headerOpenMenuButton.classList.remove("topbar-mobile-menu");
|
||
headerOpenMenuButton.classList.add("hide-content");
|
||
|
||
headerCloseMenuButton.classList.remove("hide-content");
|
||
headerCloseMenuButton.classList.add("topbar-mobile-menu");
|
||
|
||
mobileMenuPanel.classList.remove("hide-content");
|
||
mobileMenuPanel.classList.add("topbar-mobile-panel");
|
||
});
|
||
|
||
headerCloseMenuButton.addEventListener("click", () => {
|
||
headerCloseMenuButton.classList.remove("topbar-mobile-menu");
|
||
headerCloseMenuButton.classList.add("hide-content");
|
||
|
||
mobileMenuPanel.classList.add("hide-content");
|
||
mobileMenuPanel.classList.remove("topbar-mobile-panel");
|
||
|
||
headerOpenMenuButton.classList.add("topbar-mobile-menu");
|
||
headerOpenMenuButton.classList.remove("hide-content");
|
||
});
|
||
</script>
|
||
|
||
<!-- END: this line ends content from: inc/topbar.default.html -->
|
||
<!-- START: this line starts content from: inc/header.default.html -->
|
||
|
||
<div class="header">
|
||
<a href="../../2011/zucker/index.html">
|
||
<img src="../../png/ioccc.png"
|
||
alt="IOCCC image by Matt Zucker"
|
||
width=300
|
||
height=110>
|
||
</a>
|
||
<h1>The International Obfuscated C Code Contest</h1>
|
||
<h2>2020/ferguson2 - Most enigmatic</h2>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/header.default.html -->
|
||
<!-- START: this line starts content from: inc/navbar.mid.html -->
|
||
|
||
<div class="navbar">
|
||
<a class="Left" href="../ferguson1/index.html">← ferguson1</a>
|
||
<a class="Left" href="../index.html">↑ 2020 ↑</a>
|
||
<a class="Left" href="../giles/index.html">giles →</a>
|
||
<a class="Right" href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/prog.c">C code</a>
|
||
<a class="Right" href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/Makefile">Makefile</a>
|
||
<a class="Right" href="#inventory">Inventory</a>
|
||
<a class="Right" href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2020%2Fferguson2%2Findex.html">✓</a>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/navbar.mid.html -->
|
||
<!-- START: this line starts content from: inc/before-content.default.html -->
|
||
|
||
<div class="content" id="content">
|
||
|
||
<!-- END: this line ends content from: inc/before-content.default.html -->
|
||
<!-- START: this line starts content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
|
||
|
||
<!-- START: this line starts content generated by: bin/output-index-author.sh -->
|
||
|
||
<h2 id="author">Author:</h2>
|
||
<ul>
|
||
<li>Name: <a href="../../authors.html#Cody_Boone_Ferguson">Cody Boone Ferguson</a><br>
|
||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||
</ul>
|
||
|
||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||
|
||
<!-- END: this line ends content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
|
||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||
|
||
<!-- BEFORE: 1st line of markdown file: 2020/ferguson2/README.md -->
|
||
<p>https://github.com/ioccc-src/temp-test-ioccc/blob/master/## To build:</p>
|
||
<pre><code> make</code></pre>
|
||
<p>The author provided alternate code that prints the output one character at a
|
||
time to make it a bit more like the real thing in that it isn’t dumped out all
|
||
at once. See <a href="#alternate-code">Alternate code</a> below.</p>
|
||
<h2 id="to-use">To use:</h2>
|
||
<pre><code> ./prog
|
||
|
||
# get recode help:
|
||
./recode -h
|
||
|
||
# general syntax for recode passing to Enigma machine:
|
||
./recode [options] | ./prog - 2>/dev/null
|
||
# general syntax for recode without passing to Enigma machine:
|
||
./recode [options]
|
||
|
||
# recode prompts for settings; pass to Enigma machine:
|
||
./recode | ./prog - 2>/dev/null
|
||
|
||
# recode reads from input file, prompts for settings; passed to Enigma machine:
|
||
./recode -finput | ./prog - 2>/dev/null
|
||
|
||
# recode reads config from string or file; passed to Enigma machine after
|
||
# prompting for input:
|
||
./recode -R<string|file> | ./prog - 2>/dev/null
|
||
|
||
# write config to output file; passed to Enigma machine after prompting for
|
||
# input:
|
||
./recode -o<config> | ./prog - 2>/dev/null
|
||
|
||
# pseudo-randomly select settings
|
||
./recode -r
|
||
|
||
# show Enigma machine settings after selection / generation:
|
||
./recode -v</code></pre>
|
||
<p><strong>NOTE</strong>: in <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/recode.c">recode</a> no spaces between options and option arguments
|
||
are allowed.</p>
|
||
<h2 id="try">Try:</h2>
|
||
<pre><code> ./try.sh</code></pre>
|
||
<p>What does:</p>
|
||
<pre><code> echo | ./recode
|
||
echo | ./recode -v</code></pre>
|
||
<p>do?</p>
|
||
<h2 id="alternate-code">Alternate code:</h2>
|
||
<p>This version, <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/prog.alt.c">prog.alt.c</a>, writes a character at a time, sleeping
|
||
after each character, so that one can read it more easily (for longer output)
|
||
and to make it a bit more like the real thing.</p>
|
||
<h3 id="alternate-build">Alternate build:</h3>
|
||
<pre><code> make alt</code></pre>
|
||
<p>The default time to sleep is 400000 microseconds but you can change this by
|
||
doing:</p>
|
||
<pre><code> make clobber SLEEP=600000 alt</code></pre>
|
||
<p>to change it to 600000 microseconds. It guards against negative numbers.</p>
|
||
<h3 id="alternate-use">Alternate use:</h3>
|
||
<p>Use <code>prog.alt</code> as you would <code>prog</code> above.</p>
|
||
<h3 id="alternate-try">Alternate try:</h3>
|
||
<pre><code> ./try.alt.sh</code></pre>
|
||
<p>Notice how only the last part should use the <code>prog.alt</code>. Why? Try it and find
|
||
out! Can you figure out why this works this way?</p>
|
||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||
<p>This code is an <a href="https://youtu.be/ybkkiGtJmkM">enigma</a>. Try to decode it!</p>
|
||
<p>There is a good deal of useful documentation that is provided with this entry:</p>
|
||
<ul>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/enigma.1">enigma.1</a> - A useful man page for this entry. To render, try:</li>
|
||
</ul>
|
||
<pre><code> man ./enigma.1</code></pre>
|
||
<ul>
|
||
<li><a href="recode.html">recode.html</a>
|
||
<ul>
|
||
<li>Some useful information about <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/recode.c">recode.c</a></li>
|
||
</ul></li>
|
||
<li>[enigma.html][]
|
||
<ul>
|
||
<li>NOTE: see <a href="recode.html">recode.html</a> (or <a href="recode.html">recode.html</a> for details about how to decrypt this!</li>
|
||
</ul></li>
|
||
</ul>
|
||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||
<p>My remarks about my <a href="https://en.wikipedia.org/wiki/German_Army_(1935%E2%80%931945)">Heer</a> (army) and <a href="https://en.wikipedia.org/wiki/Luftwaffe">Luftwaffe</a> (air force) <a href="https://www.cryptomuseum.com/crypto/enigma/index.htm">Enigma
|
||
machine</a> <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/prog.c">simulator</a> for
|
||
the 27th IOCCC.</p>
|
||
<p>I want to dedicate this entry in part to the millions of poor souls that were
|
||
lost during the tragedy that is the <a href="https://en.wikipedia.org/wiki/World_War_II">Second World
|
||
War</a>. There are so many people
|
||
who are unknown, unloved, unclaimed and even unidentified. And who knows what
|
||
they might have gone on to do if their lives weren’t - like it is with all other
|
||
wars - needlessly taken from them? When one considers it was all because the
|
||
most powerful man in the world at the time felt he should rule all others it
|
||
makes it somehow even more tragic: there wasn’t even a good reason for the war
|
||
(is there ever?).</p>
|
||
<p>If one were to write the name of every person who died in the conflict in a
|
||
book, it would take so many pages that the book would be so heavy, so long, so
|
||
expensive to print and it wouldn’t bring anyone back to life nor would it erase
|
||
the suffering. Nothing will. It’s horrible.</p>
|
||
<p>There really are no words that can truly describe the tragedy but I wish to with
|
||
my <a href="https://www.cryptomuseum.com/crypto/enigma/index.htm">Enigma</a> simulator honour each and every soul who was lost, or suffered, or
|
||
suffered the loss of friends or loved ones, as well as the world itself, in and
|
||
from one of the greatest tragedies in the history of mankind.</p>
|
||
<p>I have more information on this entry like the testing procedure at
|
||
<a href="https://ioccc.xexyl.net/2020/enigma" class="uri">https://ioccc.xexyl.net/2020/enigma</a>.</p>
|
||
<div id="toc">
|
||
<ul>
|
||
<li><a href="#ioccc">IOCCC: an Enigma?</a></li>
|
||
<li><a href="#nathan">The 1992 Nathan Sidwell entry</a></li>
|
||
<li><a href="#usage">Usage</a>
|
||
<ul>
|
||
<li><a href="#example">Example run</a></li>
|
||
</ul></li>
|
||
<li><a href="#recode">The recode.c configurator</a></li>
|
||
<li><a href="#parsersubtlety">A parser subtlety that could cause confusion</a></li>
|
||
<li><a href="#layout">On the source code layout</a></li>
|
||
<li><a href="#obfuscation">Obfuscation</a></li>
|
||
<li><a href="#bugs">Bugs, limitations, differences from the real Enigma machines and general notes</a></li>
|
||
<li><a href="#kriegsmarine">Kriegsmarine support?</a></li>
|
||
<li><a href="#portability">Portability</a></li>
|
||
<li><a href="#winning">Winning thoughts, dedications and thanks</a></li>
|
||
<li><a href="#resources">Resources</a></li>
|
||
</ul>
|
||
</div>
|
||
<div id="ioccc">
|
||
<h3 id="ioccc-an-enigma">IOCCC: an Enigma?</h3>
|
||
</div>
|
||
<p>Is there a better single word that could describe the code that is IOCCC? I’m
|
||
sure there are some other words that are equally as valid but I believe ‘Enigma’
|
||
is a great word nonetheless.</p>
|
||
<p>However it’s curious that no winning entry has ever been a simulator of the
|
||
<a href="https://en.wikipedia.org/wiki/Enigma_machine">German Enigma machine</a>. I was
|
||
actually quite surprised (though pleased as it gave me the chance to learn about
|
||
it and submit and win an entry) at that because it’s such a brilliant piece of
|
||
engineering of the time even though it had a critical flaw: that no letter could
|
||
be itself; this combined with cribs (known or suspected plaintext) - which was
|
||
down to carelessness, capturing an Enigma and sometimes settings sheet, as well
|
||
as known messages the Germans started out with - allowed for <a href="https://en.wikipedia.org/wiki/Cryptanalysis_of_the_Enigma">cracking the
|
||
code</a>.</p>
|
||
<p>Combining this entry with two of the <a href="https://en.wikipedia.org/wiki/Morse_code">Morse
|
||
code</a> entries is particularly
|
||
interesting because that’s what the Germans did: the party sending the message
|
||
would first set up the machine, write down the letters and then transmit by
|
||
<a href="https://en.wikipedia.org/wiki/Morse_code">Morse code</a> the encoded message. Then
|
||
those picking up on the message would note the Morse code, translate it to the
|
||
alphabet and then input it into their Enigma machine configured in the same way
|
||
and thus have the original message.</p>
|
||
<p>The <a href="../../1998/dorssel/index.html">1998 ASCII / Morse code translator</a> entry by <a href="../../authors.html#Frans_van_Dorsselaer">Franz van
|
||
Dorsselaer</a> prints the Morse code of text;
|
||
and the <a href="../../2014/vik/index.html">2014 Morse audio transcoder</a> by <a href="../../authors.html#Daniel_Vik">Daniel
|
||
Vik</a> can be used to allow for the actual sound of it.
|
||
With my entry we can complete the loop!</p>
|
||
<div id="nathan">
|
||
<h3 id="the-1992-nathan-sidwell-entry">The 1992 Nathan Sidwell entry</h3>
|
||
</div>
|
||
<p>The author <a href="../../authors.html#Nathan_Sidwell">Nathan Sidwell</a> of the <a href="../../1992/nathan/index.html">1992 Worst
|
||
Abuse of the Rules</a> had this to say about his program:</p>
|
||
<pre><code> This program is a hello world text encrypter/decrypter. It uses an
|
||
[enigma](https://www.cryptomuseum.com/crypto/enigma/index.htm) (I think) style
|
||
encryption algorithm, where the encryption key character is modified by a value,
|
||
determined from the previous character. Non-printable characters (those with
|
||
ASCII values `< ' '` or `> 0x7e`) are passed unaltered, thus any kind of file
|
||
may be successfully processed, but if the original is printable, the processed
|
||
file will be too. The input is read from stdin, and the output presented to
|
||
stdout. The key, a text string, is presented as a command argument. This is
|
||
optional, and if omitted, the file is self-{de,en}crypted. To specify
|
||
decryption, a `-` should be given before the key. (Actually encryption and
|
||
decryption proper inverse operations, so you can use decrypt to scramble and
|
||
encrypt to descramble, if you're perverse.)</code></pre>
|
||
<p>But the Enigma algorithm is more complex than that and my entry can encipher
|
||
(and by extension decipher) text in the manner of the Enigma machines of the
|
||
<a href="https://en.wikipedia.org/wiki/German_Army_(1935%E2%80%931945)">Heer</a> (army) and <a href="https://en.wikipedia.org/wiki/Luftwaffe">Luftwaffe</a> (air
|
||
force); the <a href="https://en.wikipedia.org/wiki/Kriegsmarine">Kriegsmarine</a> (navy;
|
||
literally <code>War Nazy</code>) was more complex (see section <a href="#kriegsmarine">Kriegsmarine
|
||
support?</a> for more information on that.</p>
|
||
<p>My entry should also work as a non-military grade Enigma; they had no
|
||
<a href="https://www.cryptomuseum.com/crypto/enigma/i/sb.htm">plugboard</a> and by
|
||
default mine is empty. I explain how to set up the simulator later.</p>
|
||
<p><a href="../../authors.html#Yusuke_Endoh">Yusuke Endoh</a> asked the judges and me if the real
|
||
1992 entry source was available. Simon Cooper didn’t have access to it because
|
||
it was before his time in the IOCCC; but before the other judges could answer
|
||
<a href="../../authors.html#Ilya_Kurdyukov">Ilya Kurdyukov</a> sent a link to the original 1992
|
||
code. As of 4 March 2023 the original before unseen code was published but I
|
||
leave this in for historical purposes.</p>
|
||
<h3 id="usage">Usage</h3>
|
||
<p>If you run the program by itself it’ll use the default settings and prompt you
|
||
for input (end with EOF). At that point it’ll process the input string and print
|
||
the result (after finishing the enciphering).</p>
|
||
<p>If you run it like:</p>
|
||
<pre><code> ./prog -</code></pre>
|
||
<p>It will prompt you for the settings of the machine (example below).</p>
|
||
<p>The first group is in the order of
|
||
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm">rotor</a> (number),
|
||
<a href="https://en.wikipedia.org/wiki/Enigma_rotor_details#Ring_setting">ring setting</a> (letter) and
|
||
ring (starting) position (letter). It will do this for the first, second and
|
||
then third for each.</p>
|
||
<p>Then it will prompt you for the
|
||
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm#Reflector">reflector</a> (by number).
|
||
The first one is reflector B and the second is reflector C.</p>
|
||
<p>Finally it’ll prompt you for the <a href="https://www.cryptomuseum.com/crypto/enigma/i/sb.htm">plugboard
|
||
pairs</a>.</p>
|
||
<p>After that you can input the string and it’ll go from there.</p>
|
||
<div id="example">
|
||
<h4 id="example-run">Example run</h4>
|
||
</div>
|
||
<p>BTW: There’s a much more entertaining way to explore this entry. See
|
||
<a href="recode.html">recode.html</a> for more details. There’s a secret message that one might like
|
||
to decipher. These however show the general program as well as how to use the
|
||
two winning entries of the <a href="https://en.wikipedia.org/wiki/Morse_code">Morse
|
||
code</a> that I referred to earlier:</p>
|
||
<pre><code> $ ./prog -
|
||
Ring 1: 3
|
||
Setting 1: I
|
||
Position 1: O
|
||
Ring 2: 1
|
||
Setting 2: C
|
||
Position 2: C
|
||
Ring 3: 5
|
||
Setting 3: C
|
||
Position 3: Z
|
||
Reflector: 2
|
||
Plugboard pair 1: CO
|
||
Plugboard pair 2: DE
|
||
Plugboard pair 3: SN
|
||
Plugboard pair 4: XY
|
||
Plugboard pair 5: MS
|
||
Plugboard pair 6: AT
|
||
Plugboard pair 7: VF
|
||
Plugboard pair 8: UR
|
||
Plugboard pair 9: KL
|
||
Plugboard pair 10: BJ
|
||
IOCCC
|
||
^D
|
||
CFDRG</code></pre>
|
||
<p>Notice that all output except the deciphered/enciphered text is sent to stdout.</p>
|
||
<p>If I didn’t specify the <code>-</code> by e.g. <code>echo IOCCC | ./prog</code> then it will use the
|
||
default settings; as the judges suggest this invocation I will not show it here.</p>
|
||
<p>But you can also type it out like this:</p>
|
||
<pre><code> $ ./prog
|
||
IOCCC
|
||
UUMMX</code></pre>
|
||
<p>The IOCCC comes from stdin; the <code>UUMMX</code> is written to stdout.</p>
|
||
<p>If I compile the 2014 entry and copy it to my local directory as
|
||
<code>vik</code> I might do:</p>
|
||
<pre><code> $ echo TEST|./prog |./vik | mplayer -demuxer rawaudio -</code></pre>
|
||
<p>And you would hear <a href="https://en.wikipedia.org/wiki/Morse_code">Morse code</a> of the
|
||
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm">Enigma</a> output
|
||
of ‘TEST’ (i.e. <code>KCWV</code>)! Or perhaps not in this case. I’m not sure: I discovered
|
||
a bug in that entry (Fedora, CentOS and macOS all affected).</p>
|
||
<p>For example I can use the syntax provided in the winning remarks along with my
|
||
entry to write it to a file. Say:</p>
|
||
<pre><code> $ echo TEST|./prog |./vik > test.raw
|
||
$ ./vik e < test.raw | ./prog
|
||
LEST</code></pre>
|
||
<p>Why did that happen? This shows more details:</p>
|
||
<pre><code> $ ./vik e < test.raw
|
||
SCWV</code></pre>
|
||
<p>However as can be seen the first char is wrong:</p>
|
||
<pre><code> $ echo TEST|./prog
|
||
KCWV</code></pre>
|
||
<p>And piping the original output to my entry itself you get the original input:</p>
|
||
<pre><code> $ echo TEST | ./prog | ./prog
|
||
TEST</code></pre>
|
||
<p>I’m not sure what causes that or if there’s a way to fix it but that’s the
|
||
idea anyway. Neither do I know if the original transcoding is correct.</p>
|
||
<p>What if I use the input string <code>LEST</code> instead? In that case it worked fine:</p>
|
||
<pre><code> $ echo LEST | ./prog | ./vik > lest.raw
|
||
$ ./vik e < lest.raw | ./prog
|
||
LEST</code></pre>
|
||
<p>But there’s one obvious question, right? Let’s try the most important one:</p>
|
||
<pre><code> $ echo IOCCC | ./prog | ./vik > ioccc.raw
|
||
$ ./vik e < ioccc.raw
|
||
UUMMX
|
||
$ ./vik e < ioccc.raw | ./prog
|
||
IOCCC</code></pre>
|
||
<p>Phew! The program redeemed itself after the test failure! :)</p>
|
||
<p>(Technically above it didn’t print a newline after the output and this is how it
|
||
is with some of the things I pasted in the other file and maybe others here
|
||
too. Notice also how it showed the same output that my program gave it - <code>UUMMX</code>.)</p>
|
||
<p>What about the other <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/dorssel/dorssel.c">Morse code entry</a>?</p>
|
||
<pre><code> $ echo IOCCC | ./prog | ./dorssel
|
||
..- ..- -- -- -..-</code></pre>
|
||
<div id="recode">
|
||
<h3 id="the-recode.c-configurator">The recode.c configurator</h3>
|
||
</div>
|
||
<p>I have included a supplementary program <a href="recode.c">recode.c</a> that can do a number of
|
||
things which acts as a kind of wrapper and configurator to my entry. By default
|
||
it prompts you for the settings
|
||
(<a href="https://en.wikipedia.org/wiki/Enigma_rotor_details">rotors</a>, <a href="https://en.wikipedia.org/wiki/Enigma_rotor_details#Ring_setting">rings and ring
|
||
settings</a> and
|
||
positions,
|
||
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm#Reflector">reflector</a> and
|
||
<a href="https://www.cryptomuseum.com/crypto/enigma/i/sb.htm">plugboard pairs</a>,
|
||
validating input as you go.</p>
|
||
<p>After that it prompts for text that you can pass to the Enigma simulator;
|
||
alternatively you can specify a file to read in.</p>
|
||
<p>It has a randomise mode and it can save/read the settings to/from a file to
|
||
allow for duplicity (an archaic term for the state of being double but obviously
|
||
for Enigma it has to also mean deceitful).</p>
|
||
<p>I recommend using this in a pipeline instead of the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/prog.c">simulator</a> itself
|
||
if you want to change the configuration of the simulator because it offers a
|
||
much richer experience (and because you can reuse the configuration without
|
||
having to type it out again every time).</p>
|
||
<p>It does take the effort to try and prevent invalid input (as above) though maybe
|
||
I didn’t think of everything. My entry was meant to be a simulator only as far
|
||
as the ciphering goes but I thought this would make it much more interesting:
|
||
make it more flexible by a wrapper program.</p>
|
||
<p>For examples using it you might enjoy a fun message that I have encrypted using
|
||
a key that you should be able to figure out (it’s in a list). This might lead to
|
||
something else fun as well but I will not say more than that. Anyway, see
|
||
<a href="recode.html">recode.html</a> for more details. See also the <a href="recode.1">recode.1</a> and
|
||
<a href="enigma.1">enigma.1</a> man pages.</p>
|
||
<div id="parsersubtlety">
|
||
<h3 id="a-parser-subtlety-that-could-cause-confusion">A parser subtlety that could cause confusion</h3>
|
||
</div>
|
||
<p>The parser is in a sense rather rudimentary but allows for both interactive and automatic
|
||
(e.g., via the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/recode.c">recode</a> program) input.
|
||
This does mean that something like the following can happen:</p>
|
||
<pre><code> $ ./prog -
|
||
Ring 1: 1AB
|
||
Setting 1: Position 1: Ring 2: 2CD
|
||
Setting 2: Position 2: Ring 3: 3
|
||
Setting 3: A
|
||
Position 3: B
|
||
Reflector: 1A
|
||
Plugboard pair 1: BC
|
||
Plugboard pair 2: ..
|
||
Plugboard pair 3: ..
|
||
Plugboard pair 4: DE
|
||
Plugboard pair 5: FG
|
||
Plugboard pair 6: HI
|
||
Plugboard pair 7: JK
|
||
Plugboard pair 8: LM
|
||
Plugboard pair 9: NO
|
||
Plugboard pair 10: PQ
|
||
IOCCC
|
||
WD
|
||
SIRDK</code></pre>
|
||
<p>First of all: what is that <code>WD</code>? I didn’t type that but it showed up hitting
|
||
<code>ctrl-d</code> to end input.</p>
|
||
<p>If everything is input correctly it would show nothing except the actual
|
||
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm">Enigma machine</a> output
|
||
(maybe at times ^D - I have noticed this at least when I don’t fill in all
|
||
<a href="https://www.cryptomuseum.com/crypto/enigma/i/sb.htm">plugboard</a> pairs - which
|
||
might or might not be possible with the Enigma machines that had plugboards; I
|
||
really do not know). I don’t view this as a bug because the parsing of input is
|
||
meant to be simple and in fact you can expect the same output from the same
|
||
input even if there are errors in the input.</p>
|
||
<p>Anyway as you can see the first <code>1AB</code> was the first ring, setting and position.
|
||
After this it wants Ring 2 and I did similar; for ring 3 I did it each variable
|
||
by itself. However for the reflector I did <code>1A</code> but it only expects 1 char! So
|
||
will that mean that the plugboard pairs are off? Yes it does seem to be so. This
|
||
is buffering at play I believe but it’s useful for allowing the <code>recode</code> program
|
||
to easily configure the Enigma machine. In the <a href="recode.html">recode.html</a> file
|
||
file I give a hint as to how this could be fixed but the caveat is it would
|
||
necessitate a need for rewriting
|
||
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/recode.c">recode.c</a>.</p>
|
||
<p>There’s another thing to be aware of and that’s the way the ranges are enforced.
|
||
There are five rotors which obviously are in C 0-4 but in ‘natural language’
|
||
1-5 (they were labelled I, II, III, IV and V though).</p>
|
||
<p>There are two
|
||
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm#Reflector">reflectors</a> and the
|
||
same applies: in C 0-1 but in human it’s 1-2 (technically these were reflectors B and C in
|
||
the Enigma machine which I display by name in <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/recode.c">recode.c</a> just like
|
||
with the rotors).</p>
|
||
<p>For more information see <a href="recode.html">recode.html</a>.</p>
|
||
<p>BTW: If you need a reminder to go to the gym just do your Enigma ABCs and it
|
||
should help you remember:</p>
|
||
<pre><code> $ echo ABC | ./prog
|
||
GYM
|
||
$ echo ABC | ./prog | ./prog
|
||
ABC</code></pre>
|
||
<div id="layout">
|
||
<h3 id="on-the-source-code-layout">On the source code layout</h3>
|
||
</div>
|
||
<p>The layout of <a href="recode.c">recode.c</a> isn’t too significant (but see below) but I want to
|
||
mention <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/prog.c">prog.c</a> especially:</p>
|
||
<p>I did think of a more artistic layout but
|
||
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm#Reflector">reflecting</a>
|
||
on it I think that the blankness of it can be another way of honouring all the
|
||
many people who died in - like all other wars - what was a useless conflict
|
||
because - again like all other wars - a powerful human being decided that they
|
||
should rule others.</p>
|
||
<p>The blankness is a
|
||
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm#Reflector">reflection</a>
|
||
of the millions of people who died unknown, uncared for, unloved, without ever
|
||
being acknowledged in their far too short lives, some even unidentified; it’s
|
||
the presence of absence.</p>
|
||
<p>I find it somehow fitting that the day I have finished this is 30 April 2020,
|
||
which was exactly 75 years from the day that the person responsible for the
|
||
<a href="https://en.wikipedia.org/wiki/World_War_II">Second World War</a>, Adolf Hitler,
|
||
ended his life. (I later made a bug fix but I consider this inconsequential).</p>
|
||
<p>As for <a href="recode.c">recode.c</a> though I really love this:</p>
|
||
<pre><code> /\
|
||
/ This is *not* what you think:</code></pre>
|
||
<p>…because it seems so wrong in C code at first glance. Also what does the
|
||
‘this’ refer to?</p>
|
||
<h3 id="obfuscation">Obfuscation</h3>
|
||
<p>It’s an <a href="https://en.wikipedia.org/wiki/Enigma_machine">Enigma machine</a> simulator! Isn’t
|
||
that proof that it’s obfuscated itself?! :) Silliness aside <a href="obfuscation.txt">obfuscation.txt</a>
|
||
has some of the ways I think this entry is obfuscated. To decipher try:</p>
|
||
<pre><code> ./recode -Robfuscation.key -fobfuscation.txt | ./prog - 2>/dev/null > obfuscation.md</code></pre>
|
||
<p>To encipher:</p>
|
||
<pre><code> ./recode -Robfuscation.key -fobfuscation.md | ./prog - 2>/dev/null > obfuscation.txt</code></pre>
|
||
<p>The file <a href="obfuscation.key">obfuscation.key</a> is the key to decipher/encipher
|
||
<a href="obfuscation.txt">obfuscation.txt</a>.</p>
|
||
<p>For the lazy <a href="obfuscation.html">obfuscation.html</a> has the deciphered version.</p>
|
||
<p>As for the <a href="obfuscation.key">obfuscation.key</a> file if you observe the contents you’ll find the
|
||
word <code>OBFUSCATION</code>:</p>
|
||
<pre><code> 2OB5FU1SC2ATIONCDEFGHJKLMPQRYZ
|
||
OB FU SC ATION</code></pre>
|
||
<div id="bugs">
|
||
<h3 id="bugs-limitations-differences-from-the-real-enigma-machines-and-general-notes">Bugs, limitations, differences from the real Enigma machines and general notes</h3>
|
||
</div>
|
||
<p>Ways that my simulator differs from the real thing. Not all of these are bugs
|
||
and some could be considered features; others are just differences.</p>
|
||
<ul>
|
||
<li><p>Does not check for using the same
|
||
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm#Reflector">rotor</a>
|
||
more than once. The real Enigma machines this would not work because they had to
|
||
choose from a set of rotors and there were no duplicates. This shouldn’t be a
|
||
problem here however except that it wouldn’t be a possible configuration of the
|
||
real Enigma machine. The <code>recode</code> program <em>however does validate this</em> (except
|
||
when reading in settings via the <code>-R</code> option which I explain in the
|
||
<a href="recode.html">recode.html</a> file.</p></li>
|
||
<li><p>The way the <a href="https://www.cryptomuseum.com/crypto/enigma/i/sb.htm">plugboard</a>
|
||
- for the machines that had them - is, if you connect A to B then no other
|
||
letters can connect to A or B. Earlier there wasn’t proper detection and this
|
||
caused invalid output.</p>
|
||
<p>Why only 10 pairs when the German alphabet has 26 letters (the Enigma did
|
||
not have the Eszett or the umlauts and in any case there is some
|
||
disagreement about these being part of the alphabet; anyway for umlauts one
|
||
can add an E after the letter and for the Eszett you can use ‘ss’ or ‘SS’
|
||
which is what they did)? It’s theoretically possible to have 13 but the
|
||
Enigma typically had 10 pairs. It’s easy enough to update my entry to do
|
||
this once you de-obfuscate it but I’m not helping there (and in fact I don’t
|
||
think I could any more even if I wanted to - at least not easily).</p></li>
|
||
<li><p>It does not obviously have the clicking sound associated with the moving
|
||
parts of the real machine. I think it would be annoying to have this as it
|
||
processes each letter - but with the <a href="../../2014/vik/index.html">2014 Morse audio transcoder</a> entry you
|
||
can at least have the output played in Morse code as the Germans did; I think
|
||
that’s really cool (I think it’s really cool even if there’s a bug in it). That
|
||
it pays homage to that (and another) entry is a bonus here.</p></li>
|
||
<li><p>The <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/prog.c">simulator</a> doesn’t report errors but tries to gracefully deal
|
||
with them: if one chooses a value out of range it moves it into the range (if >
|
||
the max then the max, if < min then the min). If invalid chars are input for the
|
||
plugboard pairs then it’s not added to the plugboard etc.</p></li>
|
||
<li><p>The real <a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm">Enigma
|
||
machines</a> had
|
||
only letters: no digits, no punctuation. My entry prints <code>!isalpha()</code> chars
|
||
untouched. The Germans had different systems for punctuations, numbers etc. (one
|
||
of the documents I link to has these details).</p></li>
|
||
<li><p>My entry preserves case of letters. The real Enigma had only one case as it
|
||
was just a keyboard and they didn’t need case-sensitivity. Context would be
|
||
important as some words in German have different meanings depending on if
|
||
capitalised or not (and all nouns are capitalised).</p></li>
|
||
<li><p>Later models introduced a fourth rotor. The
|
||
<a href="https://en.wikipedia.org/wiki/Kriegsmarine">Kriegsmarine</a> procedures were
|
||
also far more complex than the <a href="https://en.wikipedia.org/wiki/German_Army_(1935%E2%80%931945)">Heer</a> (army) and <a href="https://en.wikipedia.org/wiki/Luftwaffe">Luftwaffe</a> (air force)
|
||
(though apparently the additional notch provided another flaw). I find this particularly
|
||
interesting because it was Hermann Goering who was the Supreme Commander of the
|
||
Luftwaffe and the intelligence agency Forschungsamt (FA) was his; it provided
|
||
Hitler with invaluable information so one would think the Luftwaffe system would
|
||
be more complex! See <a href="#kriegsmarine">Kriegsmarine support?</a> for more
|
||
information.</p></li>
|
||
<li><p>I only include
|
||
<a href="https://en.wikipedia.org/wiki/Enigma_machine#Reflector">reflectors</a> <a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm#wiringtables">B and
|
||
C</a>.
|
||
To have included more would have used too many bytes (each reflector and
|
||
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm#rotors">rotor</a> is
|
||
26 characters!) and I could not include them for this reason; I include five
|
||
rotors and two reflectors and that’s a total of (<code>5 * 26 + 2 * 26 == 182</code> chars)
|
||
but there are as you can see many other strings too. It is however feasible to
|
||
update the rotor and reflectors options and you could even make your own
|
||
versions if you wanted to. Doing this is an exercise to the reader however (the
|
||
idea of trying this makes me cringe because of how I obfuscated things including
|
||
encrypting some of it with the Enigma itself).</p></li>
|
||
</ul>
|
||
<p>There’s one thing I’m unsure of in my implementation. Because of all the
|
||
possible settings I used some other simulators as a starting point and more
|
||
importantly to validate that my code worked right. These other simulators had
|
||
bugs though and so one thing looked odd and I don’t know if it is right or not.
|
||
An online simulator appears correct but I don’t see the option to change that
|
||
part.</p>
|
||
<p>If you notice in the <code>Q()</code> function where I set up specific pointers and other
|
||
data there is a call to the macro <code>q</code> but I only refer to the first ring setting
|
||
(of which I no longer even know which element it is! Or was it position? I don’t
|
||
even know that now for certain). That’s because the Python code did that (though
|
||
very differently of course) but I also had to bug-fix the Python in another
|
||
part.</p>
|
||
<p>I do not know if this is correct but as I show somewhere my entry does match the
|
||
online simulator so I presume it is correct. It might be that the Germans tended
|
||
to have it at A but again I do not know.</p>
|
||
<div id="kriegsmarine">
|
||
<h3 id="kriegsmarine-support">Kriegsmarine support?</h3>
|
||
</div>
|
||
<p>Is it possible to add <a href="https://en.wikipedia.org/wiki/Kriegsmarine">Kriegsmarine</a>
|
||
support? I thought so by adding the additional rotors but looking at it again it
|
||
appeared that it’s not as simple as adding the rotors to the code and then
|
||
updating the references to the array etc.</p>
|
||
<p>This is because it had three additional
|
||
<a href="https://en.wikipedia.org/wiki/Enigma_rotor_details">rotors</a> - <a href="https://www.cryptomuseum.com/crypto/enigma/m4/index.htm#wheels"><code>VI</code>, <code>VII</code> and
|
||
<code>VII</code></a> - and had
|
||
<a href="https://en.wikipedia.org/wiki/Enigma_rotor_details#Turnover_notch_positions">two notches</a>
|
||
and this changes the way things work. The <a href="https://www.cryptomuseum.com/crypto/enigma/m4/index.htm">Kriegsmarine
|
||
M4</a> also had an
|
||
additional change which would complicate matters more.</p>
|
||
<p>I looked into trying to do this for another version after winning but some of
|
||
the obfuscation techniques dramatically complicates even attempting this so I
|
||
haven’t even tried.</p>
|
||
<p>It is feasible that you could add your own rotors however but I leave this as an
|
||
exercise to the reader. I will say that the five rotors I, II, III, IV and V can
|
||
be found in the source code verbatim and you could confirm it by looking them
|
||
up; however much more would have to be done in order to get them to work, than
|
||
to just put the strings in. Again the way I set things up complicates this
|
||
greatly.</p>
|
||
<h3 id="portability"><a href="#toc">Portability</a></h3>
|
||
<p>I have tested it under macOS, Fedora and CentOS Linux and all seems okay under
|
||
these platforms. When I was in the final stages of obfuscation I made an error
|
||
somehow (or else maybe the vim formatting caused a problem - I have seen this
|
||
before) and I had to go back and undo some of the obfuscation to figure out what
|
||
was going on (I had a hunch where and I noted it in the obfuscation I believe)
|
||
but this made me wonder on if I made any other mistakes since it appeared to be
|
||
working before that.</p>
|
||
<p>I don’t know if EBCDIC will work but I think it might because it appears that
|
||
the alphabet is a contiguous sequence. I don’t believe endianness matters but I
|
||
no longer remember what I’ve done in full and I’ve no way to test it.</p>
|
||
<p>If there are any inconsistencies in input/output one also has to be certain that
|
||
input was put in correctly because as soon as a letter differs the entire
|
||
sequence will be off.</p>
|
||
<p>The results of my test script (not included here but I will probably have it on
|
||
my website) are the same under Fedora, CentOS and macOS.</p>
|
||
<h3 id="resources">Resources</h3>
|
||
<h4 id="a-note-on-wehrmacht-its-branches-and-other-agencies-and-their-enigma-machines">A note on Wehrmacht, its branches and other agencies and their Enigma machines</h4>
|
||
<p>The <a href="https://en.wikipedia.org/wiki/Wehrmacht">Wehrmacht</a> was the defence force
|
||
in full which included the <a href="https://en.wikipedia.org/wiki/German_Army_(1935%E2%80%931945)">Heer</a> (army),
|
||
<a href="https://en.wikipedia.org/wiki/Luftwaffe">Luftwaffe</a> (air force) and
|
||
<a href="https://en.wikipedia.org/wiki/Kriegsmarine">Kriegsmarine</a> (navy). As I said the
|
||
Kriegsmarine procedures were more complex: they had additional rotors and one of
|
||
their models had a different
|
||
<a href="https://en.wikipedia.org/wiki/Enigma_machine#Reflector">reflector</a> system (thin
|
||
instead of thick - some of the documents below discuss this). The military
|
||
intelligence agency, the Abwehr, had their own system too. Non-military grade
|
||
Enigma machines didn’t have the
|
||
<a href="https://www.cryptomuseum.com/crypto/enigma/i/sb.htm">plugboard</a>. And so on.</p>
|
||
<p>However one of the documents below distinguishes the Kriegsmarine from the
|
||
Wehrmacht; when you see this you can read it as the Kriegsmarine versus the rest
|
||
of the Wehrmacht rather than the Wehrmacht and the Kriegsmarine.</p>
|
||
<p><a href="https://web.archive.org/web/20200710094321/http://users.telenet.be/d.rijmenants/en/enigmaproc.htm">Enigma Message Procedures</a>: The <a href="https://en.wikipedia.org/wiki/German_Army_(1935%E2%80%931945)">Heer</a>,
|
||
<a href="https://en.wikipedia.org/wiki/Luftwaffe">Luftwaffe</a> and
|
||
<a href="https://en.wikipedia.org/wiki/Kriegsmarine">Kriegsmarine</a>
|
||
<a href="https://en.wikipedia.org/wiki/Enigma_machine">Enigma</a>
|
||
procedures.</p>
|
||
<p><a href="http://enigmaco.de/enigma/enigma.html">Interactive Enigma Machine</a>: Shows wiring of the <a href="https://en.wikipedia.org/wiki/Enigma_machine">Enigma
|
||
machine</a> based on the
|
||
settings and input (unfortunately uses Flash). This was what I used to verify
|
||
output (as best I could find). To set this up to use the default settings in my
|
||
simulator make sure to use
|
||
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm#Rotors">Rotors</a>
|
||
I, II and III and the starting positions at B, B and C respectively (as in left,
|
||
centre, right). To do this click the button at the top right that looks like:</p>
|
||
<pre><code> o->
|
||
<-o</code></pre>
|
||
<p>and then select the rotors. Next click the button again at the left of the
|
||
rotor selection ‘screen’. Then use the arrow buttons above each rotor to set
|
||
from left to right B, B and C. After this you can type your message in the input
|
||
field and watch the wiring of the rotors change and show the path it takes.</p>
|
||
<p>If I made use of the Enigma code in the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/recode.c">recode.c</a> program I would
|
||
maybe consider doing something like that but I intentionally do not use it
|
||
there: as cool as it might be it would give a better idea of how the algorithm
|
||
works (unless I were to make it just as obscure as I do in prog.c but that’s
|
||
also a bit risky). I don’t believe I could do it now anyway.</p>
|
||
<p>I’m uncertain how to change the rotor setting itself in this simulator to
|
||
determine if the ring settings being different from <code>ABC</code> would cause a problem
|
||
(this is the thing I mention I’m uncertain about in the bugs section).</p>
|
||
<p>Going back to the configuring the online simulator try inputting the text IOCCC
|
||
and you’ll see the resulting text being:</p>
|
||
<pre><code> UUMMX</code></pre>
|
||
<p>Which is exactly as my entry shows! So at least for the starting position <code>BBC</code>
|
||
and an empty <a href="https://www.cryptomuseum.com/crypto/enigma/i/sb.htm">plugboard</a>
|
||
and the other defaults in my entry (which appear to be consistent with the
|
||
online simulator too) I can verify it works.</p>
|
||
<p><a href="https://web.archive.org/web/20200621180323/http://www.codesandciphers.co.uk/enigma/index.htm">Tony Sale’s pages on The Enigma cipher machine</a>: This is many pages on the
|
||
Enigma machine by the late Tony Sale who was the original curator of the
|
||
<a href="https://www.cryptomuseum.com/bp/">Bletchley Park Museum</a>. There is a wealth of
|
||
information in these pages on how the Enigma worked and this includes some
|
||
challenges to do to see how well you understand the algorithm.</p>
|
||
<p>Fun fact: the abbreviation for the <a href="https://en.wikipedia.org/wiki/Signals_intelligence#World_War_II">Signals
|
||
Intelligence</a>
|
||
is that of our wonderful <code>SIGINT</code>.</p>
|
||
<p><a href="https://web.archive.org/web/20200710094303/http://users.telenet.be/d.rijmenants/en/enigmatech.htm">Technical Details of the Enigma Machine</a>: ‘This page provides the technical
|
||
details of the <a href="https://en.wikipedia.org/wiki/Wehrmacht">Wehrmacht</a> and
|
||
<a href="https://en.wikipedia.org/wiki/Luftwaffe">Luftwaffe</a>
|
||
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm">Enigma</a>, and the Kriegsmarine Enigma M4.’
|
||
It is quite a nice document with diagrams, pictures of actual Enigma
|
||
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm#Rotors">rotors</a> and
|
||
other parts and more.</p>
|
||
<p><a href="https://web.archive.org/web/20200710094243/http://users.telenet.be/d.rijmenants/en/enigma.htm">The German Enigma Cipher Machine</a>: The history of Enigma, its development,
|
||
use during the war and cryptanalysis.</p>
|
||
<p><a href="http://www.ellsbury.com/enigma3.htm">How the Enigma was Set Up and Operated</a>: This is the third page in a document
|
||
series on the Enigma that explains the initial set up of the Enigma machine for
|
||
each day. This is a good introduction to the set up. There is one thing that I
|
||
was not aware of (or if I was it did not register): the operator would after
|
||
setting the positions also put in three letters before the actual message (there
|
||
were several parts to each message but this was another layer of complexity). I
|
||
did not implement this in the recode program but what would it be anyway? If the
|
||
user here wants to they could add three letters to their message beginning. I
|
||
don’t think there need be any addition to the recode program - at least not
|
||
that.</p>
|
||
<h2 id="authors-dedication">Author’s dedication:</h2>
|
||
<div id="winning">
|
||
<h3 id="winning-thoughts-dedications-and-thanks">Winning thoughts, dedications and thanks</h3>
|
||
</div>
|
||
<p>Once again I’m honoured to win along with some of the other veterans who I have
|
||
a huge amount of respect for; there’s <a href="../../authors.html#Don_Yang">Don Yang</a>, <a href="../../authors.html#Dave_Burton">Dave
|
||
Burton</a>, <a href="../../authors.html#Yusuke_Endoh">Yusuke Endoh</a>
|
||
and <a href="../../authors.html#Edward_Giles">Edward Giles</a> all of whom are amazing
|
||
programmers. I’m especially proud to win besides Dave Burton and Yusuke Endoh
|
||
but Don Yang and Edward Giles too.</p>
|
||
<p>But there are some others who I don’t remember like <a href="../../authors.html#Ilya_Kurdyukov">Ilya
|
||
Kurdyukov</a>
|
||
(who’s offered a lot of interesting thoughts on <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/prog.c">Snake</a> and
|
||
who plans to have his own version after the entries are published), <a href="../../authors.html#Nathan_Otterness">Nathan
|
||
Otterness</a>, <a href="../../authors.html#Nicholas_Carlini">Nicholas
|
||
Carlini</a> (your entry is an absolutely brilliant
|
||
abuse of <code>printf</code> - and I totally agree with the judges remarks that your entry
|
||
is so novel that it’ll be worth special mention in the future Best of IOCCC
|
||
list!) and <a href="../../authors.html#_tsoj">tsoj</a> too.</p>
|
||
<p>Well done and congratulations to all of you again! Thank you for submitting the
|
||
wonderful entries and I’m honoured to have my two entries beside yours!</p>
|
||
<p>To Yusuke Endoh, Dave Burton and Nicholas Carlini I very much appreciate your
|
||
wonderful comments on this program. Your comments Yusuke on this entry specially
|
||
and also Dave’s comments on my double-win are both extremely special to me - it
|
||
truly takes my pride to another level!</p>
|
||
<p>I would like to dedicate this entry to my wonderful mum Dianne Ferguson whom I
|
||
love with all my heart and soul <3 Thank you for being the best mother
|
||
imaginable! You’ve been there for me in the darkest of my hours without question
|
||
without complaint and with all the love, compassion, empathy, sympathy and
|
||
devotion anyone could ever ask for. Bless you again and again and again dear
|
||
mother.</p>
|
||
<p>I also want to dedicate this to Vicky Wilmore who has given me a lot of
|
||
love the past few years and who was there for me in some very dark times. Thank
|
||
you Vicky sweetheart from the bottom of my heart and soul xxx</p>
|
||
<p>Once more besides those two I want to also dedicate this to all the many
|
||
millions of people whose lives were taken from them in what amounts to - like
|
||
all other wars - a horrible, pointless conflict and an utter waste of life,
|
||
something precious that is far too often taken for granted. As I noted before I
|
||
found it fitting that I finished this on 30 April 2020 - exactly 75 years after
|
||
Adolf Hitler, he who started the <a href="https://en.wikipedia.org/wiki/World_War_II">Second World
|
||
War</a>, ended his life. The blankness
|
||
of the layout is another way of honouring the poor souls who lost their lives,
|
||
many of whom we will never know even their name let alone what they might have
|
||
accomplished if it wasn’t for their tragic and pointless deaths. Always remember
|
||
that life is precious and never ever take it for granted! Believe in yourselves.
|
||
Everyone. Do not let anyone ruin that for you ever.</p>
|
||
<p>I would like to thank my dear friend <a href="https://www.ficture.nl">Martijn
|
||
Schoemaker</a> for encouraging me in my programming over
|
||
the years and who I owe a great deal to. Thank you for believing in me and my
|
||
programming abilities (and other abilities) even when I couldn’t believe in
|
||
myself! Very much appreciated especially coming from an amazing programmer who I
|
||
have huge admiration for!</p>
|
||
<p>Finally I want to thank Leo Broukhis, Simon Cooper and Landon Curt Noll for
|
||
continuing to hold the contest after all these years - and for having selected
|
||
my entries. It’s a huge honour; thank you! I also happen to love your comments
|
||
as well as the award titles. And yes indeed ‘most of us could use
|
||
<em>[Double-layered Chocolate Fudge Cake][]</em>!’</p>
|
||
<p>If you wish to contact me please do so. Please contact via mastodon. You can try
|
||
email but I’m more likely to respond to mastodon messages.</p>
|
||
<!--
|
||
|
||
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
|
||
|
||
You are free to share and adapt this file under the terms of this license:
|
||
|
||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||
|
||
For more information, see:
|
||
|
||
https://creativecommons.org/licenses/by-sa/4.0/
|
||
|
||
-->
|
||
<!-- AFTER: last line of markdown file: 2020/ferguson2/README.md -->
|
||
|
||
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||
<!-- START: this line starts content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
|
||
|
||
<!-- START: this line starts content generated by: bin/output-index-inventory.sh -->
|
||
|
||
<div id="inventory">
|
||
<h1 id="inventory-for-2020ferguson2">Inventory for 2020/ferguson2</h1>
|
||
</div>
|
||
<h2 id="primary-files">Primary files</h2>
|
||
<ul>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/prog.c">prog.c</a> - entry source code</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/Makefile">Makefile</a> - entry Makefile</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/prog.alt.c">prog.alt.c</a> - alternate source code</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/prog.orig.c">prog.orig.c</a> - original source code</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/enigma.html">enigma.html</a> - secret message in a html file to decrypt</li>
|
||
<li><a href="input.txt">input.txt</a> - sample input</li>
|
||
<li><a href="obfuscation.html">obfuscation.html</a> - about the obfuscation of this entry</li>
|
||
<li><a href="obfuscation.txt">obfuscation.txt</a> - about the obfuscation of this entry - encrypted with entry</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/recode.c">recode.c</a> - Enigma machine configurator source code</li>
|
||
<li><a href="recode.html">recode.html</a> - Enigma configurator documentation</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/try.alt.sh">try.alt.sh</a> - script to try alternate code</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/try.sh">try.sh</a> - script to try entry</li>
|
||
<li><a href="try.this.txt">try.this.txt</a> - sample input</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/enigma.1">enigma.1</a> - Enigma machine simulator man page</li>
|
||
<li><a href="key.txt">key.txt</a> - key to decipher/encipher the word ‘IOCCC’</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/obfuscation.key">obfuscation.key</a> - key to decipher or encipher obfuscation.txt</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/recode.1">recode.1</a> - configurator tool recode.c man page</li>
|
||
</ul>
|
||
<h2 id="secondary-files">Secondary files</h2>
|
||
<ul>
|
||
<li><a href="2020_ferguson2.tar.bz2">2020_ferguson2.tar.bz2</a> - download entry tarball</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/README.md">README.md</a> - markdown source for this web page</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/.entry.json">.entry.json</a> - entry summary and manifest in JSON</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/.gitignore">.gitignore</a> - list of files that should not be committed under git</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/obfuscation.md">obfuscation.md</a> - markdown source for obfuscation.html</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/.path">.path</a> - directory path from top level directory</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/recode.md">recode.md</a> - markdown source for recode.html</li>
|
||
<li><a href="index.html">index.html</a> - this web page</li>
|
||
</ul>
|
||
<hr style="width:10%;text-align:left;margin-left:0">
|
||
<h4>
|
||
Jump to: <a href="#">top</a>
|
||
</h4>
|
||
|
||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||
|
||
<!-- END: this line ends content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
|
||
<!-- START: this line starts content from: inc/after-content.default.html -->
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/after-content.default.html -->
|
||
<!-- START: this line starts content from: inc/footer.inventory.html -->
|
||
|
||
<!--
|
||
|
||
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
|
||
|
||
You are free to share and adapt this file under the terms of this license:
|
||
|
||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||
|
||
For more information, see:
|
||
|
||
https://creativecommons.org/licenses/by-sa/4.0/
|
||
|
||
-->
|
||
|
||
<div class="footer">
|
||
|
||
<div id="copyright"><h3>Copyright © 1984-2024 by Landon Curt Noll:
|
||
<a href="https://creativecommons.org/faq/#what-does-some-rights-reserved-mean"
|
||
target="_blank"
|
||
rel="license noopener noreferrer">Some Rights Reserved</a></h3>
|
||
<p>
|
||
This work is <b>licensed by Landon Curt Noll</b> under
|
||
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/?ref=chooser-v1"
|
||
target="_blank"
|
||
rel="license noopener noreferrer"
|
||
style="display:inline-block;">CC BY-SA 4.0</a></b>.
|
||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||
src="../../png/cc.png"
|
||
alt="cc inside circle symbol">
|
||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||
src="../../png/by.png"
|
||
alt="person inside circle symbol">
|
||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||
src="../../png/sa.png"
|
||
alt="arrow looping back on itself inside circle symbol"><br>
|
||
You should <b>carefully review</b> the
|
||
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode.en"
|
||
target="_blank"
|
||
rel="license noopener noreferrer">CC BY-SA 4.0 LEGAL CODE</a></b>
|
||
before using the licensed material.<br>
|
||
You may wish to review the
|
||
<b><a href="../../license.html"
|
||
target="_blank"
|
||
rel="license noopener noreferrer">highlights of some of the key features and terms</a></b>
|
||
of <b>CC BY-SA 4.0</b>.<br>
|
||
</p>
|
||
</div>
|
||
|
||
<div id="coda"><h3>Coda</h3>
|
||
<p>
|
||
<a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2020%2Fferguson2%2Findex.html" rel="nofollow">Nu HTML check this web page</a><br>
|
||
<a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a><br>
|
||
</p>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/footer.inventory.html -->
|
||
<!-- START: this line starts content from: inc/bottom.default.html -->
|
||
|
||
</body>
|
||
</html>
|
||
|
||
<!-- END: this line ends content from: inc/bottom.default.html -->
|