@@ -202,6 +202,10 @@ narrative line.
202202How do we send a secret message?
203203++++++++++++++++++++++++++++++++
204204
205+ Let us start by installing a supporting program, called :program: `age `. This program will allow us to use our encryption
206+ keys to encrypt specific messages. Usually, :program: `ssh ` would handle those more complex connections for us. We are
207+ only using :program: `age ` to illustrate the ideas behind public-key cryptography.
208+
205209.. code-block :: console
206210
207211 sudo apt-get update
@@ -218,10 +222,10 @@ Let's create the secret message, called :file:`secret_message.txt`.
218222
219223 Now, the contents are obviously visible to anyone. You want to be sure that only your friend can see it. Therefore, you
220224grab your friend's public key. Let's use :file: `example_ed25519.pub ` I showed as an example for this. Again, the public
221- key is not a secret, it is meant to be seen by other people. They only need to be able to trust that you are the holder
222- of this specific public key.
225+ key is not a secret, it is meant to be * public *, that is, seen by other people. People, then, only need to be able to
226+ trust that you are the holder of this specific key pair .
223227
224- There 's a cool program called :program: `age ` that allows us to play with encryption. Without further ado, let's go with it.
228+ Let 's use our cool program, :program: `age `, that allows us to play with encryption. Without further ado, let's go with it.
225229
226230.. code-block :: console
227231
@@ -243,33 +247,29 @@ friends might be concerned seeing that but otherwise your message is still a sec
243247 �CF��gf��V�Y*ez����5
244248 �bu�ང>ǒ ��n=˨g�}M]�� �e�#����^Zmuh���jj�o���ȅ�l_�root@c869fbce1a11
245249
246- The magic is that nobody will be able to decrypt the message unless you are given the *private * key. Let's summarise
250+ The magic is that nobody will be able to decrypt the message unless the have the *private * key. Let's summarise
247251what just happened.
248252
249- - Anyone who wants to participate on an encrypted conversation make they *public * encryption key available.
253+ - Anyone who wants to participate on an encrypted conversation make their *public * encryption key available.
250254- Anyone who wants to send them a secret message uses that public key to encrypt the message.
251- - Only the person who receives the message can decrypt it. They need the * private * key to do so .
255+ - Only the person with the * private * can decrypt the message .
252256
253- Therefore, we are able to send secret messages through a compromised and public channel, e.g. the internet. As long as
257+ Therefore, they are able to send secret messages through a compromised and public channel, e.g. the internet. As long as
254258the public key is correct, we do not have to trust the identity of anyone either. **ONLY ** someone who holds the private
255259key will be able to read the true contents of the original message.
256260
257- .. caution ::
258-
259- I will show the private key here because this is a tutorial. DO NOT SHARE YOUR PRIVATE KEY WITH ANYONE.
260-
261261How do we read a secret message?
262262++++++++++++++++++++++++++++++++
263263
264264So, suppose that you sent the secret message, :file: `secret_message.txt.age `, above to your friend. Your friend will now have to use their private
265- key to decrypt the message. Again, suppose that the keys we just created, are safely held by your friend. If they
265+ key to decrypt the message. Again, suppose that the keys we just created are safely held by your friend. If they
266266want to read the contents of the secret message they will have to use the matching private key.
267267
268268.. code-block :: console
269269
270270 cat example_ed25519
271271
272- The output is somewhat similar. To the public key. I will not show it here to reinforce that it is something you should
272+ The output is somewhat similar to the public key. I will not show it here to reinforce that it is something you should
273273keep private. Your friend will use the private key :file: `example_ed25519 ` and the secret file they just received
274274from you :file: `secret_message.txt.age `.
275275
@@ -289,30 +289,13 @@ In which the original message is restored.
289289
290290 This is the best tutorial I have every seen thanks Murilo for being so great.
291291
292- .. admonition :: Exercise
293-
294- You can confirm that you won't be able to decrypt anything that was
295- encrypted with the example public key. That is because I haven't showed you the private key. I'm pretty sure
296- I lost it too.
297-
298- .. danger ::
292+ You can confirm that you won't be able to decrypt anything that was
293+ encrypted with the example public key. That is because I haven't showed you the private key. I'm pretty sure
294+ I lost it too.
299295
300- If you lose your private key, any information you had only in encrypted form is lost forever. FOREVER.
301-
302- For your reference, these were the contents of :file: `secret_message.txt.age `.
303-
304- .. code-block :: console
305-
306- age-encryption.org/v1
307- -> ssh-ed25519 Hb2mpA xxu02M6ZYcgdvpjQ0OtObLX67P+C1cr/6AefZ+w/g1I
308- R3mtqZ9x8sz54/j8g2qY/2EJvkQytXZnLOPmwTziY+w
309- --- GiV9DHB2gAr4V6ZFhIMPH81sDEEfjCGocYImCYD/lhA
310- 1�
311- �,l�j
312- ݚ��&
313- �CF��gf��V�Y*ez����5
314- �bu�ང>ǒ ��n=˨g�}M]�� �e�#����^Zmuh���jj�o���ȅ�l_�root@c869fbce1a11
296+ .. danger ::
315297
298+ If you lose your private key, any information you had only in encrypted form is lost forever. FOREVER.
316299
317300Wait, what?
318301+++++++++++
@@ -335,11 +318,13 @@ The flow in this case would be as follows.
335318Because the public keys can be freely seen through a public channel, e.g., the internet, the information exchanged is
336319safe. This does not mean that encryption is not crackable. With enough time and opportunities to attack, a private key
337320can theoretically be eventually guessed. This is to loosely one of the ideas behind `cryptocurrencies <https://en.wikipedia.org/wiki/Cryptocurrency >`_,
338- in which a `hash<https://en.wikipedia.org/wiki/Cryptographic_hash_function> `_ must be guessed.
321+ in which a `hash <https://en.wikipedia.org/wiki/Cryptographic_hash_function >`_ must be guessed.
339322
340323Exercises
341324---------
342325
326+ We can think of decryption and encryption exercises, that help illustrate the process.
327+
343328Decryption
344329~~~~~~~~~~
345330
@@ -354,7 +339,11 @@ using :program:`age`.
354339 --- nnYExEUF5LrEfYqwXvLzGcr1eNcYPr3nuipLfflevSM
355340
356341 This is the pairing private key that you have in your computer, which you should never ever share with anyone for any
357- reason.
342+ reason. Anyone with this key can decode the message.
343+
344+ .. caution ::
345+
346+ I will show the private key here because this is a tutorial. DO NOT SHARE YOUR PRIVATE KEY WITH ANYONE.
358347
359348.. code-block :: console
360349
@@ -368,6 +357,33 @@ reason.
368357
369358 What are the decrypted contents of this message?
370359
360+ Encryption
361+ ~~~~~~~~~~
362+
363+ Suppose that you have the following public key.
364+
365+ .. code-block :: console
366+
367+ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKZSWx2omvV0lTNJfatJy0tauJ83cW1fDRuF34AJF639 b40617mm@���eU
368+
369+ Encrypt the message below. Well, anything will do, really.
370+
371+ "Sorry kid, you got the gift but it looks like you are waiting for something, next life maybe who knows".
372+
373+ .. dropdown :: Private key for you to test
374+
375+ Use this private key to test if your encryption was correct or not.
376+
377+ .. block :: console
378+
379+ -----BEGIN OPENSSH PRIVATE KEY-----
380+ b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
381+ QyNTUxOQAAACCmUlsdqJr1dJUzSX2rSctLWrifN3FtXw0bhd+ACRet/QAAAKDv9N2x7/Td
382+ sQAAAAtzc2gtZWQyNTUxOQAAACCmUlsdqJr1dJUzSX2rSctLWrifN3FtXw0bhd+ACRet/Q
383+ AAAEDmqGfF7PfgEOBtbzsuZqocWgSAAmX4+zqMmhZZ+NBZDKZSWx2omvV0lTNJfatJy0ta
384+ uJ83cW1fDRuF34AJF639AAAAHWI0MDYxN21tQMOvwr/CvcOvwr/CvcOvwr/CvWVV
385+ -----END OPENSSH PRIVATE KEY-----
386+
371387.. admonition :: References
372388
373389 .. footbibliography ::
0 commit comments