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 @@
6* Basic AES 6* Basic AES
7 7
8If you're not familiar with encryption techniques, [[https://en.wikipedia.org/wiki/Advanced_Encryption_Standard][AES]] is the *Advanced 8If 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 9Encryption Standard*. The National Institute of Standards and Technology
10Institute of Standards and Technology, sub-selected from the Rijndael family of 10established this specification, sub-selected from the Rijndael family of ciphers
11ciphers (128, 192, and 256 bits) in 2001. Furthering its popularity and status, 11(128, 192, and 256 bits) in 2001. Furthering its popularity and status, the US
12the US government chose AES as their default encryption method for top-secret 12government chose AES as their default encryption method for top-secret data,
13data, removing the previous standard which had been in place since 1977. 13removing the previous standard which had been in place since 1977.
14 14
15AES has proven to be an extremely safe encryption method, with 7-round and 15AES has proven to be a safe encryption method, with 7-round and 8-round attacks
168-round attacks making no material improvements since the release of this 16making no material improvements since the release of this encryption standard
17encryption standard almost two decades ago. 17almost two decades ago.
18 18
19#+begin_quote 19#+begin_quote
20Though many papers have been published on the cryptanalysis of AES, the fastest 20Though 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].
26 26
27* How Secure is AES? 27* How Secure is AES?
28 28
29In theory, AES-256 is non-crackable due to the massive number of combinations 29In theory, AES-256 (AES using a 256-bit key) is non-crackable due to the massive
30that can be produced. However, AES-128 is no longer recommended as a viable 30number of combinations that can the encryption process can produce. However,
31implementation to protect important data. 31AES-128 is no longer recommended as a viable implementation to protect important
32data due the 128-bit key's short length.
32 33
33A 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 34A 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
35between the data and the encrypted data. Additionally, this method spreads the 36between the data and the encrypted data. Additionally, this method spreads the
36message out. Lastly, the key produced by AES is the secret to decrypting it. 37message out. Lastly, the key produced by AES is the secret to decrypting it.
37Someone may know the method of AES, but without the key, they are powerless. 38Someone 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
40network. 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 41network. 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
41network sends the data through a set of S boxes (using the unique key) to 42network sends the data through a set of S boxes (using the unique key) to
42substitute the bits with another block of bits. Then, a P box will permutate, or 43substitute 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 44rearrange, the bits. This is performed numerous times, with the last round
44the last round. For AES, the key size specifies the number of transformation 45deriving the key. For AES, the key size specifies the number of transformation
45rounds: 10, 12, and 14 rounds for 128-bit, 192-bit, and 256-bit keys, 46rounds: 10, 12, and 14 rounds for 128-bit, 192-bit, and 256-bit keys,
46respectively. 47respectively.
47 48
@@ -49,13 +50,13 @@ respectively.
49 50
501. *KeyExpansion*: Using [[https://en.m.wikipedia.org/wiki/Advanced_Encryption_Standard][Rijndael's key schedule]], the keys are dynamically 511. *KeyExpansion*: Using [[https://en.m.wikipedia.org/wiki/Advanced_Encryption_Standard][Rijndael's key schedule]], the keys are dynamically
51 generated. 52 generated.
522. *AddRoundKey*: Each byte of the data is combined with this key using bitwise 532. *AddRoundKey*: The process combines each byte of the data with the generated
53 xor. 54 key(s) using bitwise xor.
543. *SubBytes*: This is followed by the substitution of each byte of data. 553. *SubBytes*: Next, the process substitutes each byte of data.
554. *ShiftRows*: Then, the final three rows are shifted a certain number of 564. *ShiftRows*: Then, the process shifts the final three rows a specific number
56 steps, dictated by the cipher. 57 of steps, dictated by the cipher.
575. *MixColumns*: After the rows have been shifted, the columns are mixed and 585. *MixColumns*: Finally, the process mixes and combines the columns into the
58 combined. 59 final data for this round of processing.
59 60
60This process does not necessarily stop after one full round. Steps 2 through 5 61This process does not necessarily stop after one full round. Steps 2 through 5
61will repeat for the number of rounds specified by the key. However, the final 62will repeat for the number of rounds specified by the key. However, the final
@@ -66,42 +67,42 @@ weakness).
66 67
67According to research done by Bogdanov et al., it would take billions of years 68According to research done by Bogdanov et al., it would take billions of years
68to brute force a 126-bit key with current hardware. Additionally, this brute 69to 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 70force attack would require storing 2^{88} bits of data! However, people have
70different attacks that have been used to show vulnerabilities with the use of 71shown different attacks displaying vulnerabilities with the use of this
71this technology. Side-channel attacks use inadvertent leaks of data from the 72technology. Side-channel attacks use inadvertent leaks of data from the hardware
72hardware or software, which can allow attackers to obtain the key or run 73or software, which can allow attackers to obtain the key or run programs on a
73programs on a user's hardware. 74user's hardware.
74 75
75Please note that this is not something you should run out and try to implement 76Please 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 77in your =Hello, World!= application after only hours of research. While AES
77(basically all encryption methods) is extremely efficient in what it does, it 78(basically all encryption methods) is efficient in what it does, it takes a lot
78takes a lot of time and patience to understand. If you're looking for something 79of time and patience to understand. If you're looking for something which
79which currently implements AES, check out the [[https://www.bouncycastle.org/documentation.html][Legion of the Bouncy Castle]] for 80currently implements AES, check out the [[https://www.bouncycastle.org/documentation.html][Legion of the Bouncy Castle]] for Java
80Java implementations of cryptographic algorithms. 81implementations of cryptographic algorithms.
81 82
82* Why Does Encryption Matter? 83* Why Does Encryption Matter?
83 84
84There are limitless reasons to enable encryption at-rest or in-transit for 85There are limitless reasons to enable encryption at-rest or in-transit for
85various aspects of your digital life. You can research specific examples, such 86aspects of your digital life. You can research specific examples, such as
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 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
87list a few basic reasons to always enable encryption, where feasible: 88list basic reasons to always enable encryption, where feasible:
88 89
891. Privacy is a human right and is recognized as a national right in some 901. Privacy is a human right and some countries recognize it as a national right
90 countries (e.g., [[https://www.law.cornell.edu/wex/fourth_amendment][US Fourth Amendment]]). 91 (e.g., [[https://www.law.cornell.edu/wex/fourth_amendment][US Fourth Amendment]]).
912. "Why not?" Encryption rarely affects performance or speed, so there's usually 922. "Why not?" Encryption rarely affects performance or speed, so there's usually
92 not a reason to avoid it in the first place. 93 not a reason to avoid it in the first place.
933. Your digital identity and activity (texts, emails, phone calls, online 943. Your digital identity and activity (texts, emails, phone calls, online
94 accounts, etc.) are extremely valuable and can result in terrible 95 accounts, etc.) are valuable and can result in consequences, such as identity
95 consequences, such as identity theft, if leaked to other parties. Encrypting 96 theft, if leaked to other parties. Encrypting this data prevents such leaks
96 this data prevents such leaks from ruining lives. 97 from ruining lives.
974. Wiping or factory-resetting does not actually wipe all data from the storage 984. Wiping or factory-resetting does not actually wipe all data from the storage
98 device. There are methods to read data from the physical disks/boards inside 99 device. There are methods to read data from the physical disks/boards inside
99 devices. 100 devices.
1005. Corporations, governments, and other nefarious groups/individuals are 1015. Corporations, governments, and other groups or individuals are actively
101 actively looking for ways to collect personal information about anyone they 102 looking for ways to collect personal information about anyone they can. If
102 can. If someone's data is unencrypted, that person may become a target due to 103 someone's data is not encrypted, that person may become a target due to the
103 the ease of data collection. 104 ease of data collection.
104 105
105​*Read More:* 106* Read More
106 107
107- [[http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.197.pdf][Federal Information Processing Standards Publication 197]] 108- [[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 @@
8[[https://en.wikipedia.org/wiki/C%2B%2B][C++]] is a general-purpose programming language with object-oriented, generic, and 8[[https://en.wikipedia.org/wiki/C%2B%2B][C++]] is a general-purpose programming language with object-oriented, generic, and
9functional features in addition to facilities for low-level memory manipulation. 9functional features in addition to facilities for low-level memory manipulation.
10 10
11The source code, shown in the snippet below, must be compiled before it can be 11A developer must compile source code, such as the example shown in the snippet
12executed. There are many steps and intricacies to the compilation process, and 12below, before they can execute the compiled program. There are numerous steps
13this post was a personal exercise to learn and remember as much information as I 13and intricacies to the compilation process, and this post was a personal
14can. 14exercise to learn and remember as much information as I can.
15 15
16#+begin_src cpp 16#+begin_src cpp
17#include <iostream> 17#include <iostream>
@@ -36,9 +36,10 @@ is not the only compiled language. Check out [[https://en.wikipedia.org/wiki/Com
36languages]] for more examples of compiled languages. 36languages]] for more examples of compiled languages.
37 37
38I'll start with a wonderful, graphical way to conceptualize the C++ compiler. 38I'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 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
40graphic and an explanation. The goal of the compilation process is to take the 40University (NIU) professor, to see the graphic and an explanation. The goal of
41C++ code and produce a shared library, dynamic library, or an executable file. 41the compilation process is to take the C++ code and produce a shared library,
42dynamic library, or an executable file.
42 43
43** Compilation Phases 44** Compilation Phases
44 45
@@ -61,10 +62,11 @@ the expanded code.
61 62
62*** Step 2 63*** Step 2
63 64
64After the code is expanded, the compiler comes into play. The compiler takes the 65After the compiler expands the code, the compiler comes into play. The compiler
65C++ code and converts this code into the assembly language, understood by the 66takes the C++ code and converts this code into the assembly language, understood
66platform. You can see this in action if you head over to the [[https://godbolt.org][GodBolt Compiler 67by the platform. You can see this in action if you head over to the [[https://godbolt.org][GodBolt
67Explorer]], which shows C++ being converted into assembly dynamically. 68Compiler Explorer]], which shows the compiled converting C++ into assembly
69dynamically.
68 70
69For example, the =Hello, world!= code snippet above compiles into the following 71For example, the =Hello, world!= code snippet above compiles into the following
70assembly code: 72assembly code:
@@ -113,17 +115,17 @@ _GLOBAL__sub_I_main:
113 115
114*** Step 3 116*** Step 3
115 117
116Third, the assembly code generated by the compiler is assembled into the object 118Third, the compiled assembles the assembly code into the object code for the
117code for the platform. Essentially, this is when the compiler takes the assembly 119platform. Essentially, this is when the compiler takes the assembly code and
118code and assembles it into machine code in a binary format. After researching 120assembles it into machine code in a binary format. After researching this
119this online, I figured out that a lot of compilers will allow you to stop 121online, I figured out that a lot of compilers will allow you to stop compilation
120compilation at this step. This would be useful for compiling each source code 122at this step. This would be useful for compiling each source code file
121file separately. This saves time later if a single file changes; only that file 123separately. This saves time later if a single file changes, since the developer
122needs to be recompiled. 124will only need to re-compile single file.
123 125
124*** Step 4 126*** Step 4
125 127
126Finally, the object code file generated by the assembler is linked together with 128Finally, the compiler links the object code file generated by the assembler
127the object code files for any library functions used to produce a shared 129together with the object code files for any library functions used to produce a
128library, dynamic library, or an executable file. It replaces all references to 130shared library, dynamic library, or an executable file. It replaces all
129undefined symbols with the correct addresses. 131references to undefined symbols with the correct addresses.