📄 cipe.texinfo
字号:
@end exampleThis is all of the minimum configuration. Note that no @code{me} and@code{peer} options are necessary. These are determined by@command{pkcipe}. It does not matter which side runs @code{pkcipe} inserver and which one in client mode.In server mode, @code{pkcipe} has to be started via @code{inetd}. Thisrequires the following steps:@cindex inetd@enumerate@itemChoose a port. (This is arbitrary, here I use 963.) Enter this port into@file{/etc/services} on @emph{both} machines, giving it a name:@examplepkcipe 963/tcp@end example@itemEnter the parameters into @file{/etc/inetd.conf}:@examplepkcipe stream tcp nowait root /usr/local/sbin/pkcipe pkcipe@end exampleor if using TCP Wrapper for access control:@examplepkcipe stream tcp nowait root /usr/sbin/tcpd /usr/local/sbin/pkcipe@end exampleRestart @code{inetd} after any change.@end enumerateThe other end then initiates the connection simply via@examplepkcipe -c @var{server.machine}:pkcipe@end exampleIt is possible to run this connection through NAT (masquerading) or viaSOCKS using a dynamic SOCKS library (@code{socksify}/@code{runsocks}script). In the latter case it may be necessary to repeat the peeraddress in a @code{-r @var{server.machine}} argument.@cindex PKCIPE, over SOCKS@page@node Connection modes, , Example 2, Examples@section Connection modesHere is in detail how it is possible to build CIPE links betweendifferent classes of carriers. Those classes are, based on how they areable to reach the carrier network (usually the Internet):@enumerate@item @c 1Direct connection on a static IP address.@item @c 2Direct connection on a dynamic IP address.@cindex dynamic addresses@item @c 3Indirect connection through a SOCKS server.@cindex SOCKS@item @c 4Indirect connection through a NAT (masquerading) router.@cindex NAT@cindex masquerading@end enumerateThis produces ten different combinations:@table @samp@item 1-1Can be configured statically like in the simple example. Or any end mayrun a PKCIPE server and let the other end connect.@item 1-2The @samp{1} end can run a PKCIPE server and let the @samp{2} endconnect. @code{pkcipe} gets the right IP addresses at both ends, laterchanges are handled automatically. @footnote{It is also possible, butless convenient, to configure this statically: The carrier address ofthe @samp{2} end should be the special dummy @code{127.0.0.1:9}, and the@code{ip-up} script in @samp{2} should have the @code{ping} statement asin the sample. See also @samp{1-3}.}@cindex Dynamic DNS@item 1-3Like @samp{1-2}, with a @code{ping} in @code{ip-up} at the @samp{3} end.The @samp{3} end does not know its effective (as seen by the other end)carrier address, so the PKCIPE exchange produces a wrong @code{peer}parameter at the @samp{1} end. The @code{ping} corrects that by sendingpackets with the right address. @footnote{Static configuration like@samp{1-2} is also possible.}@item 1-4Like @samp{1-3}.@item 2-2One end runs a PKCIPE server and publishes its current IP address usingsome external service (like a web server or dynamic DNS@footnote{Dynamic DNS is easiest to handle because it does not need anyexternal scripts or special software for CIPE, only the dynamic DNSclient. There are some services which provide dynamic DNS free ofcharge.}). The other end fetches this address to connect to and proceedslike in @samp{1-2}.@item 2-3Like @samp{1-3}, except that the @samp{2} end uses an external serviceto publish its current address.@item 2-4Like @samp{1-4}, except that the @samp{2} end uses an external serviceto publish its current address.@item 3-3This is not easily possible with the current code because neither endknows its effective carrier address (i.e. the SOCKS UDP relayer address)before the link is set up, and so neither side can send packets to theother. This information is available in the @code{ip-up} script, buttransmitting it to the other end would need some means outside of CIPE.It is planned that future versions will be able to handle this viaextended capabilities of PKCIPE; this will also require an externalservice like dynamic DNS with a special setup.@item 3-4Like @samp{3-3}.@item 4-4Not possible. Neither side gets to know its effective carrier address at all.@end table@xref{Dynamic carrier}, for a more detailed explanation of some of theseconfigurations.@c --------------------------------------------------------------------------@node Protocol descriptions, Misc, Examples, Top@chapter Protocol descriptions@menu* The CIPE Protocol:: Encrypted IP encapsulation used by CIPE.* The PKCIPE Protocol:: Public-key based setup and key exchange.@end menu@node The CIPE Protocol, The PKCIPE Protocol, Protocol descriptions, Protocol descriptions@section The CIPE protocol@cartouche@displayThis chapter is copied verbatim from the earlier documentation texts.@end display@end cartoucheThe primary goal of this software is to provide a facility for secure(against eavesdropping, including traffic analsyis, and faked messageinjection) subnetwork interconnection across an insecure packetnetwork such as the Internet.1. OverviewThis protocol was designed to be simple and efficient, and to workover existing communication facilities, especially by encapsulation inUDP packets. Compatibility with existing protocols such as the IPSECRFCs were not a concern. The first test implementation was doneentirely on the user level, while the now published one consists of akernel module and a user level program.@cindex IPSECThe CIPE model assumes a fixed link between two peers which exchangedatagrams (packetwise, not necessarily reliable). The most common wayof implementing such a thing is sending UDP messages between them.(Another would be encapsulation in PPP, etc.)Nothing that can be parameterized is inside the scope of this protocoland implementation. This is delegated to either prior arrangement or ayet-to-be-defined application level protocol. Most notably, thisinvolves exchanging a shared secret key by now, and it involves choiceof encryption algorithm.The CIPE protocol consists of two parts: Encryption and checksummingof the data packets and dynamic key exchange.2. Packet encryption@cindex Packet encryptionEach IP datagram is taken as a whole, including headers. It is paddedat the end with zero to seven random octets so that the total lengthin octets is congruent three modulo eight. The padded packet isappended with one octet of the value P described below and the CRC-32over the packet built up so far, up to and including P. (This makesthe complete packet length a multiple of eight octets.)This packet is then encrypted through a 64-bit block cipher in CBCmode with an IV as described below using either the static or thesending dynamic key of the outbound interface (for definition of keyssee below). The default cipher algorithm is IDEA. The currentimplementation also supports Blowfish with 128 bit key.@cindex IDEA@cindex BlowfishThe encrypted packet is prepended with the IV block. The highest orderbit of the first octet of the IV is zero if the static key is used,one if the dynamic key is used. The remaining 63 bits are random, butthe first 31 of them should not be all zeros (i.e. an IV/packet thatstarts with hex 0000 0000 or 8000 0000 is not allowed). Such packetsare reserved for later protocol extensions.The CRC is over the polynomial@example@noindentX^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0@end exampleand represented in network byte order.@cindex CRCThe value P is given as follows: bits 6,5,4 indicate the length of thepadding between the original packet end and P. Bits 2,1 are a typecode, indicating which kind of packet this is. The remaining bits7,3,0 are reserved and must be zero.The type codes are:00 - data01 - key exchange10 - reserved11 - reservedFor decryption, first check the highest bit of the first octet and useit to select the key. Decrypt the packet, calculate the CRC over thepacket minus the last four octets, compare that with the last fouroctets. If valid, strip off the last octet as value P, strip off thepadding as given by bits 6,5,4 of P and process the packet asindicated by bits 2,1 of P.3. Key exchange@cindex Key exchangeEvery interface is associated with a static key, a sending dynamic keyand a receiving dynamic key. (An interface is an endpoint of aconnection, which may use protocols like UDP for transport but for thepurpose of CIPE are always point-to-point links.) On startup, only thestatic key is valid. Encryption uses the static key if and only if thesending dynamic key is invalid. The value 0 (all bits zero) for thestatic key is reserved for future extensions and should not be used.The dynamic key is set by a dialogue procedure involving messages withtype code bits 01. These are encrypted just like above. The packetsconsist of a type octet followed by protocol data followed by a randomamount of padding random data, so that the packet is at least 64 octetslong. A key consists of 16 octets, a key CRC is the CRC-32 over thekey, transferred in network order.The following messages exist:NK_REQ: Type code 1, no data: Requests the peer to immediately start akey negotiation (send NK_IND). This should be sent when a packet isreceived encrypted with a dynamic key but no dynamic receive key isvalid. (Which can happen when the receiving side of a connection isrebooted while the sending side remains running.)NK_IND: Type code 2, data is new key followed by key CRC. Specifies anew sending dynamic key for this sender. Requests the peer toimmediately answer with NK_ACK.NK_ACK: Type code 3, data is CRC of the previously accepted key.Confirms receipt of NK_IND.The key negotiation procedure normally runs as follows: The sendersends a NK_IND with the new key, then invalidates its own sending key.Upon receipt of NK_IND, the receiver starts using this key as itsreceiving key and sends a NK_ACK. When the sender receives NK_ACK, itstarts using the new key as its sending key. If either of NK_IND orNK_ACK is lost in transmission, no new key will be used. The sendershould send a new NK_IND (with new key) if no matching NK_ACK isreceived within a reasonable amount of time (current specification: 10seconds).If any of the checksums contained in the key negotiation datamismatches the contained or stored key, this packet is ignored and nofurther action taken.A sending dynamic key should be invalidated after being used for acertain period of time or amount of data and a new NK_IND sent. Theprocess is symmetric and both sides act independently for their ownsending key. The dynamic key lifetime should not exceed 15 minutes andthe amount of data sent using one dynamic key should not exceed 2^32packets.Optionally, the key exchange packets can be timestamped. The timestampis a 32bit unsigned integer in network order representing the UNIX timeof the sending host, placed in octets 56-59 (starting at zero) of thekey exchange packets. The receiver may be configured to ignore thetimestamp, or it may be configured to reject all key exchange packetswhose timestamp differs from the current UNIX time of the receiving hostby more than a defined amount. It is recommended that this timeout notexceeds 30 seconds.4. Security considerationsThe packets that actually get transmitted don't carry any usableinformation related to the original IP datagram other than its length,padded to a multiple of 8. This should effectively guard against mostaspects of traffic analysis. The only information visible prior(attempt) to decrypting the packet is the bit that tells whether thestatic or dynamic key was used. Because the static key has apotentially long lifetime it is expected to be used as rarely aspossible. It is normally used only in the short period of time duringa key exchange. The dynamic key is changed often. These precautionsare there because the application is prone to known and chosenplaintext attacks and the intention is to inhibit feeding of largeamounts of data through one key.Because the type code and padding length are encrypted with thepacket, they can not be deduced from the ciphertext. Especially, it isnot possible to determine whether the packet is a data or key exchangepacket. (Usually, the last packet
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -