Subject: [Cellar] clarity for the EBML CRC Element

From: Dave Rice <[email-masked]>
Date: Tue, 29 Dec 2015 19:10:15 -0500

The EBML CRC Element has many contradictory definitions.

Version 1: The Matroska draft states:

"The CRC is computed on all the data of the Master element it's in. The CRC element should be the first in it's parent master for easier reading. All level 1 elements should include a CRC-32. The CRC in use is the IEEE CRC32 Little Endian"

Version 2: An older Matroska draft at http://matroska.org/technical/specs/rfc/index.html states:

"The CRC32 container can be placed around any EBML element or elements. The value stored in CRC32Value is the result of the CRC-32 [CRC32] checksum performed on the other child elements.
     CRC32 := c3 container [ level:1..; card:*; ] {
       %children;
       CRC32Value := 42fe binary [ size:4; ]
     }”

Version 3: The EBML draft states:

"The CRC is computed on all the data from the last CRC element (or start of the upper level element), up to the CRC element, including other previous CRC elements. All level 1 elements SHOULD include a CRC-32."

Issue with Version 1:
Usually the Matroska version is considered authoritative since that documentation was the most maintained; however, in this case the Matroska definition doesn’t make sense as it implies that the CRC Element is documenting a CRC value of data that includes the CRC Element itself.

Issue with Version 2:
This definition refers the CRC Element as a Master-element (aka “container”) with a sub-element (called “CRC32Value" 0x42FE) that contains the hash. AFAIK there has never been such an implementation. Additionally this draft does not have an open license.

Issues with Version 3:

I think there is a typo and that: "All level 1 elements SHOULD include a CRC-32” should be "All level 1 Master-elements SHOULD include a child CRC Element.”
The procedure for using multiple CRC Elements within a single Master-element seems very inefficient with each subsequent CRC representing the data of all prior CRC Elements within the same Parent Element. This is like a rolling checksum although I’m not sure that is what was intended.
Also the definition implies that the CRC element can occur multiple times within the parent element while the definition in both EBML and Matroska clarifies that CRC is not a ‘multiple' element.

So, can we clarify the following:

- The CRC Element may only occur 0 or 1 times as a child element of a Master-Element.
- That the CRC Element is a binary element and not a Master-element
- There is no definition for a CRC32Value element
- Is there a placement requirement or suggestion for the use of the CRC element within a parent (i.e. "should be the first in it's parent master”)
- What data exactly does the CRC value represent?
	All Element Data of the parent element (unfeasible)?
	The entire Parent Element (including the parent’s Element ID, Element Data Size, and Element Data) (also unfeasible)?
	All Element Data of the parent element excepting the child CRC element?
	The entire Parent Element (including the parent’s Element ID, Element Data Size, and Element Data) excepting the child CRC element?
	All data from the beginning of the Master-element up to the beginning of the CRC Element?
	All data from the beginning of the Master-element’s Element Data up to the beginning of the CRC Element?

I understand these clarifications have an impact on the validity of existing EBML implementations, but I’ve rarely seen any implementation of the EBML CRC element (better documentation may encourage such implementations ;)

Dave Rice