What is LibreDrive?

Discussion of LibreDrive mode, compatible drives and firmwares
Locked
mike admin
Posts: 3591
Joined: Wed Nov 26, 2008 2:26 am
Contact:

What is LibreDrive?

Post by mike admin » Sat Feb 02, 2019 1:19 pm

A LibreDrive is a mode of operation of an optical disc drive (DVD, Blu-ray or UHD) when the data on the disc are accessed directly, without any restrictions or transformations enforced by drive firmware. A LibreDrive would never refuse to read the data from the disc or declare itself “revoked”. LibreDrive compatible drive is required to read UHD discs.

Please read below the overview of LibreDrive architecture.

What is an optical disc drive? It is a device that scans the surface of a disc with a laser and passes this information to a controlling software on a PC. Back in time when CD was invented, the optical drive was just that - device that scanned disc surface and passed this data to PC. Many data formats were invented at the time (sector mode 2, p/q channels, sub-channel-data,etc), but in the end it was all about positioning the laser pickup head, scanning the disc, and handling these data over for processing.

Things changed for DVD, with the CSS protection scheme. The disc was divided into two areas - one area could be read as usual. However in order to read the data from another area of the disc, the software had to know a certain secret key. This was part of so-called CSS protection and was used both for rights management and to enforce disc region price fixing. A drive locked for Europe would not allow reading the data from the disc that was locked for South East Asia, where exactly same disc could be bought at a cheaper price. This data partitioning was further “enhanced” for blu-ray. In the end, any regular optical disc drive has a complex set of rules that dictate what areas of the disc can be accessed on on what conditions.

The drive itself can easily read all the data technically. It is the drive embedded software (firmware) that “plays police” - decides what area of the disc can be accessed and on what conditions.

So, how can one read the data from any area on the disc? The data on the optical disc is encoded as a series of small cavities called pits, that are organized in a spiral called a track. Had we had a sharp enough eye, we could've seen them directly. One way is to use a microscope - with a microscope one can clearly see the pits, apply standard (publicly defined) decoding algorithm and get the raw data from the disc. Obviously, this is a rather time consuming and expensive method. There is however a third way - take the drive back to the basic level. Change the optical drive embedded software in a way that the drive becomes a “primitive” device - one that just positions a laser, reads and decodes the data. Make a drive free from “policing” functionality, a drive that just passes all data from the disc to the user. We call this drive a LibreDrive.

mike admin
Posts: 3591
Joined: Wed Nov 26, 2008 2:26 am
Contact:

What happens in LibreDrive mode

Post by mike admin » Sat Feb 02, 2019 1:22 pm

When MakeMKV (or any other application that uses LibDriveIo library) talks to the drive, the library checks if drive firmware version is supported. If it is supported, the library uploads a small software (a firmware extension) into drive volatile memory. This extension exposes a new (alternative) interface to read any data from the disc. The firmware extension stays only in drive volatile memory (RAM) and drive firmware is not changed in any way. The moment you turn off your drive, it is gone without a trace. As long as your drive firmware is compatible with LibreDrive, and you do not update your drive firmware, the LibreDrive mode will work forever.

mike admin
Posts: 3591
Joined: Wed Nov 26, 2008 2:26 am
Contact:

LibreDrive and AACS

Post by mike admin » Sat Feb 02, 2019 2:03 pm

One famous “feature” of AACS is a so-called host revocation. It was designed to ensure that only “approved” software can use your drive. Every Blu-ray disc contains a file that has a list of host keys known to be used by "unauthorized" software. This list has a version number. The moment you insert the disc into your drive, the drive checks if the list is newer than the one it knows about, and if it is, the drive re-flashes itself (updates firmware). With LibreDrive mode your drive just became immune to this nonsense.

In LibreDrive mode you always would be able to use this drive with MakeMKV or any other software that uses (open source) LibDriveIo library. No AACS revocation or other update would affect usability of your drive in LibreDrive mode.

Please note that LibreDrive mode is not about hacking or meddling with AACS code. In LibreDrive mode the updated software communicates to the drive hardware directly, not touching or hacking AACS DRM code in any way at all. So your drive will continue to self-revoke on MKB updates and require authentication before releasing key material to the "authorized" software - it is just with LibreDrive mode all of it is no longer relevant.

mike admin
Posts: 3591
Joined: Wed Nov 26, 2008 2:26 am
Contact:

LibreDrive library and SDF.bin

Post by mike admin » Tue Mar 19, 2019 12:36 pm

LibreDrive functionality is implemented as part of open-source LibDriveIO library (at the time of this writing the library source code is not yet released). One of the main design goals of LibreDrive runtime is portability and stability of the code base. For this reason, the LibreDrive logic is data-driven. The library itself is just a simple interpreter, while all low-level logic for a particular drive is defined by a firmware-specific data blob (called SDF). This data blob defines how to perform a certain action (like reading a disc structure) by translating requested action (called Entrypoint) and its parameters into a set of firmware-specific SCSI commands.

The master data file that contains firmware-specific blobs for all known firmware versions is called SDF.bin . This file contains SDF blobs for each particular firmware and a master SDF blob that exports an API (yet another Entrypoint) to uniquely fingerprint a drive firmware version. This fingerprint data (called Firmware hash) is then used by the library to select an appropriate SDF blob for particular firmware.

This design ensures that the library itself would change very rarely, if at all. Adding support for a new drive model or firmware version doesn't require any changes to the library code – instead only update of SDF.bin file is required. Even adding a new major functionality, like flashing or dumping a firmware, doesn’t require library change – the host application just need to call updated API and SDF blob has to define a new Entrypoint.

With this approach it is possible to create a set of universal tools that are not tied to a specific drive platform, model or firmware version. A universal disc access library is already part of MakeMKV, and an universal firmware flashing tool is coming soon and will be released under open-source license as well.

Locked