Andrew Cooke | Contents | Latest | RSS | Previous | Next

C[omp]ute

Welcome to my blog, which was once a mailing list of the same name and is still generated by mail. Please reply via the "comment" links.

Always interested in offers/projects/new ideas. Eclectic experience in fields like: numerical computing; Python web; Java enterprise; functional languages; GPGPU; SQL databases; etc. Based in Santiago, Chile; telecommute worldwide. CV; email.

Personal Projects

Choochoo Training Diary

Last 100 entries

Surprise Paradox; [Books] Good Author List; [Computing] Efficient queries with grouping in Postgres; [Computing] Automatic Wake (Linux); [Computing] AWS CDK Aspects in Go; [Bike] Adidas Gravel Shoes; [Computing, Horror] Biological Chips; [Books] Weird Lit Recs; [Covid] Extended SIR Models; [Art] York-based Printmaker; [Physics] Quantum Transitions are not Instantaneous; [Computing] AI and Drum Machines; [Computing] Probabilities, Stopping Times, Martingales; bpftrace Intro Article; [Computing] Starlab Systems - Linux Laptops; [Computing] Extended Berkeley Packet Filter; [Green] Mainspring Linear Generator; Better Approach; Rummikub Solver; Chilean Poetry; Felicitations - Empowerment Grant; [Bike] Fixing Spyre Brakes (That Need Constant Adjustment); [Computing, Music] Raspberry Pi Media (Audio) Streamer; [Computing] Amazing Hack To Embed DSL In Python; [Bike] Ruta Del Condor (El Alfalfal); [Bike] Estimating Power On Climbs; [Computing] Applying Azure B2C Authentication To Function Apps; [Bike] Gearing On The Back Of An Envelope; [Computing] Okular and Postscript in OpenSuse; There's a fix!; [Computing] Fail2Ban on OpenSuse Leap 15.3 (NFTables); [Cycling, Computing] Power Calculation and Brakes; [Hardware, Computing] Amazing Pockit Computer; Bullying; How I Am - 3 Years Post Accident, 8+ Years With MS; [USA Politics] In America's Uncivil War Republicans Are The Aggressors; [Programming] Selenium and Python; Better Walking Data; [Bike] How Fast Before Walking More Efficient Than Cycling?; [COVID] Coronavirus And Cycling; [Programming] Docker on OpenSuse; Cadence v Speed; [Bike] Gearing For Real Cyclists; [Programming] React plotting - visx; [Programming] React Leaflet; AliExpress Independent Sellers; Applebaum - Twilight of Democracy; [Politics] Back + US Elections; [Programming,Exercise] Simple Timer Script; [News] 2019: The year revolt went global; [Politics] The world's most-surveilled cities; [Bike] Hope Freehub; [Restaurant] Mama Chau's (Chinese, Providencia); [Politics] Brexit Podcast; [Diary] Pneumonia; [Politics] Britain's Reichstag Fire moment; install cairo; [Programming] GCC Sanitizer Flags; [GPU, Programming] Per-Thread Program Counters; My Bike Accident - Looking Back One Year; [Python] Geographic heights are incredibly easy!; [Cooking] Cookie Recipe; Efficient, Simple, Directed Maximisation of Noisy Function; And for argparse; Bash Completion in Python; [Computing] Configuring Github Jekyll Locally; [Maths, Link] The Napkin Project; You can Masquerade in Firewalld; [Bike] Servicing Budget (Spring) Forks; [Crypto] CIA Internet Comms Failure; [Python] Cute Rate Limiting API; [Causality] Judea Pearl Lecture; [Security, Computing] Chinese Hardware Hack Of Supermicro Boards; SQLAlchemy Joined Table Inheritance and Delete Cascade; [Translation] The Club; [Computing] Super Potato Bruh; [Computing] Extending Jupyter; Further HRM Details; [Computing, Bike] Activities in ch2; [Books, Link] Modern Japanese Lit; What ended up there; [Link, Book] Logic Book; Update - Garmin Express / Connect; Garmin Forerunner 35 v 230; [Link, Politics, Internet] Government Trolls; [Link, Politics] Why identity politics benefits the right more than the left; SSH Forwarding; A Specification For Repeating Events; A Fight for the Soul of Science; [Science, Book, Link] Lost In Math; OpenSuse Leap 15 Network Fixes; Update; [Book] Galileo's Middle Finger; [Bike] Chinese Carbon Rims; [Bike] Servicing Shimano XT Front Hub HB-M8010; [Bike] Aliexpress Cycling Tops; [Computing] Change to ssh handling of multiple identities?; [Bike] Endura Hummvee Lite II; [Computing] Marble Based Logic; [Link, Politics] Sanity Check For Nuclear Launch; [Link, Science] Entropy and Life

© 2006-2017 Andrew Cooke (site) / post authors (content).

RC5 Without Rotation (2)

From: andrew cooke <andrew@...>

Date: Tue, 24 Dec 2013 00:23:19 -0300

A couple of nights ago I finally finished the break of ONE round of RC5 with
no rotation using the idea I mentioned near the start of
http://acooke.org/cute/BreakingRC0.html (ie carefully chosen plaintext plus
some simple arithmetic, then targetting individual bits in the xor, then a bit
more arithmetic).  It works nicely, but there's no way to extend it to
multiple rounds that I can see.


So now I'm thinking about the second idea I mentioned there, which was to
express everything as additions modulo 2.  That seems like it might work
because XOR is addition modulo 2, and addition is, well, something similar to
addition modulo 2...

But when I look at the details, it's not so easy.  Addition has a carry.  And
carry is not a modulo 2 kind of thing.

If I take the basic operation in RC5, which is (a^b)+c, and think about that
in terms of bits, and extend it to include the carry bit, k, from the bit
below, then I have something like (a^b)+c+k.

Now that is just a+b+c+k for the bit's value, modulo 2.  But the carry bit to
chain up to the next level is not so easy.  It's something like 

  abck + abc(1-k) + ab(1-c)k + (1-ab)ck

which contains multiplications!  So it isn't linear.  So it seems like the
maths is going to get messy...


So I shelved that approach and looked round for something else.  I started to
think about statistical methods and / or approximations.  I wondered if there
was some kind of iterative approach - if you have a guessed state, how can you
improve it?  And that led to the idea of using a genetic algorithm to improve
the state.

The critical part of genetic algorithms is representing and merging state.
The state itself seems pretty obvious - it's the RC5 internal state.  A bunch
of integers.  But how would you merge two individuals to generate a child?

At first I thought of what you might call "vertical" merging.  Take some
integers from one parent, and some from another.  But then there's an obvious
alternative, which you might call "horizontal" - take the lower bits of the
integers from one parent, and the higher bits from the other.

Which is better?  If you tihnk about RC5 without rotation then the horizontal
approach seems better.  Because it seems like there could be a lot of
redundancy "horizontally" (in fact, I saw redundancy in my single round
solution), while "vertically" the only effect is carry (the same carry that
was such a nuisance above).

At this point I had a kind of side-track.  Maybe I could just ignore carry to
a first approximation?  I don't think that goes anywhere, but I am noting it
just in case it's useful later.


Then suddenly, from those thoughts about the horizontal and vertical, and
carry being a vertical operation, I had a surprising insight.  Something that
in retrospect seems very obvious.  So obvious that I am worried I am doing
something stupid.  But I will write it down here and see how it looks in the
morning:

Without rotation, the least significant bits are unaffected by any other
bits.  RC5 breaks a block into two parts, a and b.  These go through repeated
(u^v)+w operations to get a' and b'.  But nothing in the (u^v)+w operation
mixes in any new, variable information in the lowest bits.  Higher bits get
the carry.  And rotation would cause chaos.  But without rotation the lowest
bits are pretty much unchanging.

In other words, the lowest bit of a' and b' is completely determined (for a
given state / key) by the lowest bit of a and b.  There are 4 possible
combinations and so with 4 plaintext blocks we can write down the truth table
for the lowest bit!

This extends to higher bits, but, because of the carry, they also depend on
lower bits.  So you can construct a truth table for the lowest two bits of
each part with 8 blocks.  And so on.

Now a block is typically 32bits (although it can vary, and my lovely Julia
code is parameterised by this).  So constructing a full table is not
feasible.  But the lowest 16 bits are easy meat.


So I need to test that.  And then, if I don't have any more ideas, look at
genetic programming.  Can the two approaches be merged?  The truth table
approach shows that there is a lot of duplicate state in the lowest bits.  But
how can I represent that in a genetic model in a way that preserves all the
flexibility?

Interesting / fun problems, even if no-one else cares about block ciphers any
more.

Andrew

It Works!

From: andrew cooke <andrew@...>

Date: Tue, 24 Dec 2013 19:48:26 -0300

Well, it works.  I can tabulate the lowest n bits (eg via chosen plaintext)
and then decrypt those in every block.

Code at
https://github.com/andrewcooke/BlockCipherSelfStudy.jl/blob/master/src/RC5.jl#L220

Andrew

Adaptive Plaintext

From: andrew cooke <andrew@...>

Date: Wed, 25 Dec 2013 00:22:50 -0300

Huh.  While I was doing the tabulation something at the back of my mind was
saying I was missing something obvious.  Which, I think, is that I don't need
to build the table.  I can con search bit by bit, using just 4 blocks per bit.

I think.  Not yet implemented....

Andrew

It Also Works!

From: andrew cooke <andrew@...>

Date: Thu, 26 Dec 2013 00:21:59 -0300

Well, that worked too, and was very simple to implement.

I've been thinking more about what "linear" means, and I suspect people amy be
using it loosely to mean something more like "compositable" or "local".  In
which case a GA might be a good idea, even though I have a nice adaptive
plaintext solution.

Andrew

Comment on this post