a start
This commit is contained in:
commit
c93981623d
8 changed files with 374 additions and 0 deletions
1
CBC.drawio
Normal file
1
CBC.drawio
Normal file
|
|
@ -0,0 +1 @@
|
|||
<mxfile host="www.draw.io" modified="2020-02-26T13:17:42.729Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" etag="0aJCxbSdBO7NPGMQXKSX" version="12.7.7" type="device"><diagram id="SsWuWXveNioaAHAvwu1x" name="Page-1">7Vtdb9sgFP01kbaHVsaOneRxa/albVK1ah/dy0RtGqPZxiJkSfrrh2OIbWhVL6OGbHmKuYZrOBy4h2tnFFzkmzcUlulHkqBs5HvJZhTMR77ve17EfyrLtrZM/EltWFCc1CbQGK7wHRJGT1hXOEHLTkVGSMZw2TXGpChQzDo2SClZd6vdkqz71BIukGa4imGmW7/ihKW1dRp6jf0twotUPhl44k4OZWVhWKYwIeuWKXg1Ci4oIay+yjcXKKvAk7jU7V4/cHffMYoK1qfB3edVwabX36NyfvaJzje37z9enAkvv2C2EgMuM4gLhjZM9JptJRSUrIoEVd68UfBynWKGrkoYV3fXfPK5LWV5xkuAXwq/iHJXD3YY7GHg/EEkR4xueRXZQCInqDMTxXUzD/sqaWsOAmGDYuoXe88NOvxCAPQHYPkaWDEu090Q3UPLPlxjDa6bjMQ/q8W6g41foCKm25JhUjiHH+iLX/RU+IUafj/R1jpOoUIzL9RgGg/JskhDSYMIFcmLKhTwUpzB5RLHXVTQBrNvFYDnoShdt+7MNwLbXWErCwXvfKtRVbxu32ua7UqyXd05lGhRR8GfD4CsaIwe37sZpAvEHluH+ny2Jiy8Z8KkjaIMMvyr2937ZlE84ZLw8NHQZex1+bIvSxf1MEWrdvhSHSnEC0LFUY2D5mhHqv2wD+fZxA7PDPJl3JMv/okvBvgyNccX0GJLw53H9qXOrtRsUk+/L4WnfWlAns00nrmj4AMFG+uSVJ4q3ZTwKlwO4KWfD13W8CqA9jU80M+MLoh4f+qYigeBuXB5ZDLe76vLwANzOkzAjAJDATOa2g2YQM9LDEI1g5QBfY9+wBudKGOAMnoq5mDKHJmYlwHstDsNRDU9n+WOng8VcOzrUz0r45CeV+FyAC89K+GynlcBdEDP68dtF/R8CBSm2dbzclL+Rz0f9Y2YU5sRcxoZipgzYDdi+nqOYhCqGaSM3JYfp8zkRBkTlNGzMgdT5tj0/Oy0Ow1KtR6JrSr04xhmH+ANyi7JEu/EVzC/IYyRnM+/rPAiw4vqBiOKhFimsKyc5ZtF9RnW+W1G1nEKKTtfrvIcF4sft6sirt0a+VhiogizUBdm9+ky/8n0Ro+kzvHBrL6ksg+zwUTIkcm6vvumb/e1prLdAZUKvV9rqo5mA++bPb7rOb4Fraap7C9oS5+1OLCgQd9zWk1Fa5nNsaEVrTkaekXruad3BV+yMMN3sE43eV9QzAjlF8/efXmuEXHorMqZulrHelYFBPdM/dOlVfT008HLdYiDy650iSjmw0fU/Br2+x6caxluLSr/Kx8bSWL/Ff/scMlx4QbUdwWTAyniKydnAPpRhM8Z3LaqlVWF5cMdVp8jO9y7X1GnPr+oe2CWryZygzb46sr54WAaakpXfSVjiIbj2Z/RUK3/lzTkxeYfXHX15n9wwavf</diagram></mxfile>
|
||||
BIN
CBC.png
Normal file
BIN
CBC.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
1
ECB.drawio
Normal file
1
ECB.drawio
Normal file
|
|
@ -0,0 +1 @@
|
|||
<mxfile host="www.draw.io" modified="2020-02-26T13:12:57.571Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" etag="rXoaLAvVaOOrlQ2glK_-" version="12.7.7" type="device"><diagram id="SsWuWXveNioaAHAvwu1x" name="Page-1">7VpNj5swEP01HLfCEAg5tsm2laqVqkZVm95c8AZrCUaOs4H99TXB5subhkYsOCqnMGN7sN+8eJ4tDHu5Sz9RmIQPJECRYZlBatgrw7IAcFz+k3uywjO35oVjS3EgOlWONX5BwmkK7wEHaN/oyAiJGE6aTp/EMfJZwwcpJcdmt0cSNd+awC1SHGsfRqr3Bw5YWHg9x6z8nxHehvLNwBQtOyg7C8c+hAE51lz2vWEvKSGseNqlSxTl4ElcinEfz7SWE6MoZl0GvHw/xMzb/HKT1d03ukofvzws70SUZxgdxIKTCOKYoZSJWbNMQkHJIQ5QHs007A/HEDO0TqCftx558rkvZLuIW4A/iriI8lBnJwxKGDh/ENkhRjPeRQ6QyAnqAFvYxyoRZZ+wlgTZD4rcb8vQFTz8QSD0D2hZClo+TsLTGvWDy/LAyHDNFLh+R8R/yv+tJ9j4A4p9miUMk1g7/MCiI93ct8LPUfB7QtnoODktmpmOAtNsSJa5CkoKRCgO3ue1gFt+BPd77DdRQSlmP3MA3znC2tRaVqnA9mRk0oj55GuDcnNTb6uGnSw5rpgcCpSy08KfL4AcqI8ub94M0i1il/6Haj5rCXNeSZj0URRBhp+b030ti+INXwmvHxVdZmaTL6UtQxTLFKPq9asdqEU822kFKnBQAp1IVS77ep7Nx+FZj3yZdeSLNfGlB754/fEF1NhScefSvtTYlapN6u33JWfalwbk2ULhmT4S3nZ0k/DyXKmnhm/jNb6GB+oJUWcRrxBudBEP1EOjDire8jST8cDur17emI5fdKyX4ExKhymYrt1TwXS9cQsmUO8lBmFaj4wBXY9+wDQmyvRAGfUq5mrK3JiYl/Vr2p0Gopp6n6WPnnda4Gig59VrGY30fBsvDfS8ei2hs55XCDe+nlfP2zroeQe0mDa2npdJ+Q/1vNzCL5dMb8yS6bk9lcwFGLdkWuodxSBU65MyXlfKzCfK9EEZ9VbmasrcmqDvfN0w7U5/pxo3q893iu7VR1D2/R8=</diagram></mxfile>
|
||||
BIN
ECB.png
Normal file
BIN
ECB.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
BIN
Tux.jpg
Normal file
BIN
Tux.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
BIN
Tux_ecb.jpg
Normal file
BIN
Tux_ecb.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
Tux_secure.jpg
Normal file
BIN
Tux_secure.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
372
index.html
Normal file
372
index.html
Normal file
|
|
@ -0,0 +1,372 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Crypto basics</title>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
@import url(https://fonts.googleapis.com/css?family=Droid+Serif);
|
||||
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
|
||||
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
|
||||
|
||||
body {
|
||||
font-family: 'Droid Serif';
|
||||
}
|
||||
h1, h2, h3 {
|
||||
font-family: 'Yanone Kaffeesatz';
|
||||
font-weight: 400;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.remark-slide-content h1 { font-size: 3em; }
|
||||
.remark-slide-content h2 { font-size: 2em; }
|
||||
.remark-slide-content h3 { font-size: 1.6em; }
|
||||
.footnote {
|
||||
position: absolute;
|
||||
bottom: 3em;
|
||||
font-size: 0.7em;
|
||||
}
|
||||
li p { line-height: 1.25em; }
|
||||
.red { color: #fa0000; }
|
||||
.large { font-size: 2em; }
|
||||
a, a > code {
|
||||
color: rgb(249, 38, 114);
|
||||
text-decoration: none;
|
||||
}
|
||||
code {
|
||||
background: #e7e8e2;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
|
||||
.remark-code-line-highlighted { background-color: #373832; }
|
||||
.pull-left {
|
||||
float: left;
|
||||
width: 47%;
|
||||
}
|
||||
.pull-right {
|
||||
float: right;
|
||||
width: 47%;
|
||||
}
|
||||
.pull-right ~ p {
|
||||
clear: both;
|
||||
}
|
||||
#slideshow .slide .content code {
|
||||
font-size: 0.8em;
|
||||
}
|
||||
#slideshow .slide .content pre code {
|
||||
font-size: 0.9em;
|
||||
padding: 15px;
|
||||
}
|
||||
.inverse {
|
||||
background: #272822;
|
||||
color: #777872;
|
||||
text-shadow: 0 0 20px #333;
|
||||
}
|
||||
.inverse h1, .inverse h2 {
|
||||
color: #f3f3f3;
|
||||
line-height: 0.8em;
|
||||
}
|
||||
|
||||
/* Slide-specific styling */
|
||||
#slide-inverse .footnote {
|
||||
bottom: 12px;
|
||||
left: 20px;
|
||||
}
|
||||
#slide-how .slides {
|
||||
font-size: 0.9em;
|
||||
position: absolute;
|
||||
top: 151px;
|
||||
right: 140px;
|
||||
}
|
||||
#slide-how .slides h3 {
|
||||
margin-top: 0.2em;
|
||||
}
|
||||
#slide-how .slides .first, #slide-how .slides .second {
|
||||
padding: 1px 20px;
|
||||
height: 90px;
|
||||
width: 120px;
|
||||
-moz-box-shadow: 0 0 10px #777;
|
||||
-webkit-box-shadow: 0 0 10px #777;
|
||||
box-shadow: 0 0 10px #777;
|
||||
}
|
||||
#slide-how .slides .first {
|
||||
background: #fff;
|
||||
position: absolute;
|
||||
top: 20%;
|
||||
left: 20%;
|
||||
z-index: 1;
|
||||
}
|
||||
#slide-how .slides .second {
|
||||
position: relative;
|
||||
background: #fff;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
/* Two-column layout */
|
||||
.left-column {
|
||||
color: #777;
|
||||
width: 20%;
|
||||
height: 92%;
|
||||
float: left;
|
||||
}
|
||||
.left-column h2:last-of-type, .left-column h3:last-child {
|
||||
color: #000;
|
||||
}
|
||||
.right-column {
|
||||
width: 75%;
|
||||
float: right;
|
||||
padding-top: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<textarea id="source">
|
||||
|
||||
name: inverse
|
||||
layout: true
|
||||
class: center, middle, inverse
|
||||
---
|
||||
# Crypto basics
|
||||
Ward Wouts<br>
|
||||
---
|
||||
# Agenda
|
||||
|
||||
1. Introduction
|
||||
1. Keys
|
||||
1. Randomness
|
||||
1. Ciphers
|
||||
1. Modes
|
||||
|
||||
---
|
||||
# Introduction
|
||||
---
|
||||
layout: false
|
||||
.left-column[
|
||||
## Introduction
|
||||
]
|
||||
.right-column[
|
||||
This talk is intended to give you some idea about the things to think about when dealing with cryptography. There are many mistakes that can be made. We'll discuss some of the more common ones.
|
||||
|
||||
We'll stay out of much of the theory behind cryptography.
|
||||
|
||||
This talk will definitely not make you an expert.
|
||||
|
||||
Hopefully at the end you will be able to avoid the biggest pitfalls, though.
|
||||
]
|
||||
---
|
||||
template: inverse
|
||||
# Keys
|
||||
---
|
||||
layout: false
|
||||
.left-column[
|
||||
## Keys
|
||||
]
|
||||
.right-column[
|
||||
In cryptograhpy we see two different styles of using keys: symmetric and private/public keys.
|
||||
|
||||
We'll keep things simple for now and only deal with symmetric keys.
|
||||
|
||||
A key is used to encrypt & decrypt data.
|
||||
|
||||
The used key should be secret. This implies unpredictable!
|
||||
]
|
||||
---
|
||||
layout: false
|
||||
.left-column[
|
||||
## What do keys look like?
|
||||
]
|
||||
.right-column[
|
||||
The most used ciphers are `DES` and `AES`.
|
||||
|
||||
- Keys for DES are 7 or 8 bytes long. (56 bits + 8 bits parity)
|
||||
- Keys for AES are 16, 24, or 32 bytes (128, 192, or 256 bits)
|
||||
|
||||
A keys typically looks like random bits, and *should be* random bits.
|
||||
|
||||
Both sides should get a hold of the key somehow:
|
||||
- derive from password
|
||||
- transmit with message
|
||||
- fetch from escrow
|
||||
|
||||
.footnote[See: https://en.wikipedia.org/wiki/Data_Encryption_Standard <br>
|
||||
And: https://en.wikipedia.org/wiki/Advanced_Encryption_Standard]
|
||||
]
|
||||
---
|
||||
.left-column[
|
||||
## Keys and randomness
|
||||
]
|
||||
.right-column[
|
||||
As stated keys should be both random and unpredictable. This is not the same thing! A stream of bits can be random (50% chance of either a 0 or a 1) and be *entirely predictable*.
|
||||
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import random as r
|
||||
|
||||
# force same starting point in deterministic bitstream
|
||||
r.seed(5)
|
||||
|
||||
key = [ r.getrandbits(8) for i in range(16) ]
|
||||
print(key)
|
||||
```
|
||||
]
|
||||
---
|
||||
.left-column[
|
||||
## Keys and randomness
|
||||
]
|
||||
.right-column[
|
||||
Contrast this with the builtin secrets random number generator for cryptographic usage:
|
||||
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import secrets as r
|
||||
|
||||
key = [ r.randbits(8) for i in range(16) ]
|
||||
print(key)
|
||||
```
|
||||
]
|
||||
---
|
||||
.left-column[
|
||||
## Keys and randomness
|
||||
]
|
||||
.right-column[
|
||||
Keys often come from non-random, predictable sources, such as:
|
||||
- time()
|
||||
- rand()
|
||||
- GetTickCount()
|
||||
|
||||
Use only secure-random functions, such as:
|
||||
- CryptGenRandom (Win32)
|
||||
- getrandom(2) (Linux)
|
||||
]
|
||||
---
|
||||
.left-column[
|
||||
## Pitfalls to watch for
|
||||
]
|
||||
.right-column[
|
||||
- hardcoded keys
|
||||
- insecure key generation
|
||||
- insecure key exchange
|
||||
]
|
||||
---
|
||||
template: inverse
|
||||
# Randomness
|
||||
---
|
||||
.left-column[
|
||||
## Randomness
|
||||
]
|
||||
.right-column[
|
||||
BLAAH
|
||||
]
|
||||
---
|
||||
.left-column[
|
||||
## Ciphers
|
||||
]
|
||||
.right-column[
|
||||
A cipher is the thing that does the actual encryption in cryptography.
|
||||
There are two categories of ciphers:
|
||||
- block ciphers
|
||||
- stream ciphers
|
||||
|
||||
If data is encrypted in 1 byte chunks: it's a stream cipher (RC4 is a wellknown one). Bigger chunks: it's a block cipher.
|
||||
|
||||
8 byte blocks? 7, or 8 byte key → likely DES.
|
||||
|
||||
16 byte blocks? 16, 24, 32 byte keys? → likely AES.
|
||||
|
||||
Block ciphers are by far the most used.
|
||||
]
|
||||
---
|
||||
template: inverse
|
||||
# Ciphers
|
||||
---
|
||||
.left-column[
|
||||
## Ciphers
|
||||
]
|
||||
.right-column[
|
||||
ASFDFADSFAS
|
||||
]
|
||||
---
|
||||
template: inverse
|
||||
# Modes
|
||||
---
|
||||
.left-column[
|
||||
## Modes
|
||||
]
|
||||
.right-column[
|
||||
So, what *is* a mode?
|
||||
|
||||
Block ciphers encrypt a fixed number of bytes. So what if the data to be encrypted is bigger that that number of bytes? And what it it's smaller?
|
||||
|
||||
A *mode* is a way of chaining multiple blocks of encryption together.
|
||||
]
|
||||
---
|
||||
.left-column[
|
||||
## ECB
|
||||
]
|
||||
.right-column[
|
||||
The simplest way of encrypting multiple blocks is:
|
||||
|
||||
<img src="ECB.png" width="100%">
|
||||
|
||||
This is called `ECB` (Electronic Code Book).
|
||||
]
|
||||
---
|
||||
.left-column[
|
||||
## ECB
|
||||
]
|
||||
.right-column[
|
||||
Don't use ECB:
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="Tux.jpg" width="100%"></td>
|
||||
<td><img src="Tux_ecb.jpg" width="100%"></td>
|
||||
<td><img src="Tux_secure.jpg" width="100%"></td>
|
||||
<tr>
|
||||
<td>Original</td>
|
||||
<td>ECB</td>
|
||||
<td>Other mode</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
.footnote[Pictures from https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#ECB]
|
||||
]
|
||||
---
|
||||
.left-column[
|
||||
## CBC
|
||||
]
|
||||
.right-column[
|
||||
An improvement is to use the last cipherblock as input for encrypting the next block:
|
||||
|
||||
<img src="CBC.png" width="100%">
|
||||
|
||||
This is called `CBC` (Cipher Block Chaining).
|
||||
]
|
||||
---
|
||||
template: inverse
|
||||
# Final notes
|
||||
---
|
||||
.left-column[
|
||||
## Credits
|
||||
]
|
||||
.right-column[
|
||||
I've reused a lot of Ron Bowes excellent material for Kringlecon 2019: https://docs.google.com/presentation/d/1uEf6jSATaZDkvdLNIEeq1B4cpnkLko_22A1hMb8xRJE/edit#slide=id.p1 <br>
|
||||
Check his talk here: https://youtu.be/obJdpKDpFBA
|
||||
]
|
||||
---
|
||||
.left-column[
|
||||
## Reading material
|
||||
]
|
||||
.right-column[
|
||||
- "Serious Cryptography: A Practical Introduction to Modern Encryption"
|
||||
by Jean-Philippe Aumasson, published by No Starch Press is an excellent book (https://nostarch.com/seriouscrypto)
|
||||
]
|
||||
|
||||
|
||||
</textarea>
|
||||
<script src="https://remarkjs.com/downloads/remark-latest.min.js">
|
||||
</script>
|
||||
<script>
|
||||
var slideshow = remark.create();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue