summaryrefslogtreecommitdiff
path: root/crypto/heimdal/kdc/string2key.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/heimdal/kdc/string2key.c')
-rw-r--r--crypto/heimdal/kdc/string2key.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/crypto/heimdal/kdc/string2key.c b/crypto/heimdal/kdc/string2key.c
index 8a38442be98e..4211bf7a93f5 100644
--- a/crypto/heimdal/kdc/string2key.c
+++ b/crypto/heimdal/kdc/string2key.c
@@ -34,7 +34,7 @@
#include "headers.h"
#include <getarg.h>
-RCSID("$Id: string2key.c,v 1.20 2003/03/25 12:28:52 joda Exp $");
+RCSID("$Id: string2key.c 19213 2006-12-04 23:36:36Z lha $");
int version5;
int version4;
@@ -70,21 +70,28 @@ usage(int status)
static void
tokey(krb5_context context,
krb5_enctype enctype,
- const char *password,
+ const char *pw,
krb5_salt salt,
const char *label)
{
+ krb5_error_code ret;
int i;
krb5_keyblock key;
char *e;
- krb5_string_to_key_salt(context, enctype, password, salt, &key);
- krb5_enctype_to_string(context, enctype, &e);
+
+ ret = krb5_string_to_key_salt(context, enctype, pw, salt, &key);
+ if (ret)
+ krb5_err(context, 1, ret, "krb5_string_to_key_salt");
+ ret = krb5_enctype_to_string(context, enctype, &e);
+ if (ret)
+ krb5_err(context, 1, ret, "krb5_enctype_to_string");
printf(label, e);
printf(": ");
for(i = 0; i < key.keyvalue.length; i++)
printf("%02x", ((unsigned char*)key.keyvalue.data)[i]);
printf("\n");
krb5_free_keyblock_contents(context, &key);
+ free(e);
}
int
@@ -93,12 +100,12 @@ main(int argc, char **argv)
krb5_context context;
krb5_principal princ;
krb5_salt salt;
- int optind;
+ int optidx;
char buf[1024];
krb5_enctype etype;
krb5_error_code ret;
- optind = krb5_program_setup(&context, argc, argv, args, num_args, NULL);
+ optidx = krb5_program_setup(&context, argc, argv, args, num_args, NULL);
if(help)
usage(0);
@@ -108,8 +115,8 @@ main(int argc, char **argv)
return 0;
}
- argc -= optind;
- argv += optind;
+ argc -= optidx;
+ argv += optidx;
if (argc > 1)
usage(1);
@@ -122,6 +129,7 @@ main(int argc, char **argv)
krb5_keytype keytype;
int *etypes;
unsigned num;
+ char *str;
ret = krb5_string_to_keytype(context, keytype_str, &keytype);
if(ret)
krb5_err(context, 1, ret, "%s", keytype_str);
@@ -131,7 +139,8 @@ main(int argc, char **argv)
if(num == 0)
krb5_errx(context, 1, "there are no encryption types for that keytype");
etype = etypes[0];
- krb5_enctype_to_string(context, etype, &keytype_str);
+ krb5_enctype_to_string(context, etype, &str);
+ keytype_str = str;
if(num > 1 && version5)
krb5_warnx(context, "ambiguous keytype, using %s", keytype_str);
}
@@ -152,22 +161,20 @@ main(int argc, char **argv)
printf("Kerberos v5 principal: ");
if(fgets(buf, sizeof(buf), stdin) == NULL)
return 1;
- if(buf[strlen(buf) - 1] == '\n')
- buf[strlen(buf) - 1] = '\0';
+ buf[strcspn(buf, "\r\n")] = '\0';
principal = estrdup(buf);
}
if(afs && cell == NULL){
printf("AFS cell: ");
if(fgets(buf, sizeof(buf), stdin) == NULL)
return 1;
- if(buf[strlen(buf) - 1] == '\n')
- buf[strlen(buf) - 1] = '\0';
+ buf[strcspn(buf, "\r\n")] = '\0';
cell = estrdup(buf);
}
if(argv[0])
password = argv[0];
if(password == NULL){
- if(des_read_pw_string(buf, sizeof(buf), "Password: ", 0))
+ if(UI_UTIL_read_pw_string(buf, sizeof(buf), "Password: ", 0))
return 1;
password = buf;
}