From: Margaret Wasserman Date: Wed, 19 Dec 2012 18:44:34 +0000 (-0500) Subject: Add inital DH common code, and call from TPQ client. X-Git-Tag: 1.0~79 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=trust_router.git;a=commitdiff_plain;h=dbc591625f4995092eb3139a523dd3a212af7f28 Add inital DH common code, and call from TPQ client. --- diff --git a/Makefile.am b/Makefile.am index 2fc0c8f..fb649db 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,7 +13,8 @@ tr_tr_LDADD = gsscon/libgsscon.la tpq_example_tpqc_SOURCES = tpq/example/tpqc_main.c \ tpq/tpqc.c \ common/tr_name.c \ -common/tr_msg.c +common/tr_msg.c \ +common/tr_dh.c tpq_example_tpqc_LDADD = gsscon/libgsscon.la diff --git a/include/tpq.h b/include/tpq.h index f07dd7a..c5967e0 100644 --- a/include/tpq.h +++ b/include/tpq.h @@ -35,6 +35,9 @@ #ifndef TPQ_H #define TPQ_H +#include +#include + #include #include @@ -45,6 +48,7 @@ typedef struct tpq_req { int conn; TR_NAME *realm; TR_NAME *coi; + DH *tpqc_dh; /* Client's public dh information */ void *resp_func; void *cookie; } TPQ_REQ; @@ -52,17 +56,21 @@ typedef struct tpq_req { typedef struct tpq_resp { TR_NAME *realm; TR_NAME *coi; - /* Address of AAA Server */ - /* Credentials */ + in_addr_t aaa_server_addr; + DH *aaa_server_dh; /* AAA server's public dh information */ /* Trust Path Used */ } TPQ_RESP; typedef struct tpqc_instance { TPQ_REQ *req_list; + char *priv_key; + int priv_len; + DH *priv_dh; /* Client's DH struct with priv and pub keys */ } TPQC_INSTANCE; typedef struct tpqs_instance { int req_count; + char *priv_key; void *req_handler; void *cookie; } TPQS_INSTANCE; diff --git a/tpq/tpqc.c b/tpq/tpqc.c index 16cc81e..74cdcff 100644 --- a/tpq/tpqc.c +++ b/tpq/tpqc.c @@ -32,22 +32,52 @@ * */ +#include #include #include #include +#include #include +char tmp_key[32] = + {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x19, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F}; +int tmp_len = 32; + TPQC_INSTANCE *tpqc_create () { TPQC_INSTANCE *tpqc = NULL; - if (tpqc = malloc(sizeof(TPQC_INSTANCE))) + if (tpqc = malloc(sizeof(TPQC_INSTANCE))) memset(tpqc, 0, sizeof(TPQC_INSTANCE)); + else + return NULL; + + /* TBD -- Generate random private key */ + tpqc->priv_key = tmp_key; + tpqc->priv_len = tmp_len; + + if (NULL == (tpqc->priv_dh = tr_create_dh_params(tpqc->priv_key, tpqc->priv_len))) { + free (tpqc); + return NULL; + } + + fprintf(stderr, "TPQC DH Parameters:\n"); + DHparams_print_fp(stdout, tpqc->priv_dh); + fprintf(stderr, "\n"); return tpqc; } +void tpqc_destroy (TPQC_INSTANCE *tpqc) +{ + if (tpqc) + free(tpqc); +} + int tpqc_open_connection (TPQC_INSTANCE *tpqc, char *server, gss_ctx_id_t *gssctx) @@ -143,11 +173,6 @@ int tpqc_send_request (TPQC_INSTANCE *tpqc, return 0; } -void tpqc_destroy (TPQC_INSTANCE *tpqc) -{ - if (tpqc) - free(tpqc); -}