[Figure: FiveStudy logo]
FiveStudy
Cybersecurity · Unit 5 · 5.4.a
AP Cybersecurity · Securing Applications and Data
Choosing the Asymmetric Key
Public to encrypt, private to decrypt — and both of them belong to the receiver.
key ideaAlways the receiver’s key pair: public to encrypt, private to decrypt.
exam-day recap
- Asymmetric encryption lets two parties communicate securely without prearranging a shared secret key.
- The public key is held by anyone and published freely; the private key is held only by its owner.
- To send confidentially to Bob, encrypt with Bob's public key and decrypt with Bob's private key.
- The sender never uses a key of their own to send confidentially; Alice's own keys play no part in sending to Bob.
- A private key cannot be derived from the public key — that infeasibility is what makes the scheme work.
- If a private key is exposed, shared, stolen, corrupted or compromised, delete the pair and generate a new one.
- The key pair is two binary strings of equal length, generated together through a mathematical process.
- Encrypting with your own private key proves origin (authenticity), not confidentiality — they are separate goals.
- Sending the same file to two recipients uses each recipient's own public key, separately.
The mechanism
Asymmetric encryption exists to solve one problem: letting two parties communicate securely without prearranging a shared secret key. With symmetric encryption both sides need the same key, and getting it to the other side safely is the hard part. Asymmetric encryption removes that step entirely.
One direction of traffic. Alice encrypts with Bob’s public key; only Bob’s private key can undo it. Alice’s own keys play no part in sending to Bob.| Step | Who does it | Which key | Why that one |
|---|
| Generate the key pair | the receiver, before any message arrives | both, at once | the pair is two binary strings of equal length, generated together through a mathematical process |
| Publish | the receiver | public key | it can be shared with anyone; no secrecy is needed or possible |
| Store securely | the receiver | private key | it is the only thing that can decrypt; its secrecy is the whole security of the scheme |
| Encrypt a message | the sender | the receiver’s public key | so that only the holder of the matching private key can read it |
| Decrypt the message | the receiver | their own private key | the mathematical partner of the public key used to encrypt |
Notice the sender never uses a key of their own to send confidentially. If a question asks “which key does Alice use to send to Bob?”, the answer is always Bob’s public key.
Keys and who holds them
| Public key | Private key |
|---|
| Who holds it | anyone — published freely | only its owner |
| Used to | encrypt data being sent to the owner | decrypt data sent to the owner |
| If exposed | no impact — exposure is the point | the key pair must be deleted and a new pair generated |
| Can it be derived from the other? | n/a | no — that infeasibility is what makes the scheme work |
If a private key is exposed, shared, stolen, corrupted or compromised, the pair is dead: delete it and generate a new one. Rotating only the public key is meaningless — they are generated together.
| Scenario | Encrypt with | Decrypt with |
|---|
| Alice sends confidential data to Bob | Bob’s public key | Bob’s private key |
| Bob replies confidentially to Alice | Alice’s public key | Alice’s private key |
| Alice sends the same file to Bob and Carol | each recipient’s own public key, separately | each recipient’s own private key |
| Alice stores a file only she will read | her own public key | her own private key |
Two-way confidential conversation needs two key pairs — one per receiver. Each direction uses the key pair of whoever is receiving.
Worked analysis
EX 1
Pick the key for each direction
Alice wants to send Bob a confidential contract, and Bob wants to send a confidential reply. List exactly which keys are used and who must generate what.
1
Establish who receives first
Alice is sending, so Bob is the receiver. Bob must already have generated a key pair and published his public key.
2
Encrypt the contract
Alice encrypts with Bob’s public key. She does not need a key pair of her own for this step.
3
Decrypt the contract
Bob decrypts with his own private key — the only key that can undo the encryption.
4
Reverse the direction
For the reply, Alice is now the receiver. She must have her own key pair and have published her public key.
5
Encrypt and decrypt the reply
Bob encrypts with Alice’s public key; Alice decrypts with her own private key.
6
Count the keys
Two key pairs, four keys, and neither private key ever moves. The public keys can be exchanged over an insecure channel — that is the point.
EX 2
Diagnose the wrong key choice
A student writes: “Alice encrypts the file with her own private key so Bob knows it came from her, and Bob decrypts it with her public key. The file is now confidential.” What is right and what is wrong?
1
Check whether it decrypts
Mechanically it works: something encrypted with Alice’s private key can be decrypted with her public key.
2
Ask who can decrypt it
Alice’s public key is public. Anyone at all can obtain it and decrypt the file.
3
Name the failure
The file is not confidential. Confidentiality requires that only the intended receiver can decrypt, which means encrypting with that receiver’s public key.
4
Salvage what is correct
The student’s instinct about origin is not silly — encrypting with a private key does demonstrate it came from the holder. But that is authenticity, not confidentiality.
5
Give the fix
To send Bob a confidential file, encrypt with Bob’s public key. Confidentiality and proof-of-origin are separate goals needing separate key choices.
EX 3
A private key is exposed
Bob accidentally commits his private key file to a public code repository. He deletes the file an hour later. What must he do, and what data is affected?
1
Treat exposure as permanent
The key was publicly readable for an hour; it must be assumed copied. Deleting the file does not undo the disclosure.
2
Apply the CED rule
If a private key is exposed, shared, stolen, corrupted or compromised, the key pair must be deleted and a new key pair generated.
3
Publish the new public key
Bob generates a fresh pair, stores the new private key securely, and distributes the new public key to everyone who sends him data.
4
Assess the damage
Anything previously sent to Bob and encrypted with the old public key is now readable by whoever took the private key — including messages captured earlier and stored.
5
Note what is not affected
Data Bob sent to others was encrypted with their public keys, so it remains secure. Only inbound traffic to Bob is compromised.
6
Close the loop
Anything still sensitive that was sent under the old pair should be re-sent under the new one.
Watch out
It is always the receiver’s key pair
Both the encrypting key and the decrypting key belong to whoever is receiving. The sender’s own keys are irrelevant to confidentiality.
A public key cannot decrypt what it encrypted
Encryption is one-way with respect to the pair. Only the matching private key reverses it — which is why publishing the public key costs nothing.
Exposure kills the pair, not just the key
The two keys are generated together and are mathematically linked. A compromised private key means deleting the pair and generating a new one, then redistributing the new public key.
Confidentiality and origin are different jobs
Encrypting with your own private key proves the message came from you; it does not hide it. Do not offer it as an answer to a confidentiality question.
Check yourself
What problem does asymmetric encryption solve that symmetric encryption does not?
Show answer
It lets users communicate securely without prearranging a shared secret key — there is no need to get a secret to the other party over a safe channel first.
Alice sends confidential data to Bob. Which key encrypts it, and which decrypts it?
Show answer
Bob’s public key encrypts it; Bob’s private key decrypts it. Both keys belong to the receiver.
Who must generate a key pair before any encrypted message can be sent to them, and why?
Show answer
The receiver. The sender needs the receiver’s public key to encrypt, so the pair must exist and the public half must be published first.
What are the two halves of a key pair, physically speaking?
Show answer
Two binary strings of equal length, generated at the same time through a mathematical process that links them.
A private key is stolen. What is the required response?
Show answer
Delete the key pair and generate a new one, then distribute the new public key. Rotating only one half is not possible — the two are generated together.
Alice sends the same confidential file to Bob and to Carol. How many encryptions and which keys?
Show answer
Two separate encryptions — one with Bob’s public key and one with Carol’s public key. Each recipient decrypts with their own private key.
Why is it safe to send a public key over an insecure channel?
Show answer
Because it can only be used to encrypt data destined for its owner. An eavesdropper who obtains it gains no ability to decrypt anything.