📚 Encryption Exam Essentials | 加密考点精讲
Encryption is the process of converting plaintext into ciphertext to protect data confidentiality, integrity, and authenticity. In both IB Computer Science and OCR A‑Level, you are expected to understand symmetric and asymmetric encryption, hashing, digital signatures, and their real‑world applications such as TLS. This revision guide breaks down every key concept with clear explanations, comparative tables, and essential definitions to help you secure top marks.
加密是将明文转换为密文的过程,用于保护数据的机密性、完整性和真实性。在 IB 计算机科学和 OCR A‑Level 考试中,你需要掌握对称加密与非对称加密、哈希、数字签名及其在 TLS 等实际场景中的应用。本复习指南逐一剖析每个关键概念,配合清晰的解释、对比表格和核心定义,助你稳稳拿高分。
1. Core Terminology | 核心术语
Plaintext is the original readable message before encryption. Ciphertext is the scrambled, unreadable output produced by an encryption algorithm. The key is a secret value used by the algorithm to encrypt and decrypt. Encryption transforms plaintext into ciphertext; decryption reverses the process.
明文是加密前可读的原始消息。密文是加密算法产生的乱码输出。密钥是算法用于加解密的秘密值。加密将明文变成密文;解密则是逆转此过程。
A cipher is the mathematical function used for encryption and decryption. The strength of encryption depends on the algorithm and the key length, measured in bits. Brute‑force attacks try all possible keys, so longer keys increase security exponentially.
密码是用于加解密的数学函数。加密强度取决于算法和密钥长度(以位为单位)。暴力攻击会尝试所有可能的密钥,因此更长的密钥会指数级提升安全性。
2. Symmetric Encryption | 对称加密
Symmetric encryption uses a single shared key for both encryption and decryption. The same key must be kept secret between sender and receiver. It is fast and efficient for bulk data, but key distribution is a major challenge: how do you securely share the key in the first place?
对称加密使用同一把共享密钥进行加密和解密。发送方与接收方必须对该密钥保密。它速度快、适合大批量数据,但密钥分发是一大难题:如何安全地预先共享密钥?
Common symmetric algorithms include AES (Advanced Encryption Standard), which is widely used today, and older ciphers like DES (Data Encryption Standard). AES operates on 128‑bit blocks and supports key lengths of 128, 192, or 256 bits. Stream ciphers encrypt data one bit or byte at a time, while block ciphers encrypt fixed‑size blocks.
常见对称算法包括广泛使用的 AES(高级加密标准),以及较老的 DES(数据加密标准)。AES 以 128 位块为单位运行,支持 128、192 或 256 位密钥。流密码逐位或逐字节加密数据,而分组密码则加密固定大小的块。
| Algorithm | Type | Key Length | Security |
|---|---|---|---|
| AES | Block | 128/192/256 | Very strong |
| DES | Block | 56 | Weak (broken) |
| 3DES | Block | 112/168 | Moderate, now deprecated |
3. Asymmetric Encryption | 非对称加密
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, but the private key must remain secret. This solves the key distribution problem inherent in symmetric systems.
非对称加密又称公钥密码,使用一对数学上相关的密钥:公钥用于加密,私钥用于解密。公钥可以公开分享,私钥必须保密。这解决了对称体系中固有的密钥分发问题。
The most common asymmetric algorithm is RSA (Rivest–Shamir–Adleman), whose security relies on the difficulty of factoring large prime numbers. Other algorithms include ECC (Elliptic Curve Cryptography), which offers equivalent security with shorter keys, making it ideal for mobile devices.
最常见的非对称算法是 RSA,其安全性依赖于大素数分解的困难性。其他算法包括 ECC(椭圆曲线密码),它能用更短的密钥提供同等安全性,非常适合移动设备。
Asymmetric encryption is computationally slower than symmetric encryption. In practice, hybrid systems combine both: asymmetric encryption is used to securely exchange a symmetric session key, then symmetric encryption handles the bulk data transfer. This is how TLS works.
非对称加密计算速度比对称加密慢。实际应用中采用混合系统:用非对称加密安全交换对称会话密钥,随后由对称加密处理大量数据传输。TLS 正是这样工作的。
4. Hashing | 哈希
A hash function takes an input (message) and produces a fixed‑size string of bytes, typically a digest. Hashing is one‑way: you cannot feasibly reverse the process to obtain the original input. Even a single‑bit change in the input produces a completely different hash (avalanche effect).
哈希函数接收输入(消息)并产生固定大小的字节串,通常称为摘要。哈希是单向的:实际上无法逆向还原原始输入。即使输入中仅改变一位,也会产生完全不同的哈希值(雪崩效应)。
Common hash functions include SHA‑256 (part of the SHA‑2 family) and the older MD5 and SHA‑1, both of which are now considered broken due to collision vulnerabilities. A collision occurs when two different inputs produce the same hash output. Secure hash functions must be collision‑resistant.
常见哈希函数包括 SHA‑256(SHA‑2 家族之一)以及较老的 MD5 和 SHA‑1,后两者因碰撞漏洞已不再安全。碰撞指两个不同输入产生相同的哈希输出。安全的哈希函数必须具有抗碰撞性。
Hashing is used to verify data integrity (checksums), store passwords securely (salted hashes), and in digital signatures. When you download a file, its hash can confirm it hasn’t been tampered with.
哈希用于验证数据完整性(校验和)、安全存储密码(加盐哈希)以及数字签名。下载文件时,通过比对哈希值可确认文件未被篡改。
5. Digital Signatures | 数字签名
A digital signature provides authentication, non‑repudiation, and integrity. The sender creates a hash of the message and encrypts it with their private key. This encrypted hash is the digital signature, sent along with the message. The recipient decrypts the signature using the sender’s public key, then compares the decrypted hash with a freshly computed hash of the received message. If they match, the signature is valid.
数字签名提供身份认证、不可否认性和完整性。发送方生成消息的哈希并使用自己的私钥对其加密。这个加密后的哈希即数字签名,随消息一同发送。接收方用发送方公钥解密签名,然后将解密出的哈希与重新计算的消息哈希进行比对。若一致,则签名有效。
Digital signatures prove who sent the message (authentication), prevent the sender from denying they sent it (non‑repudiation), and confirm the message was not altered (integrity). They are a fundamental part of secure email, software distribution, and blockchain transactions.
数字签名证明消息发送者的身份(认证),防止发送者否认发送行为(不可否认性),并确认消息未被篡改(完整性)。它们是安全邮件、软件分发和区块链交易的基础组成部分。
6. Encryption Protocols: SSL / TLS | 加密协议:SSL/TLS
Transport Layer Security (TLS), the successor to Secure Sockets Layer (SSL), is the protocol that secures communication over networks, most notably HTTPS. TLS provides encryption, authentication, and integrity for data in transit between clients and servers.
传输层安全协议(TLS)是安全套接层(SSL)的继任者,用于保护网络通信,最典型的就是 HTTPS。TLS 为客户端与服务器之间传输的数据提供加密、身份验证和完整性保护。
The TLS handshake employs asymmetric cryptography to authenticate the server (and optionally the client) and to agree on a symmetric session key. After the handshake, all data is encrypted using fast symmetric encryption. Digital certificates, issued by Certificate Authorities (CAs), bind a public key to an entity, enabling trust.
TLS 握手使用非对称加密来验证服务器(也可选择验证客户端)并协商对称会话密钥。握手完成后,所有数据均使用快速的对称加密传输。数字证书由证书颁发机构(CA)签发,将公钥与实体绑定,从而建立信任。
7. Key Exchange | 密钥交换
Key exchange algorithms allow two parties to establish a shared secret over an insecure channel. Diffie‑Hellman (DH) is a classic example: each party generates a private‑public key pair and exchanges public keys. Through modular exponentiation, both compute the same shared secret without ever transmitting it. Elliptic‑curve Diffie‑Hellman (ECDH) offers the same functionality with smaller keys and better performance.
密钥交换算法使双方能在不安全的信道上建立共享秘密。迪菲‑赫尔曼(DH)是经典示例:双方各生成一对公私钥并交换公钥。通过模幂运算,双方无需传输秘密本身即可计算出相同的共享秘密。椭圆曲线迪菲‑赫尔曼(ECDH)以更小的密钥和更优性能提供相同功能。
Modern TLS cipher suites often use ECDHE (ephemeral) to provide forward secrecy: even if a server’s private key is compromised later, past session keys cannot be derived, because ephemeral keys are discarded after each session.
现代 TLS 密码套件常使用 ECDHE(临时)以实现前向保密:即使日后服务器私钥泄露,过去的会话密钥也无法推算,因为临时密钥在每次会话后即被丢弃。
8. Cipher Modes and Padding | 加密模式与填充
Block ciphers encrypt fixed‑size blocks, but messages are rarely an exact multiple of the block size. Padding adds extra bytes to reach the required length. Common padding schemes include PKCS#7. The mode of operation defines how blocks are linked to improve security.
分组密码加密固定大小的块,但消息很少正好是块的整数倍。填充通过添加额外字节来达到所需长度。常见填充方案如 PKCS#7。操作模式则定义了如何链接各个块以增强安全性。
- ECB (Electronic Codebook): Each block encrypted independently. Identical plaintext blocks produce identical ciphertext blocks – insecure for patterns. ECB:各块独立加密,相同明文块产生相同密文块 —— 会暴露模式,不安全。
- CBC (Cipher Block Chaining): Each plaintext block XORed with previous ciphertext block before encryption; uses an Initialization Vector (IV). CBC:加密前每个明文块与前一个密文块异或;需使用初始化向量(IV)。
- CTR (Counter): Turns a block cipher into a stream cipher by encrypting a counter value and XORing with plaintext. Parallelisable. CTR:通过加密计数器值并与明文异或,将分组密码转换为流密码;支持并行处理。
9. Common Attacks on Encryption | 常见加密攻击
Brute‑force attack: Trying every possible key. Defence: use long keys. Known‑plaintext attack: Attacker has some plaintext‑ciphertext pairs and tries to deduce the key. Ciphertext‑only attack: Attacker only has ciphertexts. Man‑in‑the‑middle (MITM) attack: An attacker intercepts public keys during exchange and substitutes their own, enabling decryption of traffic. This is prevented by certificate pinning and PKI.
暴力攻击:尝试每个可能的密钥,对策是使用长密钥。已知明文攻击:攻击者拥有部分明文‑密文对并试图推导密钥。唯密文攻击:攻击者仅有密文。中间人攻击(MITM):攻击者在密钥交换过程中截获公钥并替换成自己的,从而解密通信内容。通过证书锁定和公钥基础设施(PKI)可防范。
Side‑channel attacks exploit physical information leakage such as timing, power consumption, or electromagnetic emanations. Defences include constant‑time algorithms and shielding. SQL injection and social engineering are not cryptographic attacks, but they often bypass encryption entirely by targeting implementation or human weaknesses.
侧信道攻击利用物理信息泄露,如计时、功耗或电磁辐射。防御手段包括恒定时间算法和屏蔽措施。SQL 注入和社会工程学并非密码学攻击,但它们常通过攻击实现环节或人为弱点完全绕过加密。
10. Cryptographic Applications in Real Life | 现实中的密码应用
Encryption protects data at rest (full‑disk encryption, database encryption) and data in transit (HTTPS, VPNs, SSH). Wi‑Fi uses WPA3 (based on AES and the Dragonfly handshake). Messaging apps like Signal use the Signal Protocol, which combines Double Ratchet Algorithm, prekeys, and end‑to‑end encryption for forward secrecy and future secrecy.
加密保护静态数据(全盘加密、数据库加密)和传输中数据(HTTPS、VPN、SSH)。Wi‑Fi 采用 WPA3(基于 AES 和 Dragonfly 握手)。Signal 等即时通讯应用使用 Signal 协议,结合双棘轮算法、预密钥和端到端加密,实现前向保密与未来保密。
Blockchain relies on hashing (SHA‑256 in Bitcoin) for linking blocks and on digital signatures (ECDSA) for transaction authorisation. Password managers use a master password to derive a key that encrypts a vault of passwords; they employ strong KDFs like PBKDF2 or Argon2.
区块链依赖哈希(如比特币中的 SHA‑256)链接区块,并依赖数字签名(ECDSA)进行交易授权。密码管理器使用主密码派生密钥来加密密码库;它们采用强密钥派生函数(KDF),如 PBKDF2 或 Argon2。
11. Encryption in the IB and OCR Syllabi | IB 与 OCR 考纲要点
For IB Computer Science, Topic 3 (Networks) and the HL extension (Abstract Data Structures and the Case Study) require knowledge of symmetric/asymmetric encryption, SSL/TLS, and the importance of encryption in network security. For OCR A‑Level, Component 1 (Computer Systems) covers encryption, hashing, digital signatures, and their role in securing data; Component 2 (Algorithms and Programming) may ask you to describe the logic of cryptographic algorithms at a high level.
IB 计算机科学中,主题 3(网络)和 HL 拓展(抽象数据结构与案例研究)要求掌握对称/非对称加密、SSL/TLS 以及加密在网络安全中的重要性。OCR A‑Level 中,Component 1(计算机系统)涵盖加密、哈希、数字签名及其在数据安全中的作用;Component 2(算法与编程)可能要求高层描述密码算法的逻辑。
In exams, you may be asked to compare symmetric and asymmetric encryption, explain how a digital signature provides non‑repudiation, describe the TLS handshake, or evaluate the security of a given scenario. Always relate theory to practical examples and use precise terminology: cipher, key, plaintext, ciphertext, hash, digest, certificate, CA, forward secrecy.
考试可能要求比较对称与非对称加密,解释数字签名如何提供不可否认性,描述 TLS 握手过程,或评估特定场景的安全性。始终将理论联系实际例子,并使用精确术语:密码、密钥、明文、密文、哈希、摘要、证书、CA、前向保密。
12. Quick‑Reference Comparison | 速查对比
| Feature | Symmetric | Asymmetric |
|---|---|---|
| Keys | One shared secret | Public + private pair |
| Speed | Fast | Slower |
| Key distribution | Problematic | Public key can be open |
| Use case | Bulk data encryption | Key exchange, digital signatures |
| Examples | AES, ChaCha20 | RSA, ECC |
Use this table to structure comparison questions efficiently. Remember that modern systems combine both: asymmetric to bootstrap a symmetric connection, as seen in HTTPS.
使用此表可高效构建对比题答案。记住,现代系统将两者结合:用非对称加密启动对称连接,HTTPS 正是如此。
Published by TutorHao | IB OCR Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply