You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/labs/security/lab9-cryptography.md
+43-45Lines changed: 43 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,12 @@
3
3
4
4
## Objectives
5
5
6
-
After completing this lab, you will be able to
6
+
After completing this lab, you will be able to:
7
7
8
8
- apply cryptographic concepts in securing data and communication
9
9
10
10
Estimated time to complete this lab: 120 minutes
11
11
12
-
13
-
14
12
## Common Cryptography terms and definitions
15
13
16
14
### Cryptography
@@ -27,19 +25,19 @@ Cryptology is the discipline of cryptography and cryptanalysis combined. Cryptol
27
25
28
26
### Encryption
29
27
30
-
Encryption is the transformation of data into a form that is as close to impossible as possible to read without the appropriate knowledge (e.g. a key). Its purpose is to ensure privacy by keeping information hidden from anyone for whom it is not intended.
28
+
Encryption transforms data into a form that is close to impossible to read without the appropriate knowledge (e.g., a key). Its purpose is to ensure privacy by keeping information hidden from anyone for whom it is not intended.
31
29
32
30
### Decryption
33
31
34
-
Decryption is the reverse of encryption; it is the transformation of encrypted data back into an intelligible form.
32
+
Decryption is the reverse of encryption; it transforms encrypted data into an intelligible form.
35
33
36
34
### Cipher
37
35
38
36
A method of encryption and decryption is called a cipher.
39
37
40
38
Hash Functions (Digest algorithms)
41
39
42
-
Cryptographic hash functions are used in various contexts, for example to compute the message digest when making a digital signature. A hash function compresses the bits of a message to a fixed-size hash value in a way that distributes the possible messages evenly among the possible hash values. A cryptographic hash function does this in a way that makes it extremely difficult to come up with a message that would hash to a particular hash value. Some examples of the bestknown and most widely used hash functions are described below.
40
+
Cryptographic hash functions are used in various contexts, for example to compute the message digest when making a digital signature. A hash function compresses the bits of a message to a fixed-size hash value to distribute the possible messages evenly among the possible hash values. A cryptographic hash function does this in a way that makes it extremely difficult to come up with a message that would hash to a particular hash value. Below are some examples of the best-known and most widely used hash functions.
43
41
44
42
**a)** - **SHA-1 (Secure Hash Algorithm)** -This is a cryptographic hash algorithm published by the United States Government. It produces a 160 bit hash value from an arbitrary length string. It is considered to be very good.
45
43
@@ -49,37 +47,37 @@ Cryptographic hash functions are used in various contexts, for example to comput
49
47
50
48
It describes a step-by-step problem-solving procedure, especially an established, recursive computational procedure for solving a problem in a finite number of steps. Technically, an algorithm must reach a result after a finite number of steps. The efficiency of an algorithm can be measured as the number of elementary steps it takes to solve the problem. There are two classes of key-based algorithms. They are:
Symmetric algorithms use the same key for encryption and decryption (or the decryption key is easily derived from the encryption key). Secret key algorithms use the same key for both encryption and decryption (or one is easily derivable from the other). This is the more straightforward approach to data encryption, it is mathematically less complicated than public-key cryptography. Symmetric algorithms can be divided into stream ciphers and block ciphers. Stream ciphers can encrypt a single bit of plaintext at a time, whereas block ciphers take a number of bits (typically 64 bits in modern ciphers), and encrypt them as a single unit. Symmetric algorithms are much faster to execute on a computer than asymmetric ones.
55
53
56
54
Examples of symmetric algorithms are: AES, 3DES, Blowfish, CAST5, IDEA and Twofish.
Asymmetric algorithms on the other hand use a different key for encryption and decryption, and the decryption key cannot be derived from the encryption key. Asymmetric ciphers permit the encryption key to be public, allowing anyone to encrypt with the key, whereas only the proper recipient (who knows the decryption key) can decrypt the message. The encryption key is also called the public key and the decryption key the private key or secret key.
58
+
Asymmetric algorithms on the other hand use a different key for encryption and decryption, and the decryption key cannot be derived from the encryption key. Asymmetric ciphers permit the encryption key to be public, allowing anyone to encrypt with the key, whereas only the proper recipient (who knows the decryption key) can decrypt the message. The encryption key is also called the public key, and the decryption key is the private or secret key.
61
59
62
-
RSA is probably the bestknown asymmetric encryption algorithm.
60
+
RSA is probably the best-known asymmetric encryption algorithm.
63
61
64
62
### Digital Signature
65
63
66
-
A digital signature binds a document to the owner of a particular key. Digital signatures are used to verify that a message really comes from the claimed sender.
64
+
A digital signature binds a document to the owner of a particular key.
67
65
68
-
The digital signature of a document is a piece of information based on both the document and the signer's private key. It is typically created through the use of a hash function and a private signing function (encrypting with the signer's private key). A digital signature is a small amount of data that was created using some secret key, and there is a public key that can be used to verify that the signature was really generated using the corresponding private key.
66
+
The digital signature of a document is a piece of information based on both the document and the signer's private key. It is typically created through a hash function and a private signing function (encrypting with the signer's private key). A digital signature is a small amount of data created using some secret key, and there is a public key that can be used to verify that the signature was generated using the corresponding private key.
69
67
70
68
Several methods for making and verifying digital signatures are freely available but the most widely known algorithm is the RSA public-key algorithm.
71
69
72
70
### Cryptographic Protocols
73
71
74
-
Cryptography works on many levels. On one level you have algorithms, such as block ciphers and public key cryptosystems. Building upon these you obtain protocols, and building upon protocols you find applications (or other protocols). Below is a list of common everyday applications that make use of cryptographic protocols. These protocols are built on lower level cryptographic algorithms.
72
+
Cryptography works on many levels. On one level you have algorithms, such as block ciphers and public key cryptosystems. Building upon these, you obtain protocols, and upon protocols, you find applications (or other protocols). Below is a list of typical everyday applications that use cryptographic protocols. These protocols are built on lower level cryptographic algorithms.
75
73
76
74
i.) Domain Name Server Security (DNSSEC)
77
75
78
76
This is a protocol for secure distributed name services. It is currently available as an Internet Draft.
79
77
80
78
ii.) Secure Socket Layer (SSL)
81
79
82
-
SSL is one of the two protocols used for secure WWW connections (the other is SHTTP). WWW security has become important as, increasing amounts of sensitive information, such as credit card numbers, are being transmitted over the Internet.
80
+
SSL is one of the two protocols used for secure WWW connections (the other is SHTTP). WWW security has become necessary as increasing amounts of sensitive information, such as credit card numbers, are transmitted over the Internet.
83
81
84
82
iii.) Secure Hypertext Transfer Protocol (SHTTP)
85
83
@@ -93,17 +91,17 @@ v) SSH2 Protocol
93
91
94
92
This protocol is versatile for the needs of the internet, and is currently used in the SSH2 software. The protocol is used to secure terminal sessions and TCP connections.
95
93
96
-
The following exercises examine two particular applications that make use of cryptographic protocols - GnuPG and OpenSSH.
94
+
The following exercises examine two applications that use cryptographic protocols - GnuPG and OpenSSH.
97
95
98
96
## Exercise 1
99
97
100
98
### GnuPG
101
99
102
-
GnuPG (GNU Privacy Guard) is a set of programs for public key encryption and digital signatures. The tools can be used to encrypt data and to create digital signatures. It also includes an advanced key management facility. GnuPG uses public-key cryptography to enable users to communicate securely
100
+
GnuPG (GNU Privacy Guard) is a set of programs for public key encryption and digital signatures. The tools can be used to encrypt data and to create digital signatures. It also includes an advanced key management facility. GnuPG uses public-key cryptography to enable users to communicate securely.
103
101
104
102
Perform the following exercises as a regular user. e.g. user ying
105
103
106
-
To create a new keypair
104
+
To create a new key pair
107
105
108
106
1. Log into the system as user “ying”
109
107
@@ -117,7 +115,7 @@ If it isn’t, get the super-user to install it.
117
115
118
116
3. List and make a note of all the hidden directories in your home directory.
119
117
120
-
4. List the keys you currently have in your key-ring. Type:
118
+
4. List the keys you currently have in your keyring. Type:
121
119
122
120
`[ying@serverXY ying]$ gpg --list-keys`
123
121
@@ -149,25 +147,25 @@ Please select what kind of key you want:
149
147
Your selection? 1
150
148
```
151
149
152
-
At the prompt for the type of key your want to create accept the default i.e.(DSA and ElGamal). Type 1
150
+
At the prompt for the type of key you want to create, accept the default, i.e.(DSA and ElGamal). Type 1
153
151
154
152
!!! WARNING
155
153
156
-
Option (1) will create two key-pairs for you. The DSA key-pair will be the primary keypair - for making digital signatures and a subordinate ELGamel keypair for data encryption.
154
+
Option (1) will create two key-pairs for you. The DSA key-pair will be the primary key pair - for making digital signatures and a subordinate ELGamel key pair for data encryption.
157
155
158
-
6. You will create an ELG-E keysize of 1024. Accept the default again at the prompt below:
156
+
6. You will create an ELG-E key size of 1024. Accept the default again at the prompt below:
159
157
160
-
DSA keypair will have 1024 bits.
158
+
DSA key pair will have 1024 bits.
161
159
162
-
About to generate a new ELG-E keypair.
160
+
About to generate a new ELG-E key pair.
163
161
164
-
minimum keysize is 768 bits
162
+
minimum key size is 768 bits
165
163
166
-
default keysize is 1024 bits
164
+
default key size is 1024 bits
167
165
168
-
highest suggested keysize is 2048 bits
166
+
highest suggested key size is 2048 bits
169
167
170
-
What keysize do you want? (1024) 1024
168
+
What key size do you want? (1024) 1024
171
169
172
170
7. Create keys that will expire in a year. Type “1y” at the prompt below:
173
171
@@ -282,7 +280,7 @@ sub 1024g/1EDB00AC 2003-10-16 \[expires: 2004-10-15\]
282
280
283
281
<spanid="anchor-2"></span>Revocation certificates
284
282
285
-
Revocation certificates are used revoking keys in case someone gets knowledge of your secret key or incase you forget your passphrase. They are also useful for other various functions.
283
+
Revocation certificates are used to revoke keys in case someone gets knowledge of your secret key or in case you forget your passphrase. They are also useful for other various functions.
286
284
287
285
To create a revocation certificate
288
286
@@ -308,9 +306,9 @@ The whole point of all this encrypting, signing and decrypting business is becau
308
306
309
307
With that said - the perhaps not to so obvious has to be stated:
310
308
311
-
To communicate with other people using a public-keybased cryptosystem - you must exchange public keys.
309
+
You must exchange public keys to communicate with other people using a public-key-based cryptosystem..
312
310
313
-
Or at least make your public key available in any publicly accessible place (Bill-boards, web pages, key servers, radio, T.V, SPAMMING via e-mail ..etc ….. )
311
+
Or at least make your public key available in any publicly accessible place (Bill-boards, web pages, key servers, radio, T.V, SPAMMING via e-mail ..etc)
314
312
315
313
To export your public keys
316
314
@@ -336,17 +334,17 @@ To export your public keys
336
334
337
335
3. Use the cat command to view the binary version of ying’s public key (ying-pub.gpg)
338
336
339
-
4. (To reset your terminal type: “reset”)
337
+
4. (To reset your terminal type: “reset”)
340
338
341
339
5. Use the cat command to view the ASCII version of ying’s public key (ying-pub.asc)
342
340
343
-
6. You will observe that the ASCII version is more suited for posting on web-pages or spamming etc..
341
+
6. You will observe that the ASCII version is more suited for posting on web-pages or spamming etc.
344
342
345
343
## Exercise 3
346
344
347
345
### Digital signatures
348
346
349
-
Creating and verifying signatures uses the public/private keypair in an operation different from encryption and decryption. A signature is created using the private key of the signer. The signature can be verified using the corresponding public key.
347
+
Creating and verifying signatures uses the public/private key pair, which differs from encryption and decryption. A signature is created using the private key of the signer. The signature can be verified using the corresponding public key.
350
348
351
349
To digitally sign a file
352
350
@@ -362,7 +360,7 @@ To digitally sign a file
362
360
363
361
Input your passphrase when prompted.
364
362
365
-
The above command will create another file “secret1.txt.gpg” which is compressed and has a signature attached to it. Run the “file” command on the file to check this. View the file with cat
363
+
The above command will create another file “secret1.txt.gpg” which is compressed and has a signature attached to it. Run the “file” command on the file to check this. View the file with cat
366
364
367
365
4. Check the signature on the signed “secret1.txt.gpg” file. Type:
368
366
@@ -374,7 +372,7 @@ gpg: Good signature from "Ying Yang (my test) <ying@serverXY>"
374
372
375
373
5. Create another file secret2.txt with the text “ Hello All” in it.
376
374
377
-
6. Sign the secret2.txt file but this time let the file be ASCII armored. Type:
375
+
6. Sign the secret2.txt file, but let the file be ASCII armored this time. Type:
378
376
379
377
\[ying@serverXY ying\]$ ***gpg -sa secret2.txt***
380
378
@@ -402,7 +400,7 @@ MAKE SURE THAT YOUR PARTNER HAS PERFORMED THE WHOLE OF
402
400
403
401
IF YOU DON’T HAVE A PARTNER. LOG OFF USER YING’s ACCOUNT AND LOG INTO THE SYSTEM AS THE USER “me”.
404
402
405
-
THEN REPEAT THE WHOLE OF “EXECISES -1,2,3” AS THE USER “me”.
403
+
THEN REPEAT THE WHOLE OF “EXERCISES -1,2,3” AS THE USER “me”.
406
404
407
405
YOU MAY THEN PERFORM EXERCISE 4 BELOW. REPLACE ALL REFERENCES TO THE USER YING AT “serverPR” WITH - USER “me” AT serverXY (i.e. your localhost)
408
406
@@ -412,23 +410,23 @@ AS YOUR PARTNER IN THE NEXT EXERCISE.
412
410
413
411
## Exercise 4
414
412
415
-
In this exercise you will begin the actual communication with another user, using the so called “Web of Trust”.
413
+
In this exercise, you will use the so-called “Web of Trust” to communicate with another user.
416
414
417
415
Importing public keys
418
416
419
-
1. Log into the system as user ying.
417
+
1. Log into the system as user ying./
420
418
421
419
2. Make your ASCII-armored public-key file (ying-pub.asc) available to your partner ( use
422
420
423
421
either - me@serverXY or ying@serverPR)
424
422
425
423
NOTE:
426
424
427
-
There are several ways of doing this e.g. e-mail, copying and pasting, scp, ftp, Saving on a diskette etc...
425
+
There are several ways of doing this e.g. e-mail, copying and pasting, scp, ftp, Saving on a diskette etc.
428
426
429
427
Select the most efficient method for yourself.
430
428
431
-
3. Ask your partner to also make their public-key file available to you.
429
+
3. Ask your partner to make their publickey file available to you.
432
430
433
431
4. Assuming your partner’s public key is store in a file called “ me-pub.asc” in your pwd;
434
432
@@ -560,7 +558,7 @@ It is a FREE version of the SSH protocol suite of network connectivity tools. Op
560
558
561
559
It helps to provide secure encrypted communications between two untrusted hosts over an insecure network (such as the internet).
562
560
563
-
It includes both the serverside components and the clientside suite of programs.
561
+
It includes both the server-side components and the client-side suite of programs
564
562
565
563
**sshd**
566
564
@@ -570,19 +568,19 @@ It forks a new daemon for each incoming connection. The forked daemons handle ke
570
568
571
569
authentication, command execution, and data exchange. According to sshd’s man page, sshd works as follows:
572
570
573
-
For SSH protocol version 2…..
571
+
For SSH protocol version 2:
574
572
575
573
Each host has a host-specific key (RSA or DSA) used to identify the host. When the daemon starts, it does not generate a server key (As is the case in SSH protocol version 1). Forward security is provided through a Diffie-Hellman key agreement. This key agreement results in a shared session key.
576
574
577
575
The rest of the session is encrypted using a symmetric cipher, currently 128 bit AES, Blowfish, 3DES, CAST128, Arcfour, 192 bit AES, or 256 bit AES. The client selects the encryption algorithm to use from those offered by the server. Additionally, session integrity is provided through a cryptographic message authentication code (hmac-sha1 or hmac-md5).
578
576
579
-
Protocol version 2 provides a public keybased user (PubkeyAuthentication) or client host (HostbasedAuthentication) authentication method, conventional password authentication and challenge responsebased methods.
577
+
Protocol version 2 provides a public key-based user (PubkeyAuthentication) or client host (HostbasedAuthentication) authentication method, conventional password authentication, and challenge response-based methods.
580
578
581
579
The SSH2 protocol implemented in OpenSSH is standardized by the “IETF secsh” working group
582
580
583
581
ssh
584
582
585
-
The clients suite of programs include “ssh”. This is a program used for logging into remote systems and can also be used for executing commands on remote systems.
583
+
The client's suite of programs include “ssh”. This is a program used for logging into remote systems and can also be used for executing commands on remote systems.
586
584
587
585
## Exercise 5
588
586
@@ -780,13 +778,13 @@ To use scp
780
778
781
779
### Creating User Public and Private keys for SSH
782
780
783
-
Each individual user that wants to use SSH with RSA or DSA authentication needs a set of public keys and private keys. The ssh-keygen program can be used to create these keys ( just as it was used earlier when you created spare keys for your system)
781
+
Each user who wants to use SSH with RSA or DSA authentication needs a set of public and private keys. The ssh-keygen program can be used to create these keys ( just as it was used earlier when you created spare keys for your system)
784
782
785
783
The only “advised” difference when creating user keys is to also create a passphrase.
786
784
787
785
The passphrase is a password that the is used to encrypt the private key before it is stored on the file system.
788
786
789
-
The public is store in a file with the same file name as the private key but with the extension “.pub” appended to it. There is no way to recover a lost passphrase. If the passphrase is lost or forgotten, a new key must be generated.
787
+
The public is store in a file with the same file name as the private key but with the extension “.pub” appended to it. There is no way to recover a lost passphrase. A new key must be generated if the passphrase is lost or forgotten.
0 commit comments