← 返回资讯屏轩教育 · 行业资讯

Encryption Key Concepts for IB & CCEA Computer Science | IB/CCEA 计算机加密考点精讲

2026-07-14 23:28 · 本文部分内容由AI辅助创作

📚 Encryption Key Concepts for IB & CCEA Computer Science | IB/CCEA 计算机加密考点精讲

Encryption is the process of transforming readable data (plaintext) into an unreadable format (ciphertext) using an algorithm and a key. It forms the backbone of modern digital security, ensuring confidentiality, integrity, and authenticity of information across networks. In IB and CCEA Computer Science syllabi, encryption appears in topics such as system security, data transmission, and ethical computing. A solid grasp of symmetric and asymmetric encryption, hashing, digital signatures, and practical protocols like SSL/TLS is essential for achieving high marks in both coursework and examinations.

加密是利用算法和密钥将可读数据(明文)转换为不可读格式(密文)的过程。它是现代数字安全的基石,保障信息在网络传输中的机密性、完整性和真实性。在IB和CCEA计算机科学课程中,加密出现在系统安全、数据传输和计算机伦理等主题中。扎实掌握对称与非对称加密、哈希、数字签名以及SSL/TLS等实际协议,对于在作业和考试中取得高分至关重要。


1. Core Terminology in Cryptography | 密码学核心术语

Before diving into algorithms, students must be able to define plaintext, ciphertext, encryption, decryption, key, cipher, and cryptanalysis with precision. Plaintext is the original intelligible message; ciphertext is the encrypted output. The encryption algorithm (cipher) mathematically transforms plaintext into ciphertext using a key, and decryption reverses this process. A key is a piece of information that determines the functional output of the cryptographic algorithm. Cryptanalysis refers to techniques used to break encryption without possession of the key.

在深入算法之前,学生必须能够准确定义明文、密文、加密、解密、密钥、密码和密码分析。明文是原始可读的信息,密文是加密后的输出。加密算法(密码)利用密钥通过数学方法将明文转换为密文,解密则相反。密钥是决定密码算法功能输出的信息。密码分析是指在未持有密钥的情况下破解加密的技术。


2. Symmetric Encryption | 对称加密

Symmetric encryption uses the same secret key for both encryption and decryption. It is fast and efficient, making it suitable for bulk data encryption. Common examples include AES (Advanced Encryption Standard) and the older DES (Data Encryption Standard). The main challenge lies in securely distributing the shared key between communicating parties, known as the key distribution problem. If the key is intercepted during transmission, all encrypted data becomes vulnerable.

对称加密使用相同的密钥进行加密和解密。它速度快、效率高,适合大量数据加密。常见的例子包括AES(高级加密标准)和较早的DES(数据加密标准)。主要挑战在于如何在通信双方之间安全地分发共享密钥,这被称为密钥分发问题。如果密钥在传输过程中被截获,所有加密数据将变得脆弱。

Block ciphers like AES divide plaintext into fixed-size blocks (e.g. 128 bits) and encrypt each block separately, often using modes of operation such as CBC (Cipher Block Chaining). Stream ciphers, on the other hand, encrypt data one bit or byte at a time, generating a pseudorandom keystream that is XORed with the plaintext. RC4 is a well-known but now deprecated stream cipher.

像AES这样的分组密码将明文分成固定大小的块(如128位),并分别加密每个块,通常采用CBC(密码块链接)等工作模式。流密码则一次加密一位或一个字节数据,生成伪随机密钥流并与明文进行异或操作。RC4是一种著名但已弃用的流密码。


3. Asymmetric Encryption | 非对称加密

Asymmetric encryption, also called public-key cryptography, uses a pair of mathematically linked keys: a public key for encryption and a private key for decryption. The public key can be distributed openly, while the private key remains secret. This elegantly solves the key distribution problem. RSA (Rivest–Shamir–Adleman) and ElGamal are classic asymmetric algorithms, with RSA relying on the difficulty of factoring large prime numbers.

非对称加密,也称公钥密码学,使用一对数学上关联的密钥:用于加密的公钥和用于解密的私钥。公钥可以公开分发,而私钥则保持秘密,这巧妙地解决了密钥分发问题。RSA(Rivest–Shamir–Adleman)和ElGamal是经典的非对称算法,其中RSA依赖于大质数因式分解的难度。

q are chosen. Their product n = p × q becomes part of both keys. Euler’s totient φ(n) = (p–1)(q– e of e modulo φ(n). Encryption of message M yields ciphertext C = Mᵉ mod n; decryption computes M = Cᵈ mod n. These operations are computationally intensive, so asymmetric encryption is typically used to securely exchange symmetric session keys rather than encrypt large volumes of data directly.

在RSA密钥生成过程中,选择两个大质数 p 和 q。它们的乘积 n = p × q 成为两个密钥的一部分。计算欧拉函数 φ(n) = (p–1)(q–1),并选择一个公开指数 e,满足 1 < e < φ(n) 且 gcd(e, φ(n)) = 1。私密指数 d 是 e 模 φ(n) 的乘法逆元。加密消息 M 得到密文 C = Mᵉ mod n;解密计算 M = Cᵈ mod n。这些操作计算量大,因此非对称加密通常用于安全交换对称会话密钥,而非直接加密大量数据。


4. Hashing and Integrity Checking | 哈希与完整性校验

A hash function takes an input of arbitrary size and produces a fixed-size output called a hash digest or checksum. Hashing is a one-way function, meaning it is computationally infeasible to reverse the process. It is widely used to verify data integrity and store passwords securely. Common hashing algorithms include SHA-256, SHA-3, and the now-broken MD5 and SHA-1.

哈希函数接受任意大小的输入,并产生一个固定大小的输出,称为哈希摘要或校验和。哈希是一种单向函数,即在计算上无法逆转该过程。它广泛用于验证数据完整性和安全存储密码。常见的哈希算法包括SHA-256、SHA-3,以及现已不安全的MD5和SHA-1。

esistance (given m₁, impossible to find m₂ ≠ m₁ with the same hash), and collision resistance (impossible to find any pair m₁ ≠ m₂ with the same hash). In password storage, systems do not store the plaintext password but its salted hash – ring (salt) concatenated with the password before hashing to defeat rainbow table attacks.

安全密码哈希函数的属性:原像抵抗(给定 h,无法找到 m 使得 hash(m) = h)、第二原像抵抗(给定 m₁,无法找到 m₂ ≠ m₁ 使得哈希相同)、以及碰撞抵抗(无法找到任意一对 m₁ ≠ m₂ 哈希值相同)。在密码存储中,系统不存储明文密码,而是存储其加了盐的哈希值——在哈希之前将一个随机字符串(盐)与密码拼接,以挫败彩虹表攻击。


5. Digital Signatures and Certificates | 数字签名与证书

A digital signature is created by encrypting a hash of the message with the sender's private key. It provides authentication (the receiver can verify the sender’s identity), non-repudiation (the sender cannot deny having sent the message), and integrity (any tampering with the message will invalidate the signature). The receiver decrypts the signature with the sender's public key, recomputes the hash of the received message, and compares the two hashes.

数字签名通过使用发送者的私钥加密消息的哈希而创建。它提供认证(接收者可以验证发送者身份)、不可否认性(发送者无法否认发送过该消息)和完整性(任何对消息的篡改都会使签名失效)。接收者使用发送者的公钥解密签名,重新计算收到消息的哈希,并比较这两个哈希值。

Digital certificates bind a public key to an identity (e.g. domain name) and are issued by a trusted third party called a Certificate Authority (CA). The X.509 standard defines the format of these certificates, which include the subject’s public key, validity period, issuer’s digital signature, and other metadata. Certificates form the trust foundation of HTTPS and email encryption.

数字证书将公钥与一个身份(如域名)绑定,并由称为证书颁发机构(CA)的受信第三方签发。X.509标准定义了这些证书的格式,包含主体的公钥、有效期、签发者的数字签名和其他元数据。证书构成了HTTPS和邮件加密的信任基础。


6. SSL/TLS and Transport Layer Security | SSL/TLS与传输层安全

Secure Sockets Layer (SSL) and its successor Transport Layer Security (TLS) are cryptographic protocols that provide secure communication over a computer network. They operate between the application layer and the transport layer, typically protecting HTTP traffic to form HTTPS. The TLS handshake negotiates cipher suite (algorithms for key exchange, encryption, and MAC), authenticates the server (and optionally the client) using digital certificates, and establishes a shared session key using a hybrid approach: asymmetric encryption for key exchange (e.g. Diffie–Hellman) and symmetric encryption for bulk data transfer.

安全套接字层(SSL)及其后继者传输层安全(TLS)是提供计算机网络间安全通信的加密协议。它们工作在应用层和传输层之间,通常保护HTTP流量形成HTTPS。TLS握手会协商密码套件(包括密钥交换、加密和消息认证码的算法),使用数字证书认证服务器(以及可选的客户端),并通过混合方式建立共享会话密钥:非对称加密用于密钥交换(如Diffie–Hellman),对称加密用于批量数据传输。

A simplified TLS 1.3 handshake: Client sends a "ClientHello" with supported cipher suites and a Diffie–Hellman key share. Server responds with "ServerHello" choosing a cipher suite, its own key share, and its certificate. Both parties compute the premaster secret and then derive symmetric session keys. Finished messages are exchanged encrypted with these keys. This reduces the handshake to one round-trip, improving performance.

简化的TLS 1.3握手:客户端发送“ClientHello”,包含支持的密码套件和Diffie–Hellman密钥份额。服务器以“ServerHello”回应,选择一个密码套件、提供自己的密钥份额和证书。双方计算预主密钥,然后推导出对称会话密钥。随后交换的Finished消息均使用这些密钥加密。这使握手减少到一次往返,提升了性能。


广告 / Sponsored

7. Symmetric vs. Asymmetric: A Comparison | 对称与非对称对比

Feature / 特征Symmetric Encryption / 对称加密Asymmetric Encryption / 非对称加密
Keys / 密钥Single shared key / 单一共享密钥Public & private key pair / 公钥私钥对
Speed / 速度Fast / 快Slow (100–1000× slower) / 慢(慢100–1000倍)
Key Distribution / 密钥分发Difficult – secure channel needed / 困难 – 需要安全通道Easy – public key can be shared openly / 容易 – 公钥可公开
Typical Use / 典型用途Bulk data encryption (e.g. file/disk encryption) / 批量数据加密(文件/磁盘加密)Key exchange, digital signatures, small data / 密钥交换、数字签名、小型数据
Examples / 例子AES, DES, Blowfish / AES、DES、BlowfishRSA, ECC, ElGamal / RSA、ECC、ElGamal

In practice, hybrid cryptosystems combine the strengths of both: asymmetric encryption secures the handshake and exchanges a temporary symmetric key; subsequent session data is encrypted with that symmetric key for efficiency. This is exactly how TLS works.

实践中,混合密码系统结合了两者的优点:非对称加密保护握手并交换一个临时对称密钥;后续会话数据用该对称密钥进行高效加密。这正是TLS的工作方式。


8. Diffie–Hellman Key Exchange | Diffie–Hellman 密钥交换

Diffie– lem. The parties agree on public parameters: a prime p and a generator g. Alice chooses a private random number a, computes A = gᵃ mod p, and sends A to Bob. Bob chooses b, computes B = gᵇ mod p, and sends B to Alice. Alice then computes s = Bᵃ mod p, while Bob computes s = Aᵇ mod p. Both arrive at the same shared secret s. An eavesdropper seeing p, g, A, B cannot feasibly compute a, b, or s if p is large enough.

Diffie–Hellman (DH)允许双方在不安全的信道上商定一个共享秘密,无需事先拥有秘密。它依赖于离散对数问题。双方约定公开参数:质数 p 和生成元 g。Alice选择一个私有随机数 a,计算 A = gᵃ mod p,并将 A 发给Bob。Bob选择 b,计算 B = gᵇ mod p,并将 B 发给Alice。然后Alice计算 s = Bᵃ mod p,而Bob计算 s = Aᵇ mod p。双方得到相同的共享秘密 s。窃听者即使看到 p、g、A、B,在 p 足够大时也无法实际计算出 a、b 或 s。

Ephemeral Diffie–Hellman (DHE) generates fresh key pairs for each session, providing forward secrecy – even if the server’s long-term private key is later compromised, past session keys remain secure. Elliptic Curve Diffie–Hellman (ECDH) uses elliptic curves to achieve the same goal with smaller keys and faster computations.

临时Diffie–Hellman(DHE)为每个会话生成新的密钥对,提供前向保密性——即使服务器的长期私钥事后泄露,过去的会话密钥仍然安全。椭圆曲线Diffie–Hellman(ECDH)利用椭圆曲线以更小的密钥和更快的计算实现相同目标。


9. Common Attacks and Defences | 常见攻击与防御

Brute-force attacks systematically try all possible keys until the correct one is found. Key length directly determines resistance: a 128-bit key has 2¹²⁸ combinations, making brute-force impractical with current technology. However, weak algorithms like DES with a 56‑bit key can be broken in hours. Modern systems enforce minimum key lengths (e.g. AES-256, RSA‑2048).

暴力攻击系统地尝试所有可能的密钥,直到找到正确的一个。密钥长度直接决定抵抗能力:128位密钥有 2¹²⁸ 种组合,用当前技术暴力破解不切实际。然而,像56位密钥的DES这样的弱算法在几小时内就能被破解。现代系统强制执行最小密钥长度(例如AES-256,RSA‑2048)。

Man-in-the-middle (MITM) attacks intercept and relay communications between two parties, potentially altering messages. TLS defends against MITM by verifying the server’s certificate against a trusted CA. Mutual TLS (client certificate) extends this authentication to the client. Always validate certificates and use HSTS to prevent downgrade attacks.

中间人攻击(MITM)拦截并中继双方通信,可能篡改消息。TLS通过根据受信任的CA验证服务器证书来防御MITM。双向TLS(客户端证书)将这种认证扩展到客户端。始终验证证书并使用HSTS防止降级攻击。

Side-channel attacks exploit physical implementations rather than mathematical weaknesses – measuring power consumption, timing, or electromagnetic leaks to infer keys. Constant-time implementations and hardware security modules (HSMs) mitigate these risks. Students should also know about replay attacks, where valid data transmissions are maliciously repeated, and how nonces or timestamps prevent them.

侧信道攻击利用物理实现而非数学弱点——通过测量功耗、时序或电磁泄漏来推断密钥。恒定时间实现和硬件安全模块(HSM)能缓解这些风险。学生还应了解重放攻击(有效数据传输被恶意重复)以及如何使用随机数或时间戳加以预防。


10. Encryption in Practice for IB & CCEA Exams | 加密在 IB 和 CCEA 考试中的实际应用

Exam questions often ask students to explain the steps of symmetric/asymmetric encryption with diagrams, discuss key distribution problems, compare encryption methods, or apply RSA mathematics given small prime numbers. For CCEA, be prepared to describe how encryption protects data at rest and in transit, and relate it to legislation like the Computer Misuse Act and GDPR. IB learners may encounter encryption in the context of paper 1 system fundamentals or the case study, where they must evaluate security measures for a given scenario.

考试题目经常要求学生图解对称/非对称加密的步骤,讨论密钥分发问题,比较加密方法,或在给定小质数的情况下应用RSA数学。对于CCEA,要准备描述加密如何保护静态和传输中的数据,并将其与《计算机滥用法》和GDPR等法律关联。IB学生可能在试卷1系统基础或案例研究中遇到加密,需针对给定场景评估安全措施。

When answering, always use precise terminology. For instance, say 'Alice encrypts the session key with Bob’s public key' rather than 'the key is encrypted with a public key'. Mark schemes reward correct sequencing of cryptographic operations and recognition that real-world systems use a hybrid model, not purely asymmetric encryption for all data.

作答时始终使用精确术语。例如,说“Alice用Bob的公钥加密会话密钥”,而不是“密钥用公钥加密”。评分方案奖励密码操作的正确顺序,以及认识到现实系统使用混合模型,而非对所有数据纯粹使用非对称加密。


11. Ethical and Legal Considerations | 伦理与法律考量

Encryption is a dual-use technology – it protects privacy and secures commerce, but can also be used by criminals to hide illegal activities. Governments debate backdoors, key escrow, and lawful access requirements. Students should be able to discuss the tension between national security and individual privacy, referencing events like the Apple vs. FBI case. The CCEA specification often links this to the Data Protection Act and GDPR’s requirement for appropriate technical measures, where encryption is explicitly cited as a safeguard.

加密是一种两用技术——它保护隐私和商业安全,但也可被犯罪分子用于隐藏非法活动。政府围绕后门、密钥托管和合法访问要求展开辩论。学生应能够讨论国家安全与个人隐私之间的张力,引用苹果与FBI等案例。CCEA教学大纲通常将其与《数据保护法》和GDPR对适当技术措施的要求联系起来,其中加密被明确列为保障措施。


12. Summary and Quick Recall | 总结与快速回顾

To master encryption for IB and CCEA Computer Science, remember the following key points: Symmetric encryption (AES) is fast but has a key distribution problem; asymmetric encryption (RSA) solves key distribution but is slow – real systems combine them. Hashing ensures integrity, digital signatures provide authentication and non-repudiation. TLS secures web traffic using certificates and hybrid encryption. Attack awareness and ethical context complete the picture. Practice RSA calculations and protocol diagrams until you can reproduce them confidently under timed conditions.

要精通IB和CCEA计算机科学中的加密,记住以下要点:对称加密(AES)速度快但有密钥分发问题;非对称加密(RSA)解决密钥分发问题但速度慢——实际系统将它们结合。哈希确保完整性,数字签名提供认证和不可否认性。TLS使用证书和混合加密保护网络流量。攻击意识和伦理背景使知识体系完整。练习RSA计算和协议图表,直到能在限时条件下自信地复现。

Published by TutorHao | Computer Science Revision Series | aleveler.com

广告 / Sponsored
IBDP国际文凭计算机科学学生用书 高级及标准水平 Computer Science for the IB Diplo…
计算机 备考教辅 · 正版现货 · 与本文内容相关
查看详情 / View on Taobao参考价 ¥524.0

更多咨询请联系16621398022(同微信)

备考资讯每日更新,关注不错过
考纲变化 · 科目分析 · 学习方法
扫码关注公众号 tutorhao
在微信里长按二维码识别关注
或截图后用「扫一扫 → 相册」选择本图
公众号:tutorhao