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, t_kx; /* Time peer created, last pk, kx */
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 */
348 #define AF_NOTE 4u /* Catch notifications */
350 #define AF_TRACE 8u /* Catch tracing */
352 #define AF_WARN 16u /* Catch warning messages */
355 # define AF_ALLMSGS (AF_NOTE | AF_TRACE | AF_WARN)
357 # define AF_ALLMSGS (AF_NOTE | AF_WARN)
360 /*----- Global variables --------------------------------------------------*/
362 extern sel_state sel; /* Global I/O event state */
363 extern group *gg; /* The group we work in */
364 extern mp *kpriv; /* Our private key */
365 extern octet buf_i[PKBUFSZ], buf_o[PKBUFSZ], buf_t[PKBUFSZ];
368 extern const trace_opt tr_opts[]; /* Trace options array */
369 extern unsigned tr_flags; /* Trace options flags */
372 /*----- Other macros ------------------------------------------------------*/
374 #define TIMER noise_timer(RAND_GLOBAL)
376 /*----- Key management ----------------------------------------------------*/
378 /* --- @km_interval@ --- *
382 * Returns: Zero if OK, nonzero to force reloading of keys.
384 * Use: Called on the interval timer to perform various useful jobs.
387 extern int km_interval(void);
389 /* --- @km_init@ --- *
391 * Arguments: @const char *kr_priv@ = private keyring file
392 * @const char *kr_pub@ = public keyring file
393 * @const char *tag@ = tag to load
397 * Use: Initializes, and loads the private key.
400 extern void km_init(const char */*kr_priv*/, const char */*kr_pub*/,
401 const char */*tag*/);
403 /* --- @km_getpubkey@ --- *
405 * Arguments: @const char *tag@ = public key tag to load
406 * @ge *kpub@ = where to put the public key
407 * @time_t *t_exp@ = where to put the expiry time
409 * Returns: Zero if OK, nonzero if it failed.
411 * Use: Fetches a public key from the keyring.
414 extern int km_getpubkey(const char */*tag*/, ge */*kpub*/,
417 /*----- Key exchange ------------------------------------------------------*/
419 /* --- @kx_start@ --- *
421 * Arguments: @keyexch *kx@ = pointer to key exchange context
425 * Use: Stimulates a key exchange. If a key exchage is in progress,
426 * a new challenge is sent (unless the quiet timer forbids
427 * this); if no exchange is in progress, one is commenced.
430 extern void kx_start(keyexch */*kx*/);
432 /* --- @kx_message@ --- *
434 * Arguments: @keyexch *kx@ = pointer to key exchange context
435 * @unsigned msg@ = the message code
436 * @buf *b@ = pointer to buffer containing the packet
440 * Use: Reads a packet containing key exchange messages and handles
444 extern void kx_message(keyexch */*kx*/, unsigned /*msg*/, buf */*b*/);
446 /* --- @kx_free@ --- *
448 * Arguments: @keyexch *kx@ = pointer to key exchange context
452 * Use: Frees everything in a key exchange context.
455 extern void kx_free(keyexch */*kx*/);
457 /* --- @kx_newkeys@ --- *
459 * Arguments: @keyexch *kx@ = pointer to key exchange context
463 * Use: Informs the key exchange module that its keys may have
464 * changed. If fetching the new keys fails, the peer will be
465 * destroyed, we log messages and struggle along with the old
469 extern void kx_newkeys(keyexch */*kx*/);
471 /* --- @kx_init@ --- *
473 * Arguments: @keyexch *kx@ = pointer to key exchange context
474 * @peer *p@ = pointer to peer context
475 * @keyset **ks@ = pointer to keyset list
477 * Returns: Zero if OK, nonzero if it failed.
479 * Use: Initializes a key exchange module. The module currently
480 * contains no keys, and will attempt to initiate a key
484 extern int kx_init(keyexch */*kx*/, peer */*p*/, keyset **/*ks*/);
486 /*----- Keysets and symmetric cryptography --------------------------------*/
488 /* --- @ks_drop@ --- *
490 * Arguments: @keyset *ks@ = pointer to a keyset
494 * Use: Decrements a keyset's reference counter. If the counter hits
495 * zero, the keyset is freed.
498 extern void ks_drop(keyset */*ks*/);
500 /* --- @ks_gen@ --- *
502 * Arguments: @const void *k@ = pointer to key material
503 * @size_t x, y, z@ = offsets into key material (see below)
504 * @peer *p@ = pointer to peer information
506 * Returns: A pointer to the new keyset.
508 * Use: Derives a new keyset from the given key material. The
509 * offsets @x@, @y@ and @z@ separate the key material into three
510 * parts. Between the @k@ and @k + x@ is `my' contribution to
511 * the key material; between @k + x@ and @k + y@ is `your'
512 * contribution; and between @k + y@ and @k + z@ is a shared
513 * value we made together. These are used to construct two
514 * pairs of symmetric keys. Each pair consists of an encryption
515 * key and a message authentication key. One pair is used for
516 * outgoing messages, the other for incoming messages.
518 * The new key is marked so that it won't be selected for output
519 * by @ksl_encrypt@. You can still encrypt data with it by
520 * calling @ks_encrypt@ directly.
523 extern keyset *ks_gen(const void */*k*/,
524 size_t /*x*/, size_t /*y*/, size_t /*z*/,
527 /* --- @ks_tregen@ --- *
529 * Arguments: @keyset *ks@ = pointer to a keyset
531 * Returns: The time at which moves ought to be made to replace this key.
534 extern time_t ks_tregen(keyset */*ks*/);
536 /* --- @ks_activate@ --- *
538 * Arguments: @keyset *ks@ = pointer to a keyset
542 * Use: Activates a keyset, so that it can be used for encrypting
546 extern void ks_activate(keyset */*ks*/);
548 /* --- @ks_encrypt@ --- *
550 * Arguments: @keyset *ks@ = pointer to a keyset
551 * @unsigned ty@ = message type
552 * @buf *b@ = pointer to input buffer
553 * @buf *bb@ = pointer to output buffer
555 * Returns: Zero if OK, nonzero if the key needs replacing. If the
556 * encryption failed, the output buffer is broken and zero is
559 * Use: Encrypts a block of data using the key. Note that the `key
560 * ought to be replaced' notification is only ever given once
561 * for each key. Also note that this call forces a keyset to be
562 * used even if it's marked as not for data output.
565 extern int ks_encrypt(keyset */*ks*/, unsigned /*ty*/,
566 buf */*b*/, buf */*bb*/);
568 /* --- @ks_decrypt@ --- *
570 * Arguments: @keyset *ks@ = pointer to a keyset
571 * @unsigned ty@ = expected type code
572 * @buf *b@ = pointer to an input buffer
573 * @buf *bb@ = pointer to an output buffer
575 * Returns: Zero on success, or nonzero if there was some problem.
577 * Use: Attempts to decrypt a message using a given key. Note that
578 * requesting decryption with a key directly won't clear a
579 * marking that it's not for encryption.
582 extern int ks_decrypt(keyset */*ks*/, unsigned /*ty*/,
583 buf */*b*/, buf */*bb*/);
585 /* --- @ksl_free@ --- *
587 * Arguments: @keyset **ksroot@ = pointer to keyset list head
591 * Use: Frees (releases references to) all of the keys in a keyset.
594 extern void ksl_free(keyset **/*ksroot*/);
596 /* --- @ksl_link@ --- *
598 * Arguments: @keyset **ksroot@ = pointer to keyset list head
599 * @keyset *ks@ = pointer to a keyset
603 * Use: Links a keyset into a list. A keyset can only be on one list
604 * at a time. Bad things happen otherwise.
607 extern void ksl_link(keyset **/*ksroot*/, keyset */*ks*/);
609 /* --- @ksl_prune@ --- *
611 * Arguments: @keyset **ksroot@ = pointer to keyset list head
615 * Use: Prunes the keyset list by removing keys which mustn't be used
619 extern void ksl_prune(keyset **/*ksroot*/);
621 /* --- @ksl_encrypt@ --- *
623 * Arguments: @keyset **ksroot@ = pointer to keyset list head
624 * @unsigned ty@ = message type
625 * @buf *b@ = pointer to input buffer
626 * @buf *bb@ = pointer to output buffer
628 * Returns: Nonzero if a new key is needed.
630 * Use: Encrypts a packet.
633 extern int ksl_encrypt(keyset **/*ksroot*/, unsigned /*ty*/,
634 buf */*b*/, buf */*bb*/);
636 /* --- @ksl_decrypt@ --- *
638 * Arguments: @keyset **ksroot@ = pointer to keyset list head
639 * @unsigned ty@ = expected type code
640 * @buf *b@ = pointer to input buffer
641 * @buf *bb@ = pointer to output buffer
643 * Returns: Nonzero if the packet couldn't be decrypted.
645 * Use: Decrypts a packet.
648 extern int ksl_decrypt(keyset **/*ksroot*/, unsigned /*ty*/,
649 buf */*b*/, buf */*bb*/);
651 /*----- Administration interface ------------------------------------------*/
653 /* --- @a_warn@ --- *
655 * Arguments: @const char *fmt@ = pointer to format string
656 * @...@ = other arguments
660 * Use: Informs all admin connections of a warning.
663 extern void a_warn(const char */*fmt*/, ...);
665 /* --- @a_notify@ --- *
667 * Arguments: @const char *fmt@ = pointer to format string
668 * @...@ = other arguments
672 * Use: Sends a notification to interested admin connections.
675 extern void a_notify(const char */*fmt*/, ...);
677 /* --- @a_create@ --- *
679 * Arguments: @int fd_in, fd_out@ = file descriptors to use
680 * @unsigned f@ = initial flags to set
684 * Use: Creates a new admin connection.
687 extern void a_create(int /*fd_in*/, int /*fd_out*/, unsigned /*f*/);
689 /* --- @a_quit@ --- *
695 * Use: Shuts things down nicely.
698 extern void a_quit(void);
700 /* --- @a_daemon@ --- *
706 * Use: Informs the admin module that it's a daemon.
709 extern void a_daemon(void);
711 /* --- @a_init@ --- *
713 * Arguments: @const char *sock@ = socket name to create
717 * Use: Creates the admin listening socket.
720 extern void a_init(const char */*sock*/);
722 /*----- Peer management ---------------------------------------------------*/
724 /* --- @p_txstart@ --- *
726 * Arguments: @peer *p@ = pointer to peer block
727 * @unsigned msg@ = message type code
729 * Returns: A pointer to a buffer to write to.
731 * Use: Starts sending to a peer. Only one send can happen at a
735 extern buf *p_txstart(peer */*p*/, unsigned /*msg*/);
737 /* --- @p_txend@ --- *
739 * Arguments: @peer *p@ = pointer to peer block
743 * Use: Sends a packet to the peer.
746 extern void p_txend(peer */*p*/);
750 * Arguments: @peer *p@ = pointer to peer block
751 * @buf *b@ = buffer containing incoming packet
755 * Use: Handles a packet which needs to be sent to a peer.
758 extern void p_tun(peer */*p*/, buf */*b*/);
760 /* --- @p_interval@ --- *
766 * Use: Called periodically to do tidying.
769 extern void p_interval(void);
771 /* --- @p_stats@ --- *
773 * Arguments: @peer *p@ = pointer to a peer block
775 * Returns: A pointer to the peer's statistics.
778 extern stats *p_stats(peer */*p*/);
780 /* --- @p_ifname@ --- *
782 * Arguments: @peer *p@ = pointer to a peer block
784 * Returns: A pointer to the peer's interface name.
787 extern const char *p_ifname(peer */*p*/);
789 /* --- @p_addr@ --- *
791 * Arguments: @peer *p@ = pointer to a peer block
793 * Returns: A pointer to the peer's address.
796 extern const addr *p_addr(peer */*p*/);
798 /* --- @p_init@ --- *
800 * Arguments: @struct in_addr addr@ = address to bind to
801 * @unsigned port@ = port number to listen to
805 * Use: Initializes the peer system; creates the socket.
808 extern void p_init(struct in_addr /*addr*/, unsigned /*port*/);
810 /* --- @p_port@ --- *
814 * Returns: Port number used for socket.
817 unsigned p_port(void);
819 /* --- @p_create@ --- *
821 * Arguments: @const char *name@ = name for this peer
822 * @struct sockaddr *sa@ = socket address of peer
823 * @size_t sz@ = size of socket address
825 * Returns: Pointer to the peer block, or null if it failed.
827 * Use: Creates a new named peer block. No peer is actually attached
831 extern peer *p_create(const char */*name*/,
832 struct sockaddr */*sa*/, size_t /*sz*/);
834 /* --- @p_name@ --- *
836 * Arguments: @peer *p@ = pointer to a peer block
838 * Returns: A pointer to the peer's name.
841 extern const char *p_name(peer */*p*/);
843 /* --- @p_find@ --- *
845 * Arguments: @const char *name@ = name to look up
847 * Returns: Pointer to the peer block, or null if not found.
849 * Use: Finds a peer by name.
852 extern peer *p_find(const char */*name*/);
854 /* --- @p_destroy@ --- *
856 * Arguments: @peer *p@ = pointer to a peer
860 * Use: Destroys a peer.
863 extern void p_destroy(peer */*p*/);
865 /* --- @p_first@, @p_next@ --- *
867 * Arguments: @peer *p@ = a peer block
869 * Returns: @peer_first@ returns the first peer in some ordering;
870 * @peer_next@ returns the peer following a given one in the
871 * same ordering. Null is returned for the end of the list.
874 extern peer *p_first(void);
875 extern peer *p_next(peer */*p*/);
877 /*----- Tunnel interface --------------------------------------------------*/
879 /* --- @tun_init@ --- *
885 * Use: Initializes the tunneling system. Maybe this will require
886 * opening file descriptors or something.
889 extern void tun_init(void);
891 /* --- @tun_create@ --- *
893 * Arguments: @tunnel *t@ = pointer to tunnel block
894 * @peer *p@ = pointer to peer block
896 * Returns: Zero if it worked, nonzero on failure.
898 * Use: Initializes a new tunnel.
901 extern int tun_create(tunnel */*t*/, peer */*p*/);
903 /* --- @tun_ifname@ --- *
905 * Arguments: @tunnel *t@ = pointer to tunnel block
907 * Returns: A pointer to the tunnel's interface name.
910 extern const char *tun_ifname(tunnel */*t*/);
912 /* --- @tun_inject@ --- *
914 * Arguments: @tunnel *t@ = pointer to tunnel block
915 * @buf *b@ = buffer to send
919 * Use: Injects a packet into the local network stack.
922 extern void tun_inject(tunnel */*t*/, buf */*b*/);
924 /* --- @tun_destroy@ --- *
926 * Arguments: @tunnel *t@ = pointer to tunnel block
930 * Use: Destroys a tunnel.
933 extern void tun_destroy(tunnel */*t*/);
935 /*----- Other handy utilities ---------------------------------------------*/
939 * Arguments: @mp *m@ = a multiprecision integer
941 * Returns: A pointer to the integer's textual representation.
943 * Use: Converts a multiprecision integer to a string. Corrupts
947 extern const char *mpstr(mp */*m*/);
951 * Arguments: @group *g@ = a group
952 * @ge *x@ = a group element
954 * Returns: A pointer to the element's textual representation.
956 * Use: Converts a group element to a string. Corrupts
960 extern const char *gestr(group */*g*/, ge */*x*/);
962 /* --- @timestr@ --- *
964 * Arguments: @time_t t@ = a time to convert
966 * Returns: A pointer to a textual representation of the time.
968 * Use: Converts a time to a textual representation. Corrupts
972 extern const char *timestr(time_t /*t*/);
974 /*----- That's all, folks -------------------------------------------------*/