Quentin Santos

Obsessed with programming since 2002

About me

I have always been fascinated with computers. Nowadays, I mostly use Rust, but I started out with a QuickBASIC book from the local library when I was in elementary school. I also got a Master in computer science from ENSL and a PhD in cryptography from ENS.

Contact me at qsantos@qsantos.fr.

Articles

  • Hacking radiators for fun and no profit

    My flat has a bunch of electrical radiators, branded Acova. They have a remote. Each. Fixed to the wall right next to it. This means I have to get up from my seat to turn a radiator on. Worse, I might have to get to an entirely different room. Remember the first virtue. This is the remote. You can move it around, but there is little point anyway when you would have to carry four. Also, they eat batteries. Unlike the TV remote, my radiator remotes are not IR (although an IR variant does exist, and was already hacked), but… Read more

  • The Acova / Zehnder ComfoRF radiator protocol

    For context, read Hacking radiators for fun and no profit. Disclaimer: This whole article is generated by Claude. Feed it to your own LLM to implement the protocol. You can read it yourself of course, but this is LLM prose. I replaced my Acova radiators' wall remotes with a single Heltec WiFi LoRa 32 V3 (ESP32-S3 + SX1262). This is everything needed to do the same: read your radiator's session key once over SWD, then drive the radiator from the Heltec by reproducing the 868 MHz protocol. All values below are the verified, working implementation — not an approximation. What… Read more

  • Making a dumb TV just smart enough

    I own an old, cheap TV. It has no Internet connection, no fancy smart features that make you want to install a Pi-hole, and no ask-me-again-later updates. Quite basic, but it does its job well However, it is connected to my own desktop computer through an HDMI cable, so I can watch movies and TV series from the couch. Setting it up used to involve going to my desk, enabling the secondary monitor, opening the relevant application, moving its window to the secondary monitor, setting it in fullscreen, going back to the couch, remembering I forgot my wireless keyboard, getting… Read more

  • The USB interposer

    In a previous article, I claimed that there were no good alternatives to the RP2350-USB-A board. To accept a USB keyboard or other device, a USB board has to present itself as a USB host. It does this by pulling down the two USB data pins. The USB device then signals itself by having a data pin pulled up. The RP2350-USB-A has a pull-up resistor on a data line, forcing it to act as a USB device. This means it is not possible to use that board as a keyboard pass-through, for instance. Unless you modify it. I looked at… Read more

  • My first PCB: AIC3204 eval board

    tl;dr: The files are on GitHub. I had some fun with the Adafruit TLV320DAC3100. This is a small board built around the (TLV320)DAC3100 audio chip. “DAC” stands for “Digital-to-Analog Conversion”; that is, it takes some audio signal (here, I²S) and converts it to the analog equivalent (differential for speakers, single-ended for headphones). Adafruit’s breakout board for the DAC3100 chip, clearly visible in the middle of the board Microcontrollers typically don’t have analog output, and getting analog circuitry right can be tricky. With something like the DAC3100 board, you can just tell the chip what sound you want to produce, without… Read more

  • A few spikes in Pico cos()

    A picture is worth a thousand LLM prompts: Profiling the cosf() function of the Pico SDK on an RP2350 (150 MHz). The plateaux at 360 ns and 580 ns correspond to 54 and 87 CPU cycles, respectively. The spikes are bad, at 3440 ns, or 516 CPU cycles. Horizontal value is the input value x for cosf(x), ranging from 0 to 2π. The orange line shows the result of evaluating cosf(x), which looks exactly as expected. The blue line shows the time it took to evaluate cosf(x) for each x, in nanoseconds. I discovered this while investigating why my main… Read more

  • The RP2350 is too fast

    I had a few hours of “fun” figuring out why my RP2350 could use my ILI9341 display, but not the ST7796 one. To be more specific, displaying stuff with the first display worked flawlessly, while the ST7796 would display a single frame correctly, and then glitch. Depending on the exact code running, the glitches would include: color change (purple instead of cyan) every other frame full black only every other line drawn, only on the left half of the screen complete freeze Changing completely unrelated code would change the exact glitch, most likely because it slightly changed the timing at… Read more

  • Asynchronous I²C in C

    Context I have a RP2350 and an SSD1306 module. I want to use the former to display stuff on the latter. The most common modules are connected over I²C: RP2350-USB-A running the Pico demo on an SSD1306 board with 128×64 OLED display. The yellow grid is a small breadboard, that makes it easy to connect things together without soldering. The simple way to use such a display looks like this: int main(void) { // init stuff // … // main loop char buffer[1025]; // 1 byte for command + 1-bit per pixel while (1) { do_work(); put_pixel_data_in(buffer); update_display(); buffer[0] =… Read more

  • (No) alternatives to the RP2350-USB-A

    Following my adventures (part 1, part 2) with the RP2350-USB-A, I took another look at the alternatives. Specifically, I am looking for a cheap dev board with two full USB ports (1 device, 1 host), that could be easily programmable, and would be production-ready for hobbyist projects (if you’re a professional, you’ll just manufacture your own board). First, I want to clarify that strikes out the boards that expose UART-over-USB as one of the two USB ports, such as the Arduino Due, or the ESP32-S3-DevKitC. In these cases, the MCU (MicroController Unit) only supports USB, but also has UART for… Read more

  • The RP2350-USB-A cannot see devices disconnect

    What’s better for New Year’s Eve than debugging some USB hardware issues? In my previous article, I explained how the design of Waveshare’s RP2350-USB-A can make the USB-A host connector incapable of detecting certain USB devices, and of any hot-plugging. The solution was to desolder R13, a pull-up resistor on D+: With this fix, my RP2350-USB-A was able to detect when I connected a keyboard to the USB-A port, and to receive keypresses. However, I noticed another issue: when disconnecting the keyboard, the board would not detect that it happened. When connecting the keyboard again, it would often not work… Read more

  • Fixing the RP2350-USB-A not working as USB host

    tl;dr: you need to desolder R13, the resistor closest the pin 6 of the board, as indicated by the red arrow in the cover picture of this article Context I am currently toying around with emulating a USB device. However, I also wanted to be able to plug a keyboard in, so I needed a second USB port. Since I am not at the stage where I would design my own boards, I only use dev boards. I found exactly what I needed for my purposes with the RP2350-USB-A: It is still relatively cheap at ~5 €, features a USB-C… Read more

  • The serial TX path seems to be down

    The previous series of articles about UART was initially motivated by an error I was getting when using the ESP-Prog. I could have jumped straight to the conclusion, but I took the time to really understand what was going on, and we are finally reaching the end of this investigation. How to use “real” UART Arduino’s Automatic Reset Linux always toggles DTR & RTS Espressif’s Automatic Reset Talking to Espressif’s Bootloader The ESP32-S2 reset pin Reproducing Espressif’s reset circuit The missing part of Espressif’s reset circuit Transistors in reverse and redundant circuits The serial TX path seems to be down… Read more

  • Transistors in reverse and redundant circuits

    How to use “real” UART Arduino’s Automatic Reset Linux always toggles DTR & RTS Espressif’s Automatic Reset Talking to Espressif’s Bootloader The ESP32-S2 reset pin Reproducing Espressif’s reset circuit The missing part of Espressif’s reset circuit Transistors in reverse and redundant circuits The serial TX path seems to be down The mystery In the previous article, I briefly mentioned a slight difference between the ESP-Prog and the reproduced circuit, when it comes to EN: Breadboard circuit with pull-up resistors and delay capacitor, no board connected, EN and IO0 only ESP-Prog connected to an ESP32-S2-Saola-1RI board, EN and IO0 only Focusing… Read more

  • The missing part of Espressif’s reset circuit

    How to use “real” UART Arduino’s Automatic Reset Linux always toggles DTR & RTS Espressif’s Automatic Reset Talking to Espressif’s Bootloader The ESP32-S2 reset pin Reproducing Espressif’s reset circuit The missing part of Espressif’s reset circuit Transistors in reverse and redundant circuits The serial TX path seems to be down In the previous article, we peeked at the reset circuit of ESP-Prog with an oscilloscope, and reproduced it with basic components. We observed that it did not behave quite as expected. In this article, we’ll look into the missing pieces. The expected behavior of the reset circuit. What we actually… Read more

  • Reproducing Espressif’s reset circuit

    How to use “real” UART Arduino’s Automatic Reset Linux always toggles DTR & RTS Espressif’s Automatic Reset Talking to Espressif’s Bootloader The ESP32-S2 reset pin Reproducing Espressif’s reset circuit The missing part of Espressif’s reset circuit Transistors in reverse and redundant circuits The serial TX path seems to be down I recently discussed how Espressif implements automatic reset, a feature that lets users easily update the code on an Espressif microcontroller. There are actually more subtleties than a quick look would suggest, and I spent a fair bit of time investigating them. This article and the next two present (The… Read more

  • The ESP32-S2 reset pin

    How to use “real” UART Arduino’s Automatic Reset Linux always toggles DTR & RTS Espressif’s Automatic Reset Talking to Espressif’s Bootloader The ESP32-S2 reset pin Reproducing Espressif’s reset circuit The missing part of Espressif’s reset circuit Transistors in reverse and redundant circuits The serial TX path seems to be down RST defaults to high This is an addendum to the article about Espressif’s automatic reset. In that article, we observed the effect of the RST pin on the ESP32-S2-Saola-1RI board: if nothing is connected to RST, it runs normally if something sets the electrical level of RST to low (0V),… Read more

  • Talking to Espressif’s Bootloader

    How to use “real” UART Arduino’s Automatic Reset Linux always toggles DTR & RTS Espressif’s Automatic Reset Talking to Espressif’s Bootloader The ESP32-S2 reset pin Reproducing Espressif’s reset circuit The missing part of Espressif’s reset circuit Transistors in reverse and redundant circuits The serial TX path seems to be down In my article about Espressif’s Automatic Reset, I briefly showed UART output from the bootloader, but did not go in more details. In this article, I want to go just a bit further, by showing some two-way interactions. As usual, GND to GND, VCC to 5V, TX to RX and… Read more

  • Espressif’s Automatic Reset

    How to use “real” UART Arduino’s Automatic Reset Linux always toggles DTR & RTS Espressif’s Automatic Reset Talking to Espressif’s Bootloader The ESP32-S2 reset pin Reproducing Espressif’s reset circuit The missing part of Espressif’s reset circuit Transistors in reverse and redundant circuits The serial TX path seems to be down In previous articles, we saw how to use “real” UART, and looked into the trick used by Arduino to automatically reset boards when uploading firmware. Today, we’ll look into how Espressif does something similar, using even more tricks. “Real” UART on the Saola As usual, let’s first simply connect the… Read more

  • Linux always toggles DTR & RTS

    How to use “real” UART Arduino’s Automatic Reset Linux always toggles DTR & RTS Espressif’s Automatic Reset Talking to Espressif’s Bootloader The ESP32-S2 reset pin Reproducing Espressif’s reset circuit The missing part of Espressif’s reset circuit Transistors in reverse and redundant circuits The serial TX path seems to be down In my previous article, I explained how Arduino makes the life of its users easier by automatically resetting the board when the UART pin DTR (or RTS) transitions from electrically high to low. This exploits the fact that this transition happens automatically when someone or something opens the serial device… Read more

  • Arduino’s Automatic Reset

    How to use “real” UART Arduino’s Automatic Reset Linux always toggles DTR & RTS Espressif’s Automatic Reset Talking to Espressif’s Bootloader The ESP32-S2 reset pin Reproducing Espressif’s reset circuit The missing part of Espressif’s reset circuit Transistors in reverse and redundant circuits The serial TX path seems to be down As mentioned in my previous article, I am planning to publish a long-form article on UART. I am doing a series of shorter articles to lay the groundwork. This is one of these “short” articles; this one about how Arduino uses UART. Of course, I still went way too deep… Read more

  • How to use “real” UART

    How to use “real” UART Arduino’s Automatic Reset Linux always toggles DTR & RTS Espressif’s Automatic Reset Talking to Espressif’s Bootloader The ESP32-S2 reset pin Reproducing Espressif’s reset circuit The missing part of Espressif’s reset circuit Transistors in reverse and redundant circuits The serial TX path seems to be down I recently went into a deep dive on “UART” and will publish a much longer article on the topic. This is just a recap of the basics to help put things in context. Many tutorials focus on using UART over USB, which adds many layers of abstraction, hiding what it… Read more

  • IndexedDB is Weird

    Why? Well: The IndexedDB API is callback-based. With JavaScript being single-threaded, a blocking API would mean fully blocking the page, render and basic user interaction included, while the request is being processed. Although this is apparently good-enough for JSON.parse(), the W3C decided to make the IndexedDB API non-blocking. The first drafts for IndexedDB are from 2009, with the first implementations becoming available in 2011. In contrast, async only reached the main browsers in late 2016. Without async, a JavaScript API that avoids blocking needs to be callback-based. So, even though JavaScript got itself an out from callback hell in the… Read more

  • Rust Gotcha: last() on DoubleEndedIterator

    tl;dr: don’t call last() on a DoubleEndedIterator Edit: And, now it is a Clippy lint! How do you efficiently get the last part of a space-separated string in Rust? It will be obvious to some, but the obvious answer of s.split(' ').last() is wrong. The mistake is easy to make; I encountered it in a recent MR I reviewed, and I realized I used it in some of my own code. Let’s see why. If it were Python, s.split(' ') would return a list with all the parts of s. In other words, this code wastes precious CPU cycles extracting… Read more

  • Rust Strings for C Programmers

    This article will quickly explain the Rust types [T; N], &[T; N], &[T], Vec<T>, &Vec<T> with C code, and what the str, &str, String, OsString and CString add. Arrays and Slices RustC [T; N] (array) Example: [i32; 100] Allocated on the stackT[N] Example: int[100] Allocated on the stack &[T; N] (array reference) Example: &[i32; 100] N is tracked at compilation. Bounds-checks are done at runtime (opt-out using get_unchecked¹).const T[N] in function parameters or const T* Example: const int[100] or const int* Partially tracked at compilation², no access bounds-checks at runtime. &mut [T; N] (exclusive array reference) Example: &mut [i32; 100]… Read more

  • You can move !Unpin

    Although I am now mostly comfortable with Rust, some concepts still elude me. One of them is the exact meaning of Unpin. The documentation says: The documentation of Unpin says: Types that do not require any pinning guarantees. Where pinning is described as: The ability to rely on this guarantee that the value a pointer is pointing at (its pointee) will Not be moved out of its memory location More generally, remain valid at that same memory location From this, you could naturally deduce that Unpin is the trait that allows Rust values to be moved. Except it is not.… Read more

  • On-Die ECC

    This article will be pretty short. When I built my new desktop computer, I considered ECC memory. So, I looked around for DDR5 ECC memory. Surprisingly, DDR5 memory sticks that mentioned ECC was not significantly more expensive than other DDR5 memory sticks. Sometimes, they were even cheaper! At some point, I read that all DDR5 memory sticks supported ECC. But, also, not really. It turns out that “ECC memory” has now been overloaded to mean two subtly different concepts: Side-band ECC: The memory stick stores, and sends some additional bits of information along with the data. These bits then travel… Read more

  • AMD CPUs, CCDs and CCXs

    When researching for my article about Linux pipes and for other upcoming articles, I had to get more familiar with how my CPU works. I thought I knew quite a bit, with L1/L2/L3 caches, ISA extensions, branch predictors, register renaming and so much more. But, it turns out, even as a mere user, there is so much more to know1. In particular, modern CPUs are exploring several strategies to increase the number of cores while keeping single-thread performance high. I was vaguely aware of P-cores and E-cores2 on Intel CPUs. For AMD CPUs, I encountered the concept of CCDs and… Read more

  • Upgrading to Debian Trixie

    I had been running Bookworm for quite a while. It has now been stable for more than a year. In other words, Trixie has now been testing for more than a year, and will most likely become the new stable in less than a year. In the past, I encountered a few surprises with unstable releases and recent testing releases. So, I avoid upgrading too soon. But it felt pretty safe at this point. Besides, I wanted to run a more recent version of the kernel to have fun with modern perf events. So I basically did the usual process:… Read more

  • Beware Rust Buffering

    This article is about a small pitfall I stumbled uopen Rust. Since it took me relatively too much time to figure it out, I made this article as a reminder. Also, there is a post scriptum, also about buffers, but not about Rust. While writing my article about Linux pipes, I needed a small program to write some data, any data, very, very fast. So, I wrote ./zeroes, which just writes… zeroes. Note that ./zeroes | program is very different from <dev/zero program. The latter just opens the special file /dev/zero on file descriptor 0 (stdin). And reading from this… Read more

  • Interactive Flamegraphs

    In my latest article, I made heavy use of flamegraphs. To makes things clearer, flamegraphs are visualizations of how much time is spent in each function in a program: // no CDATA because of https://core.trac.wordpress.org/ticket/3670 "use strict"; function init(evt) { var details, searchbtn, unzoombtn, matchedtxt, svg, searching, currentSearchTerm, ignorecase, ignorecaseBtn; svg = evt.target; details = svg.getElementById("details").firstChild; searchbtn = svg.getElementById("search"); ignorecaseBtn = svg.getElementById("ignorecase"); unzoombtn = svg.getElementById("unzoom"); matchedtxt = svg.getElementById("matched"); searching = 0; currentSearchTerm = null; // event listeners svg.addEventListener("click", function(e) { var target = find_group(e.target); if (target) { if (target.nodeName == "a") { if (e.ctrlKey === false) return; e.preventDefault(); } if… Read more

  • Linux Pipes are Slow

    Errata: Some significant mistakes were pointed out to me by email by Brendan MacDonell. I have included errata, but the results might not be reliable, so take this with pinch of salt! vmsplice is too fast Some programs use a particular system call “vmsplice” to move data faster through a pipe. Francesco already did a deep dive on using vmsplice to make things fast. However, while experimenting with it, I noticed that, when not using vmsplice, Linux pipes are slower than what I would have expected. Since you cannot always use it, I wanted to understand exactly why that was,… Read more

  • Git Super-Power: The Three-Way Merge

    tl;dr: git config --global merge.conflictstyle diff3 In my previous post, I preached about the one true way to merge MRs in a git workflow. The answer is obviously to rebase for conflicts, and a merge commit for posterity of the MR. What I did not talk about is that there is a reason that pushes so many people to heresy. And that reason is fearing having to resolve merge conflicts! The thing is that merge conflicts are really not hard to resolve when using the right method. But it's not the default one. The default one looks like this: Your… Read more

  • Merging Responsibly

    tl;dr: I do not like merging the main branch into feature branches, and I do not like squashing MR/PRs git commit git has emerged as the obvious choice for SCCS (Source Code Control System). The consensus is that it is unambiguously better than the previous standard, SVN. There is some debate as to what is the current best SCCS, especially regarding the confusing command-line interface of git1, but the first mover effect gave the advantage to git, and network effects make the space a winner-take-all situation. However, we are not here to discuss this, which is a settled issue in… Read more

  • ViHN: Vim for Hacker News

    tl;dr: I made ViHN to read Hacker News without having to move my hands away from the keyboard. It's freely available on Firefox and Chrome. This is about yet another Hacker News extension. But other people with my obsession for killing the mouse might enjoy it. Most of the content of this article is just an ancient1 talking about the good ol' times. But you can jump directly to the description of the extension. btw, I use Vim I know that I am not the only one who had a keyboard-zealot phase. When GNOME Shell happened, I was forced to… Read more

  • Rewriting NHK Easier in Rust

    The Christmas holidays are the perfect time of the year to shut oneself in, talk to no one, and pour days into staring at a computer screen. So, naturally, I rewrote my longest-actually-running project in Rust 🦀. The Challenge Many Words NHK Easier serves news written in simple Japanese for language learners. It has a couple of features to make the learning process easier. The most important and more complex one shows the corresponding dictionary entry when hovering a word. The EDICT dictionary with proper names is 11 MB compressed with bzip2. We do not want to send that for… Read more

  • Dynamic Programming is not Black Magic

    This year's Advent of Code has been brutal (compare the stats of 2023 with that of 2022, especially day 1 part 1 vs. day 1 part 2). It included a problem to solve with dynamic programming as soon as day 12, which discouraged some people I know. This specific problem was particularly gnarly for Advent of Code, with multiple special cases to take into account, making it basically intractable if you are not already familiar with dynamic programming. However, dynamic programming itself is mostly natural when you understand what it does. And many common algorithms are actually just the application… Read more

  • The Secret to a Green CI: Efficient Pre-commit Hooks with checkout-index

    tl;dr Linting in the CI Most people are familiar with the concept of “CI” as in “CI/CD”. For the ones who are not, it usually refers to a set of automatic tests that are run when a developer sends their code for review. These tests typically include “linters”, which will check that the code follows certain stylistic rules, and detect common mistakes. It can be pretty annoying to wait for the CI to complete, only to discover that it failed because that I forgot a “;” in TypeScript, added an extra “;” in Python, did not format my Rust code… Read more

  • Learning Morse with Koch

    If you take an interest in learning Morse code, you will quickly hear about “Koch method” and “Farnsworth method”. You will also read many opinions stated with absolute certainty, often contradicting each other. Some advice is straight out non-actionable. I have recently read Koch Dissertation on Learning Morse Code. Yeah, I have unusual ways to spend my time. Anyway, the reason for this is that I wanted to actually understand what Koch actually claimed, and what he actually proved. I start with a rant about reading a badly scanned German paper from almost 90 years ago, and a small digression… Read more

  • Tiny Docker Containers with Rust

    The Magic Thanks to Python, I have gotten used to Docker images that takes minutes (or dozens of minutes) to build and hundreds of megabytes to store and upload. FROM python3:3.14 # install everything RUN apt-get update \ && apt-get install -y --no-install-recommends libsome-random-library0 libanother-library0 \ libmaybe-its-for-pandas-i-dunno0 libit-goes-on0 liband-on0 \ liband-on-and-on0 \ && rm -rf /var/lib/apt/lists/* # install more of everything COPY requirements.txt . RUN pip3 install -r requirements.txt ENTRYPOINT ["gunicorn", "--daemon", "--workers=4", "--bind=0.0.0.0:8080", "app:create_app()"] But there is another way. The Rust way. Where you build your image in a second, and it only takes 5 MB1. FROM scratch COPY… Read more

  • Koch's Dissertation on Learning Morse Code

    This post is a summary of the dissertation that Dr.-Ing. Ludwig Koch submitted in 1935 to become doctor engineer. This is what is referred to by “Koch method” in the context of learning Morse code. I will publish my commentary in another post. You can find the scan, the transcription, and the full translation in the dedicated repository. The scan comes from the Internet Archive. Edit: For another full translation, look here. For other summaries of the dissertation, look here, or here. I did my own summary independently of these, and before reading them. Koch uses char/min as the unit… Read more

  • Where to Start with Rust

    As a Rust evangelist, I have been asked a few times for resources to start learning Rust. I have compiled my thoughts in this article. I have ordered the resources in a rough order: you should first take a look at the first resources and later at the other ones. Do not take it as gospel, and do peek at the rest of the list before completing even the official tutorial. The Rust Programming Language This is the official tutorial for Rust. It is also known as “the Rust book”. I do not recommend you read it entirely, but you… Read more

  • Client-Side Password Hashing

    tl;dr: When you think about it, hashing password only client-side (in the browser, in JavaScript) is not as terrible as you might think. And if you do most of the work client-side, you get something that is actually pretty secure. Storing Passwords So, I have been working on modernizing a Web application and fixing some of its issues. As someone who has spent way too much time implementing cryptographic primitives and cracking password hashes for fun, one of the main problems was that passwords were only hashed client-side. For the context, we have learned quite a long time ago that… Read more

  • Strongly Typed Web Apps

    I Am Old I like software to be correct. I know. Controversial, right? But as I have gained experience tinkering with various technologies, and building hobby project after hobby project, with some professional projects in-between, I have come to realize that I do not want to just pray and hope. I want to know that my programs work. And I do not want to spend 99 % of my time manually testing them. When I first encountered Python, coming from a QBasic, C and C++ background, it was a bliss not having to declare types manually. Instead of wasting time… Read more

  • Overkill Debugging

    Hack that Code! I have a not-so-secret technique that I use whenever I encounter a bug that evades my grasps. Or when I am lazy. Okay, mostly when I am lazy. The idea is no more than applying the concept of binary search to source code: Remove half the code Compile and run If the bug is still present, repeat with the remaining code Otherwise, repeat with the code that was removed in 1 Of course, this naive approach is rarely practical. For once, removing half the code indiscriminately tend to make things not compile. Also, sometimes, a bug manifests… Read more

  • HamFox: Forking Firefox for Fun and no Profit

    Null Cipher The radio amateur service does not allow encryption of communications. This is a fundamental rule meant to ensure that the amateur service is not used for unintended purposes, such as commercial ones. As a consequence, we cannot transmit passwords securely over the amateur frequencies. But we can use cryptographic authentication. Just not anything that would be used to hide the contents of the communications. Cryptographic authentication is something that HTTPS/TLS allows out-of-the-box. We just need to make sure that we are not using encryption. In this article, we'll see how to do this with Mozilla Firefox. Forking Firefox… Read more

  • HTTPS Without Encryption

    As I have discussed previously, we can use cryptography over the amateur radio service, as long as we disable encryption. I have shown how to do this with SSH. Now, let's see how to do this with HTTPS. Modifying a Web browser, or even just a Web server, is an involved process, so we'll start small, with the openssl command-line tool. On with crypto-crimes! No, not that crypto. OpenSSL Server The openssl command-line tool can be used like netcat to open a TLS session. To start a server, instead of: $ nc -nlvp 4433 Listening on 0.0.0.0 4433 We'll do:… Read more

  • HamSSH

    In a previous article, I explained that encryption is not allowed on the radio amateur service, but that we could still use public-key cryptography. In particular, we could use SSH for authentication, but without encryption. This would allow secure remote control of base stations, satellites and more. In this article, I will discuss how we can do that in practice without reinventing the wheel. The result is the HamSSH project, which forks OpenSSH to provide an encryption-free, but still authentication-secure implementation of SSH. Building OpenSSH The most common implementation of the SSH protocol is OpenSSH. To build the project from… Read more

  • Float Woes in C

    The C programming language is a gift that keeps giving. Today, we are going to see how a seemingly banal and common operation can hide unfathomable depths of unmentionable horrors. Woes with Integer Coercion What is the problem of the code below? // returns the closest integer to f int float2int(float f) { return (int) f; } It's written in C. — A Rust enthusiast That's… a good point. But let's assume we actually want to write C, for some forsaken reason. And we do not care whether we convert up, down or sideways. There is still a fundamental issue… Read more

  • Ham Crypto

    Amateur Radio Amateur radio is about tinkering with the electromagnetic field. This may involve designing analog circuits to shape or unveil the modulation of signals, or sometimes using digital ones to recover information from the noise, or operating multi-hundred-watts transceivers to chat directly with the other side of the world, or lower-power ones to go just as far with Morse code, or even bouncing signals off the Moon. Also, lasers. Yes, this is the 2005 picture from Wikipedia. No, things have not changed that much since. Physics still work the same. Amateur radio operators, or “hams” for short, benefit from… Read more

  • Flexible Array Members: Typical C Shenanigans

    Speed. I am Speed. The one thing that C cares about is speed. Seriously, you might not get the right results, but at least, you will get them fast. Let's look at two common ways to represent a vector in C. struct vector { unsigned long size; int data[42]; }; The first one is to just use the built-in array type. This approach is simple, but implies choosing the size of the vector when compiling. The program cannot decide the size depending on user-input or some other runtime parameter. Note: Variable-Length Arrays (VLA) do allow declaring arrays whose length is… Read more

  • Why Undefined Behavior Matters

    So Many Bugs So, you've been programming for one month, or for ten years, and you have gotten familiar with Murphy's and Sturgeon's laws. And you are wondering if there is some way to catch all the bugs, not just spray-and-pray with regression/unit/integration/system/acceptance testing. Or you are a curious onlooker, wondering why all these programmers cannot make a piece of software that works reliably, what with apps doing unexpected things and with all the security breaches you hear off. First, what are we talking about? Essentially, a bug is anytime a system does not do what it is expected to:… Read more

  • Continuous Integration and Delivery Made Easy

    These are not really advanced topics, but I wanted to write about them anyway. So here it is. Continuous Integration Sometimes, I report bugs in software. Others, in libraries. Or I can just fix things by myself. And more. Point being: there are lots of bugs everywhere. What do we, software developers, do to avoid writing too many bugs? We run tests. Unit tests. Integration tests. System tests. Acceptance tests. And where possible, we write software to do these tests for us. Usually, that means unit tests and integration tests. Usually, such tests won't guarantee that our code is without… Read more

  • Building for Windows without Running Windows

    By the way, I use Linux 1998 2008 2018 2022 will be the year of the Linux desktop. Definitely sometimes before 2028. Maybe before 2038? Ok, maybe not. In any case, I am the most comfortable working (and studying, and procrastinating, and gaming, and procrastinating) on Linux (yeah, yeah, GNU/Linux or GNU+Linux, I know). Actually I am a weakling running Debian with the non-tiling WM Xfce4 (I could as well install Xubuntu at this point). Anyway, the point is that I still need to target Windows as a platform for the 96 % of users who have not yet seen… Read more

  • Astronomical Depth Buffer

    Guess what. We're going to talk about floating point arithmetic and what happens when using distances that range from the millimeter to Pluto's distance to the Sun. Yes, yet again. Floating Point Arithmetic OpenGL uses single precision floating point arithmetic. In any case, that's what your GPU prefers to use. This means you can be as precise as 60 parts in a billion, but not more. That's more than enough for drawing human-sized objects: the error is much smaller than the width of human hair. And it causes no problem when drawing the Solar-system: the error to Pluto's orbit is… Read more

  • Solving Kepler's Equation 5 Million Times a Second

    I know it is a controversial opinion, but you might need to know where things are when running a simulation. As a bonus, it helps you in knowing what to draw on the screen. Of course, you can just use a position vector (x, y, z) where x, y and z are the coordinates of the object. But things have the inconvenient tendency not to stay in the same place for all eternity. So we'll want to know where that object is at the given time. Now, the more generic approach is to run a physics simulation. We compute the… Read more

  • Floating Point Woes in Three Dimensions

    Sometimes, stuff in space rotates[citation needed]. In this article, I am going to explain the basic idea to simulate rotation efficiently, and a few technical hurdles I encountered while implementing it. I have not yet got down to reinventing the wheel writing a physics engine. Besides, I don't want to simulate physics just to keep track of the orientation of the object through time. Doing so would drastically limit how much we can time-wrap (to maybe ×10,000). Instead, we can just assume a constant rotation (angular velocity), and deduce the orientation at any given time from the base orientation and… Read more

  • Looking Up-Close at Orbits

    In the previous post, I explained the basic idea that is used to draw orbits using line segments, and a little trick to make even very elliptical orbit look good. So, this is where we are: Looks good. But if we zoom in: The line segments are visible again! What is going on?! I thought we had taken care of spreading the line segments to hide the angle as much as possible! — A distraught hypothetical reader Well, true. But we did it assuming we were looking straight down at the ellipse. Here, perspective comes into play. Although it conserves… Read more

  • Drawing Nice Orbits

    So, I have been working on Kepler Project again, and I thought I would write about some of the interesting challenges I have encountered and how I overcame them. The Shapes of an Orbit Today, we will talk about drawing orbits. I will talk about the orbital computations themselves another time. Here, we can see the full orbits of the four terrestrial (i.e. rocky) planets: from interior to exterior, Mercury, Venus, Earth and Mars. In the middle, of course, is the Sun, and the outermost orbit partially visible here is that of Ceres, a dwarf planet whose orbit lies between… Read more

  • Code Golfing in Python

    Code Golf I spend way too much time playing Clash of Code on CodinGame as you can see in the “featured image” above. I still haven't caught up with Haskell, and I struggle to stay above Allis. Both are really strong, and seem to know Ruby very well! My favorite mode is “Shortest”. The goal is to write a program against a given specification within 15 minutes. But, unlike the “Fastest” and “Reverse” modes, the main criterion is the number of characters in the submitted code. So, if the problem is to write a program that asks for an integer… Read more

  • First Commit

    I have been thinking about starting yet another blog for a while. As someone who breathes code, writing my own blog engine is pretty much a reflex. In fact, I created quite a few websites in the past, mostly in PHP. This stems from a search for “just the right tool for the job”. However, I have started battling with what would be best described as writer's block. During summer 2019, I have done tremendous progress on Kepler's Project, a full C++ rewrite of a former Python project (Spyce). Spyce had stalled because I would feel overwhelmed whenever I attempted… Read more