Network security
הוצג
7:25
רשתות מחשב
A network carries your bytes across a planet of machines that owe each other nothing. The first three units move a frame: layering, the link layer with IP, and…
קריינות באנגלית · כתוביות באנגלית ובסינית 中文 שאפשר להחליף ביניהן
בשיעור הזה
| English | משמעות |
|---|---|
| MAC/mæk/ | message authentication code: a tag computed with a shared key that shows a message has not been changed |
| authentication/ɔːˌθentɪˈkeɪʃn/ | Checking that a claimed identity is valid. |
| Confidentiality/ˌkɒnfɪˌdenʃiˈæləti/ | keeping data secret from anyone not allowed to read it |
| integrity/ɪnˈteɡrɪti/ | שלמות |
| TLS/ˌtiː el ˈes/ | Asymmetric cryptography agrees the key. |
| symmetric/sɪˈmetrɪk/ | סימטרי |
| asymmetric/ˌeɪsɪˈmetrɪk/ | לא סימטרי |
| Diffie–Hellman/ˈdɪfi ˈhelmən/ | a method for two parties to agree a shared secret key over a public channel |
| discrete logarithm/dɪˈskriːt ˈlɒɡərɪθəm/ | finding the secret exponent a from g^a mod p; easy to state but too slow to solve for large primes |
| ephemeral/ɪˈfemərəl/ | (of a key) new for each session and thrown away afterwards |
| forward secrecy/ˈfɔːwəd ˈsiːkrɪsi/ | past sessions stay secret even if a long-term key is stolen later |
| hash/hæʃ/ | a fixed-length digest of data that anyone can compute; it shows change but not who made it |
| digital signature/ˈdɪdʒɪtl ˈsɪɡnɪtʃə/ | a value made with a private key and checked with the public key, so anyone can verify who signed |
The three properties
- A secure channel needs three properties, and each has its own tool. A MAC 消息认证码 is a message authentication code:
| Property | Needs | Without it |
|---|---|---|
| Confidentiality 机密性 | encryption | anyone can listen in |
| Integrity 完整性 | a MAC | data can be changed |
| Authentication 身份验证 | a certificate chain to a trusted root | an impostor can pose as the server |
- TLS 传输层安全协议 combines them: symmetric 对称 encryption for the data (fast), asymmetric 非对称 cryptography to agree the key (one expensive step), and certificates for identity.

Integrity without confidentiality still —
רמת קושי 1/5 · 100 מטבעות + בונוס קטן בהשלמה הראשונה היום
A MAC catches alteration; encryption catches reading - separate defenses.
The handshake, step by step
- The messages, in order:
| Message | From | Carries |
|---|---|---|
| ClientHello | client | the cipher suites it supports, a fresh random number |
| ServerHello | server | the chosen suite, its random number, its certificate |
| Key exchange | client | a premaster secret, encrypted with the server's public key |
| Finished | both | a check of everything sent so far |
- Both sides derive the session keys from the two random numbers and the premaster secret. Then the data flows under symmetric encryption.
- TLS uses asymmetric cryptography for key agreement and server authentication, then symmetric cryptography to protect the data.
TLS uses asymmetric cryptography —
רמת קושי 1/5 · 100 מטבעות + בונוס קטן בהשלמה הראשונה היום
Asymmetric cryptography supports key agreement and server authentication; symmetric cryptography protects the data.
The attacker's options
- Passive listening is stopped by encryption. Changing data is stopped by the MAC (the Finished message catches changes to the handshake). Pretending to be the server is stopped by certificates. Replaying an old handshake is stopped by the fresh random numbers.
- Encrypting without authenticating gives you a secure channel to the wrong machine. HTTPS makes the channel private and identifies the server, but the content can still lie.
Handshake replay is defeated by —
רמת קושי 1/5 · 100 מטבעות + בונוס קטן בהשלמה הראשונה היום
Each handshake carries new randoms; a replayed one derives different keys.
Agreeing a key in public
- Diffie–Hellman 迪菲赫尔曼密钥交换 agrees a secret over an open line. Everyone knows a prime $p$ and a base $g$:
| Alice | Bob | |
|---|---|---|
| Keeps secret | $a$ | $b$ |
| Sends in the open | $A = g^a$ | $B = g^b$ |
| Computes | $B^a = g^{ab}$ | $A^b = g^{ab}$ |
- All the arithmetic is mod $p$, and both reach the same $g^{ab} \bmod p$. A listener sees $A$ and $B$, but finding $a$ from $A$ (a discrete logarithm 离散对数) is too slow for large $p$.
- With new ephemeral 临时 keys for each session, stealing the server's long-term key later cannot decrypt old traffic. This is forward secrecy 前向保密. Certificates sign the exchange, so the key is agreed with the right server.
With p = 23 and g = 5, Alice picks a = 4. What value does she send?
רמת קושי 2/5 · 140 מטבעות + בונוס קטן בהשלמה הראשונה היום
5^4 = 625, and 625 mod 23 = 625 - 621 = 4.
With ephemeral Diffie-Hellman, stealing the server's long-term key lets an attacker decrypt recorded old sessions.
רמת קושי 1/5 · 100 מטבעות + בונוס קטן בהשלמה הראשונה היום
The session keys came from throwaway exponents; the long-term key only signed the exchange.
Hash, MAC or signature?
- Anyone can compute a hash 哈希, so it proves nothing about who sent the data. A MAC needs a shared secret key: it proves the data came from someone who holds that key.
- A digital signature 数字签名 is made with a private key and checked with the public key. Anyone can check it, and only the key's owner could have made it, so the sender cannot deny it later.
Which lets a third party check that only the sender could have produced a message?
רמת קושי 1/5 · 100 מטבעות + בונוס קטן בהשלמה הראשונה היום
A MAC's key is shared, so either holder could have made it.
Worked example: Diffie–Hellman with small numbers
- Public $p = 23$, $g = 5$. Alice picks the secret $a = 6$ and sends $5^6 \bmod 23 = 8$; Bob picks $b = 15$ and sends $5^{15} \bmod 23 = 19$.
- Alice computes $19^6 \bmod 23 = 2$; Bob computes $8^{15} \bmod 23 = 2$. Both hold the key $\mathbf{2}$, which never crossed the wire. Real keys use numbers with hundreds of digits.
$p = 23$, $g = 5$, Alice's secret $a = 6$: the value she sends ($g^a \bmod p$)?
רמת קושי 2/5 · 140 מטבעות + בונוס קטן בהשלמה הראשונה היום
$5^6 = 15\,625$, and $15\,625 \bmod 23 = 8$.
Bob sent 19; Alice's secret is 6. The shared key ($19^6 \bmod 23$)?
רמת קושי 2/5 · 140 מטבעות + בונוס קטן בהשלמה הראשונה היום
Bob gets the same: $8^{15} \bmod 23 = 2$.
Marks that slip away
- Encryption without authentication. You get a private channel to whoever answered, perhaps the attacker.
- Public-key cryptography for the data. It is slow; TLS uses it once, to agree a symmetric key.
- Taking HTTPS as proof of content. It identifies the server and protects the channel; the page can still lie.
Recap
- Encryption gives confidentiality, a MAC gives integrity, a certificate chain gives authentication.
- TLS: asymmetric cryptography agrees the key; symmetric cryptography moves the data.
- Fresh random numbers stop replay; Finished messages catch tampering.
מה השתבש? רק צוות האתר רואה זאת.