Skip to content

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:

  1. Do not have any data for the disc in the AACS key cache
  2. Do have a line with the VID and MK, but not VUK, in KEYDB.cfg
  3. 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
  4. 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 ???
  5. (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:

  1. Do not have an entry for the disc in KEYDB.cfg
  2. Put the VID and MK in AACS key cache, but not the VUK
  3. 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 from aacs_get_vid to _read_vid, to mirror aacs_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.