summaryrefslogtreecommitdiffstats
path: root/src/lib/kdb
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2011-09-22 18:09:45 +0000
committerGreg Hudson <ghudson@mit.edu>2011-09-22 18:09:45 +0000
commit260161b4fe2a05b9afa95446eee9096f6c75ceaf (patch)
tree5c3d49029ed4d6460e4da3e20f14868e524ebbc7 /src/lib/kdb
parent1be77ec64675cacc3acaf8a75e5eb2339c86af24 (diff)
downloadkrb5-260161b4fe2a05b9afa95446eee9096f6c75ceaf.tar.gz
krb5-260161b4fe2a05b9afa95446eee9096f6c75ceaf.tar.xz
krb5-260161b4fe2a05b9afa95446eee9096f6c75ceaf.zip
Support special salt type in default krb5_dbe_cpw
This change allows the "special" salt type to be used in supported_enctypes or in the argument to kadmin's cpw -e. If used, kadmind will pick a salt consisting of 64 random bits represented as 16 printable ASCII characters. The use of random explicit salts creates some interoperability issues and is not generally recommended, but can be useful for interop testing, as a workaround for obscure bugs, or to increase the difficulty of brute-force password searches in situations where none of the interoperability issues apply. ticket: 6964 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25226 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/kdb')
-rw-r--r--src/lib/kdb/kdb_cpw.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/lib/kdb/kdb_cpw.c b/src/lib/kdb/kdb_cpw.c
index 88811e71b1..abaae4f7c4 100644
--- a/src/lib/kdb/kdb_cpw.c
+++ b/src/lib/kdb/kdb_cpw.c
@@ -339,6 +339,37 @@ krb5_dbe_ark(context, master_key, ks_tuple, ks_tuple_count, db_entry)
return(retval);
}
+/* Construct a random explicit salt. */
+static krb5_error_code
+make_random_salt(krb5_context context, krb5_keysalt *salt_out)
+{
+ krb5_error_code retval;
+ unsigned char rndbuf[8];
+ krb5_data salt, rnd = make_data(rndbuf, sizeof(rndbuf));
+ unsigned int i;
+
+ /*
+ * Salts are limited by RFC 4120 to 7-bit ASCII. For ease of examination
+ * and to avoid certain folding issues for older enctypes, we use printable
+ * characters with four fixed bits and four random bits, encoding 64
+ * psuedo-random bits into 16 bytes.
+ */
+ retval = krb5_c_random_make_octets(context, &rnd);
+ if (retval)
+ return retval;
+ retval = alloc_data(&salt, sizeof(rndbuf) * 2);
+ if (retval)
+ return retval;
+ for (i = 0; i < sizeof(rndbuf); i++) {
+ salt.data[i * 2] = 0x40 | (rndbuf[i] >> 4);
+ salt.data[i * 2 + 1] = 0x40 | (rndbuf[i] & 0xf);
+ }
+
+ salt_out->type = KRB5_KDB_SALTTYPE_SPECIAL;
+ salt_out->data = salt;
+ return 0;
+}
+
/*
* Add key_data for a krb5_db_entry
* If passwd is NULL the assumes that the caller wants a random password.
@@ -431,6 +462,11 @@ add_key_pwd(context, master_key, ks_tuple, ks_tuple_count, passwd,
return retval;
key_salt.data.length = SALT_TYPE_AFS_LENGTH; /*length actually used below...*/
break;
+ case KRB5_KDB_SALTTYPE_SPECIAL:
+ retval = make_random_salt(context, &key_salt);
+ if (retval)
+ return retval;
+ break;
default:
return(KRB5_KDB_BAD_SALTTYPE);
}