Bird
Raised Fist0
Cybersecurityknowledge~10 mins

Asymmetric encryption (RSA, ECC) in Cybersecurity - Interactive Code Practice

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the sentence to describe asymmetric encryption.

Cybersecurity
In asymmetric encryption, the [1] key is used to encrypt data.
Drag options to blanks, or click blank then click option'
Aprivate
Bpublic
Cshared
Dsecret
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing the private key as the one used for encryption.
Thinking both keys are the same.
2fill in blank
medium

Complete the sentence to explain RSA key generation.

Cybersecurity
RSA key generation involves selecting two large [1] numbers.
Drag options to blanks, or click blank then click option'
Aprime
Beven
Ccomposite
Drandom
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing composite numbers instead of prime numbers.
Assuming any random number can be used.
3fill in blank
hard

Fix the error in the explanation of ECC.

Cybersecurity
ECC uses [1] curves over finite fields for encryption.
Drag options to blanks, or click blank then click option'
Aelliptic
Bcircular
Cparabolic
Dlinear
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing elliptic with circular or linear curves.
Not knowing the type of curve ECC uses.
4fill in blank
hard

Fill both blanks to complete the description of asymmetric encryption keys.

Cybersecurity
The [1] key is kept secret, while the [2] key is shared publicly.
Drag options to blanks, or click blank then click option'
Aprivate
Bpublic
Cshared
Dencrypted
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up which key is public and which is private.
Thinking both keys are shared.
5fill in blank
hard

Fill all three blanks to complete the RSA encryption formula.

Cybersecurity
Ciphertext = (Plaintext [1] PublicKey) [2] Modulus; Decryption uses [3] key.
Drag options to blanks, or click blank then click option'
Araised to the power of
Bmod
Cprivate
Dmultiplied by
Attempts:
3 left
💡 Hint
Common Mistakes
Using multiplication instead of exponentiation.
Confusing which key is used for decryption.

Practice

(1/5)
1. What is the main purpose of asymmetric encryption like RSA and ECC?
easy
A. To use the same key for both encrypting and decrypting
B. To store passwords in plain text
C. To use two different keys: one to encrypt and one to decrypt
D. To speed up internet connections

Solution

  1. Step 1: Understand key usage in asymmetric encryption

    Asymmetric encryption uses two keys: a public key to encrypt and a private key to decrypt messages.
  2. Step 2: Compare with symmetric encryption

    Symmetric encryption uses the same key for both encrypting and decrypting, which is different from asymmetric encryption.
  3. Final Answer:

    To use two different keys: one to encrypt and one to decrypt -> Option C
  4. Quick Check:

    Asymmetric encryption = two keys (public/private) [OK]
Hint: Remember: public key encrypts, private key decrypts [OK]
Common Mistakes:
  • Confusing asymmetric with symmetric encryption
  • Thinking one key is used for both encrypting and decrypting
  • Believing encryption speeds up internet
  • Assuming passwords are stored in plain text
2. Which of the following is a correct statement about RSA keys?
easy
A. RSA does not use any mathematical operations
B. RSA uses a single key for both encryption and decryption
C. RSA keys are always 128 bits long
D. RSA keys are generated using large prime numbers

Solution

  1. Step 1: Recall RSA key generation method

    RSA keys are created by multiplying two large prime numbers to form the public and private keys.
  2. Step 2: Check other options for correctness

    RSA does not use a single key, keys are not fixed at 128 bits, and it heavily relies on math operations.
  3. Final Answer:

    RSA keys are generated using large prime numbers -> Option D
  4. Quick Check:

    RSA key generation = large primes [OK]
Hint: RSA keys come from multiplying big prime numbers [OK]
Common Mistakes:
  • Thinking RSA uses one key only
  • Assuming RSA keys have fixed small size
  • Ignoring the role of prime numbers
  • Believing RSA avoids math operations
3. Consider this simplified RSA encryption example:
public_key = (e=3, n=33)
private_key = (d=7, n=33)
message = 4
encrypted = (message^e) mod n
decrypted = (encrypted^d) mod n

What is the decrypted message?
medium
A. 4
B. 7
C. 3
D. 9

Solution

  1. Step 1: Calculate encrypted message

    encrypted = (4^3) mod 33 = 64 mod 33 = 31
  2. Step 2: Calculate decrypted message

    decrypted = (31^7) mod 33. Calculating 31^7 mod 33 gives 4 (using modular exponentiation).
  3. Final Answer:

    4 -> Option A
  4. Quick Check:

    Decrypted message matches original message [OK]
Hint: Encrypt then decrypt returns original message [OK]
Common Mistakes:
  • Forgetting to apply modulo operation
  • Mixing up public and private keys
  • Incorrectly calculating powers
  • Assuming encrypted equals decrypted
4. A developer wrote this ECC key generation snippet but it fails:
private_key = generate_ecc_key()
public_key = private_key * G

What is the likely error?
medium
A. Public key is generated by multiplying G by private key, not the other way
B. Private key must be a point, not a number
C. Private key cannot be used to generate public key
D. Multiplying private key by G is incorrect; should add G

Solution

  1. Step 1: Understand ECC key generation

    In ECC, the public key is generated by multiplying the base point G by the private key scalar.
  2. Step 2: Identify the error in code

    The code multiplies private_key by G, but the correct order is G multiplied by private_key.
  3. Final Answer:

    Public key is generated by multiplying G by private key, not the other way -> Option A
  4. Quick Check:

    ECC public key = G * private key [OK]
Hint: Order matters: base point times private key [OK]
Common Mistakes:
  • Reversing multiplication order
  • Confusing addition with multiplication
  • Thinking private key is a point
  • Believing private key can't generate public key
5. Why might ECC be preferred over RSA for securing mobile devices?
hard
A. RSA is faster and more efficient on mobile devices
B. ECC uses smaller keys for similar security, saving battery and space
C. ECC keys are easier to guess than RSA keys
D. ECC does not require a private key

Solution

  1. Step 1: Compare key sizes and efficiency

    ECC achieves strong security with smaller keys compared to RSA, which helps reduce processing power and battery use on mobiles.
  2. Step 2: Evaluate other options

    ECC keys are not easier to guess; RSA is generally slower on mobiles; ECC requires private keys like RSA.
  3. Final Answer:

    ECC uses smaller keys for similar security, saving battery and space -> Option B
  4. Quick Check:

    ECC = smaller keys, better for mobiles [OK]
Hint: Smaller keys mean less power use on mobiles [OK]
Common Mistakes:
  • Thinking ECC keys are weaker
  • Assuming RSA is faster on mobiles
  • Believing ECC doesn't use private keys
  • Ignoring battery and space constraints