struct tidc_instance {
TID_REQ *req_list;
// TBD -- Do we still need a separate private key */
- char *priv_key;
- int priv_len;
- DH *priv_dh; /* Client's DH struct with priv and pub keys */
+ // char *priv_key;
+ // int priv_len;
+ DH *client_dh; /* Client's DH struct with priv and pub keys */
};
typedef int (TIDS_REQ_FUNC)(TIDS_INSTANCE *, TID_REQ *, TID_RESP **, void *);
#include <trust_router/tid.h>
#include <trust_router/tr_dh.h>
-static int tidc_response_received = 0;
-
void static tidc_print_usage (const char *name)
{
printf("Usage: %s <server> <RP-realm> <target-realm> <community>\n", name);
int i;
printf ("Response received! Realm = %s, Community = %s.\n", resp->realm->buf, resp->comm->buf);
- tidc_response_received = 1;
/* Generate the client key -- TBD, handle more than one server */
if (TID_SUCCESS != resp->result) {
/* Print out the client key. */
printf("Client Key Generated (len = %d):\n", c_keylen);
for (i = 0; i < c_keylen; i++) {
- printf("%x", c_keybuf[i]);
+ printf("%.2x", c_keybuf[i]);
}
printf("\n");
printf("TIDC Client:\nServer = %s, rp_realm = %s, target_realm = %s, community = %s\n", server, rp_realm, realm, coi);
- /* Create a TID client instance */
+ /* Create a TID client instance & the client DH */
tidc = tidc_create();
+ if (NULL == (tidc->client_dh = tr_create_dh_params(NULL, 0))) {
+ printf("Error creating client DH params.\n");
+ return 1;
+ }
/* Set-up TID connection */
if (-1 == (conn = tidc_open_connection(tidc, server, &gssctx))) {
return 1;
}
- /* Wait for a response */
- while (!tidc_response_received);
-
/* Clean-up the TID client instance, and exit */
tidc_destroy(tidc);
#include <tr_msg.h>
#include <gsscon.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;
TIDC_INSTANCE *tidc_create ()
else
return NULL;
- // TBD -- Add a flag, so we don't do this for the trust router */
- if (NULL == (tidc->priv_dh = tr_create_dh_params(NULL, 0))) {
- free (tidc);
- return NULL;
- }
-
- fprintf(stderr, "TIDC DH Parameters:\n");
- DHparams_print_fp(stdout, tidc->priv_dh);
- fprintf(stderr, "\n");
-
return tidc;
}
tid_req->realm = tr_new_name(realm);
tid_req->comm = tr_new_name(comm);
- tid_req->tidc_dh = tidc->priv_dh;
-
+ tid_req->tidc_dh = tidc->client_dh;
+
tid_req->resp_func = resp_handler;
tid_req->cookie = cookie;
return -1;
}
+ /* Use the DH parameters from the original request */
+ tidc->client_dh = req->tidc_dh;
+
/* Set-up TID connection */
/* TBD -- version of open_connection that takes an inaddr */
if (-1 == (conn = tidc_open_connection(tidc, inet_ntoa(aaa_servers->aaa_server_addr), &gssctx))) {
resp_cookie.tr = tr;
resp_cookie.orig_req = req;
- /* TBD -- version of send request that takes TR_NAMES */
+ /* TBD -- version of send request that takes TR_NAMES? */
if (0 > (rc = tidc_send_request(tidc, conn, gssctx, req->rp_realm->buf, req->realm->buf, req->comm->buf, &tr_tidc_resp_handler, (void *)&resp_cookie))) {
printf("Error in tidc_send_request, rc = %d.\n", rc);
return -1;
TR_CFG_RC rc = TR_CFG_SUCCESS; /* presume success */
int err = 0, n = 0;;
- /* parse command-line arguments -- TBD */
+ /* parse command-line arguments? -- TBD */
/* create a Trust Router instance */
if (NULL == (tr = tr_create())) {
exit(1);
}
- /* start the trust path query server, won't return unless error. */
+ /* start the trust path query server, won't return unless fatal error. */
if (0 != (err = tids_start(tr->tids, &tr_tids_req_handler, (void *)tr))) {
- printf ("Error starting Trust Path Query Server, err = %d.\n", err);
+ printf ("Error from Trust Path Query Server, err = %d.\n", err);
exit(err);
}