gss.c (parse_name): Add code to parse an optional fourth parameter
authorTheodore Tso <tytso@mit.edu>
Thu, 25 Jul 1996 06:19:16 +0000 (06:19 +0000)
committerTheodore Tso <tytso@mit.edu>
Thu, 25 Jul 1996 06:19:16 +0000 (06:19 +0000)
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
src/windows/gss/gss-client.c
src/windows/gss/gss.c
src/windows/gss/gss.h

index 24d655f337c6f69dc3b3992ac14d9be869375ce1..9de73ec2dea06c34f43e09f1329d668ac0909c57 100644 (file)
@@ -1,3 +1,13 @@
+Thu Jul 25 02:16:56 1996  Theodore Y. Ts'o  <tytso@mit.edu>
+
+       * 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  <tytso@rsts-11.mit.edu>
 
        * gss-clie.c: Renamed to gss-client.c, for VFAT/NTFS filesystems
index 1dc4d8054f6c72ef49d2d718419d4db186546676..bb0025e8fcb404dcf243b288e8bc476c3048da47 100644 (file)
@@ -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 */
index 4b56e1e7727607dbe55c885e10ddc95132461b57..f57b76319ad964770c6b575be2d785df61a3ad67 100644 (file)
 
 #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;
+       }
+
 }
 /*+*************************************************************************
 **
index 1a3778a954209fc178e5e90327d27d2c69dc0f66..175044de8fe7ee447cec62281d473cecd78797dc 100644 (file)
@@ -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);