enctype (16 bits)
key length (32 bits)
key contents
+ key version (32 bits) [in release 1.14 and later]
principal ::=
count of components (32 bits) [includes realm in version 1]
length (16 bits)
value (length bytes)
-Some implementations of Kerberos recognize a 32-bit key version at the
-end of an entry, if the record length is at least 4 bytes longer than
-the entry and the value of those 32 bits is not 0. If present, this
-key version supersedes the 8-bit key version. MIT krb5 does not yet
-implement this extension.
+The 32-bit key version overrides the 8-bit key version. To determine
+if it is present, the implementation must check that at least 4 bytes
+remain in the record after the other fields are read, and that the
+value of the 32-bit integer contained in those bytes is non-zero.
krb5_int16 princ_size;
register int i;
krb5_int32 size;
- krb5_int32 start_pos;
+ krb5_int32 start_pos, pos;
krb5_error_code error;
char *tmpdata;
krb5_data *princ;
+ uint32_t vno32;
KTCHECKLOCK(id);
memset(ret_entry, 0, sizeof(krb5_keytab_entry));
goto fail;
}
+ /* Check for a 32-bit kvno extension if four or more bytes remain. */
+ pos = ftell(KTFILEP(id));
+ if (pos - start_pos + 4 <= size) {
+ if (!fread(&vno32, sizeof(vno32), 1, KTFILEP(id))) {
+ error = KRB5_KT_END;
+ goto fail;
+ }
+ if (KTVERSION(id) != KRB5_KT_VNO_1)
+ vno32 = ntohl(vno32);
+ /* If the value is 0, the bytes are just zero-fill. */
+ if (vno32)
+ ret_entry->vno = vno32;
+ }
+
/*
* Reposition file pointer to the next inter-record length field.
*/
krb5_int32 princ_type;
krb5_int32 size_needed;
krb5_int32 commit_point = -1;
+ uint32_t vno32;
int i;
KTCHECKLOCK(id);
goto abend;
}
+ /* 32-bit key version number */
+ vno32 = entry->vno;
+ if (KTVERSION(id) != KRB5_KT_VNO_1)
+ vno32 = htonl(vno32);
+ if (!fwrite(&vno32, sizeof(vno32), 1, KTFILEP(id)))
+ goto abend;
+
if (fflush(KTFILEP(id)))
goto abend;
total_size += sizeof(krb5_octet);
total_size += sizeof(krb5_int16);
total_size += sizeof(krb5_int16) + entry->key.length;
+ total_size += sizeof(uint32_t);
*size_needed = total_size;
return retval;