Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lorenz SZ40/42 cipher attachment operation #528

Merged
merged 21 commits into from
Nov 6, 2019

Conversation

VirtualColossus
Copy link
Contributor

This is an operation which emulates the Lorenz SZ40/42 cipher attachment, models available include the SZ40, SZ42a and SZ42b with the option for the Klartextfunktion (plaintext limitation).

Three example wheel lug patterns are included (KH, ZMUG & BREAM) which are from the settings within Tony Sale's original Virtual Colossus code which was written to help work out the mechanics of the Colossus Rebuild at TNMOC (http://www.tnmoc.org/). A custom pattern mode also allows setting of any pattern of lugs on each of the twelve wheels.

Wheel starts can be set for each of the twelve rotors plus there is an option to set whether this operation is receiving or sending. Normally on the real Lorenz, the cipher text itself is never seen by the operators at each end of the link so an option was required to know if it is enciphering from plain text or deciphering from ITA2 code.

This emulation has been tested against a number of examples with start positions which were originally in Tony Sale's Virtual Colossus. This is as close as I can get to confirming that the operation is enciphering/deciphering correctly as I don't believe a working Lorenz SZ42 is
currently available! This operation is also fully compatible and tested against my web emulator, Virtual Lorenz (https://lorenz.virtualcolossus.co.uk). Virtual Lorenz has been used to encipher a new message which has then been run on the Colossus Rebuild at TNMOC and confirmed to be accurate.

Examples with recipe
kh - example.txt
zmug - example.txt

@n1474335
Copy link
Member

Hi @VirtualColossus, thank you very much for this contribution! I've played around on your Virtual Colossus and Lorenz a number of times so it's very gratifying to see it entering the CyberChef ecosystem. We had intended on implementing Lorenz and Colossus at some point in the future when we got the chance, but you've saved us a lot of time!

Before I merge this PR, we'll have a good rummage through and think about the best way to package it. I think we'll split this and the other related operations (Enigma, Typex, Bombe, Multi-Bombe) out into their own module as they are starting to get reasonably large. I guess a suitable name for this module might be "Bletchley".

It would also be worth expanding a little on the description you've provided. I'd like to change the infoUrl to the Wikipedia article on Lorenz so that it fits out convention and user expectations a little better, however I'm not at all against including a link to virtualcolossus.co.uk in the description body.

@n1474335 n1474335 requested a review from j433866 April 1, 2019 12:44
@VirtualColossus
Copy link
Contributor Author

Hi @n1474335, my pleasure, maybe I'll start having a think about how to achieve a Colossus sometime.

I've updated the description and link as requested. If you think it needs more detail - maybe I can suggest a larger addition to your wiki pages as you have with Bombe, Enigma & Types with a few examples and walkthrough.

I think a "Bletchley Park" module would be a great idea.

@s2224834
Copy link
Contributor

s2224834 commented Oct 28, 2019

Sorry it's taken so long to look at this, but I would like to get this merged and I've had a look at it now. I think the user interface and so forth are great. I'd like to see the run() function broken up a bit so it's easier to read, as it's a bit of a beast at the moment. There are bits that lend themselves naturally to being separate functions, like the ITA2 encoding/decoding. It would also be good to get the test cases you include in your first post here added as unit tests. Other than those minor tweaks and @n1474335 figuring out how the module split should work, I think we're good to go.

A walkthrough as per the Enigma/Bombe/Typex page would be nice if you could - there's quite a lot of options, and while I think the way they've been implemented is sensible, it's a little intimidating just because configuring a real Lorenz is so complicated!

@VirtualColossus
Copy link
Contributor Author

VirtualColossus commented Oct 28, 2019

Great! I'll see what I can do. It's been a while now since I checked out code last but will find time to catch up when I can .. dread to think what the UI and run() function for a Colossus operation will look like!

@VirtualColossus
Copy link
Contributor Author

Following changes have been made:
run() function tidied up with ITA2 encoding/decoding moved
test cases added
Suggested Lorenz walkthrough : https://github.com/VirtualColossus/CyberChef/wiki/Lorenz-SZ

Let me know if any further changes required.

Query: Can I add section 'learn more' linking to my website & TNMOC or would you prefer to stick with just links to Wikipedia?

@s2224834
Copy link
Contributor

The walkthrough could use a couple more links to recipes as you work through it, but other than that I like it. Happy with your code changes - good to see the unit tests catching some bugs! I'll leave @n1474335 to answer the links query.

Nice work, and thanks very much!

@n1474335
Copy link
Member

@VirtualColossus Thanks very much for your work on this, it's looking really good.

RE links: I'm keen for the infoURL link to be Wikipedia in most cases as it provides users with a predictable format for reading about a technology they might be unfamiliar with.

I'm happy for you to link to TMNOC and your website in the wiki article (as we have linked to a number of places in the article on Enigma, the Bombe and Typex). I'm also happy in this particular case for you to link to your website in the operation description, however this does not set a precedent for future operations. We're making an exception in this case due to the context and utility of the site, providing a unique way to test the algorithm.

@VirtualColossus
Copy link
Contributor Author

Thanks.
I've added a number of extra recipes in the walkthough and a few links at the end.

@n1474335 n1474335 merged commit b9571db into gchq:master Nov 6, 2019
@n1474335
Copy link
Member

n1474335 commented Nov 6, 2019

Thanks very much once again, this is a really great addition. I've put the wiki article here and added a link to it in the operation description.

@s2224834
Copy link
Contributor

s2224834 commented Nov 7, 2019

Yes, thanks again from me too. Let us know when you figure out how to do Colossus! :-)

@VirtualColossus
Copy link
Contributor Author

No problem - I enjoyed working out how to do this within your platform (very nice work by the way). Colossus could be tricky, but tell you what, I'll swap you a Colossus operation for the recorded sound from your real TypeX you have (I'd love real sounds of it running and typing for my TypeX simulation I'm currently working on!) ;)

@n1474335
Copy link
Member

n1474335 commented Nov 8, 2019

You know, in exchange for a Colossus operation, we might just be able to sort something out. I've spoken to our History department and they think this could be possible some time in the new year (they're a little busy at the moment what with all our centenary stuff and the Science Museum exhibition). What exactly would you like recorded?

@VirtualColossus
Copy link
Contributor Author

Wow! OK - I'm not sure I was expecting a positive result from that request, but I'm on it - thank you! If you thought Lorenz run function & args were a beast, just wait until you see Colossus ones ;-) I'll try to keep it manageable! For audio, I guess it depends on how operational your TypeX actually is. If possible, I'd like to have motor starting/stopping, idle running (motor sound), key press (no operation if that's a thing), key press and operating print (ie sound of full camshaft turn & both printers output). I just need a good short loop of audio so only actually need a single operation or a few seconds of each, but I can slice up if you can do it. Operationally, I'm almost there on my simulation, but I still have a lot of tidying up & the website/tutorial to do before I go live so I suspect New Year will be fine (as long as it's beginning, not end of!). I've attached a few pics of current work in progress if you're interested in what I'm using the audio for. You might notice that I'm adding in the CyberChef wired rotors from your TypeX operation, and hopefully, if I have time, will have an import/export from CyberChef too :-)
VirtualTypex1
VirtualTypex2
VirtualTypex3

@n1474335
Copy link
Member

I like your use of the argSelector type in the Lorenz operation and I expect that could come in quite handy for Colossus to hide the complexity unless the user really wants to change things.

We should be able to record those things for you. We'll hopefully get it done by the end of Feb, barring anything major coming up.

Nice touch with the CyberChef rotor settings! It looks really good.

@n1474335
Copy link
Member

n1474335 commented Jan 24, 2020

@VirtualColossus I'm pleased to say we have completed the TypeX recording. We also decided to record Enigma while we were at it, so you've got both. I have emailed the files through to you. I hope you find them useful!

@VirtualColossus
Copy link
Contributor Author

@n1474335 I have the recordings - they are fantastic, just what I was after plus a few other bonus items I wasn't expecting. A little audio, especially from the actual machine itself, makes an incredible difference to how my simulations work and mean people get much more of a feel for how it would have been to use one of these rare machines themselves. Thank you SO much, already working on putting these into the simulation. Thanks for the extra Christmas present - I really appreciate your efforts, a big pat on the back for all your team for doing this.

@VirtualColossus
Copy link
Contributor Author

In case you're interested in checking out the results of the Typex audio recording you kindly organised, my simulation is now live on https://typex.virtualcolossus.co.uk

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants