Commit f1f35bd407

f1f35bd4070c7dd0d232c5a3f2f7373511475565

parent: ceb109db05

Unsigned

cmc <hello@cleberg.net> · 2025-11-12 01:42 UTC

fix grammar in 2018 posts

Layout: unified · split

content/blog/2018-11-28-aes-encryption.org +45 −44
@@ -6,15 +6,15 @@
66* Basic AES
77
88If you're not familiar with encryption techniques, [[https://en.wikipedia.org/wiki/Advanced_Encryption_Standard][AES]] is the *Advanced
9Encryption Standard*. This specification was established by the National
10Institute of Standards and Technology, sub-selected from the Rijndael family of
11ciphers (128, 192, and 256 bits) in 2001. Furthering its popularity and status,
12the US government chose AES as their default encryption method for top-secret
13data, removing the previous standard which had been in place since 1977.
9Encryption Standard*. The National Institute of Standards and Technology
10established this specification, sub-selected from the Rijndael family of ciphers
11(128, 192, and 256 bits) in 2001. Furthering its popularity and status, the US
12government chose AES as their default encryption method for top-secret data,
13removing the previous standard which had been in place since 1977.
1414
15AES has proven to be an extremely safe encryption method, with 7-round and
168-round attacks making no material improvements since the release of this
17encryption standard almost two decades ago.
15AES has proven to be a safe encryption method, with 7-round and 8-round attacks
16making no material improvements since the release of this encryption standard
17almost two decades ago.
1818
1919#+begin_quote
2020Though many papers have been published on the cryptanalysis of AES, the fastest
@@ -26,12 +26,13 @@ slightly more powerful than those proposed 10 years ago [23,24].
2626
2727* How Secure is AES?
2828
29In theory, AES-256 is non-crackable due to the massive number of combinations
30that can be produced. However, AES-128 is no longer recommended as a viable
31implementation to protect important data.
29In theory, AES-256 (AES using a 256-bit key) is non-crackable due to the massive
30number of combinations that can the encryption process can produce. However,
31AES-128 is no longer recommended as a viable implementation to protect important
32data due the 128-bit key's short length.
3233
3334A semi-short [[http://www.moserware.com/2009/09/stick-figure-guide-to-advanced.html][comic strip]] from Moserware quickly explains AES for the public to
34understand. Basically AES encrypts the data by obscuring the relationship
35understand. Basically, AES encrypts the data by obscuring the relationship
3536between the data and the encrypted data. Additionally, this method spreads the
3637message out. Lastly, the key produced by AES is the secret to decrypting it.
3738Someone may know the method of AES, but without the key, they are powerless.
@@ -40,8 +41,8 @@ To obscure and spread the data out, AES creates a substitution-permutation
4041network. Wikipedia has a wonderful [[https://upload.wikimedia.org/wikipedia/commons/thumb/c/cd/SubstitutionPermutationNetwork2.png/468px-SubstitutionPermutationNetwork2.png][example of an SP network]] available. This
4142network sends the data through a set of S boxes (using the unique key) to
4243substitute the bits with another block of bits. Then, a P box will permutate, or
43rearrange, the bits. This is done over and over, with the key being derived from
44the last round. For AES, the key size specifies the number of transformation
44rearrange, the bits. This is performed numerous times, with the last round
45deriving the key. For AES, the key size specifies the number of transformation
4546rounds: 10, 12, and 14 rounds for 128-bit, 192-bit, and 256-bit keys,
4647respectively.
4748
@@ -49,13 +50,13 @@ respectively.
4950
50511. *KeyExpansion*: Using [[https://en.m.wikipedia.org/wiki/Advanced_Encryption_Standard][Rijndael's key schedule]], the keys are dynamically
5152 generated.
522. *AddRoundKey*: Each byte of the data is combined with this key using bitwise
53 xor.
543. *SubBytes*: This is followed by the substitution of each byte of data.
554. *ShiftRows*: Then, the final three rows are shifted a certain number of
56 steps, dictated by the cipher.
575. *MixColumns*: After the rows have been shifted, the columns are mixed and
58 combined.
532. *AddRoundKey*: The process combines each byte of the data with the generated
54 key(s) using bitwise xor.
553. *SubBytes*: Next, the process substitutes each byte of data.
564. *ShiftRows*: Then, the process shifts the final three rows a specific number
57 of steps, dictated by the cipher.
585. *MixColumns*: Finally, the process mixes and combines the columns into the
59 final data for this round of processing.
5960
6061This process does not necessarily stop after one full round. Steps 2 through 5
6162will repeat for the number of rounds specified by the key. However, the final
@@ -66,42 +67,42 @@ weakness).
6667
6768According to research done by Bogdanov et al., it would take billions of years
6869to brute force a 126-bit key with current hardware. Additionally, this brute
69force attack would require storing 2^{88} bits of data! However, there are a few
70different attacks that have been used to show vulnerabilities with the use of
71this technology. Side-channel attacks use inadvertent leaks of data from the
72hardware or software, which can allow attackers to obtain the key or run
73programs on a user's hardware.
70force attack would require storing 2^{88} bits of data! However, people have
71shown different attacks displaying vulnerabilities with the use of this
72technology. Side-channel attacks use inadvertent leaks of data from the hardware
73or software, which can allow attackers to obtain the key or run programs on a
74user's hardware.
7475
7576Please note that this is not something you should run out and try to implement
76in your =Hello, World!= app after only a few hours of research. While AES
77(basically all encryption methods) is extremely efficient in what it does, it
78takes a lot of time and patience to understand. If you're looking for something
79which currently implements AES, check out the [[https://www.bouncycastle.org/documentation.html][Legion of the Bouncy Castle]] for
80Java implementations of cryptographic algorithms.
77in your =Hello, World!= application after only hours of research. While AES
78(basically all encryption methods) is efficient in what it does, it takes a lot
79of time and patience to understand. If you're looking for something which
80currently implements AES, check out the [[https://www.bouncycastle.org/documentation.html][Legion of the Bouncy Castle]] for Java
81implementations of cryptographic algorithms.
8182
8283* Why Does Encryption Matter?
8384
8485There are limitless reasons to enable encryption at-rest or in-transit for
85various aspects of your digital life. You can research specific examples, such
86as [[https://arstechnica.com/tech-policy/2018/12/australia-passes-new-law-to-thwart-strong-encryption/][Australia passes new law to thwart strong encryption]]. However, I will simply
87list a few basic reasons to always enable encryption, where feasible:
86aspects of your digital life. You can research specific examples, such as
87[[https://arstechnica.com/tech-policy/2018/12/australia-passes-new-law-to-thwart-strong-encryption/][Australia passes new law to thwart strong encryption]]. However, I will simply
88list basic reasons to always enable encryption, where feasible:
8889
891. Privacy is a human right and is recognized as a national right in some
90 countries (e.g., [[https://www.law.cornell.edu/wex/fourth_amendment][US Fourth Amendment]]).
901. Privacy is a human right and some countries recognize it as a national right
91 (e.g., [[https://www.law.cornell.edu/wex/fourth_amendment][US Fourth Amendment]]).
91922. "Why not?" Encryption rarely affects performance or speed, so there's usually
9293 not a reason to avoid it in the first place.
93943. Your digital identity and activity (texts, emails, phone calls, online
94 accounts, etc.) are extremely valuable and can result in terrible
95 consequences, such as identity theft, if leaked to other parties. Encrypting
96 this data prevents such leaks from ruining lives.
95 accounts, etc.) are valuable and can result in consequences, such as identity
96 theft, if leaked to other parties. Encrypting this data prevents such leaks
97 from ruining lives.
97984. Wiping or factory-resetting does not actually wipe all data from the storage
9899 device. There are methods to read data from the physical disks/boards inside
99100 devices.
1005. Corporations, governments, and other nefarious groups/individuals are
101 actively looking for ways to collect personal information about anyone they
102 can. If someone's data is unencrypted, that person may become a target due to
103 the ease of data collection.
1015. Corporations, governments, and other groups or individuals are actively
102 looking for ways to collect personal information about anyone they can. If
103 someone's data is not encrypted, that person may become a target due to the
104 ease of data collection.
104105
105​*Read More:*
106* Read More
106107
107108- [[http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.197.pdf][Federal Information Processing Standards Publication 197]]
content/blog/2018-11-28-cpp-compiler.org +24 −22
@@ -8,10 +8,10 @@
88[[https://en.wikipedia.org/wiki/C%2B%2B][C++]] is a general-purpose programming language with object-oriented, generic, and
99functional features in addition to facilities for low-level memory manipulation.
1010
11The source code, shown in the snippet below, must be compiled before it can be
12executed. There are many steps and intricacies to the compilation process, and
13this post was a personal exercise to learn and remember as much information as I
14can.
11A developer must compile source code, such as the example shown in the snippet
12below, before they can execute the compiled program. There are numerous steps
13and intricacies to the compilation process, and this post was a personal
14exercise to learn and remember as much information as I can.
1515
1616#+begin_src cpp
1717#include <iostream>
@@ -36,9 +36,10 @@ is not the only compiled language. Check out [[https://en.wikipedia.org/wiki/Com
3636languages]] for more examples of compiled languages.
3737
3838I'll start with a wonderful, graphical way to conceptualize the C++ compiler.
39View [[https://web.archive.org/web/20190419035048/http://faculty.cs.niu.edu/~mcmahon/CS241/Notes/compile.html][The C++ Compilation Process]] by Kurt MacMahon, an NIU professor, to see the
40graphic and an explanation. The goal of the compilation process is to take the
41C++ code and produce a shared library, dynamic library, or an executable file.
39View [[https://web.archive.org/web/20190419035048/http://faculty.cs.niu.edu/~mcmahon/CS241/Notes/compile.html][The C++ Compilation Process]] by Kurt MacMahon, a Northern Illinois
40University (NIU) professor, to see the graphic and an explanation. The goal of
41the compilation process is to take the C++ code and produce a shared library,
42dynamic library, or an executable file.
4243
4344** Compilation Phases
4445
@@ -61,10 +62,11 @@ the expanded code.
6162
6263*** Step 2
6364
64After the code is expanded, the compiler comes into play. The compiler takes the
65C++ code and converts this code into the assembly language, understood by the
66platform. You can see this in action if you head over to the [[https://godbolt.org][GodBolt Compiler
67Explorer]], which shows C++ being converted into assembly dynamically.
65After the compiler expands the code, the compiler comes into play. The compiler
66takes the C++ code and converts this code into the assembly language, understood
67by the platform. You can see this in action if you head over to the [[https://godbolt.org][GodBolt
68Compiler Explorer]], which shows the compiled converting C++ into assembly
69dynamically.
6870
6971For example, the =Hello, world!= code snippet above compiles into the following
7072assembly code:
@@ -113,17 +115,17 @@ _GLOBAL__sub_I_main:
113115
114116*** Step 3
115117
116Third, the assembly code generated by the compiler is assembled into the object
117code for the platform. Essentially, this is when the compiler takes the assembly
118code and assembles it into machine code in a binary format. After researching
119this online, I figured out that a lot of compilers will allow you to stop
120compilation at this step. This would be useful for compiling each source code
121file separately. This saves time later if a single file changes; only that file
122needs to be recompiled.
118Third, the compiled assembles the assembly code into the object code for the
119platform. Essentially, this is when the compiler takes the assembly code and
120assembles it into machine code in a binary format. After researching this
121online, I figured out that a lot of compilers will allow you to stop compilation
122at this step. This would be useful for compiling each source code file
123separately. This saves time later if a single file changes, since the developer
124will only need to re-compile single file.
123125
124126*** Step 4
125127
126Finally, the object code file generated by the assembler is linked together with
127the object code files for any library functions used to produce a shared
128library, dynamic library, or an executable file. It replaces all references to
129undefined symbols with the correct addresses.
128Finally, the compiler links the object code file generated by the assembler
129together with the object code files for any library functions used to produce a
130shared library, dynamic library, or an executable file. It replaces all
131references to undefined symbols with the correct addresses.