3 * $Id: tripe.h,v 1.19 2004/04/08 01:36:17 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 #include <catacomb/blowfish.h>
141 #include <catacomb/blowfish-cbc.h>
142 #include <catacomb/blowfish-counter.h>
143 #include <catacomb/rmd160.h>
144 #include <catacomb/rmd160-hmac.h>
146 #define CIPHER (&blowfish_cbc)
147 #define MAC (&rmd160_hmac)
149 #define HASH_CTX rmd160_ctx
150 #define HASH_INIT rmd160_init
151 #define HASH rmd160_hash
152 #define HASH_STRING(c, s) HASH((c), s, sizeof(s))
153 #define HASH_DONE rmd160_done
154 #define HASHSZ RMD160_HASHSZ
156 #define MGF_CTX blowfish_counterctx
157 #define MGF_INIT blowfish_counterinit
158 #define MGF_CRYPT blowfish_counterencrypt
161 #define IVSZ BLOWFISH_BLKSZ
164 /*----- Data structures ---------------------------------------------------*/
166 /* --- Socket addresses --- *
168 * A magic union of supported socket addresses.
173 struct sockaddr_in sin;
176 /* --- A symmetric keyset --- *
178 * A keyset contains a set of symmetric keys for encrypting and decrypting
179 * packets. Keysets are stored in a list, sorted in reverse order of
180 * creation, so that the most recent keyset (the one most likely to be used)
183 * Each keyset has a time limit and a data limit. The keyset is destroyed
184 * when either it has existed for too long, or it has been used to encrypt
185 * too much data. New key exchanges are triggered when keys are close to
189 typedef struct keyset {
190 struct keyset *next; /* Next active keyset in the list */
191 unsigned ref; /* Reference count for keyset */
192 struct peer *p; /* Pointer to peer structure */
193 time_t t_exp; /* Expiry time for this keyset */
194 unsigned long sz_exp; /* Data limit for the keyset */
195 T( unsigned seq; ) /* Sequence number for tracing */
196 unsigned f; /* Various useful flags */
197 gcipher *cin, *cout; /* Keyset ciphers for encryption */
198 gmac *min, *mout; /* Keyset MACs for integrity */
199 uint32 oseq; /* Outbound sequence number */
200 uint32 iseq, iwin; /* Inbound sequence number */
203 #define KS_SEQWINSZ 32 /* Bits in sequence number window */
205 #define KSF_LISTEN 1u /* Don't encrypt packets yet */
206 #define KSF_LINK 2u /* Key is in a linked list */
208 /* --- Key exchange --- *
210 * TrIPE uses the Wrestlers Protocol for its key exchange. The Wrestlers
211 * Protocol has a number of desirable features (e.g., perfect forward
212 * secrecy, and zero-knowledge authentication) which make it attractive for
213 * use in TrIPE. The Wrestlers Protocol was designed by Mark Wooding and
220 typedef struct kxchal {
221 struct keyexch *kx; /* Pointer back to key exchange */
222 ge *c; /* Responder's challenge */
223 ge *r; /* My reply to the challenge */
224 keyset *ks; /* Pointer to temporary keyset */
225 unsigned f; /* Various useful flags */
226 sel_timer t; /* Response timer for challenge */
227 octet hc[HASHSZ]; /* Hash of his challenge */
228 mp *ck; /* The check value */
229 octet hswrq_in[HASHSZ]; /* Inbound switch request message */
230 octet hswok_in[HASHSZ]; /* Inbound switch confirmation */
231 octet hswrq_out[HASHSZ]; /* Outbound switch request message */
232 octet hswok_out[HASHSZ]; /* Outbound switch confirmation */
235 typedef struct keyexch {
236 struct peer *p; /* Pointer back to the peer */
237 keyset **ks; /* Peer's list of keysets */
238 unsigned f; /* Various useful flags */
239 unsigned s; /* Current state in exchange */
240 sel_timer t; /* Timer for next exchange */
241 ge *kpub; /* Peer's public key */
242 time_t texp_kpub; /* Expiry time for public key */
243 mp *alpha; /* My temporary secret */
244 ge *c; /* My challenge */
245 ge *rx; /* The expected response */
246 unsigned nr; /* Number of extant responses */
247 time_t t_valid; /* When this exchange goes bad */
248 octet hc[HASHSZ]; /* Hash of my challenge */
249 kxchal *r[KX_NCHAL]; /* Array of challenges */
252 #define KXF_TIMER 1u /* Waiting for a timer to go off */
253 #define KXF_DEAD 2u /* The key-exchanger isn't up */
254 #define KXF_PUBKEY 4u /* Key exchanger has a public key */
257 KXS_DEAD, /* Uninitialized state (magical) */
258 KXS_CHAL, /* Main answer-challenges state */
259 KXS_COMMIT, /* Committed: send switch request */
260 KXS_SWITCH /* Switched: send confirmation */
263 /* --- Tunnel structure --- *
265 * Used to maintain system-specific information about the tunnel interface.
268 #if TUN_TYPE == TUN_LINUX
269 # include <linux/if.h>
270 # include <linux/if_tun.h>
273 typedef struct tunnel {
274 #if TUN_TYPE == TUN_UNET
275 sel_file f; /* Selector for Usernet device */
276 struct peer *p; /* Pointer to my peer */
277 #elif TUN_TYPE == TUN_LINUX
278 sel_file f; /* Selector for TUN/TAP device */
279 struct peer *p; /* Pointer to my peer */
280 char ifn[IFNAMSIZ]; /* Interface name buffer */
281 #elif TUN_TYPE == TUN_BSD
282 sel_file f; /* Selector for tunnel device */
283 struct peer *p; /* Pointer to my peer */
284 unsigned n; /* Number of my tunnel device */
286 # error "No support for this tunnel type"
290 /* --- Peer statistics --- *
292 * Contains various interesting and not-so-interesting statistics about a
293 * peer. This is updated by various parts of the code. The format of the
294 * structure isn't considered private, and @p_stats@ returns a pointer to the
295 * statistics block for a given peer.
298 typedef struct stats {
299 unsigned long sz_in, sz_out; /* Size of all data in and out */
300 unsigned long sz_kxin, sz_kxout; /* Size of key exchange messages */
301 unsigned long sz_ipin, sz_ipout; /* Size of encapsulated IP packets */
302 time_t t_start, t_last; /* Time peer created, last recv */
303 unsigned long n_reject; /* Number of rejected packets */
304 unsigned long n_in, n_out; /* Number of packets in and out */
305 unsigned long n_kxin, n_kxout; /* Number of key exchange packets */
306 unsigned long n_ipin, n_ipout; /* Number of encrypted packets */
309 /* --- Peer structure --- *
311 * The main structure which glues everything else together.
314 typedef struct peer {
315 struct peer *next, *prev; /* Links to next and previous */
316 char *name; /* Name of this peer */
317 tunnel t; /* Tunnel for local packets */
318 keyset *ks; /* List head for keysets */
319 buf b; /* Buffer for sending packets */
320 addr peer; /* Peer socket address */
321 size_t sasz; /* Socket address size */
322 stats st; /* Statistics */
323 keyexch kx; /* Key exchange protocol block */
326 /* --- Admin structure --- */
328 #define OBUFSZ 16384u
330 typedef struct obuf {
331 struct obuf *next; /* Next buffer in list */
332 char *p_in, *p_out; /* Pointers into the buffer */
333 char buf[OBUFSZ]; /* The actual buffer */
336 typedef struct admin {
337 struct admin *next, *prev; /* Links to next and previous */
338 unsigned f; /* Various useful flags */
340 unsigned seq; /* Sequence number for tracing */
342 char *pname; /* Peer name to create */
343 char *paddr; /* Address string to resolve */
344 obuf *o_head, *o_tail; /* Output buffer list */
345 selbuf b; /* Line buffer for commands */
346 sel_file w; /* Selector for write buffering */
347 bres_client r; /* Background resolver task */
348 sel_timer t; /* Timer for resolver */
349 addr peer; /* Address to set */
350 size_t sasz; /* Size of the address */
353 #define AF_DEAD 1u /* Destroy this admin block */
354 #define AF_LOCK 2u /* Don't destroy it yet */
356 /*----- Global variables --------------------------------------------------*/
358 extern sel_state sel; /* Global I/O event state */
359 extern group *gg; /* The group we work in */
360 extern mp *kpriv; /* Our private key */
361 extern octet buf_i[PKBUFSZ], buf_o[PKBUFSZ], buf_t[PKBUFSZ];
364 extern const trace_opt tr_opts[]; /* Trace options array */
365 extern unsigned tr_flags; /* Trace options flags */
368 /*----- Other macros ------------------------------------------------------*/
370 #define TIMER noise_timer(RAND_GLOBAL)
372 /*----- Key management ----------------------------------------------------*/
374 /* --- @km_interval@ --- *
378 * Returns: Zero if OK, nonzero to force reloading of keys.
380 * Use: Called on the interval timer to perform various useful jobs.
383 extern int km_interval(void);
385 /* --- @km_init@ --- *
387 * Arguments: @const char *kr_priv@ = private keyring file
388 * @const char *kr_pub@ = public keyring file
389 * @const char *tag@ = tag to load
393 * Use: Initializes, and loads the private key.
396 extern void km_init(const char */*kr_priv*/, const char */*kr_pub*/,
397 const char */*tag*/);
399 /* --- @km_getpubkey@ --- *
401 * Arguments: @const char *tag@ = public key tag to load
402 * @ge *kpub@ = where to put the public key
403 * @time_t *t_exp@ = where to put the expiry time
405 * Returns: Zero if OK, nonzero if it failed.
407 * Use: Fetches a public key from the keyring.
410 extern int km_getpubkey(const char */*tag*/, ge */*kpub*/,
413 /*----- Key exchange ------------------------------------------------------*/
415 /* --- @kx_start@ --- *
417 * Arguments: @keyexch *kx@ = pointer to key exchange context
421 * Use: Stimulates a key exchange. If a key exchage is in progress,
422 * a new challenge is sent (unless the quiet timer forbids
423 * this); if no exchange is in progress, one is commenced.
426 extern void kx_start(keyexch */*kx*/);
428 /* --- @kx_message@ --- *
430 * Arguments: @keyexch *kx@ = pointer to key exchange context
431 * @unsigned msg@ = the message code
432 * @buf *b@ = pointer to buffer containing the packet
436 * Use: Reads a packet containing key exchange messages and handles
440 extern void kx_message(keyexch */*kx*/, unsigned /*msg*/, buf */*b*/);
442 /* --- @kx_free@ --- *
444 * Arguments: @keyexch *kx@ = pointer to key exchange context
448 * Use: Frees everything in a key exchange context.
451 extern void kx_free(keyexch */*kx*/);
453 /* --- @kx_newkeys@ --- *
455 * Arguments: @keyexch *kx@ = pointer to key exchange context
459 * Use: Informs the key exchange module that its keys may have
460 * changed. If fetching the new keys fails, the peer will be
461 * destroyed, we log messages and struggle along with the old
465 extern void kx_newkeys(keyexch */*kx*/);
467 /* --- @kx_init@ --- *
469 * Arguments: @keyexch *kx@ = pointer to key exchange context
470 * @peer *p@ = pointer to peer context
471 * @keyset **ks@ = pointer to keyset list
473 * Returns: Zero if OK, nonzero if it failed.
475 * Use: Initializes a key exchange module. The module currently
476 * contains no keys, and will attempt to initiate a key
480 extern int kx_init(keyexch */*kx*/, peer */*p*/, keyset **/*ks*/);
482 /*----- Keysets and symmetric cryptography --------------------------------*/
484 /* --- @ks_drop@ --- *
486 * Arguments: @keyset *ks@ = pointer to a keyset
490 * Use: Decrements a keyset's reference counter. If the counter hits
491 * zero, the keyset is freed.
494 extern void ks_drop(keyset */*ks*/);
496 /* --- @ks_gen@ --- *
498 * Arguments: @const void *k@ = pointer to key material
499 * @size_t x, y, z@ = offsets into key material (see below)
500 * @peer *p@ = pointer to peer information
502 * Returns: A pointer to the new keyset.
504 * Use: Derives a new keyset from the given key material. The
505 * offsets @x@, @y@ and @z@ separate the key material into three
506 * parts. Between the @k@ and @k + x@ is `my' contribution to
507 * the key material; between @k + x@ and @k + y@ is `your'
508 * contribution; and between @k + y@ and @k + z@ is a shared
509 * value we made together. These are used to construct two
510 * pairs of symmetric keys. Each pair consists of an encryption
511 * key and a message authentication key. One pair is used for
512 * outgoing messages, the other for incoming messages.
514 * The new key is marked so that it won't be selected for output
515 * by @ksl_encrypt@. You can still encrypt data with it by
516 * calling @ks_encrypt@ directly.
519 extern keyset *ks_gen(const void */*k*/,
520 size_t /*x*/, size_t /*y*/, size_t /*z*/,
523 /* --- @ks_tregen@ --- *
525 * Arguments: @keyset *ks@ = pointer to a keyset
527 * Returns: The time at which moves ought to be made to replace this key.
530 extern time_t ks_tregen(keyset */*ks*/);
532 /* --- @ks_activate@ --- *
534 * Arguments: @keyset *ks@ = pointer to a keyset
538 * Use: Activates a keyset, so that it can be used for encrypting
542 extern void ks_activate(keyset */*ks*/);
544 /* --- @ks_encrypt@ --- *
546 * Arguments: @keyset *ks@ = pointer to a keyset
547 * @unsigned ty@ = message type
548 * @buf *b@ = pointer to input buffer
549 * @buf *bb@ = pointer to output buffer
551 * Returns: Zero if OK, nonzero if the key needs replacing. If the
552 * encryption failed, the output buffer is broken and zero is
555 * Use: Encrypts a block of data using the key. Note that the `key
556 * ought to be replaced' notification is only ever given once
557 * for each key. Also note that this call forces a keyset to be
558 * used even if it's marked as not for data output.
561 extern int ks_encrypt(keyset */*ks*/, unsigned /*ty*/,
562 buf */*b*/, buf */*bb*/);
564 /* --- @ks_decrypt@ --- *
566 * Arguments: @keyset *ks@ = pointer to a keyset
567 * @unsigned ty@ = expected type code
568 * @buf *b@ = pointer to an input buffer
569 * @buf *bb@ = pointer to an output buffer
571 * Returns: Zero on success, or nonzero if there was some problem.
573 * Use: Attempts to decrypt a message using a given key. Note that
574 * requesting decryption with a key directly won't clear a
575 * marking that it's not for encryption.
578 extern int ks_decrypt(keyset */*ks*/, unsigned /*ty*/,
579 buf */*b*/, buf */*bb*/);
581 /* --- @ksl_free@ --- *
583 * Arguments: @keyset **ksroot@ = pointer to keyset list head
587 * Use: Frees (releases references to) all of the keys in a keyset.
590 extern void ksl_free(keyset **/*ksroot*/);
592 /* --- @ksl_link@ --- *
594 * Arguments: @keyset **ksroot@ = pointer to keyset list head
595 * @keyset *ks@ = pointer to a keyset
599 * Use: Links a keyset into a list. A keyset can only be on one list
600 * at a time. Bad things happen otherwise.
603 extern void ksl_link(keyset **/*ksroot*/, keyset */*ks*/);
605 /* --- @ksl_prune@ --- *
607 * Arguments: @keyset **ksroot@ = pointer to keyset list head
611 * Use: Prunes the keyset list by removing keys which mustn't be used
615 extern void ksl_prune(keyset **/*ksroot*/);
617 /* --- @ksl_encrypt@ --- *
619 * Arguments: @keyset **ksroot@ = pointer to keyset list head
620 * @unsigned ty@ = message type
621 * @buf *b@ = pointer to input buffer
622 * @buf *bb@ = pointer to output buffer
624 * Returns: Nonzero if a new key is needed.
626 * Use: Encrypts a packet.
629 extern int ksl_encrypt(keyset **/*ksroot*/, unsigned /*ty*/,
630 buf */*b*/, buf */*bb*/);
632 /* --- @ksl_decrypt@ --- *
634 * Arguments: @keyset **ksroot@ = pointer to keyset list head
635 * @unsigned ty@ = expected type code
636 * @buf *b@ = pointer to input buffer
637 * @buf *bb@ = pointer to output buffer
639 * Returns: Nonzero if the packet couldn't be decrypted.
641 * Use: Decrypts a packet.
644 extern int ksl_decrypt(keyset **/*ksroot*/, unsigned /*ty*/,
645 buf */*b*/, buf */*bb*/);
647 /*----- Administration interface ------------------------------------------*/
649 /* --- @a_warn@ --- *
651 * Arguments: @const char *fmt@ = pointer to format string
652 * @...@ = other arguments
656 * Use: Informs all admin connections of a warning.
659 extern void a_warn(const char */*fmt*/, ...);
661 /* --- @a_create@ --- *
663 * Arguments: @int fd_in, fd_out@ = file descriptors to use
667 * Use: Creates a new admin connection.
670 extern void a_create(int /*fd_in*/, int /*fd_out*/);
672 /* --- @a_quit@ --- *
678 * Use: Shuts things down nicely.
681 extern void a_quit(void);
683 /* --- @a_daemon@ --- *
689 * Use: Informs the admin module that it's a daemon.
692 extern void a_daemon(void);
694 /* --- @a_init@ --- *
696 * Arguments: @const char *sock@ = socket name to create
700 * Use: Creates the admin listening socket.
703 extern void a_init(const char */*sock*/);
705 /*----- Peer management ---------------------------------------------------*/
707 /* --- @p_txstart@ --- *
709 * Arguments: @peer *p@ = pointer to peer block
710 * @unsigned msg@ = message type code
712 * Returns: A pointer to a buffer to write to.
714 * Use: Starts sending to a peer. Only one send can happen at a
718 extern buf *p_txstart(peer */*p*/, unsigned /*msg*/);
720 /* --- @p_txend@ --- *
722 * Arguments: @peer *p@ = pointer to peer block
726 * Use: Sends a packet to the peer.
729 extern void p_txend(peer */*p*/);
733 * Arguments: @peer *p@ = pointer to peer block
734 * @buf *b@ = buffer containing incoming packet
738 * Use: Handles a packet which needs to be sent to a peer.
741 extern void p_tun(peer */*p*/, buf */*b*/);
743 /* --- @p_interval@ --- *
749 * Use: Called periodically to do tidying.
752 extern void p_interval(void);
754 /* --- @p_stats@ --- *
756 * Arguments: @peer *p@ = pointer to a peer block
758 * Returns: A pointer to the peer's statistics.
761 extern stats *p_stats(peer */*p*/);
763 /* --- @p_ifname@ --- *
765 * Arguments: @peer *p@ = pointer to a peer block
767 * Returns: A pointer to the peer's interface name.
770 extern const char *p_ifname(peer */*p*/);
772 /* --- @p_addr@ --- *
774 * Arguments: @peer *p@ = pointer to a peer block
776 * Returns: A pointer to the peer's address.
779 extern const addr *p_addr(peer */*p*/);
781 /* --- @p_init@ --- *
783 * Arguments: @struct in_addr addr@ = address to bind to
784 * @unsigned port@ = port number to listen to
788 * Use: Initializes the peer system; creates the socket.
791 extern void p_init(struct in_addr /*addr*/, unsigned /*port*/);
793 /* --- @p_port@ --- *
797 * Returns: Port number used for socket.
800 unsigned p_port(void);
802 /* --- @p_create@ --- *
804 * Arguments: @const char *name@ = name for this peer
805 * @struct sockaddr *sa@ = socket address of peer
806 * @size_t sz@ = size of socket address
808 * Returns: Pointer to the peer block, or null if it failed.
810 * Use: Creates a new named peer block. No peer is actually attached
814 extern peer *p_create(const char */*name*/,
815 struct sockaddr */*sa*/, size_t /*sz*/);
817 /* --- @p_name@ --- *
819 * Arguments: @peer *p@ = pointer to a peer block
821 * Returns: A pointer to the peer's name.
824 extern const char *p_name(peer */*p*/);
826 /* --- @p_find@ --- *
828 * Arguments: @const char *name@ = name to look up
830 * Returns: Pointer to the peer block, or null if not found.
832 * Use: Finds a peer by name.
835 extern peer *p_find(const char */*name*/);
837 /* --- @p_destroy@ --- *
839 * Arguments: @peer *p@ = pointer to a peer
843 * Use: Destroys a peer.
846 extern void p_destroy(peer */*p*/);
848 /* --- @p_first@, @p_next@ --- *
850 * Arguments: @peer *p@ = a peer block
852 * Returns: @peer_first@ returns the first peer in some ordering;
853 * @peer_next@ returns the peer following a given one in the
854 * same ordering. Null is returned for the end of the list.
857 extern peer *p_first(void);
858 extern peer *p_next(peer */*p*/);
860 /*----- Tunnel interface --------------------------------------------------*/
862 /* --- @tun_init@ --- *
868 * Use: Initializes the tunneling system. Maybe this will require
869 * opening file descriptors or something.
872 extern void tun_init(void);
874 /* --- @tun_create@ --- *
876 * Arguments: @tunnel *t@ = pointer to tunnel block
877 * @peer *p@ = pointer to peer block
879 * Returns: Zero if it worked, nonzero on failure.
881 * Use: Initializes a new tunnel.
884 extern int tun_create(tunnel */*t*/, peer */*p*/);
886 /* --- @tun_ifname@ --- *
888 * Arguments: @tunnel *t@ = pointer to tunnel block
890 * Returns: A pointer to the tunnel's interface name.
893 extern const char *tun_ifname(tunnel */*t*/);
895 /* --- @tun_inject@ --- *
897 * Arguments: @tunnel *t@ = pointer to tunnel block
898 * @buf *b@ = buffer to send
902 * Use: Injects a packet into the local network stack.
905 extern void tun_inject(tunnel */*t*/, buf */*b*/);
907 /* --- @tun_destroy@ --- *
909 * Arguments: @tunnel *t@ = pointer to tunnel block
913 * Use: Destroys a tunnel.
916 extern void tun_destroy(tunnel */*t*/);
918 /*----- Other handy utilities ---------------------------------------------*/
922 * Arguments: @mp *m@ = a multiprecision integer
924 * Returns: A pointer to the integer's textual representation.
926 * Use: Converts a multiprecision integer to a string. Corrupts
930 extern const char *mpstr(mp */*m*/);
934 * Arguments: @group *g@ = a group
935 * @ge *x@ = a group element
937 * Returns: A pointer to the element's textual representation.
939 * Use: Converts a group element to a string. Corrupts
943 extern const char *gestr(group */*g*/, ge */*x*/);
945 /* --- @timestr@ --- *
947 * Arguments: @time_t t@ = a time to convert
949 * Returns: A pointer to a textual representation of the time.
951 * Use: Converts a time to a textual representation. Corrupts
955 extern const char *timestr(time_t /*t*/);
957 /*----- That's all, folks -------------------------------------------------*/