/* -*-c-*-
*
- * $Id: tripe.h,v 1.17 2003/10/15 09:30:18 mdw Exp $
+ * $Id: tripe.h,v 1.18 2004/04/03 12:35:13 mdw Exp $
*
* Main header file for TrIPE
*
/*----- Revision history --------------------------------------------------*
*
* $Log: tripe.h,v $
+ * Revision 1.18 2004/04/03 12:35:13 mdw
+ * Support elliptic curve key exchange.
+ *
* Revision 1.17 2003/10/15 09:30:18 mdw
* Add support for Ethereal protocol analysis.
*
#include <catacomb/rand.h>
#include <catacomb/mp.h>
-#include <catacomb/mpmont.h>
#include <catacomb/mprand.h>
#include <catacomb/dh.h>
+#include <catacomb/ec.h>
+#include <catacomb/ec-keys.h>
+#include <catacomb/group.h>
#include "tripe-protocol.h"
#include "util.h"
typedef struct kxchal {
struct keyexch *kx; /* Pointer back to key exchange */
- mp *c; /* Responder's challenge */
- mp *r; /* My reply to the challenge */
+ ge *c; /* Responder's challenge */
+ ge *r; /* My reply to the challenge */
keyset *ks; /* Pointer to temporary keyset */
unsigned f; /* Various useful flags */
sel_timer t; /* Response timer for challenge */
unsigned f; /* Various useful flags */
unsigned s; /* Current state in exchange */
sel_timer t; /* Timer for next exchange */
- dh_pub kpub; /* Peer's public key */
+ ge *kpub; /* Peer's public key */
time_t texp_kpub; /* Expiry time for public key */
mp *alpha; /* My temporary secret */
- mp *c; /* My challenge */
- mp *rx; /* The expected response */
+ ge *c; /* My challenge */
+ ge *rx; /* The expected response */
unsigned nr; /* Number of extant responses */
time_t t_valid; /* When this exchange goes bad */
octet hc[HASHSZ]; /* Hash of my challenge */
/*----- Global variables --------------------------------------------------*/
extern sel_state sel; /* Global I/O event state */
-extern dh_priv kpriv; /* Our private key */
-extern mpmont mg; /* Montgomery context for DH group */
+extern group *gg; /* The group we work in */
+extern mp *kpriv; /* Our private key */
extern octet buf_i[PKBUFSZ], buf_o[PKBUFSZ], buf_t[PKBUFSZ];
#ifndef NTRACE
/* --- @km_getpubkey@ --- *
*
* Arguments: @const char *tag@ = public key tag to load
- * @dh_pub *kpub@ = where to put the public key
+ * @ge *kpub@ = where to put the public key
* @time_t *t_exp@ = where to put the expiry time
*
* Returns: Zero if OK, nonzero if it failed.
* Use: Fetches a public key from the keyring.
*/
-extern int km_getpubkey(const char */*tag*/, dh_pub */*kpub*/,
+extern int km_getpubkey(const char */*tag*/, ge */*kpub*/,
time_t */*t_exp*/);
/*----- Key exchange ------------------------------------------------------*/
extern const char *mpstr(mp */*m*/);
+/* --- @gestr@ --- *
+ *
+ * Arguments: @group *g@ = a group
+ * @ge *x@ = a group element
+ *
+ * Returns: A pointer to the element's textual representation.
+ *
+ * Use: Converts a group element to a string. Corrupts
+ * @buf_t@.
+ */
+
+extern const char *gestr(group */*g*/, ge */*x*/);
+
/* --- @timestr@ --- *
*
* Arguments: @time_t t@ = a time to convert