add option -H --hex to the add command

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14793 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2005-04-14 16:45:14 +00:00
parent cc37425e3e
commit 239d06f465
2 changed files with 29 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997-2004 Kungliga Tekniska H<>gskolan
* Copyright (c) 1997-2005 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -101,7 +101,28 @@ kt_add(struct add_options *opt, int argc, char **argv)
opt->password_string = buf;
}
if(opt->password_string) {
if (!opt->salt_flag) {
if (opt->hex_flag) {
size_t len;
void *data;
len = (strlen(opt->password_string) + 1) / 2;
data = malloc(len);
if (data == NULL) {
krb5_warn(context, ENOMEM, "malloc");
goto out;
}
if (hex_decode(opt->password_string, data, len) != len) {
free(data);
krb5_warn(context, ENOMEM, "hex decode failed");
goto out;
}
ret = krb5_keyblock_init(context, enctype,
data, len, &entry.keyblock);
free(data);
} else if (!opt->salt_flag) {
krb5_salt salt;
krb5_data pw;

View File

@@ -75,6 +75,12 @@ command = {
type = "flag"
help = "generate random key"
}
option = {
long = "hex"
short = "H"
type = "flag"
help = "password is a hexadecimal string"
}
function = "kt_add"
help = "Adds a key to a keytab."
max_args = "0"