]> git.sur5r.net Git - openldap/blobdiff - clients/ud/string_to_key.c
Don't depend error handling on exact resultCode.
[openldap] / clients / ud / string_to_key.c
index d140d36b394c102159b9450a911ec4ba0b67931f..44f683c28369f84783c2a1c36eef19136df70540 100644 (file)
@@ -1,8 +1,12 @@
-#if defined(KERBEROS) && !defined(openbsd)
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+#include "portable.h"
+
+#if defined(LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND) && !defined(openbsd)
 /*
- * $Source: /repo/OpenLDAP/pkg/ldap/clients/ud/string_to_key.c,v $
- * $Author: kurt $
- *
  * Copyright 1985, 1986, 1987, 1988, 1989 by the Massachusetts Institute
  * of Technology.
  *
  *     spm     8/85    MIT project athena
  */
 
-#ifndef        lint
-static char rcsid_string_to_key_c[] =
-"$Id: string_to_key.c,v 1.1.3.1 1998/08/08 22:43:17 kurt Exp $";
-#endif
-
-#include <mit-copyright.h>
 #include <stdio.h>
-#include <des.h>
-/* #include "des_internal.h" */
-#if 1
-#include <krb.h>
-#endif
+#include <ac/krb.h>
 
+#if defined( DEBUG ) && defined( HAVE_DES_DEBUG )
+#define USE_DES_DEBUG
 extern int des_debug;
-extern int des_debug_print();
+#endif
+
 extern void des_fixup_key_parity();
 
-#ifndef AFSKERBEROS
+#ifndef HAVE_AFS_KERBEROS
 #define WORLDPEACEINOURTIME
 #endif
 
 #if defined(WORLDPEACEINOURTIME) /* Use original, not ifs version */
+#ifndef HAVE_KERBEROS_V
 /*
  * convert an arbitrary length string to a DES key
  */
-int
-des_string_to_key(str,key)
-    char *str;
-    register des_cblock *key;
+void
+des_string_to_key( char *str, register des_cblock *key )
 {
     register char *in_str;
     register unsigned temp,i;
@@ -73,7 +69,7 @@ des_string_to_key(str,key)
     /* init key array for bits */
     memset(k_char, 0, sizeof(k_char));
 
-#ifdef DEBUG
+#ifdef USE_DES_DEBUG
     if (des_debug)
        fprintf(stdout,
                "\n\ninput str length = %d  string = %s\nstring = 0x ",
@@ -84,7 +80,7 @@ des_string_to_key(str,key)
     for (i = 1; i <= length; i++) {
        /* get next input key byte */
        temp = (unsigned int) *str++;
-#ifdef DEBUG
+#ifdef USE_DES_DEBUG
        if (des_debug)
            fprintf(stdout,"%02x ",temp & 0xff);
 #endif
@@ -125,13 +121,16 @@ des_string_to_key(str,key)
     /* now fix up key parity again */
     des_fixup_key_parity(key);
 
+#ifdef USE_DES_DEBUG
     if (des_debug)
        fprintf(stdout,
-               "\nResulting string_to_key = 0x%x 0x%x\n",
+               "\nResulting string_to_key = 0x%lx 0x%lx\n",
                *((unsigned long *) key),
                *((unsigned long *) key+1));
+#endif
 }
 
+#endif /* HAVE_KERBEROS_V */
 #else /* Use ifs version */
 
 #if 0
@@ -151,10 +150,12 @@ des_string_to_key(str,key)
    encryption key.  It is compatible with the original Andrew authentication
    service password database. */
 
-static void Andrew_StringToKey (str, cell, key)
-  char          *str;
-  char          *cell;                  /* cell for password */
-  des_cblock *key;
+static void
+Andrew_StringToKey(
+  char          *str,
+  char          *cell,                  /* cell for password */
+  des_cblock *key
+)
 {   char  password[8+1];                /* crypt is limited to 8 chars anyway */
     int   i;
     int   passlen;
@@ -190,10 +191,12 @@ static void Andrew_StringToKey (str, cell, key)
     des_fixup_key_parity (key);
 }
 
-static void StringToKey (str, cell, key)
-  char          *str;
-  char          *cell;                  /* cell for password */
-  des_cblock *key;
+static void
+StringToKey(
+  char          *str,
+  char          *cell,                  /* cell for password */
+  des_cblock   *key
+)
 {   des_key_schedule schedule;
     char temp_key[8];
     char ivec[8];
@@ -219,16 +222,19 @@ static void StringToKey (str, cell, key)
     des_fixup_key_parity (key);
 }
 
-/* static */  void
-ka_StringToKey (str, cell, key)
-  char          *str;
-  char          *cell;                  /* cell for password */
-  des_cblock   *key;
+void
+ka_StringToKey (
+  char          *str,
+  char          *cell,                  /* cell for password */
+  des_cblock   *key
+)
 {   char  realm[REALM_SZ];
 
 #if NOWAYOUTTODAY
     long  code;
-    /* code = ka_CellToRealm (cell, realm, 0/*local*/); */
+#if 0
+    code = ka_CellToRealm (cell, realm, 0/*local*/);
+#endif
     if (code) strcpy (realm, "");
     else lcstring (realm, realm, sizeof(realm)); /* for backward compatibility */
 #else
@@ -243,9 +249,7 @@ ka_StringToKey (str, cell, key)
  * convert an arbitrary length string to a DES key
  */
 int
-des_string_to_key(str,key)
-    char *str;
-    register des_cblock *key;
+des_string_to_key( char *str, register des_cblock *key )
 {
        /* NB: i should probably call routine to get local cell here */
        ka_StringToKey(str, "umich.edu", key);