Saved data not always looked up in correct locations
The Issues
Here Iʼm writing about the VID and MK, because thatʼs what Iʼve checked, but the issue may also appear with other data.
This information is not always looked up when it should be. In particular, the aacs_get_vid
and aacs_get_mk
functions both check the AACS cache, but do not check the KEYDB config file. Based on the comments it looks like the code assumes that was already checked, but that doesnʼt always happen. This can be a problem when, for example, libbdplus wants to get the VID, which is not found despite being in KEYDB.
Additionally, when calculating the VUK, the cache directory is not checked for the VID, only the KEYDB config file. This is because _read_vid
, unlike _calc_mk
, does not use the cache.
To reproduce
For both issues, to avoid code paths that try to get information from the drive, operate on an image of a disc with known VID and MK.
For the first issue:
- Do not have any data for the disc in the AACS key cache
- Do have a line with the VID and MK, but not VUK, in KEYDB.cfg
- Run
aacs_info
on the disc image.- Expected and actual result: it displays VID and MK
- Note that this puts the VUK in the AACS key cache, and the need to calculate the VUK is the only reason the VID was displayed
- Run
aacs_info
on the disc image again- Expected result: output matches that in step 3
- Actual result: MK is displayed but VID is reported as ???
- (optional) If the disc uses BD+, and you otherwise have that set up correctly, run
bd_info
from libbluray on the disc image- Expected result: It reports “BD+ handled: yes”
- Actual result: It reports “BD+ handled: no” and the debug log says it could not find the VID
- Note: I barely know anything about BD+ and this might be misleading, but when I put the data in
~/.cache/aacs/vid
, it says yes instead.
For the second issue:
- Do not have an entry for the disc in KEYDB.cfg
- Put the VID and MK in AACS key cache, but not the VUK
- Run
bd_info
from libbluray on the disc image.- Expected result: it says “AACS handled: yes”, and the VUK is added to the cache
- Actual result: it says “AACS handled: no”, and debug log says it did not find the VID
Proposed fix
- For the first issue, Iʼm not sure, and thatʼs the primary reason Iʼm filing an issue instead of a merge request. The obvious-to-me solution is to have
_read_vid
and_calc_vuk
look here, either by calling_find_config_entry
or by having a similar loop, but I think I might be missing tradeoffs and that is actually a bad solution. - For the second issue, move the VID call to
keycache_find
fromaacs_get_vid
to_read_vid
, to mirroraacs_get_mk
and_calc_mk
.
Further notes
I think there are more issues here, but I have not tested them. For example, it looks like if the MK is in the AACS cache and there is no keydb config file, it will not be found. I think my proposed fix for the second issue also causes this.