Random Numbers Part 2: Residues, Groups, and the ZX Spectrum

It’s interesting how simple random number generators in computers such as the 1982 ZX Spectrum are:

\(X_{n} = 75^n \pmod{65537}\)

The nth term is equal to 75 to the power of n, modulo 65537. The first few terms are:

Index Term
0 1
1 75
2 5,625
3 28,653
4 51,791
5 17,642
6 12,410
7 13,232
8 9,345
9 45,505
10 4,951

There are 65536 terms in the sequence, before it resets and repeats from the beginning again. The ‘randomness’ is introduced by the modulus we’re working under - each time the power of 75 exceeds 65537, we wrap around and land somewhere “unexpected”.

Random Numbers Part 1: Modulus and Primes

I’ve wondered a few times how we might generate a one-to-one mapping between a range of integers, and a “shuffled” counterpart in that range. For example, imagine a website where we expose primary keys as part of the URL path:

http://www.example.com/pageId=123

This invites someone to try plugging in different pageId values into the URL, as it would be a fair guess that it just represents a database sequence. A scraper could enumerate all pages on the website by incrementing pageId by 1 on each request.

Hairpin NATs and Martian Packets

This is going to be a bit of a dry post unfortunately. I want to document a problem I encountered with my home network, and what I learned diagnosing and solving it. It relates to Wireguard, Network Address Translation, network interfaces and packet captures. So pre-warned, let’s get into it!

Axiom 49 Keyboard Repair

I recently repaired a MIDI keyboard which has been causing me trouble for a long while. This was my first go at doing electronic board repair with surface mount components, and it went well!

See the LCD display flicker on and off as the unit resets itself at random moments:

This model is pretty old now, and many of these units suffered a problem dubbed the “blue screen of death”. This relates to how the LCD would go dead and the blue backlight was the only sign of life.

I found a walkthrough of this repair in this excellent YouTube video. Fortunately I was able to follow along with that repair video and replicate the steps, both testing to find the problem and also the fix.

Read more …

How it started vs. How it's going - www.benrowland.net

Too long ago in 2004, this website started. I vividly recall the satisfaction when I typed www.benrowland.net into a browser, and it worked. I ran the website on Tomcat running in a DOS window on my Windows desktop, so it wasn’t quite a production-grade deployment. I had pointed my domain name to the IP address allocated to my home computer by my ISP, and there was something magical about watching the internet routing happen the way I’d hoped it would.

Spring Boot, Gradle and Java 11

When upgrading a hobby Spring Boot project to Java 11, there were a few issues which reminded me of how closely related Gradle, the Spring Boot plugin, and the java version you’re using are.

Naively trying a gradlew bootRun on the project (which was using Gradle 3.1) resulted in this:

Could not determine java version from '11.0.5'

Fortunately I’d seen that one before, so I upgraded my version of Gradle to 5.1.1 by updating gradle-wrapper.properties.

HTTPS and Java - Pitfalls and Best Practices - Part 1

As software developers, we often want to talk to services over the internet, usually using HTTP. However, it’s now very common to see online services using HTTPS – an extension of HTTP which enables secure communications over a network.

This move has made life more interesting for developers who want to interact with these services. Most of the time, connecting to a host over HTTPS “just works” from Java, but sometimes things don’t quite work … and Java can be a bit cryptic in how it reports the failure.

HTTPS and Java - Pitfalls and Best Practices - Part 2

Chain of Trust

When a Java program connects to a host over HTTPS, it’s important to know you’re really communicating with who you think you are. If I write a program which connects to https://www.example.com, then I’m sending information over a secure channel. How can I be sure I’m not talking to a malicious third party who is somehow intercepting my traffic, such as user credentials?

The identity of a server is proven with certificates. As an overview, when a Java program connects to a host over HTTPS, before secure communication can take place, the server sends back its certificate. Java then verifies that this certificate was issued by a legitimate Certificate Authority (CA). This is possible because Java ships with a trust store, containing a white list of trusted Certificate Authorities. As Java updates are rolled out, from time to time certificates are added to (or removed from) this trust store.

HTTPS and Java - Pitfalls and Best Practices - Part 3

Ciphers

So far, we’ve looked at how certificates can support the Authentication property of HTTPS. The certificate also enables a second property of HTTPS – Encryption of the traffic. This encryption is possible because the certificate contains a public key which allows clients to encrypt data, so only those holding the corresponding private key (the website owner) will be able to decrypt.

This encryption is achieved using ciphers. There may be a range of ciphers available on both ends of the connection, and the cipher chosen for the communication will be agreed in the initial TLS handshake. If no cipher can be agreed upon – say if the web server wants to use a strong, modern cipher such as AES 256, and Java cannot support that cipher, then Java will fail to connect with the message we saw earlier: Received fatal alert: handshake_failure.

HTTPS and Java - Pitfalls and Best Practices - Part 4

Perfect Forward Secrecy

At the present time, with the possibility of data breaches and digital eavesdropping, privacy is an important subject. What’s to prevent a malicious third-party from collecting traffic going to or from a website?

It might seem adequate to use HTTPS to encrypt traffic to a website, meaning it’s impossible to decrypt the traffic unless you also have access to the private key. But what if a malicious actor collects encrypted traffic over a long period of time? They may not be able to decrypt the traffic just yet … but what if at a later date they recover the private key which secures the website? Would they be able to decrypt all the collected traffic?