This post describes the cryptography algorithms and their applications (As I understand them). Over the years, I read bits of “Understanding cryptography” by Cristof Paar and these are my notes which kinda match the chapters of the book. I also, added links to related posts for each section.
The crypto provides several goals (the technical name is services
)
- confidentiality: Stop people from seeing the message
- Integrity: Make sure the message is correct(no tampering)
- Message Authentication (The message is coming from the right person)
- Nonrepudiation: prove that some person signed a message
symmetric algorithms Link to heading
symmetric algorithms provide confidentiality by using shared key
known by the Bob and Alice.
Examples:
- AES crypto-AES-SBOX
The key has to exchanged over other way(see key exchange section). But, once it’s known both sides can encrypt/decrypt messages with shared key.
asymmetric Algorithms (public key) Link to heading
asymmetric algorithms provide confidentiality by using 2 keys Public
and Private
keys. The good part is that private key can’t be calculated from public key.
Let’s Say Alice wants to send secure message to Bob:
- Bob has a key consisting of kpr and Kpub
- Bob share Kpub to Alice
- Alice uses Kpup to encrypt message
- Bob uses Kpr to decrypt message
The key point here is the Alice doesn’t know the private key of Bob.
Examples:
- RSA crypto-rsa
- Discrete crypto-diffie-hellman
- Elliptical curve crypto-clliptical-curve
Digital signature Link to heading
provides Integrity, Authentication, and Nonrepudiation. Bob signs a message by creating a digital signal which is function of Kpr(Bob’t private key) and sends both the message and signature. Alice using Bob’s Public key, the message and signature to decide the message is valid or not. Digital signatures mainly use asymmetric algorithms above.
Examples:
- RSA
- Discrete
- Elliptical curve
Hash functions Link to heading
Hash function provides Integrity for the message by calculating one-way fixed size hash for arbitrary length messages. The hash algorithm needs to have the following properties
- One-way: You can’t get a message from the digest
- No-collision: you can’t create 2 messages with the digest
- Takes arbitrary length message
- generate fixed size digest
Examples:
- MD4 Family (MD5) crypto-md5-python
- SHA Family (SHA-0 and later)
Integrity Algorithms Link to heading
They provide Integrity, Authentication by combining hash and symmetric. So, These algorithms still need a key to calculate a digest sent with message. And receiver uses the message, digest and key to check that message is valid or not.
Examples:
- HMAC(using hash functions SHA1 or MD5) crypto-hmac
- CBC-MAC
- GMAC
Key exchange Link to heading
In above Algorithms, we assumed the keys are already known by Alice and Bob. But we need a way to exchange the keys.
- symmertic exchange (not common)
- Asymmetric exchange (very popular)
In Asymmetric exchange, Both sides share public keys and the other side uses the public key and private key, to calculate secret key.
Examples:
- Diffie–Hellman key exchange (DHKE) crypto-keyexchange