User Tools

Site Tools


security:cryptography-fundamentals

This is an old revision of the document!


Cryptography Fundamentals

This document explains cryptography from the most general concepts


Introduction

When systems communicate over a network, there are three major security concerns:

  • Confidentiality
  • Integrity
  • Authenticity

These concerns are solved using cryptography.


Security Goals

Confidentiality

Confidentiality means:

Only authorized parties can read the data.

Example:

Alice sends a password to Bob.

Without protection:

Alice ---- Internet ---- Bob
                ^
             Attacker

The attacker can read the message.

Solution:

Encryption

Integrity

Integrity means:

Data was not modified during transmission.

Example:

Original:

Transfer $100

Modified by attacker:

Transfer $10000

Solution:

Digital Signatures

Authenticity

Authenticity means:

Verify who actually sent the message.

Example:

Someone claims to be your bank.

How do you know it is really your bank?

Solution:

Digital Signatures
Certificates

What Is Cryptography?

Cryptography is the science of protecting information.

Main categories:

Cryptography
│
├── Encryption
│
└── Digital Signatures

Encryption

Encryption protects:

Confidentiality

Goal:

Prevent unauthorized people from reading data.

Process:

Plain Text
    ↓
Encrypt
    ↓
Cipher Text
    ↓
Decrypt
    ↓
Plain Text

Example:

Hello World

may become:

A83D91F22C...

Only someone with the correct key can recover the original message.


What Is A Key?

A key is a secret value used by cryptographic algorithms.

Example:

Message:
Hello

Key:
abc123

Analogy:

House Key

Without key:

Cannot open the door.

With key:

Can open the door.

Types of Cryptography

There are two major cryptographic models.

Cryptography
│
├── Symmetric Cryptography
│
└── Asymmetric Cryptography

Symmetric Cryptography

Definition

Symmetric cryptography uses:

ONE SECRET KEY

for both encryption and decryption.


Architecture

           Secret Key
               |
       ----------------
       |              |
    Encrypt       Decrypt

Workflow

Alice and Bob share the same secret key.

Secret Key = abc123

Encryption:

Encrypt("Hello", abc123)

Decryption:

Decrypt(ciphertext, abc123)

Same key is used for both operations.


Real-Life Example

Think about a locked box.

Key
 ↓
Lock Box
 ↓
Unlock Box

The same key locks and unlocks the box.


Advantages

  • Fast
  • Efficient
  • Easy to implement

Disadvantages

The key must be shared securely.

Problem:

Alice ---- Secret Key ---- Bob

If attacker obtains the key:

Attacker can decrypt everything.

Common Algorithms

  • AES
  • ChaCha20
  • DES (legacy)

Asymmetric Cryptography

Definition

Asymmetric cryptography uses:

TWO KEYS

A key pair:

Public Key
Private Key

These keys are mathematically related.


Public Key

Public key can be shared freely.

Example locations:

  • Websites
  • Certificates
  • API documentation

Anyone may know the public key.


Private Key

Private key must remain secret.

Only the owner should possess it.

If leaked:

Security is compromised.

Asymmetric Encryption

Purpose

Provides:

Confidentiality

Workflow

Public Key  → Encrypt

Private Key → Decrypt

Example

Alice owns:

Public Key
Private Key

Bob wants to send a secret message.

Bob:

Encrypt(message, Alice Public Key)

Alice:

Decrypt(message, Alice Private Key)

Result

Anyone can encrypt.

Only owner can decrypt.

Digital Signatures

Digital signatures solve:

  • Integrity
  • Authenticity

Workflow

Private Key → Sign

Public Key  → Verify

Example

Server signs a document.

Document
   ↓
Sign with Private Key
   ↓
Signed Document

Verification:

Signed Document
   ↓
Verify with Public Key
   ↓
Valid or Invalid

Result

Only owner can sign.

Everyone can verify.

Encryption vs Digital Signature

Encryption

Goal:

Hide data

Workflow:

Public Key  → Encrypt

Private Key → Decrypt

Question answered:

Can someone read this?

Digital Signature

Goal:

Verify authenticity

Workflow:

Private Key → Sign

Public Key  → Verify

Question answered:

Did this really come from the owner?

security/cryptography-fundamentals.1781260932.txt.gz · Last modified: by phong2018