1. Home
  2. Explore
  3. Computer Science
  4. Cryptography Fundamentals

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Cryptography Fundamentals

  • 35Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Cryptography Basics

What is the definition of cryptography according to the talk?

35 questions

  1. 1

    What is the definition of cryptography according to the talk?

    Model answer

    Cryptography is the study (or science) of techniques of secret communication or secret writing, based on the Greek word 'crypto' meaning hidden.

    Explanation

    The talk defines cryptography as the science of secret communication, emphasizing its root meaning 'hidden'.

  2. 2

    What are the three parties commonly used to illustrate cryptographic communication?

    Model answer

    Alice and Bob are the legitimate communicating parties, and Eve is the eavesdropper or malicious actor.

    Explanation

    The standard cryptographic example uses Alice and Bob for legitimate communication and Eve as the attacker.

  3. 3

    What is the difference between plaintext and ciphertext?

    Model answer

    Plaintext is the original readable message, while ciphertext is the encrypted, seemingly meaningless output.

    Explanation

    Encryption transforms plaintext into ciphertext; decryption reverses it.

  4. 4

    What does the Node.js crypto module rely on under the hood?

    Model answer

    The crypto module is a JavaScript wrapper on top of OpenSSL, an open-source widely used cryptographic library.

    Explanation

    The talk states the crypto module is built on OpenSSL.

  5. 5

    How can you get a list of all available encryption algorithms in Node.js?

    Model answer

    By calling crypto.getCiphers(), which returns an array of algorithm names (e.g., 171 on the speaker's machine).

    Explanation

    The talk demonstrates getCiphers() to show available ciphers.

  6. 6

    What is the key size of AES-256?

    Model answer

    AES-256 uses a key size of 256 bits.

    Explanation

    The number 256 in AES-256 refers to the key length in bits.

  7. 7

    What does CBC stand for in AES-256-CBC, and how does it work?

    Model answer

    CBC stands for Cipher Block Chaining, a mode where the plaintext is split into blocks and each block is encrypted separately, with chaining from the previous block.

    Explanation

    CBC mode processes data in blocks and uses chaining for security.

  8. 8

    Why is an initialization vector (IV) used in AES-CBC encryption?

    Model answer

    The IV is a random value that ensures that even if the same plaintext and key are used, the ciphertext will be different each time, preventing pattern detection.

    Explanation

    The IV adds randomness to make encryption non-deterministic and resist replay attacks.

  9. 9

    What Node.js functions are used to create a cipher object and finalize encryption?

    Model answer

    crypto.createCipheriv(algorithm, key, iv) creates the cipher, and then cipher.update(plaintext) and cipher.final() produce the ciphertext.

    Explanation

    The talk shows the typical encryption workflow using createCipheriv, update, and final.

  10. 10

    What is the corresponding decryption API for createCipheriv?

    Model answer

    crypto.createDecipheriv(algorithm, key, iv) is used for decryption, with decipher.update(ciphertext) and decipher.final() returning the plaintext.

    Explanation

    Decryption mirrors encryption using createDecipheriv.

  11. 11

    Why should a human-memorable password not be used directly as a cryptographic key?

    Model answer

    Human passwords have limited entropy, making them vulnerable to brute-force attacks; attackers can guess from a small set of common passwords.

    Explanation

    The talk warns against using passwords directly because they narrow the key space.

  12. 12

    What is a key derivation function (KDF) and what are its two key properties?

    Model answer

    A KDF derives a strong, long key from a password and is purposely slow (CPU and memory heavy) to thwart brute-force attacks.

    Explanation

    KDFs like scrypt are intentionally slow to increase the cost of guessing.

  13. 13

    What is the role of salt in a KDF?

    Model answer

    Salt is a random value added to the KDF input to prevent precomputed attacks (rainbow tables), forcing attackers to run the slow function for each attempt.

    Explanation

    Salt ensures that even if the same password is used, the derived key is different.

  14. 14

    Name three KDFs available in the Node.js crypto module. (scrypt, HKDF, PBKDF2)

    Model answer

    scrypt, HKDF, and PBKDF2 are available in the crypto module.

    Explanation

    The talk mentions these as built-in KDFs.

  15. 15

    Why is Math.random() unsuitable for cryptographic use?

    Model answer

    Math.random() is not cryptographically secure; an attacker can predict or influence its output.

    Explanation

    MDN documentation states it is not secure for cryptography, as mentioned in the talk.

  16. 16

    List four cryptographically secure random generation functions in Node.js.

    Model answer

    crypto.randomBytes(), crypto.randomFill(), crypto.randomInt(), and crypto.randomUUID().

    Explanation

    The talk enumerates these as secure alternatives.

  17. 17

    What is the key distribution problem?

    Model answer

    The challenge of how two parties can securely share a symmetric key over an insecure channel without meeting offline.

    Explanation

    The talk introduces this as a fundamental problem solved by Diffie-Hellman and RSA.

  18. 18

    How does the Diffie-Hellman key exchange allow Alice and Bob to generate a shared key?

    Model answer

    Alice and Bob agree on a prime and generator, each generate a private/public key pair, exchange public keys, and then independently compute the same shared secret using their private key and the other's public key.

    Explanation

    The talk describes the steps: Alice sends her public key, Bob sends his, and both derive the same key, while Eve cannot.

  19. 19

    What is a disadvantage of Diffie-Hellman compared to RSA?

    Model answer

    Diffie-Hellman requires a key exchange every time two parties want to communicate, whereas RSA allows anyone to encrypt messages using a published public key.

    Explanation

    The talk contrasts the two, noting that RSA avoids repeated key exchanges.

  20. 20

    What function in Node.js creates a Diffie-Hellman key exchange object? Why is it slow?

    Model answer

    crypto.createDiffieHellman(primeLength) creates the object; it is slow (e.g., 20 seconds) because generating a large prime is computationally expensive.

    Explanation

    The talk mentions the slowness of key generation.

  21. 21

    What is ECDH and why is it mentioned?

    Model answer

    ECDH (Elliptic Curve Diffie-Hellman) is a variant of Diffie-Hellman using elliptic curve cryptography, widely used today.

    Explanation

    The talk notes ECDH as another notable key exchange method.

  22. 22

    What problem does RSA solve that Diffie-Hellman does not?

    Model answer

    RSA eliminates the need for key exchange entirely by using a public key for encryption and a private key for decryption; the public key can be shared openly.

    Explanation

    RSA is an asymmetric encryption algorithm that avoids the key distribution problem.

  23. 23

    What are the steps for RSA key generation in Node.js?

    Model answer

    Call crypto.generateKeyPair('rsa', options, callback) to generate a key pair, then export the keys using publicKey.export() and privateKey.export().

    Explanation

    The talk shows the generateKeyPair function for RSA.

  24. 24

    Which functions are used for RSA encryption and decryption in Node.js?

    Model answer

    crypto.publicEncrypt(publicKey, buffer) for encryption and crypto.privateDecrypt(privateKey, buffer) for decryption, both requiring a padding parameter.

    Explanation

    The talk demonstrates these functions for asymmetric operations.

  25. 25

    What is the current threat to RSA mentioned in the talk?

    Model answer

    Researchers have demonstrated that a sufficiently powerful quantum computer could break RSA encryption, though it is not yet a practical concern for commercial use.

    Explanation

    The talk acknowledges quantum computing as a future threat but notes it is not immediate.

  26. 26

    What is the purpose of digital signatures?

    Model answer

    Digital signatures allow a recipient to verify that a message came from the claimed sender and has not been tampered with.

    Explanation

    The talk introduces signing to address authenticity and integrity.

  27. 27

    How does Alice create a digital signature in Node.js?

    Model answer

    Alice calls crypto.sign(algorithm, data, privateKey) where algorithm is a hash function like 'sha256', producing a signature.

    Explanation

    The talk shows the sign function with a hash algorithm and private key.

  28. 28

    How does Bob verify Alice's signature?

    Model answer

    Bob calls crypto.verify(algorithm, data, publicKey, signature) which returns true if the signature is valid.

    Explanation

    Verification uses the public key and the same hash algorithm.

  29. 29

    What is HMAC and when is it used?

    Model answer

    HMAC (Hash-based Message Authentication Code) is used for signing and verification in symmetric cryptography (where both parties share a secret key).

    Explanation

    The talk mentions HMAC as relevant to symmetric signing.

  30. 30

    What are the four parts of a digital certificate as illustrated in the talk?

    Model answer

    The certificate includes: who it is issued to (subject), what it claims (e.g., public key), who issued it (issuer), and a digital signature.

    Explanation

    The talk uses a physical certificate analogy to explain these components.

  31. 31

    What is a certificate signing request (CSR)?

    Model answer

    A CSR is a request containing a public key and metadata about the subject, which is then signed by a certificate authority (CA) to create a certificate.

    Explanation

    The talk describes the CSR as the data to be signed.

  32. 32

    What is the X.509 specification used for?

    Model answer

    X.509 is the standard format for structuring digital certificates, including public keys, identity information, and signatures.

    Explanation

    The talk references X.509 as the specification for certificates.

  33. 33

    How is a certificate verified in Node.js using the crypto module?

    Model answer

    Load the certificate using new x509.Certificate(certPem) and call certificate.verify(caCertificate) to verify it using the issuer's public key.

    Explanation

    The talk shows using the x509Certificate class and its verify method.

  34. 34

    What is a certificate chain (hierarchy)?

    Model answer

    A certificate chain is a sequence of certificates where each certificate is signed by the next one, ending at a root certificate that is inherently trusted (e.g., baked into the OS).

    Explanation

    The talk explains trust propagation from a root authority down to leaf certificates.

  35. 35

    How does a browser verify a website's certificate?

    Model answer

    The browser follows the certificate chain, verifying each certificate using the issuer's public key until it reaches a trusted root certificate built into the operating system.

    Explanation

    The talk uses the example of visiting a website and verifying the certificate chain.

1 of 35
Question 1 of 35

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent