-#if defined(KERBEROS) && !defined(openbsd)
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2000 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.3 1998/09/08 00:26:56 kurt Exp $";
-#endif
-
-#ifdef KERBEROS_V
-#include <kerberosIV/mit-copyright.h>
-#include <kerberosIV/des.h>
-#else
-#include <mit-copyright.h>
-#include <des.h>
-#endif /* KERBEROS_V */
-
#include <stdio.h>
+#include <ac/krb.h>
-/* #include "des_internal.h" */
-#if 1
-#ifdef KERBEROS_V
-#include <kerberosIV/krb.h>
-#else
-#include <krb.h>
-#endif /* KERBEROS_V */
-#endif /* 1 */
-
+#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 KERBEROS_V
+#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;
length = strlen(str);
/* init key array for bits */
- memset(k_char, 0, sizeof(k_char));
+ 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 ",
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
(void) des_key_sched(key,key_sked);
(void) des_cbc_cksum((des_cblock *)in_str,key,length,key_sked,key);
/* erase key_sked */
- memset((char *)key_sked, 0, sizeof(key_sked));
+ memset((char *)key_sked, '\0', sizeof(key_sked));
/* 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 /* KERBEROS_V */
+#endif /* HAVE_KERBEROS_V */
#else /* Use ifs version */
#if 0
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;
- memset(key, 0, sizeof(des_cblock));
- memset(password, 0, sizeof(password));
+ memset(key, '\0', sizeof(des_cblock));
+ memset(password, '\0', sizeof(password));
strncpy (password, cell, 8);
passlen = strlen (str);
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];
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
* 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);