I’ve made a new release of my M-209 cipher simulation software:
https://gitlab.com/NF6X_Crypto/hagelin/-/archive/hagelin-1.4/hagelin-hagelin-1.4.tar.gz
This release eliminates the specially-encoded trailer that older versions needed in the key files. It now deciphers the human-readable key table instead, and tries to tolerate minor formatting variations.
Older versions of the simulator produced key tables with a human-readable portion using the same format as shown in original M-209 technical manuals, followed by a specially-formatted trailing section to be read in by the simulator software:
... 23 0-5 - - - 24 1-5 X Y 25 1-6 Y Z 26 3-4 - 27 4-5 ------------------------------- 26 LETTER CHECK TNMYS CRMKK UHLKW LDQHM RQOLW R ------------------------------- >01101000010000110011110110 >1011000101011110110010011 >10001001010100101100110 >000101101001110110100 >0010100111010101001 >10110101100011000 >01 02 02 02 02 02 02 02 02 03 03 03 03 03 03 03 04 04 04 04 04 05 05 15 16 34 45
When reading in a key table, the simulator would ignore the human-readable portion, and only pay attention to the specially-formatted trailer at the end.
Starting with this new release, the simulator no longer includes the specially-formatted trailer at the end of key tables it produces. When reading in key tables, it now decodes the human-readable portion. If the trailer from an older version of the program is present, it will be ignored, so the new simulator version can read key table files generated by older versions. Older versions will not be able to read key tables produced by this version, though.
When reading in key table files, the simulator tries to ignore minor formatting variations. This will hopefully help it read M-209 key tables produced by other software. As long as the basic structure is maintained, the simulator should tolerate variations such as different whitespace, adding a colon after the lug bar number, omitting the dash between the lug numbers, etc.
The simulator expects the entire key table to be in upper case, including the pin settings and the optional 26 letter check. Lines containing any lower case characters will be ignored. Thus, it should be safe to include extra text in the key file as long as it is in mixed case.
Another new feature is that if a 26 letter check is included in the key file, the simulator will now verify the key settings against it when reading the file. The letter check must be in all upper case, with exactly 26 letters on one line. The letters may be divided into 5-letter groups separated by whitespace if desired. The check will be skipped if the check letters are not found in the key file. If they are present, then the check must pass or else the simulator will exit with an error message.
If a key file fails to load properly, try adding the “-v” flag as the first command-line option to see verbose debugging messages while the key file is being read and parsed.
This new version now requires the Boost C++ libraries. I’ve tested it on my Mac using dependencies provided by MacPorts, but I haven’t tested the new release on other platforms.
Advanced users might prefer to pull the source code from GitLab this way instead of downloading the tar file linked to above:
git clone git@gitlab.com:NF6X_Crypto/hagelin.git
Please let me know if you find problems with this new release.