+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
#include "portable.h"
-#if defined(HAVE_KERBEROS) && !defined(openbsd)
+#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.
*
#include <stdio.h>
#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 HAVE_AFS_KERBEROS
/*
* convert an arbitrary length string to a DES key
*/
-int
+void
des_string_to_key( char *str, register des_cblock *key )
{
register char *in_str;
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 /* HAVE_KERBEROS_V */
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);
strncat (password, cell, sizeof(password)-passlen);
if ((passlen = strlen(password)) > sizeof(password)) passlen = sizeof(password);
- memcpy(ivec, "kerberos", 8);
- memcpy(temp_key, "kerberos", 8);
+ AC_MEMCPY(ivec, "kerberos", 8);
+ AC_MEMCPY(temp_key, "kerberos", 8);
des_fixup_key_parity (temp_key);
des_key_sched (temp_key, schedule);
des_cbc_cksum (password, ivec, passlen, schedule, ivec);
- memcpy(temp_key, ivec, 8);
+ AC_MEMCPY(temp_key, ivec, 8);
des_fixup_key_parity (temp_key);
des_key_sched (temp_key, schedule);
des_cbc_cksum (password, key, passlen, schedule, ivec);