A-Level CCEA Computer Science: Encryption Exam Focus | A-Level CCEA 计算机:加密 考点精讲

📚 A-Level CCEA Computer Science: Encryption Exam Focus | A-Level CCEA 计算机:加密 考点精讲

Encryption is a fundamental topic in the CCEA A-Level Computer Science specification, underpinning modern digital security. This article distils the essential concepts, algorithms, and protocols you must master for the examination, from symmetric and asymmetric ciphers to hashing and digital signatures. We will walk through classic examples such as Caesar and Vigenère before diving into AES, RSA, SSL/TLS, and practical storage concerns.

加密是 CCEA A-Level 计算机科学考试大纲中的基础性主题,支撑着现代数字安全。本文提炼了考试必须掌握的核心概念、算法和协议,涵盖对称与非对称密码、哈希函数以及数字签名。我们将从凯撒密码和维吉尼亚密码等经典示例入手,再深入探讨 AES、RSA、SSL/TLS 以及实际的密码存储问题。

1. What is Encryption? | 什么是加密?

Encryption is the process of converting plaintext into ciphertext using an algorithm and a key, ensuring that unauthorised parties cannot read the original message. The reverse process, decryption, recovers the plaintext from the ciphertext using a corresponding key. Encryption provides confidentiality, but it can also be combined with other mechanisms to deliver integrity and authentication.

加密是使用算法和密钥将明文转换为密文的过程,确保未经授权的第三方无法读取原始消息。其逆过程——解密,则利用相应的密钥从密文中恢复出明文。加密提供了机密性,但也可以与其他机制结合,实现完整性和身份验证。

2. Symmetric Encryption | 对称加密

Symmetric encryption uses a single shared key for both encryption and decryption. The sender and receiver must have exchanged this key securely beforehand. Symmetric algorithms are typically fast and suitable for encrypting large volumes of data. The main challenge is secure key distribution, because anyone who possesses the key can decrypt the message.

对称加密使用单一共享密钥进行加密和解密。发送方和接收方必须提前安全地交换该密钥。对称算法通常速度快,适合加密大量数据。其主要挑战在于密钥的安全分发——任何持有该密钥的人都能解密消息。

Common examples of symmetric ciphers include the Data Encryption Standard (DES), Triple DES (3DES), and the widely adopted Advanced Encryption Standard (AES). DES operates on 64‑bit blocks with a 56‑bit key, but it is now considered insecure due to its short key length. AES offers key lengths of 128, 192, or 256 bits and works on 128‑bit blocks, providing a much higher security level.

常见的对称密码例子包括数据加密标准 (DES)、三重 DES (3DES) 以及广泛采用的 高级加密标准 (AES)。DES 使用 56 位密钥处理 64 位分组,但由于密钥长度过短,现已被认为不安全。AES 提供 128、192 或 256 位的密钥长度,并在 128 位分组上运算,安全性显著提高。


3. Asymmetric Encryption | 非对称加密

Asymmetric encryption, also known as public‑key cryptography, employs a pair of mathematically related keys: a public key for encryption and a private key for decryption. Anyone can encrypt a message using the recipient’s public key, but only the holder of the corresponding private key can decrypt it. This eliminates the key‑distribution problem inherent in symmetric systems.

非对称加密,又称公钥密码学,使用一对数学相关的密钥:公钥用于加密,私钥用于解密。任何人都可以使用接收方的公钥加密消息,但只有持有对应私钥的人才能够解密。这消除了对称系统中固有的密钥分发问题。

Asymmetric algorithms are computationally heavier than symmetric ones, so they are often used to encrypt small amounts of data—such as symmetric keys or digital signatures—rather than entire messages. The most well‑known asymmetric algorithm is RSA, alongside elliptic‑curve cryptography (ECC).

非对称算法的计算开销比对称算法大,因此通常用于加密少量数据——如对称密钥或数字签名——而非整条消息。最著名的非对称算法是 RSA,此外还有椭圆曲线密码学 (ECC)。


4. Caesar Cipher | 凯撒密码

The Caesar cipher is a historical substitution cipher where each letter in the plaintext is shifted by a fixed number of positions along the alphabet. For example, with a shift key of 3, ‘A’ becomes ‘D’, ‘B’ becomes ‘E’, and so on. The key is simply the shift value. This cipher is symmetric because the same shift is used for both encryption and decryption.

凯撒密码是一种历史替换密码,通过将明文中每个字母沿字母表移动固定数量的位置来加密。例如,移位密钥为 3 时,’A’ 变为 ‘D’,’B’ 变为 ‘E’,以此类推。密钥就是移位值。该密码是对称的,因为加密和解密使用相同的移位数。

Mathematically, encryption with a key k can be expressed as:

Eₖ(x) = (x + k) mod 26

and decryption as:

Dₖ(y) = (y − k) mod 26

where letters are mapped to numbers (A=0, B=1, …, Z=25). The Caesar cipher is extremely weak because there are only 25 possible keys, making it trivially susceptible to brute‑force attacks.

数学上,使用密钥 k 的加密可表示为:Eₖ(x) = (x + k) mod 26,解密为:Dₖ(y) = (y − k) mod 26,其中字母映射为数字 (A=0, B=1, …, Z=25)。凯撒密码非常脆弱,因为只有 25 个可能的密钥,极易受到暴力破解攻击。


5. Vigenère Cipher | 维吉尼亚密码

The Vigenère cipher improves upon the Caesar cipher by using a keyword to determine a series of different shifts. Each letter of the keyword indicates a Caesar shift for the corresponding plaintext letter: ‘A’ represents shift 0, ‘B’ shift 1, …, ‘Z’ shift 25. When the keyword is shorter than the message, it is repeated cyclically.

维吉尼亚密码改进了凯撒密码,使用一个关键字来决定一系列不同的移位。关键字中的每个字母表示对应明文字母的凯撒移位:’A’ 代表移位 0,’B’ 移位 1,…,’Z’ 移位 25。如果关键字短于消息,则循环重复使用。

For instance, with keyword “KEY” (shifts 10, 4, 24), the plaintext “ATTACK” becomes:

  • A (shift 10) → K
  • T (shift 4) → X
  • T (shift 24) → R
  • A (shift 10) → K
  • C (shift 4) → G
  • K (shift 24) → I

producing ciphertext “KXRKGI”. The Vigenère cipher resisted frequency analysis for centuries, but it is still breakable with modern techniques. It is important mainly as a historical stepping stone in the CCEA syllabus.

例如,使用关键字 “KEY” (移位 10, 4, 24),明文 “ATTACK” 变为:”A (移位 10) → K”、”T (移位 4) → X”、”T (移位 24) → R”、”A (移位 10) → K”、”C (移位 4) → G”、”K (移位 24) → I”,最终得到密文 “KXRKGI”。维吉尼亚密码曾抵抗了几个世纪的频率分析,但利用现代技术仍可破解。在 CCEA 大纲中它主要是一个历史性的进阶示例。


6. Modern Symmetric Algorithms: AES | 现代对称算法:AES

The Advanced Encryption Standard (AES) is the most widely used symmetric block cipher today. It was selected through a public competition and is standardised by NIST. AES processes data in 128‑bit blocks and supports key sizes of 128, 192, or 256 bits. The algorithm consists of several rounds (10, 12, or 14 depending on key length) of substitution, permutation, mixing, and key addition operations.

高级加密标准 (AES) 是目前使用最广泛的对称分组密码。它通过公开竞赛选出,并由 NIST 标准化。AES 以 128 位分组处理数据,支持 128、192 或 256 位的密钥长度。该算法包括多轮 (10、12 或 14 轮,取决于密钥长度) 的替换、置换、混合和密钥加操作。

Each round involves four stages: SubBytes (non‑linear byte substitution using an S‑box), ShiftRows (cyclic shifting of rows), MixColumns (linear mixing of columns), and AddRoundKey (XORing the state with a round key). The final round omits the MixColumns step. AES is computationally efficient in both hardware and software, and it remains secure against all known practical attacks when used with appropriate key lengths.

每轮包含四个步骤:SubBytes (利用 S‑盒进行非线性字节替换)、ShiftRows (行循环移位)、MixColumns (列线性混合) 和 AddRoundKey (将状态与轮密钥进行异或)。最后一轮省略 MixColumns 步骤。AES 在硬件和软件上计算效率都很高,且在使用合适密钥长度时,仍能抵御所有已知的实用攻击。


7. Modern Asymmetric Algorithms: RSA | 现代非对称算法:RSA

RSA (Rivest–Shamir–Adleman) is the most famous public‑key cryptosystem. Its security relies on the practical difficulty of factoring the product of two large prime numbers. The key generation process selects two large primes p and q, computes n = p × q, and then calculates φ(n) = (p−1)(q−1). A public exponent e is chosen such that 1 < e < φ(n) and gcd(e, φ(n)) = 1; the private exponent d is the modular inverse of e modulo φ(n), i.e., d × e ≡ 1 (mod φ(n)).

RSA (Rivest–Shamir–Adleman) 是最著名的公钥密码系统。其安全性依赖于分解两个大素数乘积的实际困难。密钥生成过程选择两个大素数 p 和 q,计算 n = p × q,然后计算 φ(n) = (p−1)(q−1)。选择一个公开指数 e,满足 1 < e < φ(n) 且 gcd(e, φ(n)) = 1;私密指数 d 是 e 模 φ(n) 的模逆,即 d × e ≡ 1 (mod φ(n))。

Encryption of a plaintext message M (represented as an integer smaller than n) is:

C = Mᵉ mod n

Decryption is:

M = Cᵈ mod n

The public key is (n, e) and the private key is (n, d). Because factoring n into p and q is computationally infeasible for large properly chosen primes, an attacker cannot easily derive d from e and n. RSA is used for key exchange, digital signatures, and securing web traffic. Typical key lengths today are 2048 bits or higher.

加密明文消息 M (表示为小于 n 的整数) 的公式为:C = Mᵉ mod n,解密为:M = Cᵈ mod n。公钥为 (n, e),私钥为 (n, d)。由于对大且恰当选取的素数来说,分解 n 为 p 和 q 在计算上是不可行的,攻击者无法轻易从 e 和 n 推导出 d。RSA 用于密钥交换、数字签名以及保护 Web 流量。目前典型的密钥长度为 2048 位或更高。


8. Hashing and Its Uses | 哈希及其用途

A hash function takes an input (or ‘message’) and returns a fixed‑size string of bytes, typically a digest that appears random. Key properties of cryptographic hash functions are: determinism (same input always gives the same output), pre‑image resistance (infeasible to reverse), second pre‑image resistance (infeasible to find a different input with the same hash), and collision resistance (infeasible to find any two distinct inputs that produce the same hash).

哈希函数接受输入 (或 ‘消息’) 并返回固定大小的字节串,通常表现为一个看似随机的摘要。密码学哈希函数的关键性质包括:确定性 (相同输入始终产生相同输出)、原像抵抗 (不可逆向推算)、第二原像抵抗 (无法找到产生相同哈希的不同输入) 以及碰撞抵抗 (无法找到任意两个不同输入产生相同哈希)。

Common hash algorithms include MD5 (Message Digest 5) and the SHA family (SHA‑1, SHA‑256, SHA‑3). MD5 and SHA‑1 are now considered broken for security‑sensitive applications due to collision vulnerabilities. SHA‑256, part of the SHA‑2 family, is widely used today. Hashes are essential for verifying data integrity (e.g., checksums, file verification), storing passwords (with salting), and forming the basis of digital signatures.

常见的哈希算法包括 MD5 (消息摘要 5) 和 SHA 系列 (SHA‑1、SHA‑256、SHA‑3)。由于碰撞漏洞,MD5 和 SHA‑1 在安全敏感应用中已被认为不安全。SHA‑256 属于 SHA‑2 系列,现今广泛使用。哈希对于验证数据完整性 (如校验和、文件验证)、存储密码 (结合加盐) 以及构成数字签名的基础至关重要。


9. Digital Signatures & Certificates | 数字签名与证书

A digital signature is created by encrypting a message hash with the sender’s private key. The recipient can verify the signature by decrypting it with the sender’s public key and comparing the resulting hash with a freshly computed hash of the received message. If they match, the signature confirms that the message was not altered and indeed originated from the holder of the private key. This provides authentication, non‑repudiation, and integrity.

数字签名通过使用发送方的私钥加密消息哈希而创建。接收方可用发送方的公钥解密签名,并将所得哈希与刚计算的消息哈希进行比较。如果匹配,签名就确认了消息未被篡改且确实来自私钥持有者。这提供了身份验证、不可否认性和完整性。

Digital certificates bind a public key to an identity (e.g., a domain name) and are issued by trusted Certificate Authorities (CAs). A certificate contains the owner’s public key, identity information, the CA’s digital signature, and a validity period. When you connect to a secure website, the browser verifies the certificate chain to establish trust. The most common standard for certificates is X.509.

数字证书将公钥绑定到某个身份 (如域名),并由受信任的证书颁发机构 (CA) 签发。证书包含所有者的公钥、身份信息、CA 的数字签名以及有效期。连接安全网站时,浏览器会验证证书链以建立信任。最常见的证书标准是 X.509。


10. SSL/TLS Protocols | 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 securing HTTP traffic (HTTPS). The TLS handshake establishes a secure session: the client and server agree on a cipher suite, authenticate each other using certificates, and exchange a symmetric session key using asymmetric encryption (e.g., RSA or Diffie‑Hellman).

安全套接层 (SSL) 及其后继者传输层安全 (TLS) 是在计算机网络上提供安全通信的密码协议。它们工作在应用层和传输层之间,通常用于保护 HTTP 流量 (HTTPS)。TLS 握手用于建立安全会话:客户端和服务器协商密码套件,使用证书相互认证,并通过非对称加密 (如 RSA 或 Diffie‑Hellman) 交换对称会话密钥。

Once the handshake is complete, all subsequent data is encrypted with the agreed symmetric cipher (such as AES) using the session key. Modern servers should only support TLS 1.2 and TLS 1.3, as earlier versions have known vulnerabilities. TLS 1.3 simplifies the handshake and removes support for weak algorithms, improving both security and performance.

握手完成后,所有后续数据使用协商好的对称密码 (如 AES) 和会话密钥进行加密。现代服务器应仅支持 TLS 1.2 和 TLS 1.3,因为早期版本存在已知漏洞。TLS 1.3 简化了握手过程并移除了对弱算法的支持,在提高安全性的同时改善了性能。


11. Password Storage and Salting | 密码存储与加盐

Storing user passwords in plaintext is a severe security risk. Instead, systems store a hash of the password. When a user logs in, the supplied password is hashed and compared with the stored hash. However, if two users choose the same password, their hashes will be identical, and attackers can use precomputed rainbow tables to reverse common hashes. To counter this, a random salt—a unique, random string—is appended to each password before hashing, and the salt is stored alongside the hash.

以明文形式存储用户密码是严重的安全风险。因此,系统存储密码的哈希值。用户登录时,输入的密码被哈希化后与存储的哈希比较。然而,如果两个用户选择了相同的密码,他们的哈希值也会相同,攻击者可以使用预计算的彩虹表来逆转常见哈希。为了应对这一点,在哈希之前为每个密码附加一个随机的盐值 (一个唯一且随机的字符串),并将盐值与哈希一同存储。

Modern best practice uses purpose‑built key derivation functions like bcrypt, scrypt, or Argon2, which incorporate salting and are deliberately slow (key stretching) to hinder brute‑force attacks. CCEA candidates should understand why simple hashing (e.g., SHA‑256 alone) is insufficient for password storage and why salting and stretching are necessary.

现代最佳实践使用专门设计的密钥派生函数,如 bcrypt、scrypt 或 Argon2,它们包含加盐且故意运行缓慢 (密钥拉伸),以阻碍暴力破解攻击。CCEA 考生应理解为什么单纯的哈希 (如仅使用 SHA‑256) 不足以安全存储密码,以及为何加盐和拉伸是必要的。


12. Encryption in Practice | 加密实践

In real‑world systems, encryption is rarely used in isolation. A hybrid approach is common: asymmetric encryption (e.g., RSA or ECDH) is used to securely exchange a symmetric session key, and then symmetric encryption (e.g., AES) protects the bulk data transmission because of its speed. This hybrid model powers HTTPS, VPNs, secure email, and instant messaging.

在现实系统中,加密很少单独使用。常见的一种混合方法:使用非对称加密 (如 RSA 或 ECDH) 安全交换对称会话密钥,然后利用对称加密 (如 AES) 保护海量数据传输,因为后者速度更快。这种混合模型为 HTTPS、VPN、安全电子邮件和即时通讯提供动力。

Other considerations include perfect forward secrecy (PFS), where a session key compromise does not expose past sessions—achieved through ephemeral Diffie‑Hellman key exchange. Additionally, encryption must be complemented by proper key management, certificate lifecycle policies, and resistance to side‑channel attacks. As a CCEA student, you should be able to evaluate the strengths and weaknesses of different approaches and recommend appropriate encryption solutions for given scenarios.

其他考量包括完美前向保密 (PFS),即会话密钥的泄露不会暴露过去的会话——这通过临时 Diffie‑Hellman 密钥交换实现。此外,加密必须辅以完善的密钥管理、证书生命周期策略以及抵御侧信道攻击的能力。作为 CCEA 考生,你应能够评估不同方法的优势与劣势,并针对给定场景推荐合适的加密方案。

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

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

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading