From 3bae11c7cf1f8ab8fa153fdc9957de85ad61d71a Mon Sep 17 00:00:00 2001 From: Jacob Lindahl Date: Fri, 17 May 2024 18:22:35 +0900 Subject: [PATCH] fix: off-by-one --- content/blog/what-does-my-rsa-public-key-actually-mean.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/blog/what-does-my-rsa-public-key-actually-mean.md b/content/blog/what-does-my-rsa-public-key-actually-mean.md index 627867c..54a1cfc 100644 --- a/content/blog/what-does-my-rsa-public-key-actually-mean.md +++ b/content/blog/what-does-my-rsa-public-key-actually-mean.md @@ -102,7 +102,7 @@ f0 10 75 73 65 72 40 65 78 61 6d 70 6c 65 2e 63 |..user@example.c| 6f 6d f1 0b 6d 79 5f 75 73 65 72 6e 61 6d 65 |om..my_username| ``` -The idea is that the first byte (or bytes, depending on the format) represent a **tag**. In the basic example above, the byte `f0` means email, and the byte `f1` means username. The next byte(s) indicates the **length** of the information. So, `f0 10` means that we're expecting a 16 byte long email next. So, we read the next 16 bytes `75 73 65 72 40 65 78 61 6d 70 6c 65 2e 63 6f 6d` and that should be an email **value**. If we decode those bytes as ASCII, what do we get? `user@example.com`. _VoilĂ !_ Now rinse and repeat for the next bytes: a `f1` username… that is `0b 10` bytes long… `6d 79 5f 75 73 65 72 6e 61 6d 65`—`my_username`! +The idea is that the first byte (or bytes, depending on the format) represent a **tag**. In the basic example above, the byte `f0` means email, and the byte `f1` means username. The next byte(s) indicates the **length** of the information. So, `f0 10` means that we're expecting a 16 byte-long email next. So, we read the next 16 bytes `75 73 65 72 40 65 78 61 6d 70 6c 65 2e 63 6f 6d` and that should be an email **value**. If we decode those bytes as ASCII, what do we get? `user@example.com`. _VoilĂ !_ Now rinse and repeat for the next bytes: a `f1` username… that is `0b` 11 bytes long… `6d 79 5f 75 73 65 72 6e 61 6d 65`—`my_username`! ASN.1 (Abstract Syntax Notation One) is a notation for describing data structures. It can represent integers, strings, sequences, booleans, etc. [There are lots of different ASN.1 encoding rules](https://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One#Encodings), but we're interested in the ones for binary, specifically, the [Distinguished Encoding Rules (DER)](https://docs.microsoft.com/en-us/windows/win32/seccertenroll/about-der-encoding-of-asn-1-types).