A-Level WJEC Computer Science: Encryption Revision Notes | WJEC A-Level 计算机:加密 考点精讲

📚 A-Level WJEC Computer Science: Encryption Revision Notes | WJEC A-Level 计算机:加密 考点精讲

Encryption is the process of converting plaintext into ciphertext to protect data from unauthorised access. It is a fundamental topic in the WJEC A-Level Computer Science specification, covering both historical ciphers and modern cryptographic techniques used to secure communication and storage.

加密是将明文转换为密文以保护数据不被未授权访问的过程。这是 WJEC A-Level 计算机科学大纲中的基础主题,涵盖了历史密码和用于保护通信与存储的现代加密技术。

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

Encryption transforms readable data (plaintext) into an unreadable format (ciphertext) using an algorithm and a key. Only someone with the correct decryption key can reverse the process and recover the original plaintext.

加密使用算法和密钥将可读数据(明文)转换为不可读的格式(密文)。只有拥有正确解密密钥的人才能逆转该过程并恢复原始明文。

The two primary goals of encryption are confidentiality (keeping data secret) and integrity (detecting unauthorised changes). In modern systems, encryption is essential for secure online transactions, email, and data storage.

加密的两个主要目标是保密性(保持数据秘密)和完整性(检测未授权的更改)。在现代系统中,加密对于安全的在线交易、电子邮件和数据存储至关重要。


2. Symmetric vs Asymmetric Encryption | 对称加密与非对称加密

Symmetric encryption uses the same key for both encryption and decryption. The sender and receiver must share this secret key securely before communication. It is fast and efficient for bulk data, but key distribution can be a problem.

对称加密使用相同的密钥进行加密和解密。发送方和接收方必须在通信前安全地共享该秘密密钥。它对大量数据快速高效,但密钥分发可能成为问题。

Asymmetric encryption, also called public-key cryptography, uses a pair of mathematically related keys: a public key for encryption and a private key for decryption. The public key can be shared openly, while the private key remains secret. It solves the key distribution problem but is computationally slower.

非对称加密,也称为公钥加密,使用一对数学相关的密钥:公钥用于加密,私钥用于解密。公钥可以公开共享,而私钥保持秘密。它解决了密钥分发问题,但计算速度较慢。

In practice, hybrid systems are used: asymmetric encryption to securely exchange a symmetric session key, and then symmetric encryption for the actual data transfer (e.g., in TLS/SSL).

在实践中,使用混合系统:非对称加密用于安全交换对称会话密钥,然后对称加密用于实际数据传输(例如在 TLS/SSL 中)。


3. Caesar Cipher and Substitution | 凯撒密码与替换密码

The Caesar cipher is a simple substitution cipher where each letter in the plaintext is shifted by a fixed number of positions in the alphabet. For example, with a shift of 3, ‘A’ becomes ‘D’, ‘B’ becomes ‘E’, and so on. The key is the shift value.

凯撒密码是一种简单的替换密码,其中明文中的每个字母在字母表中移动固定数量的位置。例如,移动 3 位,’A’ 变成 ‘D’,’B’ 变成 ‘E’,以此类推。密钥是移动值。

A general substitution cipher maps each plaintext character to a unique ciphertext character according to a fixed permutation of the alphabet. While more complex than Caesar, both are vulnerable to frequency analysis: in English text, certain letters (like ‘E’, ‘T’, ‘A’) appear more frequently, allowing an attacker to guess the mapping.

一般的替换密码根据字母表的固定排列将每个明文字符映射到唯一的密文字符。虽然比凯撒密码更复杂,但两者都容易受到频率分析攻击:在英语文本中,某些字母(如 ‘E’、’T’、’A’)出现频率更高,使得攻击者能够猜测映射关系。


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

The Vigenère cipher is a polyalphabetic substitution cipher that uses a keyword to apply multiple Caesar shifts. Each letter of the keyword determines the shift for the corresponding plaintext position. If the keyword is shorter than the plaintext, it is repeated.

维吉尼亚密码是一种多表替换密码,使用关键词应用多个凯撒移动。关键词的每个字母决定对应明文位置的移动量。如果关键词比明文短,则重复使用。

For example, with keyword ‘KEY’, plaintext ‘ATTACK’ is encrypted by shifting ‘A’ using ‘K’ (shift 10), ‘T’ using ‘E’ (shift 4), ‘T’ using ‘Y’ (shift 24), then ‘A’ using ‘K’ again, etc. This makes frequency analysis much harder because the same plaintext letter can be encrypted to different ciphertext letters depending on its position.

例如,使用关键词 ‘KEY’,明文 ‘ATTACK’ 的加密过程:’A’ 用 ‘K’ 移动(移动 10),’T’ 用 ‘E’ 移动(移动 4),’T’ 用 ‘Y’ 移动(移动 24),然后 ‘A’ 再次用 ‘K’ 移动等。这使得频率分析更加困难,因为同一个明文字母可以根据其位置被加密为不同的密文字母。

However, if the key length is known or guessed, the cipher can still be broken using the Kasiski examination or Friedman test. The strength increases with key length; a one-time pad (key as long as the message, truly random, used only once) is theoretically unbreakable.

然而,如果知道或猜出密钥长度,仍然可以使用卡西斯基检验法或弗里德曼测试破解密码。强度随密钥长度增加而增加;一次性密码本(密钥与消息一样长、真正随机、只使用一次)在理论上是不可破解的。


5. Modern Symmetric Ciphers: DES and AES | 现代对称密码:DES 与 AES

The Data Encryption Standard (DES) is a symmetric block cipher developed in the 1970s. It operates on 64-bit blocks of data using a 56-bit key. Although once widely used, its key length is now considered too short, making it susceptible to brute-force attacks. Triple DES (3DES) applies DES three times with two or three keys to increase security, but it is slower.

数据加密标准 (DES) 是 1970 年代开发的对称分组密码。它使用 56 位密钥对 64 位数据块进行操作。虽然曾经广泛使用,但现在认为密钥长度太短,容易受到暴力破解攻击。三重 DES (3DES) 使用两个或三个密钥应用三次 DES 以提高安全性,但速度较慢。

The Advanced Encryption Standard (AES) was selected to replace DES. It is also a block cipher, using key sizes of 128, 192, or 256 bits, and operates on 128-bit blocks. AES is highly secure and efficient in both hardware and software, and it is the standard symmetric encryption algorithm used worldwide today (e.g., Wi-Fi WPA2, TLS, file encryption).

高级加密标准 (AES) 被选为 DES 的替代品。它也是一种分组密码,使用 128、192 或 256 位密钥,对 128 位数据块进行操作。AES 在硬件和软件中都高度安全且高效,是当今全球使用的标准对称加密算法(例如 Wi-Fi WPA2、TLS、文件加密)。


6. Public Key Cryptography: RSA | 公钥加密:RSA

RSA (Rivest−Shamir−Adleman) is the most widely used asymmetric algorithm. It relies on the mathematical difficulty of factoring the product of two large prime numbers. The key generation involves choosing two distinct large primes p and q, computing n = p × q, and selecting an encryption exponent e and decryption exponent d such that (Mᵉ)ᵈ ≡ M mod n.

RSA (Rivest−Shamir−Adleman) 是最广泛使用的非对称算法。它依赖于分解两个大素数乘积的数学困难性。密钥生成包括选择两个不同的大素数 p 和 q,计算 n = p × q,并选择加密指数 e 和解密指数 d,使得 (Mᵉ)ᵈ ≡ M mod n。

A user’s public key consists of (n, e), and the private key is (n, d). Anyone can encrypt a message M using the recipient’s public key: C ≡ Mᵉ mod n. Only the recipient can decrypt using their private key: M ≡ Cᵈ mod n. The security of RSA depends on the infeasibility of factoring n back into p and q when the primes are sufficiently large (e.g., 2048-bit n).

用户的公钥由 (n, e) 组成,私钥是 (n, d)。任何人都可以使用接收者的公钥加密消息 M:C ≡ Mᵉ mod n。只有接收者可以使用他们的私钥解密:M ≡ Cᵈ mod n。RSA 的安全性取决于当素数足够大时(例如 2048 位的 n),将 n 分解回 p 和 q 的不可行性。

RSA is slower than symmetric ciphers, so it is typically used to encrypt small amounts of data, such as symmetric keys or digital signatures.

RSA 的速度比对称密码慢,因此通常用于加密少量数据,例如对称密钥或数字签名。


7. Key Exchange Problem and Diffie-Hellman | 密钥交换问题与 Diffie-Hellman

Before the invention of asymmetric cryptography, securely distributing a symmetric key over an insecure channel was a major challenge. The Diffie-Hellman key exchange protocol (1976) allows two parties to agree on a shared secret key over a public channel without prior secrets.

在非对称加密发明之前,通过不安全的信道安全地分发对称密钥是一个重大挑战。Diffie-Hellman 密钥交换协议 (1976) 允许双方在没有事先秘密的情况下通过公共信道协商一个共享秘密密钥。

The process uses a large prime p and a generator g. Alice chooses a private number a, computes A = gᵃ mod p, and sends A to Bob. Bob chooses private b, computes B = gᵇ mod p, and sends B to Alice. Each computes the shared secret: Alice computes K = Bᵃ mod p, Bob computes K = Aᵇ mod p. Both arrive at the same value gᵃᵇ mod p, which can be used as a symmetric key. An eavesdropper seeing g, p, A, B cannot feasibly compute a or b due to the discrete logarithm problem.

该过程使用一个大素数 p 和一个生成元 g。Alice 选择一个私有数字 a,计算 A = gᵃ mod p,并将 A 发送给 Bob。Bob 选择私有 b,计算 B = gᵇ mod p,并将 B 发送给 Alice。各自计算共享秘密:Alice 计算 K = Bᵃ mod p,Bob 计算 K = Aᵇ mod p。两者得到相同的值 gᵃᵇ mod p,可以用作对称密钥。由于离散对数问题,看到 g、p、A、B 的窃听者无法可行地计算 a 或 b。


8. Hashing and Digital Signatures | 哈希与数字签名

A hash function takes an input of any size and produces a fixed-size string called a hash or digest. Cryptographic hash functions (e.g., SHA-256) are one-way (pre-image resistant), deterministic, and collision-resistant (it is infeasible to find two different inputs with the same hash). They are used to verify data integrity.

哈希函数接受任意大小的输入并产生固定大小的字符串,称为哈希或摘要。加密哈希函数(如 SHA-256)是单向的(抗原像性)、确定性的和抗碰撞的(找到具有相同哈希的两个不同输入是不可行的)。它们用于验证数据完整性。

Digital signatures combine hashing with asymmetric encryption to provide authentication and non-repudiation. The sender creates a hash of the message, encrypts the hash with their private key (signing), and sends the message along with the signature. The recipient decrypts the signature with the sender’s public key, recomputes the hash, and compares the two. If they match, the message is authentic and has not been tampered with.

数字签名将哈希与非对称加密相结合,提供身份验证和不可否认性。发送方创建消息的哈希,用自己的私钥加密哈希(签名),并将消息连同签名一起发送。接收方用发送方的公钥解密签名,重新计算哈希,并比较两者。如果匹配,则消息是真实的且未被篡改。


9. SSL/TLS and HTTPS | SSL/TLS 与 HTTPS

Secure Sockets Layer (SSL) and its successor Transport Layer Security (TLS) are cryptographic protocols that provide secure communication over a network (e.g., HTTPS for websites). The TLS handshake involves several steps: the client and server agree on cipher suites, the server sends its digital certificate containing its public key, the client verifies the certificate via a Certificate Authority (CA), and then a symmetric session key is established using asymmetric encryption (e.g., RSA or Diffie-Hellman).

安全套接层 (SSL) 及其继任者传输层安全 (TLS) 是提供网络安全通信的加密协议(例如网站的 HTTPS)。TLS 握手包括几个步骤:客户端和服务器协商密码套件,服务器发送包含其公钥的数字证书,客户端通过证书颁发机构 (CA) 验证证书,然后使用非对称加密(如 RSA 或 Diffie-Hellman)建立对称会话密钥。

Once the session key is shared, all subsequent data is encrypted with a symmetric cipher (e.g., AES) and integrity is ensured using Message Authentication Codes (MACs). The padlock icon in a browser indicates a valid TLS connection, relying on the chain of trust from the CA’s root certificate.

一旦共享了会话密钥,所有后续数据都使用对称密码(如 AES)加密,并使用消息认证码 (MAC) 确保完整性。浏览器中的挂锁图标表示有效的 TLS 连接,依赖于从 CA 根证书的可信链。


10. Threats to Encryption: Brute Force, Man-in-the-Middle | 加密面临的威胁:暴力破解、中间人攻击

A brute-force attack tries every possible key until the correct one is found. The defence is to use sufficiently long keys: modern symmetric ciphers with 128-bit or longer keys are essentially immune, while older 56-bit DES keys can be cracked in hours. Asymmetric algorithms require even larger key sizes (e.g., 2048-bit RSA) to resist factoring attacks.

暴力破解攻击尝试每一个可能的密钥,直到找到正确的一个。防御方法是使用足够长的密钥:具有 128 位或更长密钥的现代对称密码基本免疫,而旧的 56 位 DES 密钥可以在数小时内被破解。非对称算法需要更大的密钥尺寸(例如 2048 位 RSA)来抵抗因子分解攻击。

A man-in-the-middle (MITM) attack occurs when an attacker intercepts communication and relays messages between two parties who believe they are communicating directly. In an unauthenticated Diffie-Hellman exchange, the attacker could establish separate shared secrets with each party. Digital certificates and proper public key infrastructure (PKI) prevent MITM by binding public keys to verified identities.

中间人攻击 (MITM) 发生在攻击者截获通信并在双方之间中继消息,而双方以为他们正在直接通信。在未认证的 Diffie-Hellman 交换中,攻击者可以与每一方建立单独的共享秘密。数字证书和适当的公钥基础设施 (PKI) 通过将公钥绑定到经过验证的身份来防止 MITM。

Other threats include side-channel attacks (exploiting physical implementation, such as power consumption or timing), and social engineering to obtain keys or passwords. Encryption alone is not sufficient; key management and user awareness are equally important.

其他威胁包括侧信道攻击(利用物理实现,如功耗或时间)和通过社会工程学获取密钥或密码。仅加密是不够的;密钥管理和用户意识同样重要。


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