WEBVTT

00:00.000 --> 00:03.840
>> Cryptography. The
learning objectives for

00:03.840 --> 00:05.520
this lesson are to define

00:05.520 --> 00:07.575
hashing and its
role in security,

00:07.575 --> 00:10.260
to explore message
authentication codes,

00:10.260 --> 00:13.215
and to differentiate the types
of symmetric algorithms.

00:13.215 --> 00:15.480
Let's get started. Well,

00:15.480 --> 00:16.830
before we really get started,

00:16.830 --> 00:18.810
one thing I'd like you to
understand is we're not

00:18.810 --> 00:21.135
going to be doing any
math on this lesson.

00:21.135 --> 00:23.610
The exam doesn't expect
you to understand

00:23.610 --> 00:26.640
the mathematics that are behind
these complex algorithms.

00:26.640 --> 00:27.960
What they really
want to make sure

00:27.960 --> 00:29.070
is that you know the difference

00:29.070 --> 00:31.604
between symmetric and
asymmetric algorithms,

00:31.604 --> 00:33.540
hashing and what are used

00:33.540 --> 00:36.145
cases for these types
of technologies.

00:36.145 --> 00:38.595
Think about a professional
race car driver.

00:38.595 --> 00:40.170
They are expected to get the

00:40.170 --> 00:42.385
most out of their
car on the track.

00:42.385 --> 00:44.120
But they're not the
ones that are tuning

00:44.120 --> 00:46.760
the engines or making
any repairs to the car.

00:46.760 --> 00:48.290
Also, cryptography is

00:48.290 --> 00:50.570
a very complex subject and
there's a lot of areas

00:50.570 --> 00:52.325
on the tests that are

00:52.325 --> 00:54.215
covered by the
cryptography subjects.

00:54.215 --> 00:56.930
I've broken it into three
lessons and each of

00:56.930 --> 00:58.070
these lessons will cover

00:58.070 --> 01:00.930
different aspects of
the cryptography.

01:01.370 --> 01:04.900
What are some common
uses of cryptography?

01:04.900 --> 01:07.485
The first is encrypting
data at rest.

01:07.485 --> 01:09.200
This is data that is stored on

01:09.200 --> 01:11.930
computers or in databases
or other areas.

01:11.930 --> 01:14.510
The key point is that
the data isn't moving.

01:14.510 --> 01:16.370
Usually this data will
be encrypted with

01:16.370 --> 01:19.300
a symmetrical
algorithm like AES.

01:19.300 --> 01:21.830
Full drive encryption or
file level encryption

01:21.830 --> 01:23.630
would be examples of this.

01:23.630 --> 01:27.275
Data in transit is sometimes
called data in motion.

01:27.275 --> 01:30.290
This is when data is moving
from one place to another.

01:30.290 --> 01:33.815
Think of it when you're
accessing an HTTPS web site,

01:33.815 --> 01:35.810
the data is moving
from the web server to

01:35.810 --> 01:38.815
you across that
encrypted channel.

01:38.815 --> 01:41.990
Also TLS and IPsec are methods

01:41.990 --> 01:45.660
that we can use to secure
data while it's in motion.

01:45.860 --> 01:48.725
Finally, we have data in use.

01:48.725 --> 01:50.150
This is the data that is in

01:50.150 --> 01:52.415
volatile memory such
as the system RAM,

01:52.415 --> 01:54.380
CPU registers, and cache.

01:54.380 --> 01:57.140
An example would be fields
in a database that are being

01:57.140 --> 01:59.030
modified or event logs

01:59.030 --> 02:01.340
that are being created while
the system is running.

02:01.340 --> 02:04.475
When he data goes
from rest to in use,

02:04.475 --> 02:08.550
it will be decrypted and
then read or modified.

02:09.710 --> 02:13.580
Hashing. Hashing is a
mathematical function

02:13.580 --> 02:14.900
that will take input

02:14.900 --> 02:17.120
from data and then
transform that into

02:17.120 --> 02:19.730
a fixed-length
hexadecimal output.

02:19.730 --> 02:22.610
The keys to remember
about hashing are

02:22.610 --> 02:25.520
that the output is always
of a fixed length.

02:25.520 --> 02:29.065
The same input will always
produce the same output.

02:29.065 --> 02:31.490
If I were to hash a file,

02:31.490 --> 02:32.885
it will give me an output.

02:32.885 --> 02:35.030
If I hash it 10 minutes
later or a week later,

02:35.030 --> 02:36.170
if it's the same file,

02:36.170 --> 02:37.520
I will get the same output.

02:37.520 --> 02:40.280
The reason we do this
is that this allows

02:40.280 --> 02:43.565
us to ensure that no changes
have been made to that file.

02:43.565 --> 02:47.390
Also, there is no way for
us to take that hash and

02:47.390 --> 02:48.410
reverse it to find

02:48.410 --> 02:50.870
the input or find out the
contents of the file.

02:50.870 --> 02:52.820
For example, hashing
is irreversible.

02:52.820 --> 02:54.940
It's considered
one-way encryption.

02:54.940 --> 02:59.550
Finally, the output of a
hash is known as a digest.

02:59.770 --> 03:02.590
Let's talk about a
practical example.

03:02.590 --> 03:04.040
Many of you have probably

03:04.040 --> 03:06.080
downloaded ISO files
from the Internet.

03:06.080 --> 03:08.885
Most of these ISOs
will also have

03:08.885 --> 03:12.455
a sum provided where you
download on the site.

03:12.455 --> 03:14.495
You'll see the long
string of numbers,

03:14.495 --> 03:16.895
and that is the
hash of this file.

03:16.895 --> 03:18.590
After you've
downloaded the file,

03:18.590 --> 03:21.170
you can make a hash of it
on your own system and then

03:21.170 --> 03:24.020
compare it to the one that's
provided by the site.

03:24.020 --> 03:26.570
If they match, you know that
you've got an exact copy.

03:26.570 --> 03:28.620
If they don't, then something
happened along the way,

03:28.620 --> 03:30.440
maybe the file is incomplete or

03:30.440 --> 03:32.420
it got corrupted and you'll
have to download it again.

03:32.420 --> 03:34.790
But this is a way for you
to verify that yours is

03:34.790 --> 03:36.050
an exact duplicate of

03:36.050 --> 03:39.300
what they are supplying
from the website.

03:39.700 --> 03:43.460
Now there are some potential
problems with hashing.

03:43.460 --> 03:46.625
If we're using this to
monitor file changes,

03:46.625 --> 03:47.825
like I mentioned earlier,

03:47.825 --> 03:50.625
we have to make sure
that we are certain and

03:50.625 --> 03:53.600
have no doubts about the
original hash that we took.

03:53.600 --> 03:55.310
If for some reason we are

03:55.310 --> 03:57.770
doubtful about it then
any hashes we make of

03:57.770 --> 04:00.575
it after that are pretty
much useless because

04:00.575 --> 04:02.420
our baseline that we
are using to compare

04:02.420 --> 04:04.940
everything to is
no longer solid.

04:04.940 --> 04:07.640
In addition, older
hashing algorithms

04:07.640 --> 04:09.274
can allow for collisions.

04:09.274 --> 04:11.600
A collision is when we can take

04:11.600 --> 04:14.090
two completely different
inputs but they will

04:14.090 --> 04:17.005
both produce the
same output hash.

04:17.005 --> 04:20.435
This happens more often
in our older algorithms,

04:20.435 --> 04:23.370
and we're going to cover some
of those on the next slide.

04:23.740 --> 04:26.480
Here are some
hashing algorithms.

04:26.480 --> 04:28.715
The most famous and
most widely used

04:28.715 --> 04:31.584
is the Message-Digest
Algorithm or MD5.

04:31.584 --> 04:34.425
It creates a 128-bit output,

04:34.425 --> 04:36.385
but it's easily brute-forced

04:36.385 --> 04:38.420
and it has a high
chance of collisions.

04:38.420 --> 04:41.780
I say it's the most
widely used because it's

04:41.780 --> 04:45.365
still in use for things where
no security is concerned.

04:45.365 --> 04:49.630
For example, for downloading
ISO files, MD5 is fine.

04:49.630 --> 04:53.120
But it's long since
been considered

04:53.120 --> 04:55.040
insecure and has
been replaced by

04:55.040 --> 04:57.380
other far stronger algorithms.

04:57.380 --> 05:00.380
Next, we have the Secure
Hash Algorithm or SHA.

05:00.380 --> 05:02.135
We have several
variants for this one.

05:02.135 --> 05:06.700
The first is SHA-1 and it
produces a 160-bit output,

05:06.700 --> 05:08.180
but it has also successfully

05:08.180 --> 05:09.500
been cracked and it should not

05:09.500 --> 05:12.640
be used for anything that
needs to be considered secure.

05:12.640 --> 05:16.640
SHA-3 is a replacement
and it has fundamentally

05:16.640 --> 05:18.680
changed the way the algorithm

05:18.680 --> 05:21.990
works compared to the
previous SHA-1 or even MD5.

05:21.990 --> 05:24.550
We also have the Race
Integrity Primitives

05:24.550 --> 05:27.295
Evaluation Message
Digest or RIPEMD.

05:27.295 --> 05:29.900
This was developed completely
independently from

05:29.900 --> 05:31.820
the US government and it has

05:31.820 --> 05:34.270
versions that allow for 128,

05:34.270 --> 05:38.705
160, 256 and 320 bit outputs.

05:38.705 --> 05:41.730
This is used for
bitcoin addresses.

05:43.060 --> 05:46.045
Message authentication codes.

05:46.045 --> 05:48.050
Remember when I said in
previous lessons that

05:48.050 --> 05:49.790
you would see MAC
several times throughout

05:49.790 --> 05:51.590
the course and they
would almost always

05:51.590 --> 05:54.990
be different meanings,

05:54.990 --> 05:56.980
this is another example of that.

05:56.980 --> 05:59.120
Message authentication
codes allows

05:59.120 --> 06:01.925
us to validate messages.

06:01.925 --> 06:05.875
These are hash-based message
authentication codes,

06:05.875 --> 06:08.915
HMAC, and this is
a specific usage

06:08.915 --> 06:11.150
of MAC, message
authentication codes.

06:11.150 --> 06:13.760
With HMAC, both the
source and the message

06:13.760 --> 06:17.015
content can be verified
without needing anything else.

06:17.015 --> 06:18.770
MAC is created through hashing

06:18.770 --> 06:20.365
and then it becomes an HMAC.

06:20.365 --> 06:22.280
HMACs have two parameters,

06:22.280 --> 06:24.080
the message and a
secret key that is

06:24.080 --> 06:27.060
known by the sender
and the receiver.

06:27.410 --> 06:30.995
Here's a flow of how HMAC works.

06:30.995 --> 06:34.489
The sender creates a message
which is then concatenated

06:34.489 --> 06:38.120
with a symmetric key that
the receiver also has.

06:38.120 --> 06:41.630
The message and the key are
hashed using a MAC algorithm.

06:41.630 --> 06:42.965
This could be SHA-2,

06:42.965 --> 06:45.245
SHA-3 or SHA-256,

06:45.245 --> 06:47.315
and that is sent
to the receiver.

06:47.315 --> 06:50.000
The receiver can use the
MAC algorithm to check

06:50.000 --> 06:53.405
the hash and then confirm the
integrity of the message,

06:53.405 --> 06:55.760
and then decrypt it
using the key with

06:55.760 --> 06:59.010
a reasonable certainty that
it came from the sender.

07:02.750 --> 07:05.900
Poly1305 is a MAC that is

07:05.900 --> 07:08.945
focused on speed and efficiency.

07:08.945 --> 07:11.510
If functions were on
devices that do not have

07:11.510 --> 07:14.375
hardware acceleration
for crypto like AES,

07:14.375 --> 07:17.990
and when used with algorithms
like ChaCha20 or Salsa20,

07:17.990 --> 07:19.970
it is much faster and has

07:19.970 --> 07:22.980
better performance than
traditional algorithms.

07:24.040 --> 07:26.585
Symmetric algorithms.

07:26.585 --> 07:29.540
These are used to encrypt
data or messages.

07:29.540 --> 07:32.620
They can only be unlocked
with a single key.

07:32.620 --> 07:34.780
Encryption isn't
like hashing as you

07:34.780 --> 07:37.045
can view the data once
it's been decrypted.

07:37.045 --> 07:38.680
That's a key thing
to keep in mind

07:38.680 --> 07:40.675
between hashing and encryption.

07:40.675 --> 07:43.375
The weakness for symmetric
algorithms is the

07:43.375 --> 07:46.855
creating and distributing
the keys in a secure way.

07:46.855 --> 07:48.750
This is similar to,

07:48.750 --> 07:51.310
imagine you have a file and you

07:51.310 --> 07:52.540
right-click on it and select

07:52.540 --> 07:54.295
encrypt and it asks
you for a password.

07:54.295 --> 07:56.530
You type the password. Now
the file is encrypted.

07:56.530 --> 07:58.930
You want to send that to
someone across the Internet,

07:58.930 --> 08:01.240
but you also have to send
the key with them too.

08:01.240 --> 08:03.955
For one-to-one, this is
not such a big deal.

08:03.955 --> 08:05.230
You can call someone up,

08:05.230 --> 08:07.270
you can find another
way to get the key to

08:07.270 --> 08:08.470
them or maybe it's
just something

08:08.470 --> 08:09.820
you agree to ahead of time.

08:09.820 --> 08:12.480
But imagine having to do this
with millions of people.

08:12.480 --> 08:15.860
It becomes very cumbersome to
use symmetric algorithms in

08:15.860 --> 08:20.425
this way. Stream cipher.

08:20.425 --> 08:23.750
This is where every
digit of plaintext data

08:23.750 --> 08:27.080
is encrypted one at a
time using a keystream.

08:27.080 --> 08:29.585
This is a stream of
pseudorandom values.

08:29.585 --> 08:32.165
It's useful for encrypting
data when the amount

08:32.165 --> 08:35.195
or the length of the data
isn't known like video.

08:35.195 --> 08:38.570
Key streams are generated
by an initialization vector

08:38.570 --> 08:41.585
IV that is combined
with a static key.

08:41.585 --> 08:43.850
This creates a
unique key stream.

08:43.850 --> 08:47.000
The IV is always
changing to ensure that

08:47.000 --> 08:48.320
the unique ciphertext is

08:48.320 --> 08:51.240
created from the
same plain text.

08:52.600 --> 08:56.960
Block ciphers. This is where
plain texts to separate it

08:56.960 --> 08:58.565
into equal size blocks

08:58.565 --> 09:00.950
and they're usually
128 bits in length.

09:00.950 --> 09:04.550
If there isn't enough data to
fill a block, it is padded.

09:04.550 --> 09:06.500
This is where we add
additional data to

09:06.500 --> 09:09.290
the end to bring
it up to 128 bits.

09:09.290 --> 09:11.540
Each block is then
encrypted based on

09:11.540 --> 09:13.690
the mode of operation
being used.

09:13.690 --> 09:15.500
We'll go over those
modes of operation in

09:15.500 --> 09:17.830
the next slide.
Let's do an example.

09:17.830 --> 09:21.140
We have 950 bits of data
that we need to encrypt.

09:21.140 --> 09:23.510
The data will be broken
into seven blocks that are

09:23.510 --> 09:26.395
128 bits long but
we have a leftover,

09:26.395 --> 09:28.270
the block will be 54 bits.

09:28.270 --> 09:30.760
We will add 74 bits to

09:30.760 --> 09:35.770
that to bring that last
block up to 128 bits.

09:38.390 --> 09:41.810
This is the cipher
modes of operation.

09:41.810 --> 09:43.250
There are quite a lot here.

09:43.250 --> 09:45.050
But the key to remember is

09:45.050 --> 09:47.135
that we're only
going to be using

09:47.135 --> 09:50.180
the last three or
four because this has

09:50.180 --> 09:51.440
been the evolution of

09:51.440 --> 09:53.635
the different modes
of ciphers over time.

09:53.635 --> 09:55.130
The first one we'll go over is

09:55.130 --> 09:57.470
the cipher block
chaining or CBC.

09:57.470 --> 10:00.365
This is a very simple mode
and it should not be used.

10:00.365 --> 10:03.530
The same is true of the
Electronic Code Book or ECB.

10:03.530 --> 10:04.820
Another one that's very simple

10:04.820 --> 10:06.425
mode and shouldn't be used.

10:06.425 --> 10:10.235
Next we have the Galois
Counter Mode or GCM.

10:10.235 --> 10:12.470
This is a high performance mode

10:12.470 --> 10:13.730
of operation and it provides

10:13.730 --> 10:19.430
authenticated encryption and
it's been widely adopted.

10:19.430 --> 10:21.990
We also have counter or CTR.

10:21.990 --> 10:24.050
This applies an IV and

10:24.050 --> 10:25.880
an incrementing counter value

10:25.880 --> 10:28.390
to the key to
create a keystream.

10:28.390 --> 10:30.140
You do not need padding with

10:30.140 --> 10:32.695
the leftover space
because it's removed.

10:32.695 --> 10:36.255
Then finally we have the
Output Feedback or OFB.

10:36.255 --> 10:39.375
This uses initial
chaining vector, ICV,

10:39.375 --> 10:42.065
for the first round and
then combines the output of

10:42.065 --> 10:46.320
all previous rounds as
input to the next round.

10:48.590 --> 10:52.275
Stream ciphers and
block cipher examples.

10:52.275 --> 10:54.885
For stream ciphers, we have RC4.

10:54.885 --> 10:57.115
This was developed in 1984

10:57.115 --> 10:59.075
and it has numerous
vulnerabilities.

10:59.075 --> 11:01.115
It really shouldn't
be used anymore.

11:01.115 --> 11:02.850
We also have Salsa20.

11:02.850 --> 11:04.760
It was developed
in 2005 and it's

11:04.760 --> 11:07.460
well regarded and it's
also a fast algorithm.

11:07.460 --> 11:09.255
We also have ChaCha,

11:09.255 --> 11:11.955
which is a variant of
Salsa developed in 2008.

11:11.955 --> 11:15.665
It's used in Chrome
on Android devices.

11:15.665 --> 11:17.630
It's good for devices that lack

11:17.630 --> 11:19.130
the hardware support
that couldn't

11:19.130 --> 11:21.960
use algorithms such as AES.

11:22.090 --> 11:24.320
For block ciphers, we have

11:24.320 --> 11:27.365
the Data Encryption Standard
or DES, or triple DES.

11:27.365 --> 11:30.135
This was originally
developed in 1977.

11:30.135 --> 11:33.240
This states DES should
be replaced with AES.

11:33.240 --> 11:34.455
Being an old cipher,

11:34.455 --> 11:35.835
DES has already been broken

11:35.835 --> 11:38.090
and that was the purpose for AES

11:38.090 --> 11:42.645
being created was to shift
everything from DES to AES.

11:42.645 --> 11:44.690
Finally we have AES,

11:44.690 --> 11:46.700
which is the Advanced
Encryption Standard.

11:46.700 --> 11:49.070
This is the US Federal
Government encryption standard

11:49.070 --> 11:50.719
for symmetric algorithms.

11:50.719 --> 11:53.120
It's very efficient
and secure and

11:53.120 --> 11:55.445
it's available in 128 bit,

11:55.445 --> 11:58.190
192 and 256 bit versions.

11:58.190 --> 12:00.910
It's based on the
Rijndael algorithm.

12:00.910 --> 12:03.650
Two other examples because
you've probably seen them

12:03.650 --> 12:07.745
in your own research online
are Twofish and Blowfish.

12:07.745 --> 12:10.170
These are both block ciphers.

12:10.940 --> 12:13.200
Here's some crypto humor.

12:13.200 --> 12:16.410
Like I said, this cartoon
always has good stuff.

12:16.410 --> 12:18.500
I really got a kick
out of this one

12:18.500 --> 12:20.405
when I was building this lesson.

12:20.405 --> 12:22.770
Hopefully you'd like it as well.

12:24.440 --> 12:27.050
Let's summarize. We went

12:27.050 --> 12:29.165
over hashing and
hashing algorithms.

12:29.165 --> 12:31.850
We also discuss
symmetric algorithms

12:31.850 --> 12:33.845
and streaming and block ciphers.

12:33.845 --> 12:37.255
We went over the different
encryption modes of operation.

12:37.255 --> 12:40.360
Let's do some example questions.

12:40.430 --> 12:43.095
Question 1, true or false.

12:43.095 --> 12:46.490
Symmetric encryption keys
can be sent through email so

12:46.490 --> 12:50.815
that the recipient can decrypt
any encrypted attachments.

12:50.815 --> 12:56.070
False. Symmetric keys must be
shared in a secure manner.

12:56.900 --> 13:00.230
Question 2, blank transforms

13:00.230 --> 13:04.500
data inputs into fixed length
output called a digest.

13:05.140 --> 13:09.925
Hashing. Question 3,

13:09.925 --> 13:12.440
this type of symmetric
algorithm encrypts

13:12.440 --> 13:13.730
each bit of data

13:13.730 --> 13:15.575
and is ideal for situations

13:15.575 --> 13:18.660
where the amount of
data is unknown.

13:19.420 --> 13:24.110
Stream cipher. Remember this
is often used for video.

13:24.110 --> 13:25.550
If you keep that in mind

13:25.550 --> 13:27.710
that you don't know how
long that video file

13:27.710 --> 13:31.280
is going to be and
because it's unknown,

13:31.280 --> 13:33.275
it's being streamed
across the Internet,

13:33.275 --> 13:34.835
think stream cipher,

13:34.835 --> 13:36.680
unknown length video that

13:36.680 --> 13:39.540
will maybe help you
remember for the test.

13:39.760 --> 13:42.200
Question 4, this is

13:42.200 --> 13:44.210
the current US government
encryption standard

13:44.210 --> 13:46.410
and is widely used.

13:46.670 --> 13:50.055
Advanced Encryption
Standard or AES.

13:50.055 --> 13:51.470
Hope this lesson was helpful

13:51.470 --> 13:53.880
for you and I'll see
you the next one.

