IPsec VPNs provide security services to traffic traversing a relatively less trustworthy network between two relatively more trusted systems or networks. The less-trusted network is usually the public internet. But IPsec VPNs can also be used for things like protecting network management traffic as it crosses an organization intranet.
IPsec VPN 為往返於相對不受信任的網路(兩個相對受信任的系統或網路之間)的流量提供安全服務。這個較不受信任的網路通常是公共網際網路。但 IPsec VPN 也可以用於保護管理流量穿越組織內部網路等情境。
IPsec provides these essential security functions:
IPsec 提供以下這些基本的安全功能:
- Confidentiality: IPsec ensures confidentiality by using encryption. Data encryption prevents third parties from reading the data. Only the IPsec peer can decrypt and read the encrypted data.機密性: IPsec 藉由使用加密來確保機密性。資料加密可防止第三方讀取資料,只有 IPsec 對等端可以解密並讀取加密後的資料。
- Data integrity: IPsec ensures that data arrives unchanged at the destination, meaning that the data has not been manipulated at any point along the communication path. IPsec ensures data integrity by using hash-based message authentication.資料完整性: IPsec 確保資料能不經更動地抵達目的地,也就是資料在傳輸路徑上任何一點都未被竄改。IPsec 透過雜湊訊息鑑別碼來確保資料完整性。
- Origin authentication: Authentication ensures that the connection is made with the desired communication partner. IPsec uses Internet Key Exchange (IKE) to authenticate users and devices that can carry out communication independently. IKE uses several methods to authenticate the peer system.來源 驗證: 驗證可確保連線是與所需的通訊對象建立的。IPsec 使用網際網路金鑰交換(IKE)來驗證能夠獨立進行通訊的使用者與裝置。IKE 使用多種方法來驗證對等系統。
- Anti-replay protection:Anti-replay protection verifies that each packet is unique and is not duplicated. IPsec packets are protected by comparing the sequence number of the received packets with a sliding window on the destination host or security gateway. A packet that has a sequence number that comes before the sliding window is considered either late, or a duplicate packet. Late and duplicate packets are dropped.防重放-保護:防重放保護會驗證每個封包都是唯一且未重複的。IPsec 透過在目的主機或安全閘道上,將收到封包的序號與滑動視窗進行比對來保護封包。序號早於滑動視窗的封包會被視為遲到封包或重複封包。遲到及重複的封包都會被丟棄。
- Key management: Allows for an initial secure exchange of dynamically generated keys across a nontrusted network and a periodic rekeying process, limiting the maximum amount of time and data that are protected with any one key.金鑰管理: 允許在不受信任的網路上進行動態產生金鑰的初始安全交換,並定期進行金鑰重新產生,藉此限制任一金鑰所保護的最長時間與資料量。
IPsec is a framework of open standards that spells out the rules for secure communications. IPsec relies on existing algorithms to implement encryption, authentication, and key exchange. The figure below illustrates some of the standard algorithms that IPsec uses. The framework is a modular design allowing technologies to be replaced over time. When cryptographic technologies become obsolete, it does not make the IPsec framework obsolete. Current technologies are swapped to replace the obsolete technologies, keeping the framework in place. For example, AES is now commonly implemented for confidentiality in place of the aging DES and 3DES technologies. Similarly, SHA 2-based algorithms are used for data integrity, in place of the deprecated MD5 and SHA-1-based algorithms.
IPsec 是一套開放標準的框架,明確規範了安全通訊的規則。IPsec 依賴既有的演算法來實作加密、驗證與金鑰交換。下圖說明 IPsec 使用的一些標準演算法。此框架採模組化設計,讓技術可以隨著時間更換。當某種密碼技術過時後,並不會使 IPsec 框架跟著過時,只需要將過時的技術替換成目前的技術,框架本身則維持不變。例如,AES 目前已普遍被實作用於機密性保護,取代已老舊的 DES 及 3DES 技術。同樣地,基於 SHA-2 的演算法也已用於資料完整性保護,取代已淘汰的 MD5 及基於 SHA-1 的演算法。
IPsec Framework Protocols
IPsec 框架協定
There are two main IPsec framework protocols:
IPsec 框架主要有兩種協定:
- Authentication Header (AH): AH, which is IP protocol 51, is the appropriate protocol to use when confidentiality is not required or permitted. AH does not provide data confidentiality (encryption). All text is transported unencrypted. If the AH protocol is used alone, it provides weak protection. AH does, however, provide origin authentication, data integrity, and anti-replay protection for IP packets that are passed between two systems.驗證標頭(AH): AH 是 IP 協定編號 51,適用於不需要或不允許機密性的情況。AH 不提供資料機密性(加密),所有文字都以未加密方式傳輸。若單獨使用 AH 協定,其保護力較弱。不過,AH 確實能為在兩個系統之間傳遞的 IP 封包提供來源驗證、資料完整性以及防重放保護。
- Encapsulating Security Payload (ESP): ESP is a security protocol that provides origin authentication, data integrity, and anti-replay protection. However, unlike AH, it also provides confidentiality. ESP, which is IP protocol 50, provides confidentiality by encrypting IP packets. The IP packet encryption conceals the data payload and the identities of the ultimate source and destination.封裝安全承載(ESP): ESP 是一種安全協定,可提供來源驗證、資料完整性及防重放保護。但與 AH 不同的是,ESP 也提供機密性。ESP 的 IP 協定編號為 50,透過加密 IP 封包來提供機密性。IP 封包加密可隱藏承載資料以及最終來源與目的地的身分。
ESP supports various symmetric encryption algorithms. The original data is well protected by ESP, because the original IP packet is encrypted. As illustrated in the figure for an IPv4 packet, an ESP header is added to the ciphertext, which consists of the encrypted IPv4 packet and ESP trailer. When ESP authentication is also used, the encrypted IPv4 packet and ESP trailer, as well as the ESP header, are included in the hashing process.
ESP 支援多種對稱式加密演算法。由於原始 IP 封包已被加密,原始資料受到 ESP 良好的保護。如圖中所示的 IPv4 封包,ESP 標頭會被加到密文之前,密文則由已加密的 IPv4 封包及 ESP 尾端組成。當同時使用 ESP 驗證時,已加密的 IPv4 封包、ESP 尾端以及 ESP 標頭都會納入雜湊運算過程。
When both authentication and encryption are used, the encryption is performed first. Authentication is then performed by sending the encrypted information through a hash algorithm. The hash provides data integrity and data origin authentication. Finally, a new IPv4 header is prepended to the authenticated payload. The new IPv4 address is used to route the packet. ESP does not attempt to provide data integrity for this new external IP header.
當同時使用驗證與加密時,會先執行加密。接著透過將已加密資訊送入雜湊演算法來進行驗證,此雜湊值可提供資料完整性與資料來源驗證。最後,會在已驗證的承載資料前面加上一個新的 IPv4 標頭,這個新的 IPv4 位址則用於路由該封包。ESP 並不會為這個新的外部 IP 標頭提供資料完整性保護。
Performing encryption before authentication facilitates rapid detection and rejection of replayed or bogus packets by the receiving device. Before decrypting the packet, the receiver can authenticate inbound packets. By doing this authentication, it can quickly detect problems and potentially reduce the impact of DoS attacks. ESP can, optionally, enforce anti-replay protection by requiring that a receiving host sets the replay bit in the header to indicate that the packet has been seen.
先加密後驗證的做法,能讓接收端裝置快速偵測並拒絕重放或偽造的封包。在解密封包之前,接收端便可以先驗證進入的封包,藉由這樣的驗證,能快速偵測問題並可能降低 DoS 攻擊造成的衝擊。ESP 也可以選擇性地強制執行防重放保護,方法是要求接收端主機在標頭中設定重放位元,以表示該封包已被看過。
In modern IPsec VPN implementations, the use of ESP is common. Although both encryption and authentication are optional in ESP, one of them must be used.
在現代 IPsec VPN 實作中,普遍會使用 ESP。雖然 ESP 中的加密與驗證都是選用的,但兩者至少必須使用一個。
ESP can operate in either the transport mode or tunnel mode:
ESP 可以在傳輸模式或通道模式下運作:
- ESP transport mode:Does not protect the original packet IP header. Only the original packet payload is protected—the original packet payload and ESP trailer are encrypted. An ESP header is inserted between the original IP header and the protected payload. Transport mode can be negotiated directly between two IP hosts. ESP transport mode can be used for site-to-site VPN if another technology, such as Generic Routing Encapsulation (GRE) tunneling, is used to provide the outer IP header.ESP 傳輸模式: 不會保護原始封包的 IP 標頭,僅保護原始封包的承載資料,即原始封包承載資料與 ESP 尾端會被加密。ESP 標頭會插入在原始 IP 標頭與受保護承載資料之間。傳輸模式可以直接在兩台 IP 主機之間協商。若搭配另一項技術(例如通用路由封裝〔GRE〕通道)來提供外部 IP 標頭,ESP 傳輸模式也可用於站對站 VPN。
- ESP tunnel mode: Protects the entire original IP packet, including its IP header. The original IP packet (and ESP trailer) is encrypted. An ESP header is applied for the transport layer header, and this is encapsulated in a new packet with a new IP header. The new IP header specifies the VPN peers as the source and destination IP addresses. The IP addresses specified in the original IP packet are not visible.ESP 通道模式: 保護整個原始 IP 封包,包括其 IP 標頭。原始 IP 封包(及 ESP 尾端)會被加密。ESP 標頭會套用於傳輸層標頭,並封裝在具有新 IP 標頭的新封包中,新的 IP 標頭會將 VPN 對等端指定為來源與目的地 IP 位址,原始 IP 封包中所指定的 IP 位址則不會被看見。
Confidentiality
機密性
Choosing an encryption algorithm is one of the most important decisions that a network security professional makes when building a cryptosystem.
選擇加密演算法是網路安全專業人員在建置密碼系統時,所做出最重要的決策之一。
When choosing an algorithm, two main criteria are considered:
選擇演算法時,主要會考量兩項標準:
- The algorithm must be trusted by the cryptographic community.此演算法必須受到密碼學界的信任。
- The algorithm must adequately protect against brute-force attacks.此演算法必須能充分抵禦暴力破解攻擊。
Below are some of the encryption algorithms and key lengths that IPsec can use:
以下是 IPsec 可使用的一些加密演算法及其金鑰長度:
- DES algorithm: DES, developed by IBM, uses a 56-bit key, ensuring high-performance encryption. DES is a symmetric key cryptosystem.DES 演算法: DES 由 IBM 開發,使用 56 位元金鑰,可確保高效能的加密。DES 是一種對稱金鑰密碼系統。
- 3DES algorithm: The 3DES algorithm is a variant of the 56-bit DES. 3DES operates in a way that is similar to how DES operates, in that data is broken into 64-bit blocks. 3DES then processes each block 3 times, each time with an independent 56-bit key. 3DES provides a significant improvement in encryption strength over 56-bit DES. 3DES is a symmetric key cryptosystem.3DES 演算法: 3DES 演算法是 56 位元 DES 的變體。3DES 的運作方式與 DES 類似,都會將資料切分為 64 位元區塊,接著 3DES 會對每個區塊處理 3 次,每次使用獨立的 56 位元金鑰。相較於 56 位元 DES,3DES 在加密強度上有顯著提升。3DES 是一種對稱金鑰密碼系統。
- AES:The National Institute of Standards and Technology (NIST) adopted AES to replace the aging DES-based encryption in cryptographic devices. AES provides stronger security than DES and is computationally more efficient than 3DES. AES offers three different key lengths: 128-, 192-, and 256-bit keys.AES: 美國國家標準與技術研究院(NIST)採用 AES,取代密碼裝置中老舊的 DES 加密。AES 提供比 DES 更強的安全性,且在運算效率上優於 3DES。AES 提供三種不同的金鑰長度:128 位元、192 位元及 256 位元。
- RSA:RSA is an asymmetrical key cryptosystem. It commonly uses a key length of 1024 bits or larger. IPsec does not use RSA for data encryption. IKE uses RSA encryption only during the peer authentication phase.RSA: RSA 是一種非對稱金鑰密碼系統,通常使用 1024 位元或更長的金鑰長度。IPsec 不會使用 RSA 進行資料加密,IKE 僅在對等端驗證階段使用 RSA 加密。
- SEAL: Software-Optimized Encryption Algorithm (SEAL) is a stream cipher that was developed in 1993 by Phillip Rogaway and Don Coppersmith, and uses a 160-bit key for encryption.SEAL: 軟體最佳化加密演算法(SEAL)是一種串流加密法,由 Phillip Rogaway 與 Don Coppersmith 於 1993 年開發,使用 160 位元金鑰進行加密。
Symmetric encryption algorithms such as AES require a common shared-secret key to perform encryption and decryption. You can use email, courier, or overnight express to send the shared-secret keys to the administrators of the devices. This method is obviously impractical, and does not guarantee that keys are not intercepted in transit. Public-key exchange methods allow shared keys to be dynamically generated between the encrypting and decrypting devices:
像 AES 這樣的對稱加密演算法,需要一組共同的共享密鑰才能進行加密與解密。你可以透過電子郵件、快遞或隔夜快遞將共享密鑰傳送給裝置的管理員,但這種方式顯然不切實際,也無法保證金鑰在傳輸過程中不會被攔截。公開金鑰交換方法可讓加密端與解密端裝置之間動態產生共享金鑰:
Key Management
金鑰管理
Public key exchange methods allow shared keys to be dynamically generated between encrypting and decrypting devices:
公開金鑰交換方法可讓加密端與解密端裝置之間動態產生共享金鑰:
- The Diffie-Hellman (DH) key agreement is a public key exchange method. This method provides a way for two peers to establish a shared secret key, which only they know, even though they are communicating over an insecure channel.迪菲-赫爾曼(DH)金鑰協議是一種公開金鑰交換方法,讓兩個對等端即使在不安全的通道上通訊,也能建立一組只有彼此知道的共享密鑰。
- Elliptical Curve Diffie-Hellman (ECDH)is a variant of the DH protocol using elliptic curve cryptography (ECC). It is part of the Suite B standards.橢圓曲線迪菲-赫爾曼(ECDH)是使用橢圓曲線密碼學(ECC)的 DH 協定變體,屬於 Suite B 標準的一部分。
These algorithms are used within IKE to establish session keys. They support different prime sizes that are identified by different DH or ECDH groups.
這些演算法在 IKE 中用於建立工作階段金鑰,並依不同的 DH 或 ECDH 群組支援不同的質數大小。
DH groups vary in the computational expense that is required for key agreement and the strength against cryptographic attacks. Larger prime sizes provide stronger security, but require more computational horsepower to execute:
各 DH 群組在金鑰協議所需的運算成本,以及抵禦密碼學攻擊的強度上各有不同。較大的質數可提供較強的安全性,但需要更多的運算能力來執行:
- DH1: 768-bitDH1: 768 位元
- DH2: 1024-bitDH2: 1024 位元
- DH5: 1536-bitDH5: 1536 位元
- DH14: 2048-bitDH14: 2048 位元
- DH15: 3072-bitDH15: 3072 位元
- DH16: 4096-bitDH16: 4096 位元
- DH19:256-bit ECDHDH19: 256 位元 ECDH
- DH20: 384-bit ECDHDH20: 384 位元 ECDH
- DH24: 2048-bit ECDHDH24: 2048 位元 ECDH
The following figure illustrates the key exchange process.
下圖說明金鑰交換的流程。
Internet Key Exchange
網際網路金鑰交換
IPsec implements a VPN solution using an encryption process that involves the periodic changing of encryption keys. IPsec uses the IKE protocol to authenticate a peer computer and to generate encryption keys. IKE negotiates a security association (SA), which is an agreement between two peers engaging in an IPsec exchange, and the SA consists of all the required parameters that are necessary to establish successful communication.
IPsec 使用的加密流程包含定期更換加密金鑰,以此實作 VPN 解決方案。IPsec 使用 IKE 協定來驗證對等電腦並產生加密金鑰。IKE 會協商一個安全關聯(SA),這是進行 IPsec 交換的兩個對等端之間的協議,SA 包含成功建立通訊所需的所有必要參數。
IKEv2 was created to overcome some of the IKEv1 limitations.
IKEv2 是為了克服 IKEv1 的一些限制而建立的。
IKEv2 and Benefits vs IKEv1
IKEv2 及其相較於 IKEv1 的優勢
IKEv2 is an enhancement to IKEv1. It is an updated version of the IKE protocol and it provides several benefits compared to IKEv1. Also, Cisco IOS FlexVPN relies on IKEv2 as a security technology.
IKEv2 是 IKEv1 的強化版本,是更新版的 IKE 協定,相較於 IKEv1 提供了多項優點。此外,Cisco IOS FlexVPN 也是以 IKEv2 作為其安全技術。
The two IKE versions are not compatible so both peers must use the same IKE version. IKEv2 uses similar negotiation messages to IKEv1, but with some differences. IKEv2 uses four messages for the Exchange phase; IKEv1 uses either six messages (in main mode) or three messages (in aggressive mode) for Phase1. Also, IKEv2 reduces the required bandwidth as compared to IKEv1.
這兩個 IKE 版本並不相容,因此雙方對等端必須使用相同的 IKE 版本。IKEv2 使用與 IKEv1 類似的協商訊息,但有一些差異。IKEv2 在交換階段使用四則訊息;IKEv1 在 Phase 1 則使用六則訊息(主模式)或三則訊息(積極模式)。此外,與 IKEv1 相比,IKEv2 減少了所需的頻寬。
IKEv2 is more secure and gives more authentication options to build a secure tunnel between the peers.
IKEv2 更為安全,並提供更多驗證選項,以在對等端之間建立安全通道。
IKEv2 supports EAP authentication besides the Pre-Shared Key (PSK) and the Certificate authentication. It also supports asymmetric authentication (different authentication method on each peer). The following table summarizes some of the differences between IKEv1 and IKEv2, and the benefits of the new version:
除了預先共享金鑰(PSK)與憑證驗證外,IKEv2 也支援 EAP 驗證,同時也支援非對稱驗證(每個對等端可使用不同的驗證方法)。下表整理了 IKEv1 與 IKEv2 之間的一些差異,以及新版本的優點:
IKEv1 IKEv1 | IKEv2 IKEv2 |
based on RFC 2409 基於 RFC 2409 | based on RFC 5996 基於 RFC 5996 |
no reliability 不具可靠性 | acknolwedged and sequenced 已確認且已排序 |
no Cisco IOS FlexVPN support 不支援 Cisco IOS FlexVPN | Cisco IOS FlexVPN relies on IKEv2 Cisco IOS FlexVPN 依賴 IKEv2 |
more advanced encryption algorithm 更先進的加密演算法 | |
bandwidth usage reduced 已降低頻寬使用量 |
Data Integrity
資料完整性
VPN data is transported over untrusted networks such as the public internet. Potentially, this data could be intercepted and read or modified. To guard against modification, Hashed Message Authentication Codes (HMACs) are used by IPsec.
VPN 資料是透過像公共網際網路這樣不受信任的網路傳輸的,這些資料有可能被攔截、讀取或竄改。為了防範資料被竄改,IPsec 使用雜湊訊息鑑別碼(HMAC)。
IPsec uses HMAC as the data integrity algorithm that verifies the integrity of the message. Hashing algorithms such as SHA-2 are the basis of the protection mechanism of HMAC. HMACs use existing hash algorithms, but with a significant difference. HMACs add a secret key as input to the hash function. Only the sender and the receiver know the secret key, and the output of the hash function now depends on the input data and the secret key. Therefore, only parties who have access to that secret key can compute the digest of an HMAC function.
IPsec 使用 HMAC 作為驗證訊息完整性的資料完整性演算法。像 SHA-2 這樣的雜湊演算法,是 HMAC 保護機制的基礎。HMAC 使用既有的雜湊演算法,但有一個重大差異:HMAC 會將一組密鑰做為雜湊函式的額外輸入。只有寄送端與接收端知道這組密鑰,此時雜湊函式的輸出不僅取決於輸入資料,也取決於這組密鑰。因此,只有擁有該密鑰的一方才能計算出 HMAC 函式的摘要值。
The following figure depicts a keyed hash that is a simplification of the more complex HMAC algorithm. The HMAC algorithm itself is beyond the scope of this material. HMAC is defined in RFC 2104. Like a keyed hash, HMAC utilizes a secret key known to the sender and the receiver.
下圖描繪了一個帶金鑰的雜湊,這是對更複雜的 HMAC 演算法的簡化說明。HMAC 演算法本身已超出本教材範圍,HMAC 是在 RFC 2104 中定義的。與帶金鑰的雜湊一樣,HMAC 也使用寄送端與接收端所知道的密鑰。
Origin Authentication
來源驗證
When you conduct business long distance, it is important to know who is at the other end of the phone, email, or fax. The same is true of VPN networks. The device on the other end of the VPN tunnel must be authenticated before the communication path is considered secure.
當你進行長途業務往來時,知道電話、電子郵件或傳真另一端的對象是誰非常重要,VPN 網路也是如此。在通訊路徑被視為安全之前,VPN 通道另一端的裝置必須先經過驗證。
IPsec uses these methods for peer-authentication:
IPsec 使用以下方法進行對等端驗證:
- Pre-shared keys (PSKs): A secret key value is entered into each peer manually and is used to authenticate the peer. At each end, the PSK is combined with other information to form the authentication key.預先共享金鑰(PSK): 手動在每個對等端輸入一組密鑰值,用來驗證對等端身分。在每一端,PSK 會與其他資訊結合,形成驗證金鑰。
- RSA signatures: The exchange of digital certificates authenticates the peers. The local device derives a hash and encrypts it with its private key. The encrypted hash is attached to the message and is forwarded to the remote end, and it acts like a signature. At the remote end, the encrypted hash is decrypted using the public key of the local end. If the decrypted hash matches the recomputed hash, the signature is genuine.RSA 簽章: 透過交換數位憑證來驗證對等端身分。本地裝置會產生一個雜湊值,並用其私密金鑰加密,這個已加密的雜湊值會附加在訊息中並轉送到遠端,作用如同簽章。在遠端,已加密的雜湊值會使用本地端的公開金鑰進行解密,若解密後的雜湊值與重新計算出的雜湊值相符,則表示該簽章是真實的。
- RSA encrypted nonces: A nonce is a random number that is generated by the peer. RSA-encrypted nonces use RSA to encrypt the nonce value and other values. This method requires that each peer is aware of the public key of the other peer before negotiation starts. For this reason, public keys must be manually copied to each peer as part of the configuration process. This method is the least used of the three authentication methods.RSA 加密隨機數: 隨機數是由對等端所產生的隨機數字。RSA 加密隨機數會使用 RSA 對隨機數值及其他數值進行加密。此方法要求每個對等端在協商開始前,必須知道另一個對等端的公開金鑰,因此公開金鑰必須在設定過程中手動複製到每個對等端。這是三種驗證方法中最少被使用的一種。
- ECDSA signatures: Elliptic Curve Digital Signature Algorithm (ECDSA) is the elliptic curve analog of the DSA signature method. ECDSA signatures are smaller than RSA signatures of similar cryptographic strength. On many platforms, ECDSA operations can be computed more quickly than similar-strength RSA operations. These advantages of signature size, bandwidth, and computational efficiency might make ECDSA an attractive choice for many IKE and IKEv2 implementations.ECDSA 簽章: 橢圓曲線數位簽章演算法(ECDSA)是 DSA 簽章方法的橢圓曲線版本。在同等密碼學強度下,ECDSA 簽章比 RSA 簽章更短。在許多平台上,ECDSA 運算的速度也比同等強度的 RSA 運算更快。這些在簽章大小、頻寬與運算效率上的優勢,使 ECDSA 成為許多 IKE 與 IKEv2 實作的理想選擇。



