+Mon Aug 7 17:40:10 EDT 1995 Paul Park (pjpark@mit.edu)
+ * encrypt_key.c - Handle keysalt specification with null data length.
+ * decrypt_key.c - Handle salttypes with zero salt length. Also, copy
+ out stored salt.
+
+
Mon Aug 7 14:15:59 EDT 1995 Paul Park (pjpark@mit.edu)
* decrypt_key.c - Deserialize key length into a 16 bit integer, then
jam it into the keyblock.
if (keysalt) {
if (key_data->key_data_ver == 2) {
keysalt->type = key_data->key_data_type[1];
- keysalt->data.length = key_data->key_data_length[1];
- if (!(keysalt->data.data = (char *)malloc(keysalt->data.length))){
- krb5_xfree(keyblock->contents);
- return ENOMEM;
+ if (keysalt->data.length = key_data->key_data_length[1]) {
+ if (!(keysalt->data.data =
+ (char *)malloc(keysalt->data.length))){
+ krb5_xfree(keyblock->contents);
+ return ENOMEM;
+ }
+ memcpy(keysalt->data.data, key_data->key_data_contents[1],
+ (size_t) keysalt->data.length);
}
+ else
+ keysalt->data.data = (char *) NULL;
} else {
keysalt->type = KRB5_KDB_SALTTYPE_NORMAL;
keysalt->data.length = 0;
/* After key comes the salt in necessary */
if (keysalt) {
- key_data->key_data_contents[1] =
- (krb5_octet *)malloc(keysalt->data.length);
- if (key_data->key_data_contents[1] == NULL) {
- krb5_xfree(key_data->key_data_contents[0]);
- return ENOMEM;
- }
- memcpy(key_data->key_data_contents[1],
- keysalt->data.data,
- (size_t) keysalt->data.length);
- key_data->key_data_length[1] = keysalt->data.length;
key_data->key_data_type[1] = keysalt->type;
- key_data->key_data_ver++;
+ if (key_data->key_data_type[1] >= 0) {
+ key_data->key_data_ver++;
+ key_data->key_data_length[1] = keysalt->data.length;
+ if (keysalt && keysalt->data.length) {
+ key_data->key_data_contents[1] =
+ (krb5_octet *)malloc(keysalt->data.length);
+ if (key_data->key_data_contents[1] == NULL) {
+ krb5_xfree(key_data->key_data_contents[0]);
+ return ENOMEM;
+ }
+ memcpy(key_data->key_data_contents[1],
+ keysalt->data.data,
+ (size_t) keysalt->data.length);
+ }
+ }
}
return retval;
}