chiark / gitweb /
Fix logrotate script.
[tripe] / tripe-protocol.h
CommitLineData
165db1a8 1/* -*-c-*-
2 *
3 * $Id: tripe-protocol.h,v 1.1 2003/10/15 09:30:18 mdw Exp $
4 *
5 * Protocol definition for TrIPE
6 *
7 * (c) 2003 Straylight/Edgeware
8 */
9
10/*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of Trivial IP Encryption (TrIPE).
13 *
14 * TrIPE is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * TrIPE is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with TrIPE; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 */
28
29/*----- Revision history --------------------------------------------------*
30 *
31 * $Log: tripe-protocol.h,v $
32 * Revision 1.1 2003/10/15 09:30:18 mdw
33 * Add support for Ethereal protocol analysis.
34 *
35 */
36
37#ifndef TRIPE_PROTOCOL_H
38#define TRIPE_PROTOCOL_H
39
40/*----- TrIPE protocol ----------------------------------------------------*/
41
42/* --- TrIPE message format --- *
43 *
44 * A packet begins with a single-byte message type. The top four bits are a
45 * category code used to send the message to the right general place in the
46 * code; the bottom bits identify the actual message type.
47 */
48
49#define MSG_CATMASK 0xf0
50#define MSG_TYPEMASK 0x0f
51
52/* --- Encrypted message packets --- *
53 *
54 * Messages of category @MSG_PACKET@ contain encrypted network packets. The
55 * message content is a symmetric-encrypted block (see below). Reception of
56 * a packet encrypted under a new key implicitly permits that key to be used
57 * to send further packets.
58 *
59 * The only packet type accepted is zero.
60 *
61 * Packets may be encrypted under any live keyset, but should use the most
62 * recent one.
63 */
64
65#define MSG_PACKET 0x00
66
67/* --- Key exchange packets --- */
68
69#define MSG_KEYEXCH 0x10
70
71#define KX_PRECHAL 0u
72#define KX_COOKIE 1u
73#define KX_CHAL 2u
74#define KX_REPLY 3u
75#define KX_SWITCH 4u
76#define KX_SWITCHOK 5u
77#define KX_NMSG 6u
78
79/* --- Symmetric encryption and keysets --- *
80 *
81 * Packets consist of an 80-bit MAC, a 32-bit sequence number, and the
82 * encrypted payload.
83 *
84 * The plaintext is encrypted using Blowfish in CBC mode with ciphertext
85 * stealing (as described in [Schneier]. The initialization vector is
86 * selected randomly, and prepended to the actual ciphertext.
87 *
88 * The MAC is computed using the HMAC construction with RIPEMD160 over the
89 * sequence number and the ciphertext (with IV); the first 80 bits of the
90 * output are used. (This is the minimum allowed by the draft FIPS for HMAC,
91 * and the recommended truncation.)
92 *
93 * A keyset consists of
94 *
95 * * an integrity (MAC) key;
96 * * a confidentiality (encryption) key; and
97 * * a sequence numbering space
98 *
99 * in each direction. The packets sent by a host encrypted under a
100 * particular keyset are assigned consecutive sequence numbers starting from
101 * zero. The receiving host must ensure that it only accepts each packet at
102 * most once. It should maintain a window of sequence numbers: packets with
103 * numbers beyond the end of the window are accepted and cause the window to
104 * be advanced; packets with numbers before the start of the window are
105 * rejected; packets with numbers which appear within the window are accepted
106 * only if the number has not been seen before.
107 *
108 * When a host sends a @KX_SWITCH@ or @KX_SWITCHOK@ message, it installs the
109 * newly-negotiated keyset in a `listen-only' state: it may not send a packet
110 * encrypted under the keyset until either it has received a @KX_SWITCH@ or
111 * @KX_SWITCHOK@ message, or a @MSG_PACKET@ encrypted under the keyset, from
112 * its peer.
113 */
114
115/*----- That's all, folks -------------------------------------------------*/
116
117#endif