First exams 2027 · SL & HL 2027 年首次开考 · SL 与 HL

A2.4.4 · Network security

A2.4.4 · 网络安全

Encryption and digital certificates

加密与数字证书

Encryption doesn't stop data from being intercepted. It stops an interceptor from understanding what they've got. That difference is the whole statement.

加密并不能阻止数据被截获。它阻止的是截获者理解他们所获得的内容。这个区别正是本考纲陈述的全部要点。

Core for SL & HL SL 与 HL 核心内容 Typically 3–6 marks · AO2 通常 3–6 分 · AO2 Command term: describe 命令词:describe(描述)

Explainer

讲解

Imagine sealing a letter inside a locked box before sending it. Anyone can still pick the box up, carry it away, or hand it to the wrong person. What they can't do is open it and read the letter, unless they also have the key. Encryption works exactly like the locked box, not like making the letter vanish.

想象一下,把一封信封进一个上了锁的箱子里再寄出。任何人仍然可以拿起这个箱子、带走它,或把它交给错误的人。他们做不到的是打开箱子读信,除非他们也拥有钥匙。加密的运作方式正如同这个上锁的箱子,而不是让信件凭空消失。

Df

Feeding readable data (plaintext) through an algorithm and a key produces a scrambled, unreadable result (ciphertext). This is encryption. Running the matching key back through the reverse of that algorithm, decryption, is the only way to get the original plaintext back.

将可读数据(明文)输入一个算法并配合一个密钥,会产生一份混乱、不可读的结果(密文)。这个过程就是加密。用匹配的密钥反向执行该算法,即解密,是取回原始明文的唯一方法。

Encrypted does not mean untouchable 加密并不代表不可触碰

Encrypted data can still be intercepted, copied, or stolen exactly as easily as unencrypted data. Encryption doesn't prevent access to the data at all, it prevents the data from being understood once accessed, unless the correct key is also available. Someone without the key who steals encrypted data has a file full of meaningless scrambled bytes, not nothing.

加密后的数据仍然可以被截获、复制或窃取,难度和未加密的数据完全一样。加密根本不能阻止数据被获取,它阻止的是数据在被获取之后被理解,除非同时拥有正确的密钥。没有密钥的人即使窃取了加密数据,得到的也只是一份毫无意义的混乱字节文件,而不是什么都得不到。

Explainer

讲解

Symmetric vs asymmetric encryption

对称加密与非对称加密

The two approaches differ in exactly one thing: whether locking and unlocking rely on one shared key or two separate ones.

这两种方式的区别只有一点:加锁和解锁依赖的是一把共享密钥,还是两把各自独立的密钥。

Symmetric encryption 对称加密

Shape: a single shared key does both jobs, scrambling and unscrambling alike.

形式:一把共享密钥同时完成加密与解密两项工作。

Advantage

优点

  • Fast (far less computationally intensive, so it's the practical choice for encrypting large amounts of data)
  • 速度快 (计算量远小得多,因此是加密大量数据时的实用选择)

Disadvantage

缺点

  • The key-sharing problem (both sides need the exact same key before they can communicate securely, and safely getting that key to the other person, especially over a distance, is itself a real security challenge)
  • 密钥共享问题 (双方必须先拥有完全相同的密钥才能安全通信,而将该密钥安全地传给对方,尤其是在远距离情况下,本身就是一项真实的安全挑战)
Asymmetric encryption 非对称加密

Shape: two mathematically linked keys, a public one and a private one, each doing a different job.

形式:两把数学上相互关联的密钥,一把公钥、一把私钥,各自承担不同的工作。

Advantage

优点

  • Solves the key-sharing problem (the public key can be handed out openly, to literally anyone, with no secure channel needed, since it's useless to an attacker without the matching private key)
  • 解决了密钥共享问题 (公钥可以公开分发给任何人,不需要安全通道,因为没有匹配的私钥,公钥对攻击者毫无用处)

Disadvantage

缺点

  • Slower (the underlying maths is far more processing-intensive, which is why it isn't used to encrypt large volumes of data directly)
  • 速度较慢 (其底层数学运算的处理开销大得多,这也是它不直接用于加密大量数据的原因)

Explainer

讲解

Two different uses for the same key pair

同一对密钥的两种不同用途

A public/private key pair is used in two genuinely different ways, and mixing them up is a very easy mistake to make.

一对公钥/私钥有两种截然不同的用法,而把它们弄混是一个非常容易犯的错误。

GoalEncrypted/signed withChecked/decrypted with
Keep a message secret (confidentiality)Sender locks it with whichever public key belongs to the intended readerOnly that same person's matching private key can unlock it
Prove who really sent something (authenticity)Sender signs using their own private keyAnyone can check it using the sender's public key
目标用什么加密/签名用什么核验/解密
保守消息秘密(保密性)发送者用接收者所属的公钥加锁只有该接收者匹配的私钥才能解锁
证明消息确实由某人发送(真实性)发送者用自己的私钥签名任何人都可以用发送者的公钥核验

Notice the two rows use the keys in opposite directions. For secrecy, the public key locks and only the matching private key unlocks. For proving identity, the private key is what creates the signature, and the public key is what anyone can use to check it's genuine.

注意这两行使用密钥的方向正好相反。为了保密,公钥加锁,只有匹配的私钥能解锁。为了证明身份,私钥用来生成签名,而公钥则是任何人都可以用来核验签名真伪的工具。

Try it yourself

动手试一试

A toy cipher, plaintext to ciphertext

一个玩具密码:从明文到密文

Real encryption algorithms rely on much harder mathematics than this, but the basic shape, the SAME key scrambles the message going one way and unscrambles it coming back, is genuinely how symmetric encryption behaves. This shifts every character's code by a fixed number.

真正的加密算法依赖的数学远比这复杂得多,但其基本形式,即同一把密钥朝一个方向打乱消息、朝反方向还原消息,正是对称加密真实的运作方式。下面的程序会把每个字符的编码值平移一个固定的数字。

main.py
Loading Python engine…
Output
输出
Press Run to see the output here.

Running in offline fallback mode. The full Python engine couldn't load (blocked school network, or no internet), so this console switched automatically to a small hand-written engine. It supports this page's functions and character codes, but it isn't full Python.

正在以离线备用模式运行。完整的 Python 引擎未能加载(可能是学校网络受限,或没有网络连接),因此该控制台自动切换为一个小型的自制引擎。它支持本页所用的函数和字符编码运算,但并非完整的 Python。

ord(char) gives a character's underlying numeric code, chr(code) does the reverse. This "toy" cipher is trivially breakable (trying all 255 possible shift values would crack it instantly), real algorithms like AES and RSA rely on mathematics that can't be brute-forced in any practical amount of time, but the core idea, the same key run one direction to scramble and the other to unscramble, is genuinely symmetric encryption's own shape.

ord(char) 给出字符底层的数字编码,chr(code) 则执行相反的操作。这个"玩具"密码非常容易被破解(尝试全部 255 种可能的平移值即可瞬间破解),真正的算法如 AES 和 RSA 所依赖的数学在任何实际可行的时间内都无法被暴力破解,但其核心思想,即同一把密钥朝一个方向运行来打乱、朝另一个方向运行来还原,正是对称加密本身真实的形式。

Explainer

讲解

How a digital certificate is trusted

数字证书如何建立信任

Encrypting a connection only helps if you're actually talking to the right server in the first place. Ruby runs a small online bakery and wants her checkout page to be trustworthy, not just encrypted.

对连接进行加密,前提是你确实在与正确的服务器通信,否则加密本身毫无帮助。Ruby 经营着一家小型网上烘焙店,她希望自己的结账页面不仅仅是加密的,更是可信的。

Getting and using a digital certificate 获取并使用数字证书 Step 1 of 5

1. Generate a key pair. Ruby's server generates a matched pair of keys, one public, one private. The private half never leaves her server.

1. 生成一对密钥。Ruby 的服务器生成一对匹配的密钥,一把公钥、一把私钥。私钥这一半永远不会离开她的服务器。

2. Request a certificate. Ruby sends her public key, together with proof she genuinely controls her own domain, to a certificate authority (CA), a third party both her and her future customers already trust.

2. 申请证书。Ruby 将她的公钥,连同她确实拥有该域名控制权的证明,一同发送给证书颁发机构(CA),这是一个她和她未来的顾客都已经信任的第三方。

3. The CA verifies and signs. Once satisfied Ruby is who she claims to be, the CA issues a digital certificate binding Ruby's public key to her identity, and signs it using the CA's own private key.

3. CA 核实并签名。一旦确认 Ruby 确实是她所声称的身份,CA 便签发一份将 Ruby 的公钥与她的身份绑定在一起的数字证书,并用 CA 自己的私钥对其进行签名。

4. The certificate is installed. Ruby installs the signed certificate on her web server.

4. 安装证书。Ruby 将已签名的证书安装到她的网络服务器上。

5. A customer's browser checks it. When a customer visits the checkout page, their browser checks the certificate's signature using the CA's own public key (already built into the browser). If it checks out, the browser trusts that this really is Ruby's server, not an imposter, and the padlock icon appears.

5. 顾客的浏览器进行核验。当顾客访问结账页面时,他们的浏览器会用 CA 自己的公钥(已内置于浏览器中)核验证书的签名。如果核验通过,浏览器便会相信这确实是 Ruby 的服务器,而非冒充者,随后出现挂锁图标。

!

A digital certificate answers a different question than encryption does. Encryption asks "can this data be understood if intercepted?" A certificate asks "am I actually talking to who I think I am?" A connection can be perfectly encrypted and still be with an imposter, if there's no certificate checking identity, which is exactly why HTTPS needs both.

数字证书回答的是一个与加密不同的问题。加密回答的是"这份数据如果被截获,能否被理解?"证书回答的是"我确实是在与我以为的那个对象通信吗?"一段连接可以被完美地加密,却仍然是与冒充者进行的,如果没有证书来核验身份的话,这正是 HTTPS 需要同时具备这两者的原因。

Explainer

讲解

Why key management matters

为什么密钥管理如此重要

A key is only as safe as the process around it. An encryption algorithm can be mathematically unbreakable and still fail completely if the key itself is handled carelessly.

一把密钥的安全程度,取决于围绕它的整套流程。即使一个加密算法在数学上牢不可破,只要密钥本身被草率处理,整个系统仍会彻底失效。

!

Creation and distribution: a key has to be generated securely and get to the right people without being exposed along the way, exactly the problem asymmetric encryption was built to solve.

生成与分发:密钥必须安全地生成,并在传递给正确的人时不被沿途暴露,这正是非对称加密所要解决的问题。

Storage: if an attacker gains access to a private key, they can impersonate its owner completely, decrypting anything meant for them or signing anything as them. A stolen key is often worse than a stolen password, since a password can usually be reset far more easily than an entire trust relationship can be rebuilt.

存储:如果攻击者取得了某把私钥,他们就能完全冒充其所有者,解密所有原本发给该所有者的内容,或以其名义签署任何东西。被盗的密钥往往比被盗的密码更糟糕,因为密码通常可以轻松重设,而整套信任关系被重建的难度要大得多。

Retirement and deletion: old keys eventually need to be retired (a certificate expires, an employee leaves), and done properly, so a retired key can't quietly keep working somewhere it shouldn't.

退役与删除:旧密钥最终需要被退役(证书到期、员工离职等情形),而且必须妥善处理,以确保一把已退役的密钥不会在不该继续起作用的地方悄悄发挥作用。

This is also a real compliance requirement in many industries, regulations covering healthcare and payment data specifically mandate documented key-management practices, not just "strong encryption" as a vague claim.

这在许多行业中也是一项真实的合规要求,涵盖医疗保健与支付数据的法规明确规定了必须有据可查的密钥管理规范,而不能只是笼统地宣称"采用了强加密"。

Check your understanding

检验你的理解

Isla wants to send Jack a message that only Jack can read. Which key should Isla use to encrypt it?

Isla 想给 Jack 发送一条只有 Jack 能读懂的消息。Isla 应该用哪一把密钥来加密?

Common mistake

常见错误

Markers reported this pattern extremely frequently, across many separate real questions 考官在许多不同的真实试题中都极为频繁地报告了这一模式

RecurringBy far the most common error on this whole topic is believing encrypted data becomes completely inaccessible or unreachable. It doesn't. It becomes unreadable without the key, which is a different claim entirely.

反复出现在整个主题中,迄今为止最常见的错误就是认为加密数据变得完全无法获取或不可触及。事实并非如此。没有密钥的话,数据只是变得不可读,这与"无法获取"是完全不同的说法。

✕

"Can't be accessed": "Encryption stops the data from being intercepted, so a hacker can't get it." A hacker can still intercept, copy, or steal encrypted data exactly as they would unencrypted data. Encryption never stops the data from being reached, only from being understood once it is.

"无法获取": "加密能阻止数据被截获,所以黑客无法拿到它。" 黑客仍然可以像对待未加密数据一样截获、复制或窃取加密数据。加密从来不会阻止数据被获取,它只阻止数据在被获取之后被理解。

✓

"Can't be understood": "Encryption scrambles readable data into ciphertext using a key. A hacker who intercepts the ciphertext can still access it, but without the correct decryption key they cannot understand or make use of what they've captured." States precisely what encryption does and doesn't do: nothing about interception, everything about comprehension.

"无法被理解": "加密使用密钥将可读数据打乱成密文。截获密文的黑客仍然可以拿到它,但如果没有正确的解密密钥,他们就无法理解或利用所截获的内容。" 精确说明了加密能做到什么、不能做到什么:与阻止截获无关,关键全在于阻止理解。

Revision questions

复习题

Past-paper style. Write an answer, then reveal the marking points and mark yourself.

采用历年真题风格。写下答案,然后展开评分要点给自己打分。

Question 1 · 3 marks 第 1 题 · 3 分

[3]Describe what happens to data during encryption, making clear what encryption does and does not protect against.

[3]描述数据在加密过程中发生了什么,并明确说明加密能够以及不能防范的内容。

Question 2 · 4 marks 第 2 题 · 4 分

[4]Distinguish between symmetric and asymmetric cryptography, referring to both how keys are used and a genuine advantage of each.

[4]区分对称加密与非对称加密,须同时涉及密钥的使用方式,以及各自一项真实的优点。

Question 3 · 5 marks 第 3 题 · 5 分

[5]Describe the role of a certificate authority in establishing a secure connection to a website, and explain why encryption alone would not be enough without it.

[5]描述证书颁发机构在建立与网站的安全连接过程中所扮演的角色,并解释为什么仅有加密而没有它是不够的。

Flashcards

记忆卡片

Active recall for this statement’s key terms.

针对本条考纲陈述关键术语的主动回忆练习。

Prototype render · mistake pattern grounded in real IB CS 2027 marker-report findings · not yet wired to live routes