Add inital DH common code, and call from TPQ client.
authorMargaret Wasserman <mrw@debian.(none)>
Wed, 19 Dec 2012 18:44:34 +0000 (13:44 -0500)
committerMargaret Wasserman <mrw@debian.(none)>
Wed, 19 Dec 2012 18:44:34 +0000 (13:44 -0500)
Makefile.am
include/tpq.h
tpq/tpqc.c

index 2fc0c8f..fb649db 100644 (file)
@@ -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
 
index f07dd7a..c5967e0 100644 (file)
@@ -35,6 +35,9 @@
 #ifndef TPQ_H
 #define TPQ_H
 
+#include <arpa/inet.h>
+#include <openssl/dh.h>
+
 #include <gsscon.h>
 #include <tr_name.h>
 
@@ -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;
index 16cc81e..74cdcff 100644 (file)
  *
  */
 
+#include <stdio.h>
 #include <stdlib.h>
 #include <jansson.h>
 
 #include <gsscon.h>
+#include <tr_dh.h>
 #include <tpq.h>
 
+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);
-}