Describe the concept and possible use cases for the following crypto primitives:
• Message digest
A cryptographic hash function that converts data into a fixed-size string (e.g., SHA-256). Use cases:
Verify file integrity (e.g., checksums for downloads).
Securely store passwords by hashing them instead of storing plaintext.
• Key derivation functions
Generate cryptographic keys from passwords or other data using pseudo random functions. These pseudo random functions include random salts together with recreating hash values of both the data and the salt over several iteration making it computational heavy to creak the initial data. Use cases:
PBKDF2: Create strong encrypten keys for encryption algorithm.
Scrypt: Securely store passwords with high computational/memory requirements.
• Message authentication codes
Combines a hash function with a secret key to ensure message integrity and authenticity. Since the secrete key is only known by the client and the server -> Man in the middle attacks are impossible. Use cases:
Verify API request authenticity (e.g., HMAC in JSON Web Tokens).
• Symmetric encryption
Uses a single secret key for encryption and decryption (e.g., AES) into cipher text and back into plain text. Common Algorithms are AES
Use cases:
Encrypt files/data at rest (e.g., disk encryption).
• Asymmetric encryption
Uses a public-private key pair (e.g., RSA). The encryption uses the public key to encrypt data before sending. The public key is not a secrete. The decryption can only happen by someone that has the private key which is a secrete.
Secure email communication (encrypt with recipient’s public key).
TLS handshakes for HTTPS.
• Digital signatures
The Hash value of a plain text message is encrypted with a private key to generate the digital signature. The plain text of the message alonge with the digital signature is send to a receiver. The reciver creates the hash value from the plain text message and compares it to the decrypted digital signature (using the public key) to prove integrety and authenticity.
Sign software updates to verify the publisher.
Explain the benefits of using salt in the context of storing passwords.
Salts are random data added to passwords before hashing. Benefits include:
Prevents rainbow table attacks: Unique salts ensure identical passwords produce different hashes.
Mitigates brute-force attacks: Attackers must crack each salted hash individually.
Identical passwords will still have different hashes because the salt is different. So even if the kacker knows the salt he/she would still have to create each of the possible passwords together with the salt to get to the hash.
Describe the differences between block- and stream ciphers.
Block Ciphers (e.g., AES):
Encrypt fixed-size blocks (e.g., 128 bits).
Require padding for incomplete blocks.
Stream Ciphers (e.g., ChaCha20):
Encrypt data bytewise or even bit-by-bit continuously.
No padding needed.
Describe the concept of block cipher padding.
Padding fills incomplete blocks to match the cipher’s block size (e.g., PKCS#7 adds bytes equal to the missing length). Example: A 10-byte block needing 6 more bytes adds 06 six times.
06
Describe the differences between ECB, CBC and CTR block cipher mode.
ECB:
Encrypts each block independently.
Risk: Reveals patterns (e.g., identical plaintext blocks → identical ciphertext).
CBC:
XORs each block of data with the previous block of ciphertext to produce the next block of cipher text.
Uses an Initialization Vector (IV) as the first block for randomness.
Secure: Hides patterns in plaintext.
CTR:
uses streaming mode so no padding is needed (e.g AES)
stream ciphers always produce cipher text with the same legth as the input
Describe the internal structure of a digital certificate.
A digital certificate is a doument used to prove the ownership of a public key. It includes:
Owner’s identification (e.g., domain name).
Public key of the owner.
Certificate Authority (CA) name (e.g., Let’s Encrypt).
CA’s digital signature to validate authenticity.
Expiration date (e.g., valid until 2025).
Example: HTTPS certificates validate website ownership and enable secure connections.
Last changed2 months ago