From 25ae63aa252ca6af1886668f7a8ff9bd7c196cb1 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Thu, 25 Jul 1996 06:19:16 +0000 Subject: [PATCH] gss.c (parse_name): Add code to parse an optional fourth parameter which is the mechanism OID to actually use. If it is ommited, the default mechanism is used. gss-client.c (client_establish_context): Added parameter oid_name, which allows the user to specify the OID that he/she actually wants to use to as the mechanism. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@8815 dc483132-0cff-0310-8789-dd5450dbe970 --- src/windows/gss/ChangeLog | 10 ++++++++++ src/windows/gss/gss-client.c | 30 +++++++++++++++++++++--------- src/windows/gss/gss.c | 21 +++++++++++++++++---- src/windows/gss/gss.h | 6 +++--- 4 files changed, 51 insertions(+), 16 deletions(-) diff --git a/src/windows/gss/ChangeLog b/src/windows/gss/ChangeLog index 24d655f33..9de73ec2d 100644 --- a/src/windows/gss/ChangeLog +++ b/src/windows/gss/ChangeLog @@ -1,3 +1,13 @@ +Thu Jul 25 02:16:56 1996 Theodore Y. Ts'o + + * gss.c (parse_name): Add code to parse an optional fourth + parameter which is the mechanism OID to actually use. If + it is ommited, the default mechanism is used. + + * gss-client.c (client_establish_context): Added parameter + oid_name, which allows the user to specify the OID that + he/she actually wants to use to as the mechanism. + Wed Jun 12 00:16:46 1996 Theodore Ts'o * gss-clie.c: Renamed to gss-client.c, for VFAT/NTFS filesystems diff --git a/src/windows/gss/gss-client.c b/src/windows/gss/gss-client.c index 1dc4d8054..bb0025e8f 100644 --- a/src/windows/gss/gss-client.c +++ b/src/windows/gss/gss-client.c @@ -35,12 +35,12 @@ const gss_OID_desc * gss_nt_string_uid_name = oids+2; const gss_OID_desc * gss_nt_service_name = oids+3; int -gss (char *host, char *name, char *msg, int port) +gss (char *host, char *name, char *oid, char *msg, int port) { if (port == 0 || port == -1) port = 4444; - if (call_server(host, port, name, msg) < 0) + if (call_server(host, port, name, oid, msg) < 0) return 1; return 0; @@ -70,7 +70,7 @@ gss (char *host, char *name, char *msg, int port) * otherwise 0 is returned. */ int -call_server (char *host, u_short port, char *service_name, char *msg) +call_server (char *host, u_short port, char *service_name, char *oid, char *msg) { gss_ctx_id_t context; gss_buffer_desc in_buf, out_buf; @@ -82,7 +82,7 @@ call_server (char *host, u_short port, char *service_name, char *msg) return -1; /* Establish context */ - if (client_establish_context(s, service_name, &context) < 0) + if (client_establish_context(s, service_name, oid, &context) < 0) return -1; /* Seal the message */ @@ -201,16 +201,28 @@ connect_to_server (char *host, u_short port) * and -1 is returned. */ int -client_establish_context (int s, char *sname, gss_ctx_id_t *gss_context) +client_establish_context (int s, char *sname, char *oid_name, + gss_ctx_id_t *gss_context) { gss_buffer_desc send_tok, recv_tok, *token_ptr; gss_name_t target_name; OM_uint32 maj_stat, min_stat; + gss_OID oid = GSS_C_NULL_OID; + + if (oid_name && oid_name[0]) { + send_tok.value = oid_name; + send_tok.length = strlen(oid_name); + maj_stat = gss_str_to_oid(&min_stat, &send_tok, &oid); + if (maj_stat != GSS_S_COMPLETE) { + display_status("str_to_oid", maj_stat, min_stat); + return -1; + } + } /* - * Import the name into target_name. Use send_tok to save - * local variable space. - */ + * Import the name into target_name. Use send_tok to save + * local variable space. + */ send_tok.value = sname; send_tok.length = strlen(sname) + 1; maj_stat = gss_import_name(&min_stat, &send_tok, @@ -245,7 +257,7 @@ client_establish_context (int s, char *sname, gss_ctx_id_t *gss_context) GSS_C_NO_CREDENTIAL, gss_context, target_name, - GSS_C_NULL_OID, + oid, GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG, 0, NULL, /* no channel bindings */ diff --git a/src/windows/gss/gss.c b/src/windows/gss/gss.c index 4b56e1e77..f57b76319 100644 --- a/src/windows/gss/gss.c +++ b/src/windows/gss/gss.c @@ -21,9 +21,10 @@ #define MAX_HOSTS 9 char hosts[MAX_HOSTS][256]; -char szHost[256]; // GSSAPI Host to connect to -char szServiceName[256]; // Service to do -int port = 0; // Which port to use +char szHost[256]; // GSSAPI Host to connect to +char szServiceName[256]; // Service to do +char szOID[256]; // OID to use +int port = 0; // Which port to use static void do_gssapi_test (char *name); static void parse_name (char *name); @@ -68,7 +69,7 @@ do_gssapi_test (char *name) { parse_name(name); // Get host, service and port hcursor = SetCursor(LoadCursor(NULL, IDC_WAIT)); - n = gss (szHost, szServiceName, "Test Gssapi Message", port); + n = gss (szHost, szServiceName, szOID, "Test Gssapi Message", port); SetCursor(hcursor); if (n) @@ -184,6 +185,18 @@ parse_name (char *name) { }else{ wsprintf (szServiceName, "sample@%s", szHost); // Make the service name } + if( ptr ){ + ptr = strtok( NULL, seps); + } + if( ptr ){ + wsprintf (szOID, "{ %s }", ptr); // Put in the OID + for (ptr = szOID; *ptr; ptr++) + if (*ptr == '.') + *ptr = ' '; + } else { + szOID[0] = 0; + } + } /*+************************************************************************* ** diff --git a/src/windows/gss/gss.h b/src/windows/gss/gss.h index 1a3778a95..175044de8 100644 --- a/src/windows/gss/gss.h +++ b/src/windows/gss/gss.h @@ -23,7 +23,7 @@ void OkMsgBox (char *format, ...); void my_perror (char *msg); // gss-client.c -int gss (char *host, char *name, char *msg, int port); -int call_server(char *host, u_short port, char *service_name, char *msg); +int gss (char *host, char *name, char *msg, char *oid, int port); +int call_server(char *host, u_short port, char *service_name, char *oid, char *msg); int connect_to_server(char *host, u_short port); -int client_establish_context(int s, char *service_name, gss_ctx_id_t *gss_context); +int client_establish_context(int s, char *service_name, char *oid, gss_ctx_id_t *gss_context); -- 2.26.2