From 8b963d1d04f22b92c15ab14b3f8b81625a306f1c Mon Sep 17 00:00:00 2001 From: Paul Park Date: Tue, 29 Aug 1995 18:44:47 +0000 Subject: [PATCH] Use new gss_{im,ex}port_sec_context git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6630 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/gss-sample/ChangeLog | 4 ++++ src/appl/gss-sample/gss-client.c | 21 ++++++++++++++++++++- src/appl/gss-sample/gss-server.c | 21 ++++++++++++++++++++- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/appl/gss-sample/ChangeLog b/src/appl/gss-sample/ChangeLog index bb2ec0d8b..189914dc8 100644 --- a/src/appl/gss-sample/ChangeLog +++ b/src/appl/gss-sample/ChangeLog @@ -1,4 +1,8 @@ +Tue Aug 29 13:24:50 EDT 1995 Paul Park (pjpark@mit.edu) + * gss-{client,server}.c - Test gss_{ex,im}port_sec_context(). + + Fri Jul 7 15:41:47 EDT 1995 Paul Park (pjpark@mit.edu) * Makefile.in - Remove all explicit library handling. * configure.in - Add KRB5_LIBRARIES. diff --git a/src/appl/gss-sample/gss-client.c b/src/appl/gss-sample/gss-client.c index da95f8449..c57678610 100644 --- a/src/appl/gss-sample/gss-client.c +++ b/src/appl/gss-sample/gss-client.c @@ -110,7 +110,7 @@ int call_server(host, port, service_name, msg) char *msg; { gss_ctx_id_t context; - gss_buffer_desc in_buf, out_buf; + gss_buffer_desc in_buf, out_buf, context_token; int s, state; OM_uint32 maj_stat, min_stat; @@ -122,6 +122,25 @@ int call_server(host, port, service_name, msg) if (client_establish_context(s, service_name, &context) < 0) return -1; + /* + * Attempt to save and then restore the context. + */ + maj_stat = gss_export_sec_context(&min_stat, + &context, + &context_token); + if (maj_stat != GSS_S_COMPLETE) { + display_status("exporting context", maj_stat, min_stat); + return -1; + } + maj_stat = gss_import_sec_context(&min_stat, + &context_token, + &context); + if (maj_stat != GSS_S_COMPLETE) { + display_status("importing context", maj_stat, min_stat); + return -1; + } + (void) gss_release_buffer(&min_stat, &context_token); + /* Seal the message */ in_buf.value = msg; in_buf.length = strlen(msg) + 1; diff --git a/src/appl/gss-sample/gss-server.c b/src/appl/gss-sample/gss-server.c index b90bd37fe..e40144578 100644 --- a/src/appl/gss-sample/gss-server.c +++ b/src/appl/gss-sample/gss-server.c @@ -180,7 +180,7 @@ int sign_server(s, service_name) char *service_name; { gss_cred_id_t server_creds; - gss_buffer_desc client_name, xmit_buf, msg_buf; + gss_buffer_desc client_name, xmit_buf, msg_buf, context_token; gss_ctx_id_t context; OM_uint32 maj_stat, min_stat; int s2; @@ -209,6 +209,25 @@ int sign_server(s, service_name) client_name.value, ctime(&now)); (void) gss_release_buffer(&min_stat, &client_name); + /* + * Attempt to save and then restore the context. + */ + maj_stat = gss_export_sec_context(&min_stat, + &context, + &context_token); + if (maj_stat != GSS_S_COMPLETE) { + display_status("exporting context", maj_stat, min_stat); + break; + } + maj_stat = gss_import_sec_context(&min_stat, + &context_token, + &context); + if (maj_stat != GSS_S_COMPLETE) { + display_status("importing context", maj_stat, min_stat); + break; + } + (void) gss_release_buffer(&min_stat, &context_token); + /* Receive the sealed message token */ if (recv_token(s2, &xmit_buf) < 0) break; -- 2.26.2