3 * $Id: tripe.h,v 1.20 2004/04/18 18:08:11 mdw Exp $
5 * Main header file for TrIPE
7 * (c) 2001 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Trivial IP Encryption (TrIPE).
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.
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.
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.
36 /*----- Header files ------------------------------------------------------*/
51 #include <sys/types.h>
57 #include <sys/socket.h>
59 #include <netinet/in.h>
60 #include <arpa/inet.h>
66 #include <mLib/alloc.h>
67 #include <mLib/arena.h>
68 #include <mLib/bres.h>
69 #include <mLib/dstr.h>
71 #include <mLib/fdflags.h>
72 #include <mLib/fwatch.h>
73 #include <mLib/mdwopt.h>
74 #include <mLib/quis.h>
75 #include <mLib/report.h>
77 #include <mLib/selbuf.h>
81 #include <mLib/trace.h>
83 #include <catacomb/buf.h>
85 #include <catacomb/gcipher.h>
86 #include <catacomb/gmac.h>
87 #include <catacomb/grand.h>
88 #include <catacomb/key.h>
89 #include <catacomb/paranoia.h>
91 #include <catacomb/noise.h>
92 #include <catacomb/rand.h>
94 #include <catacomb/mp.h>
95 #include <catacomb/mprand.h>
96 #include <catacomb/dh.h>
97 #include <catacomb/ec.h>
98 #include <catacomb/ec-keys.h>
99 #include <catacomb/group.h>
101 #include "tripe-protocol.h"
106 /*----- Magic numbers -----------------------------------------------------*/
108 /* --- Tunnel types --- */
115 /* --- Trace flags --- */
123 #define T_KEYEXCH 64u
124 #define T_KEYMGMT 128u
130 #define SEC(n) (n##u)
131 #define MIN(n) (n##u * 60u)
132 #define MEG(n) (n##ul * 1024ul * 1024ul)
134 /* --- Other things --- */
136 #define PKBUFSZ 65536
138 /*----- Cipher selections -------------------------------------------------*/
140 typedef struct algswitch
{
141 const gccipher
*c
; /* Symmetric encryption scheme */
142 const gccipher
*mgf
; /* Mask-generation function */
143 const gchash
*h
; /* Hash function */
144 const gcmac
*m
; /* Message authentication code */
145 size_t hashsz
; /* Hash output size */
146 size_t tagsz
; /* Length to truncate MAC tags */
147 size_t cksz
, mksz
; /* Key lengths for @c@ and @m@ */
150 extern algswitch algs
;
152 #define MAXHASHSZ 64 /* Largest possible hash size */
154 #define HASH_STRING(h, s) GH_HASH((h), (s), sizeof(s))
156 /*----- Data structures ---------------------------------------------------*/
158 /* --- Socket addresses --- *
160 * A magic union of supported socket addresses.
165 struct sockaddr_in sin
;
168 /* --- A symmetric keyset --- *
170 * A keyset contains a set of symmetric keys for encrypting and decrypting
171 * packets. Keysets are stored in a list, sorted in reverse order of
172 * creation, so that the most recent keyset (the one most likely to be used)
175 * Each keyset has a time limit and a data limit. The keyset is destroyed
176 * when either it has existed for too long, or it has been used to encrypt
177 * too much data. New key exchanges are triggered when keys are close to
181 typedef struct keyset
{
182 struct keyset
*next
; /* Next active keyset in the list */
183 unsigned ref
; /* Reference count for keyset */
184 struct peer
*p
; /* Pointer to peer structure */
185 time_t t_exp
; /* Expiry time for this keyset */
186 unsigned long sz_exp
; /* Data limit for the keyset */
187 T( unsigned seq
; ) /* Sequence number for tracing */
188 unsigned f
; /* Various useful flags */
189 gcipher
*cin
, *cout
; /* Keyset ciphers for encryption */
190 size_t tagsz
; /* Length to truncate MAC tags */
191 gmac
*min
, *mout
; /* Keyset MACs for integrity */
192 uint32 oseq
; /* Outbound sequence number */
193 uint32 iseq
, iwin
; /* Inbound sequence number */
196 #define KS_SEQWINSZ 32 /* Bits in sequence number window */
198 #define KSF_LISTEN 1u /* Don't encrypt packets yet */
199 #define KSF_LINK 2u /* Key is in a linked list */
201 /* --- Key exchange --- *
203 * TrIPE uses the Wrestlers Protocol for its key exchange. The Wrestlers
204 * Protocol has a number of desirable features (e.g., perfect forward
205 * secrecy, and zero-knowledge authentication) which make it attractive for
206 * use in TrIPE. The Wrestlers Protocol was designed by Mark Wooding and
213 typedef struct kxchal
{
214 struct keyexch
*kx
; /* Pointer back to key exchange */
215 ge
*c
; /* Responder's challenge */
216 ge
*r
; /* My reply to the challenge */
217 keyset
*ks
; /* Pointer to temporary keyset */
218 unsigned f
; /* Various useful flags */
219 sel_timer t
; /* Response timer for challenge */
220 octet hc
[MAXHASHSZ
]; /* Hash of his challenge */
221 mp
*ck
; /* The check value */
222 octet hswrq_in
[MAXHASHSZ
]; /* Inbound switch request message */
223 octet hswok_in
[MAXHASHSZ
]; /* Inbound switch confirmation */
224 octet hswrq_out
[MAXHASHSZ
]; /* Outbound switch request message */
225 octet hswok_out
[MAXHASHSZ
]; /* Outbound switch confirmation */
228 typedef struct keyexch
{
229 struct peer
*p
; /* Pointer back to the peer */
230 keyset
**ks
; /* Peer's list of keysets */
231 unsigned f
; /* Various useful flags */
232 unsigned s
; /* Current state in exchange */
233 sel_timer t
; /* Timer for next exchange */
234 ge
*kpub
; /* Peer's public key */
235 time_t texp_kpub
; /* Expiry time for public key */
236 mp
*alpha
; /* My temporary secret */
237 ge
*c
; /* My challenge */
238 ge
*rx
; /* The expected response */
239 unsigned nr
; /* Number of extant responses */
240 time_t t_valid
; /* When this exchange goes bad */
241 octet hc
[MAXHASHSZ
]; /* Hash of my challenge */
242 kxchal
*r
[KX_NCHAL
]; /* Array of challenges */
245 #define KXF_TIMER 1u /* Waiting for a timer to go off */
246 #define KXF_DEAD 2u /* The key-exchanger isn't up */
247 #define KXF_PUBKEY 4u /* Key exchanger has a public key */
250 KXS_DEAD
, /* Uninitialized state (magical) */
251 KXS_CHAL
, /* Main answer-challenges state */
252 KXS_COMMIT
, /* Committed: send switch request */
253 KXS_SWITCH
/* Switched: send confirmation */
256 /* --- Tunnel structure --- *
258 * Used to maintain system-specific information about the tunnel interface.
261 #if TUN_TYPE == TUN_LINUX
262 # include <linux/if.h>
263 # include <linux/if_tun.h>
266 typedef struct tunnel
{
267 #if TUN_TYPE == TUN_UNET
268 sel_file f
; /* Selector for Usernet device */
269 struct peer
*p
; /* Pointer to my peer */
270 #elif TUN_TYPE == TUN_LINUX
271 sel_file f
; /* Selector for TUN/TAP device */
272 struct peer
*p
; /* Pointer to my peer */
273 char ifn
[IFNAMSIZ
]; /* Interface name buffer */
274 #elif TUN_TYPE == TUN_BSD
275 sel_file f
; /* Selector for tunnel device */
276 struct peer
*p
; /* Pointer to my peer */
277 unsigned n
; /* Number of my tunnel device */
279 # error "No support for this tunnel type"
283 /* --- Peer statistics --- *
285 * Contains various interesting and not-so-interesting statistics about a
286 * peer. This is updated by various parts of the code. The format of the
287 * structure isn't considered private, and @p_stats@ returns a pointer to the
288 * statistics block for a given peer.
291 typedef struct stats
{
292 unsigned long sz_in
, sz_out
; /* Size of all data in and out */
293 unsigned long sz_kxin
, sz_kxout
; /* Size of key exchange messages */
294 unsigned long sz_ipin
, sz_ipout
; /* Size of encapsulated IP packets */
295 time_t t_start
, t_last
; /* Time peer created, last recv */
296 unsigned long n_reject
; /* Number of rejected packets */
297 unsigned long n_in
, n_out
; /* Number of packets in and out */
298 unsigned long n_kxin
, n_kxout
; /* Number of key exchange packets */
299 unsigned long n_ipin
, n_ipout
; /* Number of encrypted packets */
302 /* --- Peer structure --- *
304 * The main structure which glues everything else together.
307 typedef struct peer
{
308 struct peer
*next
, *prev
; /* Links to next and previous */
309 char *name
; /* Name of this peer */
310 tunnel t
; /* Tunnel for local packets */
311 keyset
*ks
; /* List head for keysets */
312 buf b
; /* Buffer for sending packets */
313 addr peer
; /* Peer socket address */
314 size_t sasz
; /* Socket address size */
315 stats st
; /* Statistics */
316 keyexch kx
; /* Key exchange protocol block */
319 /* --- Admin structure --- */
321 #define OBUFSZ 16384u
323 typedef struct obuf
{
324 struct obuf
*next
; /* Next buffer in list */
325 char *p_in
, *p_out
; /* Pointers into the buffer */
326 char buf
[OBUFSZ
]; /* The actual buffer */
329 typedef struct admin
{
330 struct admin
*next
, *prev
; /* Links to next and previous */
331 unsigned f
; /* Various useful flags */
333 unsigned seq
; /* Sequence number for tracing */
335 char *pname
; /* Peer name to create */
336 char *paddr
; /* Address string to resolve */
337 obuf
*o_head
, *o_tail
; /* Output buffer list */
338 selbuf b
; /* Line buffer for commands */
339 sel_file w
; /* Selector for write buffering */
340 bres_client r
; /* Background resolver task */
341 sel_timer t
; /* Timer for resolver */
342 addr peer
; /* Address to set */
343 size_t sasz
; /* Size of the address */
346 #define AF_DEAD 1u /* Destroy this admin block */
347 #define AF_LOCK 2u /* Don't destroy it yet */
349 /*----- Global variables --------------------------------------------------*/
351 extern sel_state sel
; /* Global I/O event state */
352 extern group
*gg
; /* The group we work in */
353 extern mp
*kpriv
; /* Our private key */
354 extern octet buf_i
[PKBUFSZ
], buf_o
[PKBUFSZ
], buf_t
[PKBUFSZ
];
357 extern const trace_opt tr_opts
[]; /* Trace options array */
358 extern unsigned tr_flags
; /* Trace options flags */
361 /*----- Other macros ------------------------------------------------------*/
363 #define TIMER noise_timer(RAND_GLOBAL)
365 /*----- Key management ----------------------------------------------------*/
367 /* --- @km_interval@ --- *
371 * Returns: Zero if OK, nonzero to force reloading of keys.
373 * Use: Called on the interval timer to perform various useful jobs.
376 extern int km_interval(void);
378 /* --- @km_init@ --- *
380 * Arguments: @const char *kr_priv@ = private keyring file
381 * @const char *kr_pub@ = public keyring file
382 * @const char *tag@ = tag to load
386 * Use: Initializes, and loads the private key.
389 extern void km_init(const char */
*kr_priv*/
, const char */
*kr_pub*/
,
390 const char */
*tag*/
);
392 /* --- @km_getpubkey@ --- *
394 * Arguments: @const char *tag@ = public key tag to load
395 * @ge *kpub@ = where to put the public key
396 * @time_t *t_exp@ = where to put the expiry time
398 * Returns: Zero if OK, nonzero if it failed.
400 * Use: Fetches a public key from the keyring.
403 extern int km_getpubkey(const char */
*tag*/
, ge */
*kpub*/
,
406 /*----- Key exchange ------------------------------------------------------*/
408 /* --- @kx_start@ --- *
410 * Arguments: @keyexch *kx@ = pointer to key exchange context
414 * Use: Stimulates a key exchange. If a key exchage is in progress,
415 * a new challenge is sent (unless the quiet timer forbids
416 * this); if no exchange is in progress, one is commenced.
419 extern void kx_start(keyexch */
*kx*/
);
421 /* --- @kx_message@ --- *
423 * Arguments: @keyexch *kx@ = pointer to key exchange context
424 * @unsigned msg@ = the message code
425 * @buf *b@ = pointer to buffer containing the packet
429 * Use: Reads a packet containing key exchange messages and handles
433 extern void kx_message(keyexch */
*kx*/
, unsigned /*msg*/, buf */
*b*/
);
435 /* --- @kx_free@ --- *
437 * Arguments: @keyexch *kx@ = pointer to key exchange context
441 * Use: Frees everything in a key exchange context.
444 extern void kx_free(keyexch */
*kx*/
);
446 /* --- @kx_newkeys@ --- *
448 * Arguments: @keyexch *kx@ = pointer to key exchange context
452 * Use: Informs the key exchange module that its keys may have
453 * changed. If fetching the new keys fails, the peer will be
454 * destroyed, we log messages and struggle along with the old
458 extern void kx_newkeys(keyexch */
*kx*/
);
460 /* --- @kx_init@ --- *
462 * Arguments: @keyexch *kx@ = pointer to key exchange context
463 * @peer *p@ = pointer to peer context
464 * @keyset **ks@ = pointer to keyset list
466 * Returns: Zero if OK, nonzero if it failed.
468 * Use: Initializes a key exchange module. The module currently
469 * contains no keys, and will attempt to initiate a key
473 extern int kx_init(keyexch */
*kx*/
, peer */
*p*/
, keyset
**/
*ks*/
);
475 /*----- Keysets and symmetric cryptography --------------------------------*/
477 /* --- @ks_drop@ --- *
479 * Arguments: @keyset *ks@ = pointer to a keyset
483 * Use: Decrements a keyset's reference counter. If the counter hits
484 * zero, the keyset is freed.
487 extern void ks_drop(keyset */
*ks*/
);
489 /* --- @ks_gen@ --- *
491 * Arguments: @const void *k@ = pointer to key material
492 * @size_t x, y, z@ = offsets into key material (see below)
493 * @peer *p@ = pointer to peer information
495 * Returns: A pointer to the new keyset.
497 * Use: Derives a new keyset from the given key material. The
498 * offsets @x@, @y@ and @z@ separate the key material into three
499 * parts. Between the @k@ and @k + x@ is `my' contribution to
500 * the key material; between @k + x@ and @k + y@ is `your'
501 * contribution; and between @k + y@ and @k + z@ is a shared
502 * value we made together. These are used to construct two
503 * pairs of symmetric keys. Each pair consists of an encryption
504 * key and a message authentication key. One pair is used for
505 * outgoing messages, the other for incoming messages.
507 * The new key is marked so that it won't be selected for output
508 * by @ksl_encrypt@. You can still encrypt data with it by
509 * calling @ks_encrypt@ directly.
512 extern keyset
*ks_gen(const void */
*k*/
,
513 size_t /*x*/, size_t /*y*/, size_t /*z*/,
516 /* --- @ks_tregen@ --- *
518 * Arguments: @keyset *ks@ = pointer to a keyset
520 * Returns: The time at which moves ought to be made to replace this key.
523 extern time_t ks_tregen(keyset */
*ks*/
);
525 /* --- @ks_activate@ --- *
527 * Arguments: @keyset *ks@ = pointer to a keyset
531 * Use: Activates a keyset, so that it can be used for encrypting
535 extern void ks_activate(keyset */
*ks*/
);
537 /* --- @ks_encrypt@ --- *
539 * Arguments: @keyset *ks@ = pointer to a keyset
540 * @unsigned ty@ = message type
541 * @buf *b@ = pointer to input buffer
542 * @buf *bb@ = pointer to output buffer
544 * Returns: Zero if OK, nonzero if the key needs replacing. If the
545 * encryption failed, the output buffer is broken and zero is
548 * Use: Encrypts a block of data using the key. Note that the `key
549 * ought to be replaced' notification is only ever given once
550 * for each key. Also note that this call forces a keyset to be
551 * used even if it's marked as not for data output.
554 extern int ks_encrypt(keyset */
*ks*/
, unsigned /*ty*/,
555 buf */
*b*/
, buf */
*bb*/
);
557 /* --- @ks_decrypt@ --- *
559 * Arguments: @keyset *ks@ = pointer to a keyset
560 * @unsigned ty@ = expected type code
561 * @buf *b@ = pointer to an input buffer
562 * @buf *bb@ = pointer to an output buffer
564 * Returns: Zero on success, or nonzero if there was some problem.
566 * Use: Attempts to decrypt a message using a given key. Note that
567 * requesting decryption with a key directly won't clear a
568 * marking that it's not for encryption.
571 extern int ks_decrypt(keyset */
*ks*/
, unsigned /*ty*/,
572 buf */
*b*/
, buf */
*bb*/
);
574 /* --- @ksl_free@ --- *
576 * Arguments: @keyset **ksroot@ = pointer to keyset list head
580 * Use: Frees (releases references to) all of the keys in a keyset.
583 extern void ksl_free(keyset
**/
*ksroot*/
);
585 /* --- @ksl_link@ --- *
587 * Arguments: @keyset **ksroot@ = pointer to keyset list head
588 * @keyset *ks@ = pointer to a keyset
592 * Use: Links a keyset into a list. A keyset can only be on one list
593 * at a time. Bad things happen otherwise.
596 extern void ksl_link(keyset
**/
*ksroot*/
, keyset */
*ks*/
);
598 /* --- @ksl_prune@ --- *
600 * Arguments: @keyset **ksroot@ = pointer to keyset list head
604 * Use: Prunes the keyset list by removing keys which mustn't be used
608 extern void ksl_prune(keyset
**/
*ksroot*/
);
610 /* --- @ksl_encrypt@ --- *
612 * Arguments: @keyset **ksroot@ = pointer to keyset list head
613 * @unsigned ty@ = message type
614 * @buf *b@ = pointer to input buffer
615 * @buf *bb@ = pointer to output buffer
617 * Returns: Nonzero if a new key is needed.
619 * Use: Encrypts a packet.
622 extern int ksl_encrypt(keyset
**/
*ksroot*/
, unsigned /*ty*/,
623 buf */
*b*/
, buf */
*bb*/
);
625 /* --- @ksl_decrypt@ --- *
627 * Arguments: @keyset **ksroot@ = pointer to keyset list head
628 * @unsigned ty@ = expected type code
629 * @buf *b@ = pointer to input buffer
630 * @buf *bb@ = pointer to output buffer
632 * Returns: Nonzero if the packet couldn't be decrypted.
634 * Use: Decrypts a packet.
637 extern int ksl_decrypt(keyset
**/
*ksroot*/
, unsigned /*ty*/,
638 buf */
*b*/
, buf */
*bb*/
);
640 /*----- Administration interface ------------------------------------------*/
642 /* --- @a_warn@ --- *
644 * Arguments: @const char *fmt@ = pointer to format string
645 * @...@ = other arguments
649 * Use: Informs all admin connections of a warning.
652 extern void a_warn(const char */
*fmt*/
, ...);
654 /* --- @a_create@ --- *
656 * Arguments: @int fd_in, fd_out@ = file descriptors to use
660 * Use: Creates a new admin connection.
663 extern void a_create(int /*fd_in*/, int /*fd_out*/);
665 /* --- @a_quit@ --- *
671 * Use: Shuts things down nicely.
674 extern void a_quit(void);
676 /* --- @a_daemon@ --- *
682 * Use: Informs the admin module that it's a daemon.
685 extern void a_daemon(void);
687 /* --- @a_init@ --- *
689 * Arguments: @const char *sock@ = socket name to create
693 * Use: Creates the admin listening socket.
696 extern void a_init(const char */
*sock*/
);
698 /*----- Peer management ---------------------------------------------------*/
700 /* --- @p_txstart@ --- *
702 * Arguments: @peer *p@ = pointer to peer block
703 * @unsigned msg@ = message type code
705 * Returns: A pointer to a buffer to write to.
707 * Use: Starts sending to a peer. Only one send can happen at a
711 extern buf
*p_txstart(peer */
*p*/
, unsigned /*msg*/);
713 /* --- @p_txend@ --- *
715 * Arguments: @peer *p@ = pointer to peer block
719 * Use: Sends a packet to the peer.
722 extern void p_txend(peer */
*p*/
);
726 * Arguments: @peer *p@ = pointer to peer block
727 * @buf *b@ = buffer containing incoming packet
731 * Use: Handles a packet which needs to be sent to a peer.
734 extern void p_tun(peer */
*p*/
, buf */
*b*/
);
736 /* --- @p_interval@ --- *
742 * Use: Called periodically to do tidying.
745 extern void p_interval(void);
747 /* --- @p_stats@ --- *
749 * Arguments: @peer *p@ = pointer to a peer block
751 * Returns: A pointer to the peer's statistics.
754 extern stats
*p_stats(peer */
*p*/
);
756 /* --- @p_ifname@ --- *
758 * Arguments: @peer *p@ = pointer to a peer block
760 * Returns: A pointer to the peer's interface name.
763 extern const char *p_ifname(peer */
*p*/
);
765 /* --- @p_addr@ --- *
767 * Arguments: @peer *p@ = pointer to a peer block
769 * Returns: A pointer to the peer's address.
772 extern const addr
*p_addr(peer */
*p*/
);
774 /* --- @p_init@ --- *
776 * Arguments: @struct in_addr addr@ = address to bind to
777 * @unsigned port@ = port number to listen to
781 * Use: Initializes the peer system; creates the socket.
784 extern void p_init(struct in_addr
/*addr*/, unsigned /*port*/);
786 /* --- @p_port@ --- *
790 * Returns: Port number used for socket.
793 unsigned p_port(void);
795 /* --- @p_create@ --- *
797 * Arguments: @const char *name@ = name for this peer
798 * @struct sockaddr *sa@ = socket address of peer
799 * @size_t sz@ = size of socket address
801 * Returns: Pointer to the peer block, or null if it failed.
803 * Use: Creates a new named peer block. No peer is actually attached
807 extern peer
*p_create(const char */
*name*/
,
808 struct sockaddr */
*sa*/
, size_t /*sz*/);
810 /* --- @p_name@ --- *
812 * Arguments: @peer *p@ = pointer to a peer block
814 * Returns: A pointer to the peer's name.
817 extern const char *p_name(peer */
*p*/
);
819 /* --- @p_find@ --- *
821 * Arguments: @const char *name@ = name to look up
823 * Returns: Pointer to the peer block, or null if not found.
825 * Use: Finds a peer by name.
828 extern peer
*p_find(const char */
*name*/
);
830 /* --- @p_destroy@ --- *
832 * Arguments: @peer *p@ = pointer to a peer
836 * Use: Destroys a peer.
839 extern void p_destroy(peer */
*p*/
);
841 /* --- @p_first@, @p_next@ --- *
843 * Arguments: @peer *p@ = a peer block
845 * Returns: @peer_first@ returns the first peer in some ordering;
846 * @peer_next@ returns the peer following a given one in the
847 * same ordering. Null is returned for the end of the list.
850 extern peer
*p_first(void);
851 extern peer
*p_next(peer */
*p*/
);
853 /*----- Tunnel interface --------------------------------------------------*/
855 /* --- @tun_init@ --- *
861 * Use: Initializes the tunneling system. Maybe this will require
862 * opening file descriptors or something.
865 extern void tun_init(void);
867 /* --- @tun_create@ --- *
869 * Arguments: @tunnel *t@ = pointer to tunnel block
870 * @peer *p@ = pointer to peer block
872 * Returns: Zero if it worked, nonzero on failure.
874 * Use: Initializes a new tunnel.
877 extern int tun_create(tunnel */
*t*/
, peer */
*p*/
);
879 /* --- @tun_ifname@ --- *
881 * Arguments: @tunnel *t@ = pointer to tunnel block
883 * Returns: A pointer to the tunnel's interface name.
886 extern const char *tun_ifname(tunnel */
*t*/
);
888 /* --- @tun_inject@ --- *
890 * Arguments: @tunnel *t@ = pointer to tunnel block
891 * @buf *b@ = buffer to send
895 * Use: Injects a packet into the local network stack.
898 extern void tun_inject(tunnel */
*t*/
, buf */
*b*/
);
900 /* --- @tun_destroy@ --- *
902 * Arguments: @tunnel *t@ = pointer to tunnel block
906 * Use: Destroys a tunnel.
909 extern void tun_destroy(tunnel */
*t*/
);
911 /*----- Other handy utilities ---------------------------------------------*/
915 * Arguments: @mp *m@ = a multiprecision integer
917 * Returns: A pointer to the integer's textual representation.
919 * Use: Converts a multiprecision integer to a string. Corrupts
923 extern const char *mpstr(mp */
*m*/
);
927 * Arguments: @group *g@ = a group
928 * @ge *x@ = a group element
930 * Returns: A pointer to the element's textual representation.
932 * Use: Converts a group element to a string. Corrupts
936 extern const char *gestr(group */
*g*/
, ge */
*x*/
);
938 /* --- @timestr@ --- *
940 * Arguments: @time_t t@ = a time to convert
942 * Returns: A pointer to a textual representation of the time.
944 * Use: Converts a time to a textual representation. Corrupts
948 extern const char *timestr(time_t /*t*/);
950 /*----- That's all, folks -------------------------------------------------*/