Add support for loading CCache Version 3 #1106
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Recently ran into an environment that was using version 3 ccache. The ccache parser was originally written to only support version 4, which has some minor yet important differences. This PR adds support for V3 while taking care to not modify anything that will break existing implementations.
V3 ccaches will essentially be converted into V4 after being loaded. This only addresses the parsing of V3s, it does not add the capability to generate V3s.
The updates made are based off the ccache file format at:
https://web.mit.edu/kerberos/krb5-devel/doc/formats/ccache_file_format.html
Quick overview of the changes:
The ccache version is determined by the 2nd byte of data:
ccache_version = data[1]
Ccache V3 does not contain a meta header, so that's skipped over in the ccache init:
Due to differences in their keyblocks, two new CredentialHeader classes were made:
CredentialHeaderV4
: The oldCredentialHeader
, with KeyBlock updated to KeyBlockV4CredentialHeaderV3
: The oldCredentialHeader
, with KeyBlock updated to KeyBlockV3Two new KeyBlock classes were made:
KeyBlockV4
: The old KeyBlock, no changesKeyBlockV3
: A V3 KeyBlock where the encryption type field is repeated twice (for some reason).