You are on page 1of 80

Secret Key or

Symmetric
Cryptography
Encryption Scheme

Llave Llave
secreta secreta

Algoritmo de Algoritmo de
cifrado descifrado
Alicia Mensaje Mensaje Mensaje Beto
en claro cifrado en claro
Classification Modern
Ciphers

Stream
Block Ciphers
Ciphers

RC4, Salsa20,
Public Key Private Key
Chacha20

Mobile Add/Multiplica
Exponentation AES
Phones, WLAN tion

RSA, El Gamal, ECDSA, Encrypting


DSA EdCDSA information of an
internet session.
Local encryption

Key exchange, Key exchange,


Digital Digital
Signature Signature
Stream and Block
Ciphers The same algorithm is applied
block ciphers to a block of information (a
group of characters of bits)
several times, using the same
key. The size of this block is 64,
128 or 264 bits.

Stream
Ciphers
The algorithm is applied to
one element (character or bit)
using a stream random key.
The process is done bit by bit.
Stream vs Block
Block Ciphers

Impossible Slow
to introduce Likely to
extra blocks have errors
without on the
detection process

Advantages Disadvantages

Fast Independent
Resistant to elements can
errors be modified

Stream Ciphers
Stream Ciphers
How to stream ciphering?




Stream Cipher

C C
Message M XOR XOR Message M
Cryptomessages bits
Sequence Si Sequence Si
Basic Stream Cipher




Basic Stream Cipher

K K
Sequence

C
Deterministic S S Deterministic
Å Å
Algorithm Algorithm

Message M M Message
Stream Ciphers from Pseudo-random Functions


• Fk K

c m Fk
Example A' = 6510 = 64+1 = 26+20 = 010000012
Linear Feedback Shift Registers



Linear
Feedback Shift
Registers
Pseudo-random Sequence S




Stream Cipher Examples


• http://youtu.be/LgZAI3DdUA4

• http://rc4.online-domain-tools.com/

• https://youtu.be/UeIpq-C-GSA
A5 Algorithm



RC4 algorithm




Chacha 20
Chacha20 ChaCha is a family of stream ciphers by Daniel J. Bernstein
based on a variant of Salsa20.

It performs 20 rounds and is faster than AES and its designer


recommends it for typical cryptographic applications.

The IETF version of ChaCha is specified in RFC 7539,


ChaCha20 and Poly1305 for IETF protocols and is available
as ChaChaTLS.
Google selected ChaCha20 along with the Poly1305
message authentication code for TLS over TCP.

It is also used as an arc4random random number generator in


FreeBSD, OpenBSD and NetBSD operating systems, and in
DragonFly BSD for the kernel CSPRNG subroutine.
In 2018, RFC 7539 was obsoleted by RFC 8439.
Chacha20
Chacha20 -
Salsa20/12 and Salsa20/20 are
Today fast stream ciphers designed by
Dan Bernstein in 2005.

Their variants are called


ChaCha12 and ChaCha20, were
proposed by Bernstein in 2008.

These stream ciphers have been


incorporated into several widely
deployed protocols such as TLS
and SSH.
Basic Function


Basic Function





1.

2.

3.
PRGs for ChaCha





Advantages


Practical
Session 1
Block Ciphers
Block Encryption / Decryption Scheme
MESSAGE (N bits)

BLOCK A BLOCK B A Å Xi B Å Xi

N/2 N/2
Å Å

ki ki
FUNCTION f FUNCTION f
Xi Xi
Å Å Å Å

A Å Xi B Å Xi A B

Given that Y Å Xi Å Xi = Y
Feistel Cipher


Feistel Cipher




Example



Menssage: M = STAR WARS, LA MISIÓN CONTINÚA


Feistel Cipher on mod 27
Si: +1 mod 27
M = STAR WARS, LA MISIÓN CONTINÚA Pi: Õ3241
M1 = STAR WARS LAMI SION CONT INUA
S1 = TUBS WARS MBNJ SION DPÑU INUA 1st
P1 = BUST WARS NBJM SION ÑPUD INUA Round

M2 = WARS BUST SION NBJM INUA ÑPUD 2nd


S2 = XBST BUST TJPÑ NBJM JÑVB ÑPUD
Round
P2 = SBTX BUST PJÑT NBJM VÑBJ ÑPUD

C = SBTX BUST PJÑT NBJM VÑBJ ÑPUD


How to decrypt?


Feistel Ciphers

Algorithm Block (bits) Key (bits) Rounds


Lucifer 128 128 16
DES 64 56 16
Loki 64 64 16
RC2 64 variable -
CAST 64 64 8
Blowfish 64 variable 16
IDEA 64 128 8
Feistel Ciphers


AES -
Advanced Encryption
Standard
The latest standard AES


General Characteristics
of AES


Bytes operations •

in AES


Description of the algorithm
1.

2.

3.


4.



Byte SUB
• Each byte ai,j in the
state is replaced with
its entry in a fixed 8-
bit lookup table S
(Substitution Box)
bij = S(aij)
• The s-box used is
derived from the
multiplicative inverse
over GF(28), known to
have good non-
linearity properties.
The ShiftRows step

• In the ShiftRows step, bytes in


each row of the state are shifted
cyclically to the left. The
number of places each byte is
shifted differs incrementally for
each row.
• The importance of this step is to
avoid the columns being
encrypted independently, in
which case AES would
degenerate into four
independent block ciphers.
The MixColumns
step
¡In the MixColumns step, each
column of the state is multiplied
with a fixed polynomial c(x).
¡The four bytes of each column of
the state are combined using an
invertible linear transformation.
¡ The MixColumns function takes
four bytes as input and outputs
four bytes, where each input byte
affects all four output bytes.
¡Together with ShiftRows,
MixColumns provides diffusion in
the cipher.
The AddRoundKey step


AES

• https://youtu.be/gP4PqVGudtg
Example - AES
AddRoundKey
SubBytes
ShiftRows
MixColumns
AddRoundKey
Final State
Known Attacks


Known Attacks


Pros and cons on simetric key criptosystems

PROS CONS

• •



• https://www.cryptool.org/en/cto/aes-step-by-
step
• https://nvlpubs.nist.gov/nistpubs/fips/NIST.FIPS.1
97.pdf
Referencias • https://www.kavaliro.com/wp-
content/uploads/2014/03/AES.pdf
Cipher Modes
Cipher Modes


Cipher Modes •


Electronic
Codebook (ECB)


Electronic Codebook (ECB)
Cipher Block Chaining (CBC)


Cipher Block Chaining (CBC)
Cipher Block Chaining (CBC)
Problems with CBC mode


Propagating •

Cipher Block
Chaining
Propagating Cipher Block Chaining
Cipher •

Feedback (CFB)
Cipher Feedback (CFB)
Output

Feedback (OFB)
Output Feedback (OFB)
Counter (CTR)


Counter (CTR)
Counter (CTR)
Galois Counter Mode (GCM)








You might also like