idnits 2.17.1 draft-ietf-cellar-ebml-10.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (May 27, 2019) is 1795 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '1' on line 2065 == Missing Reference: 'EBMLParentPath' is mentioned on line 874, but not defined == Missing Reference: 'EBMLMinOccurrence' is mentioned on line 885, but not defined == Missing Reference: 'EBMLMaxOccurrence' is mentioned on line 885, but not defined == Missing Reference: 'PathMinOccurrence' is mentioned on line 888, but not defined == Missing Reference: 'PathMaxOccurrence' is mentioned on line 888, but not defined -- Possible downref: Non-RFC (?) normative reference: ref. 'IEEE.754.1985' -- Possible downref: Non-RFC (?) normative reference: ref. 'ITU.V42.1994' Summary: 0 errors (**), 0 flaws (~~), 6 warnings (==), 4 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 cellar S. Lhomme 3 Internet-Draft 4 Intended status: Standards Track D. Rice 5 Expires: November 28, 2019 6 M. Bunkus 7 May 27, 2019 9 Extensible Binary Meta Language 10 draft-ietf-cellar-ebml-10 12 Abstract 14 This document defines the Extensible Binary Meta Language (EBML) 15 format as a generalized file format for any type of data in a 16 hierarchical form. EBML is designed as a binary equivalent to XML 17 and uses a storage-efficient approach to build nested Elements with 18 identifiers, lengths, and values. Similar to how an XML Schema 19 defines the structure and semantics of an XML Document, this document 20 defines how EBML Schemas are created to convey the semantics of an 21 EBML Document. 23 Status of This Memo 25 This Internet-Draft is submitted in full conformance with the 26 provisions of BCP 78 and BCP 79. 28 Internet-Drafts are working documents of the Internet Engineering 29 Task Force (IETF). Note that other groups may also distribute 30 working documents as Internet-Drafts. The list of current Internet- 31 Drafts is at https://datatracker.ietf.org/drafts/current/. 33 Internet-Drafts are draft documents valid for a maximum of six months 34 and may be updated, replaced, or obsoleted by other documents at any 35 time. It is inappropriate to use Internet-Drafts as reference 36 material or to cite them other than as "work in progress." 38 This Internet-Draft will expire on November 28, 2019. 40 Copyright Notice 42 Copyright (c) 2019 IETF Trust and the persons identified as the 43 document authors. All rights reserved. 45 This document is subject to BCP 78 and the IETF Trust's Legal 46 Provisions Relating to IETF Documents 47 (https://trustee.ietf.org/license-info) in effect on the date of 48 publication of this document. Please review these documents 49 carefully, as they describe your rights and restrictions with respect 50 to this document. Code Components extracted from this document must 51 include Simplified BSD License text as described in Section 4.e of 52 the Trust Legal Provisions and are provided without warranty as 53 described in the Simplified BSD License. 55 Table of Contents 57 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 58 2. Notation and Conventions . . . . . . . . . . . . . . . . . . 4 59 3. Structure . . . . . . . . . . . . . . . . . . . . . . . . . . 6 60 4. Variable Size Integer . . . . . . . . . . . . . . . . . . . . 7 61 4.1. VINT_WIDTH . . . . . . . . . . . . . . . . . . . . . . . 7 62 4.2. VINT_MARKER . . . . . . . . . . . . . . . . . . . . . . . 7 63 4.3. VINT_DATA . . . . . . . . . . . . . . . . . . . . . . . . 7 64 4.4. VINT Examples . . . . . . . . . . . . . . . . . . . . . . 8 65 5. Element ID . . . . . . . . . . . . . . . . . . . . . . . . . 9 66 6. Element Data Size . . . . . . . . . . . . . . . . . . . . . . 10 67 7. EBML Element Types . . . . . . . . . . . . . . . . . . . . . 12 68 7.1. Signed Integer Element . . . . . . . . . . . . . . . . . 12 69 7.2. Unsigned Integer Element . . . . . . . . . . . . . . . . 13 70 7.3. Float Element . . . . . . . . . . . . . . . . . . . . . . 13 71 7.4. String Element . . . . . . . . . . . . . . . . . . . . . 13 72 7.5. UTF-8 Element . . . . . . . . . . . . . . . . . . . . . . 13 73 7.6. Date Element . . . . . . . . . . . . . . . . . . . . . . 13 74 7.7. Master Element . . . . . . . . . . . . . . . . . . . . . 14 75 7.8. Binary Element . . . . . . . . . . . . . . . . . . . . . 14 76 8. EBML Document . . . . . . . . . . . . . . . . . . . . . . . . 14 77 8.1. EBML Header . . . . . . . . . . . . . . . . . . . . . . . 15 78 8.2. EBML Body . . . . . . . . . . . . . . . . . . . . . . . . 15 79 9. EBML Stream . . . . . . . . . . . . . . . . . . . . . . . . . 15 80 10. EBML Versioning . . . . . . . . . . . . . . . . . . . . . . . 15 81 10.1. EBML Header Version . . . . . . . . . . . . . . . . . . 16 82 10.2. EBML Document Version . . . . . . . . . . . . . . . . . 16 83 11. Elements semantic . . . . . . . . . . . . . . . . . . . . . . 16 84 11.1. EBML Schema . . . . . . . . . . . . . . . . . . . . . . 16 85 11.1.1. EBML Schema Example . . . . . . . . . . . . . . . . 17 86 11.1.2. Element . . . . . . . . . . . . . . . . 18 87 11.1.3. Attributes . . . . . . . . . . . . . . 18 88 11.1.4. Element . . . . . . . . . . . . . . . . . 18 89 11.1.5. Attributes . . . . . . . . . . . . . . . . 19 90 11.1.6. Element . . . . . . . . . . . . . . 24 91 11.1.7. Attributes . . . . . . . . . . . . . 24 92 11.1.8. Element . . . . . . . . . . . . . . . 25 93 11.1.9. Element . . . . . . . . . . . . . . . . . . . 25 94 11.1.10. Attributes . . . . . . . . . . . . . . . . . 25 95 11.1.11. XML Schema for EBML Schema . . . . . . . . . . . . . 26 96 11.1.12. Identically Recurring Elements . . . . . . . . . . . 27 97 11.1.13. Textual expression of floats . . . . . . . . . . . . 28 98 11.1.14. Note on the use of default attributes to define 99 Mandatory EBML Elements . . . . . . . . . . . . . . 28 100 11.2. EBML Header Elements . . . . . . . . . . . . . . . . . . 29 101 11.2.1. EBML Element . . . . . . . . . . . . . . . . . . . . 29 102 11.2.2. EBMLVersion Element . . . . . . . . . . . . . . . . 29 103 11.2.3. EBMLReadVersion Element . . . . . . . . . . . . . . 30 104 11.2.4. EBMLMaxIDLength Element . . . . . . . . . . . . . . 30 105 11.2.5. EBMLMaxSizeLength Element . . . . . . . . . . . . . 31 106 11.2.6. DocType Element . . . . . . . . . . . . . . . . . . 31 107 11.2.7. DocTypeVersion Element . . . . . . . . . . . . . . . 32 108 11.2.8. DocTypeReadVersion Element . . . . . . . . . . . . . 32 109 11.2.9. DocTypeExtension Element . . . . . . . . . . . . . . 33 110 11.2.10. DocTypeExtensionName Element . . . . . . . . . . . . 33 111 11.2.11. DocTypeExtensionVersion Element . . . . . . . . . . 34 112 11.3. Global Elements . . . . . . . . . . . . . . . . . . . . 34 113 11.3.1. CRC-32 Element . . . . . . . . . . . . . . . . . . . 34 114 11.3.2. Void Element . . . . . . . . . . . . . . . . . . . . 35 115 12. Considerations for Reading EBML Data . . . . . . . . . . . . 35 116 13. Terminating Elements . . . . . . . . . . . . . . . . . . . . 36 117 14. Guidelines for Updating Elements . . . . . . . . . . . . . . 36 118 14.1. Reducing a Element Data in Size . . . . . . . . . . . . 36 119 14.1.1. Adding a Void Element . . . . . . . . . . . . . . . 36 120 14.1.2. Extending the Element Data Size . . . . . . . . . . 37 121 14.1.3. Terminating Element Data . . . . . . . . . . . . . . 38 122 14.2. Considerations when Updating Elements with Cyclic 123 Redundancy Check (CRC) . . . . . . . . . . . . . . . . . 38 124 15. Backward and Forward Compatibility . . . . . . . . . . . . . 38 125 15.1. Backward Compatibility . . . . . . . . . . . . . . . . . 38 126 15.2. Forward Compatibility . . . . . . . . . . . . . . . . . 39 127 16. Security Considerations . . . . . . . . . . . . . . . . . . . 39 128 17. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 41 129 17.1. CELLAR EBML Element ID Registry . . . . . . . . . . . . 41 130 17.2. CELLAR EBML DocType Registry . . . . . . . . . . . . . . 43 131 18. References . . . . . . . . . . . . . . . . . . . . . . . . . 43 132 18.1. Normative References . . . . . . . . . . . . . . . . . . 43 133 18.2. Informative References . . . . . . . . . . . . . . . . . 44 134 18.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 45 135 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 45 137 1. Introduction 139 EBML, short for Extensible Binary Meta Language, specifies a binary 140 and octet (byte) aligned format inspired by the principle of XML (a 141 framework for structuring data). 143 The goal of this document is to define a generic, binary, space- 144 efficient format that can be used to define more complex formats 145 using an EBML Schema. EBML is used by the multimedia container 146 Matroska [1]. The applicability of EBML for other use cases is 147 beyond the scope of this document. 149 The definition of the EBML format recognizes the idea behind HTML and 150 XML as a good one: separate structure and semantics allowing the same 151 structural layer to be used with multiple, possibly widely differing 152 semantic layers. Except for the EBML Header and a few Global 153 Elements this specification does not define particular EBML format 154 semantics; however this specification is intended to define how other 155 EBML-based formats can be defined, such as the audio-video container 156 formats Matroska and WebM. 158 EBML uses a simple approach of building Elements upon three pieces of 159 data (tag, length, and value) as this approach is well known, easy to 160 parse, and allows selective data parsing. The EBML structure 161 additionally allows for hierarchical arrangement to support complex 162 structural formats in an efficient manner. 164 A typical EBML file has the following structure: 166 EBML Header (master) 167 + DocType (string) 168 + DocTypeVersion (unsigned integer) 169 EBML Body Root (master) 170 + ElementA (utf-8) 171 + Parent (master) 172 + ElementB (integer) 173 + Parent (master) 174 + ElementB (integer) 176 2. Notation and Conventions 178 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 179 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 180 "OPTIONAL" in this document are to be interpreted as described in BCP 181 14 [RFC2119] [RFC8174] when, and only when, they appear in all 182 capitals, as shown here. 184 This document defines specific terms in order to define the format 185 and application of "EBML". Specific terms are defined below: 187 "EBML": Extensible Binary Meta Language 189 "EBML Document Type": A name provided by an "EBML Schema" to 190 designate a particular implementation of "EBML" for a data format 191 (e.g.: matroska and webm). 193 "EBML Schema": A standardized definition for the structure of an 194 "EBML Document Type". 196 "EBML Document": A datastream comprised of only two components, an 197 "EBML Header" and an "EBML Body". 199 "EBML Reader": A data parser that interprets the semantics of an 200 "EBML Document" and creates a way for programs to use "EBML". 202 "EBML Stream": A file that consists of one or more "EBML Documents" 203 that are concatenated together. 205 "EBML Header": A declaration that provides processing instructions 206 and identification of the "EBML Body". The "EBML Header" is 207 analogous to an XML Declaration [W3C.REC-xml-20081126] (see section 208 2.8 on Prolog and Document Type Declaration). 210 "EBML Body": All data of an "EBML Document" following the "EBML 211 Header". 213 "Variable Size Integer": A compact variable-length binary value which 214 defines its own length. 216 "VINT": Also known as "Variable Size Integer". 218 "EBML Element": A foundation block of data that contains three parts: 219 an "Element ID", an "Element Data Size", and "Element Data". 221 "Element ID": The "Element ID" is a binary value, encoded as a 222 "Variable Size Integer", used to uniquely identify a defined "EBML 223 Element" within a specific "EBML Schema". 225 "EBML Class": A representation of the octet length of an "Element 226 ID". 228 "Element Data Size": An expression, encoded as a "Variable Size 229 Integer", of the length in octets of "Element Data". 231 "VINTMAX": The maximum possible value that can be stored as "Element 232 Data Size". 234 "Unknown-Sized Element": An "Element" with an unknown "Element Data 235 Size". 237 "Element Data": The value(s) of the "EBML Element" which is 238 identified by its "Element ID" and "Element Data Size". The form of 239 the "Element Data" is defined by this document and the corresponding 240 "EBML Schema" of the Element's "EBML Document Type". 242 "Root Level": The starting level in the hierarchy of an "EBML 243 Document". 245 "Root Element": A mandatory, non-repeating "EBML Element" which 246 occurs at the top level of the path hierarchy within an "EBML Body" 247 and contains all other "EBML Elements" of the "EBML Body", excepting 248 optional "Void Elements". 250 "Top-Level Element": An "EBML Element" defined to only occur as a 251 "Child Element" of the "Root Element". 253 "Master Element": The "Master Element" contains zero, one, or many 254 other "EBML Elements". 256 "Child Element": A "Child Element" is a relative term to describe the 257 "EBML Elements" immediately contained within a "Master Element". 259 "Parent Element": A relative term to describe the "Master Element" 260 which contains a specified element. For any specified "EBML Element" 261 that is not at "Root Level", the "Parent Element" refers to the 262 "Master Element" in which that "EBML Element" is contained. 264 "Descendant Element": A relative term to describe any "EBML Elements" 265 contained within a "Master Element", including any of the "Child 266 Elements" of its "Child Elements", and so on. 268 "Void Element": A "Void Element" is an "Element" used to overwrite 269 data or reserve space within a "Master Element" for later use. 271 "Element Name": The human-readable name of the "EBML Element". 273 "Element Path": The hierarchy of "Parent Element" where the "EBML 274 Element" is expected to be found in the "EBML Body". 276 "Empty Element": An "EBML Element" that has an "Element Data Size" 277 with all "VINT_DATA" bits set to zero, which indicates that the 278 "Element Data" of the "Element" is zero octets in length. 280 3. Structure 282 EBML uses a system of Elements to compose an EBML Document. EBML 283 Elements incorporate three parts: an Element ID, an Element Data 284 Size, and Element Data. The Element Data, which is described by the 285 Element ID, includes either binary data, one or more other EBML 286 Elements, or both. 288 4. Variable Size Integer 290 The Element ID and Element Data Size are both encoded as a Variable 291 Size Integer. The Variable Size Integer is composed of a VINT_WIDTH, 292 VINT_MARKER, and VINT_DATA, in that order. Variable Size Integers 293 MUST left-pad the VINT_DATA value with zero bits so that the whole 294 Variable Size Integer is octet-aligned. Variable Size Integer will 295 be referred to as VINT for shorthand. 297 4.1. VINT_WIDTH 299 Each Variable Size Integer begins with a VINT_WIDTH which consists of 300 zero or many zero-value bits. The count of consecutive zero-values 301 of the VINT_WIDTH plus one equals the length in octets of the 302 Variable Size Integer. For example, a Variable Size Integer that 303 starts with a VINT_WIDTH which contains zero consecutive zero-value 304 bits is one octet in length and a Variable Size Integer that starts 305 with one consecutive zero-value bit is two octets in length. The 306 VINT_WIDTH MUST only contain zero-value bits or be empty. 308 Within the EBML Header the VINT_WIDTH of a VINT MUST NOT exceed three 309 bits in length (meaning that the Variable Size Integer MUST NOT 310 exceed four octets in length) except if said VINT is used to express 311 the Element Data Size of an EBML Element with Element Name EBML and 312 Element ID "0x1A45DFA3" (see Section 11.2.1) in which case the 313 VINT_WIDTH MUST NOT exceed seven bits in length. Within the EBML 314 Body, when a VINT is used to express an Element ID, the maximum 315 length allowed for the VINT_WIDTH is one less than the value set in 316 the EBMLMaxIDLength Element. Within the EBML Body, when a VINT is 317 used to express an Element Data Size, the maximum length allowed for 318 the VINT_WIDTH is one less than the value set in the 319 EBMLMaxSizeLength Element. 321 4.2. VINT_MARKER 323 The VINT_MARKER serves as a separator between the VINT_WIDTH and 324 VINT_DATA. Each Variable Size Integer MUST contain exactly one 325 VINT_MARKER. The VINT_MARKER is one bit in length and contain a bit 326 with a value of one. The first bit with a value of one within the 327 Variable Size Integer is the VINT_MARKER. 329 4.3. VINT_DATA 331 The VINT_DATA portion of the Variable Size Integer includes all data 332 that follows (but not including) the VINT_MARKER until end of the 333 Variable Size Integer whose length is derived from the VINT_WIDTH. 334 The bits required for the VINT_WIDTH and the VINT_MARKER use one out 335 of every eight bits of the total length of the Variable Size Integer. 337 Thus a Variable Size Integer of 1 octet length supplies 7 bits for 338 VINT_DATA, a 2 octet length supplies 14 bits for VINT_DATA, and a 3 339 octet length supplies 21 bits for VINT_DATA. If the number of bits 340 required for VINT_DATA are less than the bit size of VINT_DATA, then 341 VINT_DATA MUST be zero-padded to the left to a size that fits. The 342 VINT_DATA value MUST be expressed as a big-endian unsigned integer. 344 4.4. VINT Examples 346 This table shows examples of Variable Size Integers with lengths from 347 1 to 5 octets. The Usable Bits column refers to the number of bits 348 that can be used in the VINT_DATA. The Representation column depicts 349 a binary expression of Variable Size Integers where VINT_WIDTH is 350 depicted by "0", the VINT_MARKER as "1", and the VINT_DATA as "x". 352 +------------+------------+-----------------------------------------+ 353 | Octet | Usable | Representation | 354 | Length | Bits | | 355 +------------+------------+-----------------------------------------+ 356 | 1 | 7 | 1xxx xxxx | 357 | 2 | 14 | 01xx xxxx xxxx xxxx | 358 | 3 | 21 | 001x xxxx xxxx xxxx xxxx xxxx | 359 | 4 | 28 | 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx | 360 | 5 | 35 | 0000 1xxx xxxx xxxx xxxx xxxx xxxx xxxx | 361 | | | xxxx xxxx | 362 +------------+------------+-----------------------------------------+ 364 Data encoded as a Variable Size Integer may be rendered at octet 365 lengths larger than needed to store the data in order to facilitate 366 overwriting it at a later date, e.g. when its final size isn't known 367 in advance. In this table a binary value of 0b10 is shown encoded as 368 different Variable Size Integers with lengths from one octet to four 369 octets. All four encoded examples have identical semantic meaning 370 though the VINT_WIDTH and the padding of the VINT_DATA vary. 372 +--------------+--------------+-------------------------------------+ 373 | Binary Value | Octet Length | As Represented in Variable Size | 374 | | | Integer | 375 +--------------+--------------+-------------------------------------+ 376 | 10 | 1 | 1000 0010 | 377 | 10 | 2 | 0100 0000 0000 0010 | 378 | 10 | 3 | 0010 0000 0000 0000 0000 0010 | 379 | 10 | 4 | 0001 0000 0000 0000 0000 0000 0000 | 380 | | | 0010 | 381 +--------------+--------------+-------------------------------------+ 383 5. Element ID 385 The Element ID is encoded as a Variable Size Integer. By default, 386 Element IDs are encoded in lengths from one octet to four octets, 387 although Element IDs of greater lengths MAY be used if the 388 EBMLMaxIDLength Element of the EBML Header is set to a value greater 389 than four (see Section 11.2.4). The VINT_DATA component of the 390 Element ID MUST NOT be either defined or written as either all zero 391 values or all one values. Any Element ID with the VINT_DATA 392 component set as all zero values or all one values MUST be ignored. 393 The VINT_DATA component of the Element ID MUST be encoded at the 394 shortest valid length. For example, an Element ID with binary 395 encoding of "1011 1111" is valid, whereas an Element ID with binary 396 encoding of "0100 0000 0011 1111" stores a semantically equal 397 VINT_DATA but is invalid because a shorter VINT encoding is possible. 398 Additionally, an Element ID with binary encoding of "1111 1111" is 399 invalid since the VINT_DATA section is set to all one values, whereas 400 an Element ID with binary encoding of "0100 0000 0111 1111" stores a 401 semantically equal VINT_DATA and is the shortest possible VINT 402 encoding. 404 The following table details these specific examples further: 406 +------------+-------------+----------------+-----------------------+ 407 | VINT_WIDTH | VINT_MARKER | VINT_DATA | Element ID Status | 408 +------------+-------------+----------------+-----------------------+ 409 | | 1 | 0000000 | Invalid: VINT_DATA | 410 | | | | MUST NOT be set to | 411 | | | | all 0 | 412 | 0 | 1 | 00000000000000 | Invalid: VINT_DATA | 413 | | | | MUST NOT be set to | 414 | | | | all 0 | 415 | | 1 | 0000001 | Valid | 416 | 0 | 1 | 00000000000001 | Invalid: A shorter | 417 | | | | VINT_DATA encoding is | 418 | | | | available. | 419 | | 1 | 0111111 | Valid | 420 | 0 | 1 | 00000000111111 | Invalid: A shorter | 421 | | | | VINT_DATA encoding is | 422 | | | | available. | 423 | | 1 | 1111111 | Invalid: VINT_DATA | 424 | | | | MUST NOT be set to | 425 | | | | all 1 | 426 | 0 | 1 | 00000001111111 | Valid | 427 +------------+-------------+----------------+-----------------------+ 429 The octet length of an Element ID determines its EBML Class. 431 +------------+--------+-------------------------+---------------+ 432 | EBML Class | Length | Possible IDs | Number of IDs | 433 +------------+--------+-------------------------+---------------+ 434 | Class A | 1 | 0x81 - 0xFE | 126 | 435 | Class B | 2 | 0x407F - 0x7FFE | 16,256 | 436 | Class C | 3 | 0x203FFF - 0x3FFFFE | 2,080,768 | 437 | Class D | 4 | 0x101FFFFF - 0x1FFFFFFE | 268,338,304 | 438 +------------+--------+-------------------------+---------------+ 440 6. Element Data Size 442 The Element Data Size expresses the length in octets of Element Data. 443 The Element Data Size itself is encoded as a Variable Size Integer. 444 By default, Element Data Sizes can be encoded in lengths from one 445 octet to eight octets, although Element Data Sizes of greater lengths 446 MAY be used if the octet length of the longest Element Data Size of 447 the EBML Document is declared in the EBMLMaxSizeLength Element of the 448 EBML Header (see Section 11.2.5). Unlike the VINT_DATA of the 449 Element ID, the VINT_DATA component of the Element Data Size is not 450 mandated to be encoded at the shortest valid length. For example, an 451 Element Data Size with binary encoding of 1011 1111 or a binary 452 encoding of 0100 0000 0011 1111 are both valid Element Data Sizes and 453 both store a semantically equal value (both 0b00000000111111 and 454 0b0111111, the VINT_DATA sections of the examples, represent the 455 integer 63). 457 Although an Element ID with all VINT_DATA bits set to zero is 458 invalid, an Element Data Size with all VINT_DATA bits set to zero is 459 allowed for EBML Element Types which do not mandate a non-zero length 460 (see Section 7). An Element Data Size with all VINT_DATA bits set to 461 zero indicates that the Element Data is zero octets in length. Such 462 an EBML Element is referred to as an Empty Element. If an Empty 463 Element has a default value declared then the EBML Reader MUST 464 interpret the value of the Empty Element as the default value. If an 465 Empty Element has no default value declared then the EBML Reader MUST 466 use the value of the Empty Element for the corresponding EBML Element 467 Type of the Element ID, 0 for numbers and an empty string for 468 strings. 470 An Element Data Size with all VINT_DATA bits set to one is reserved 471 as an indicator that the size of the EBML Element is unknown. The 472 only reserved value for the VINT_DATA of Element Data Size is all 473 bits set to one. An EBML Element with an unknown Element Data Size 474 is referred to as an Unknown-Sized Element. A Master Element MAY be 475 an Unknown-Sized Element; however an EBML Element that is not a 476 Master Element MUST NOT be an Unknown-Sized Element. Master Elements 477 MUST NOT use an unknown size unless the unknownsizeallowed attribute 478 of their EBML Schema is set to true (see Section 11.1.5.10). The use 479 of Unknown-Sized Elements allows for an EBML Element to be written 480 and read before the size of the EBML Element is known. Unknown-Sized 481 Element MUST NOT be used or defined unnecessarily; however if the 482 Element Data Size is not known before the Element Data is written, 483 such as in some cases of data streaming, then Unknown-Sized Elements 484 MAY be used. The end of an Unknown-Sized Element is determined by 485 whichever comes first: the end of the file or the beginning of the 486 next EBML Element, defined by this document or the corresponding EBML 487 Schema, that is not independently valid as Descendant Element of the 488 Unknown-Sized Element. 490 For Element Data Sizes encoded at octet lengths from one to eight, 491 this table depicts the range of possible values that can be encoded 492 as an Element Data Size. An Element Data Size with an octet length 493 of 8 is able to express a size of 2^56-2 or 72,057,594,037,927,934 494 octets (or about 72 petabytes). The maximum possible value that can 495 be stored as Element Data Size is referred to as VINTMAX. 497 +--------------+----------------------+ 498 | Octet Length | Possible Value Range | 499 +--------------+----------------------+ 500 | 1 | 0 to 2^7-2 | 501 | 2 | 0 to 2^14-2 | 502 | 3 | 0 to 2^21-2 | 503 | 4 | 0 to 2^28-2 | 504 | 5 | 0 to 2^35-2 | 505 | 6 | 0 to 2^42-2 | 506 | 7 | 0 to 2^49-2 | 507 | 8 | 0 to 2^56-2 | 508 +--------------+----------------------+ 510 If the length of Element Data equals 2^(n*7)-1 then the octet length 511 of the Element Data Size MUST be at least n+1. This rule prevents an 512 Element Data Size from being expressed as a reserved value. The 513 following table clarifies this rule by showing a valid and invalid 514 expression of an Element Data Size with a VINT_DATA of 127 (which is 515 equal to 2^(1*7)-1) and 16,383 (which is equal to 2^(2*7)-1). 517 +------------+-------------+-----------------------+----------------+ 518 | VINT_WIDTH | VINT_MARKER | VINT_DATA | Element Data | 519 | | | | Size Status | 520 +------------+-------------+-----------------------+----------------+ 521 | | 1 | 1111111 | Reserved | 522 | | | | (meaning | 523 | | | | Unknown) | 524 | 0 | 1 | 00000001111111 | Valid (meaning | 525 | | | | 127 octets) | 526 | 00 | 1 | 000000000000001111111 | Valid (meaning | 527 | | | | 127 octets) | 528 | 0 | 1 | 11111111111111 | Reserved | 529 | | | | (meaning | 530 | | | | Unknown) | 531 | 00 | 1 | 000000011111111111111 | Valid (16,383 | 532 | | | | octets) | 533 +------------+-------------+-----------------------+----------------+ 535 7. EBML Element Types 537 EBML Elements are defined by an EBML Schema which MUST declare one of 538 the following EBML Element Types for each EBML Element. An EBML 539 Element Type defines a concept of storing data within an EBML Element 540 that describes such characteristics as length, endianness, and 541 definition. 543 EBML Elements which are defined as a Signed Integer Element, Unsigned 544 Integer Element, Float Element, or Date Element use big endian 545 storage. 547 7.1. Signed Integer Element 549 A Signed Integer Element MUST declare a length from zero to eight 550 octets. If the EBML Element is not defined to have a default value, 551 then a Signed Integer Element with a zero-octet length represents an 552 integer value of zero. 554 A Signed Integer Element stores an integer (meaning that it can be 555 written without a fractional component) which could be negative, 556 positive, or zero. Signed Integers are stored with two's complement 557 notation with the leftmost bit being the sign bit. Because EBML 558 limits Signed Integers to 8 octets in length a Signed Integer Element 559 stores a number from -9,223,372,036,854,775,808 to 560 +9,223,372,036,854,775,807. 562 7.2. Unsigned Integer Element 564 An Unsigned Integer Element MUST declare a length from zero to eight 565 octets. If the EBML Element is not defined to have a default value, 566 then an Unsigned Integer Element with a zero-octet length represents 567 an integer value of zero. 569 An Unsigned Integer Element stores an integer (meaning that it can be 570 written without a fractional component) which could be positive or 571 zero. Because EBML limits Unsigned Integers to 8 octets in length an 572 Unsigned Integer Element stores a number from 0 to 573 18,446,744,073,709,551,615. 575 7.3. Float Element 577 A Float Element MUST declare a length of either zero octet (0 bit), 578 four octets (32 bit) or eight octets (64 bit). If the EBML Element 579 is not defined to have a default value, then a Float Element with a 580 zero-octet length represents a numerical value of zero. 582 A Float Element stores a floating-point number as defined in 583 [IEEE.754.1985]. 585 7.4. String Element 587 A String Element MUST declare a length in octets from zero to 588 VINTMAX. If the EBML Element is not defined to have a default value, 589 then a String Element with a zero-octet length represents an empty 590 string. 592 A String Element MUST either be empty (zero-length) or contain 593 printable ASCII characters [RFC0020] in the range of 0x20 to 0x7E, 594 with an exception made for termination (see Section 13). 596 7.5. UTF-8 Element 598 A UTF-8 Element MUST declare a length in octets from zero to VINTMAX. 599 If the EBML Element is not defined to have a default value, then a 600 UTF-8 Element with a zero-octet length represents an empty string. 602 A UTF-8 Element contains only a valid Unicode string as defined in 603 [RFC3629], with an exception made for termination (see Section 13). 605 7.6. Date Element 607 A Date Element MUST declare a length of either zero octets or eight 608 octets. If the EBML Element is not defined to have a default value, 609 then a Date Element with a zero-octet length represents a timestamp 610 of 2001-01-01T00:00:00.000000000 UTC [RFC3339]. 612 The Date Element stores an integer in the same format as the Signed 613 Integer Element that expresses a point in time referenced in 614 nanoseconds from the precise beginning of the third millennium of the 615 Gregorian Calendar in Coordinated Universal Time (also known as 616 2001-01-01T00:00:00.000000000 UTC). This provides a possible 617 expression of time from 1708-09-11T00:12:44.854775808 UTC to 618 2293-04-11T11:47:16.854775807 UTC. 620 7.7. Master Element 622 A Master Element MUST declare a length in octets from zero to 623 VINTMAX. The Master Element MAY also use an unknown length. See 624 Section 6 for rules that apply to elements of unknown length. 626 The Master Element contains zero, one, or many other elements. EBML 627 Elements contained within a Master Element MUST have the 628 EBMLParentPath of their Element Path equal to the EBMLMasterPath of 629 the Master Element Element Path (see Section 11.1.5.2). Element Data 630 stored within Master Elements SHOULD only consist of EBML Elements 631 and SHOULD NOT contain any data that is not part of an EBML Element. 632 The EBML Schema identifies what Element IDs are valid within the 633 Master Elements for that version of the EBML Document Type. Any data 634 contained within a Master Element that is not part of a Child Element 635 MUST be ignored. 637 7.8. Binary Element 639 A Binary Element MUST declare a length in octets from zero to 640 VINTMAX. 642 The contents of a Binary Element should not be interpreted by the 643 EBML Reader. 645 8. EBML Document 647 An EBML Document is comprised of only two components, an EBML Header 648 and an EBML Body. An EBML Document MUST start with an EBML Header 649 that declares significant characteristics of the entire EBML Body. 650 An EBML Document consists of EBML Elements and MUST NOT contain any 651 data that is not part of an EBML Element. 653 8.1. EBML Header 655 The EBML Header is a declaration that provides processing 656 instructions and identification of the EBML Body. The EBML Header of 657 an EBML Document is analogous to the XML Declaration of an XML 658 Document. 660 The EBML Header documents the EBML Schema (also known as the EBML 661 DocType) that is used to semantically interpret the structure and 662 meaning of the EBML Document. Additionally the EBML Header documents 663 the versions of both EBML and the EBML Schema that were used to write 664 the EBML Document and the versions required to read the EBML 665 Document. 667 The EBML Header MUST contain a single Master Element with an Element 668 Name of EBML and Element ID of 0x1A45DFA3 (see Section 11.2.1) and 669 any number of additional EBML Elements within it. The EBML Header of 670 an EBML Document that uses an EBMLVersion of 1 MUST only contain EBML 671 Elements that are defined as part of this document. 673 8.2. EBML Body 675 All data of an EBML Document following the EBML Header is the EBML 676 Body. The end of the EBML Body, as well as the end of the EBML 677 Document that contains the EBML Body, is reached at whichever comes 678 first: the beginning of a new EBML Header at the Root Level or the 679 end of the file. The EBML Body MUST NOT contain any data that is not 680 part of an EBML Element. This document defines precisely which EBML 681 Elements are to be used within the EBML Header, but does not name or 682 define which EBML Elements are to be used within the EBML Body. The 683 definition of which EBML Elements are to be used within the EBML Body 684 is defined by an EBML Schema. 686 9. EBML Stream 688 An EBML Stream is a file that consists of one or more EBML Documents 689 that are concatenated together. An occurrence of a EBML Header at 690 the Root Level marks the beginning of an EBML Document. 692 10. EBML Versioning 694 An EBML Document handles 2 different versions: the version of the 695 EBML Header and the version of the EBML Body. Both versions are 696 meant to be backward compatible. 698 10.1. EBML Header Version 700 The version of the EBML Header is found in EBMLVersion. An EBML 701 parser can read an EBML Header if it can read either the EBMLVersion 702 version or a version equal or higher than the one found in 703 EBMLReadVersion. 705 10.2. EBML Document Version 707 The version of the EBML Body is found in EBMLDocTypeVersion. A 708 parser for the particular DocType format can read the EBML Document 709 if it can read either the EBMLDocTypeVersion version of that format 710 or a version equal or higher than the one found in 711 EBMLDocTypeReadVersion. 713 11. Elements semantic 715 11.1. EBML Schema 717 An EBML Schema is a well-formed XML Document that defines the 718 properties, arrangement, and usage of EBML Elements that compose a 719 specific EBML Document Type. The relationship of an EBML Schema to 720 an EBML Document is analogous to the relationship of an XML Schema 721 [W3C.REC-xmlschema-0-20010502] to an XML Document 722 [W3C.REC-xml-20081126]. An EBML Schema MUST be clearly associated 723 with one or more EBML Document Types. An EBML Document Type is 724 identified by a string stored within the EBML Header in the DocType 725 Element; for example matroska or webm (see Section 11.2.6). The 726 DocType value for an EBML Document Type MUST be unique and 727 persistent. 729 An EBML Schema MUST declare exactly one EBML Element at Root Level 730 (referred to as the Root Element) that occurs exactly once within an 731 EBML Document. The Void Element MAY also occur at Root Level but is 732 not a Root Element (see Section 11.3.2). 734 The EBML Schema MUST document all Elements of the EBML Body. The 735 EBML Schema does not document Global Elements that are defined by 736 this document (namely the Void Element and the CRC-32 Element). 738 The EBML Schema MUST NOT use the Element ID "0x1A45DFA3" which is 739 reserved for the EBML Header for resynchronization purpose. 741 An EBML Schema MAY constrain the use of EBML Header Elements (see 742 Section 11.2) by adding or constraining that Element's "range" 743 attribute. For example, an EBML Schema MAY constrain the 744 EBMLMaxSizeLength to a maximum value of "8" or MAY constrain the 745 EBMLVersion to only support a value of "1". If an EBML Schema adopts 746 the EBML Header Element as-is, then it is not required to document 747 that Element within the EBML Schema. If an EBML Schema constrains 748 the range of an EBML Header Element, then that Element MUST be 749 documented within an "" node of the EBML Schema. This 750 document provides an example of an EBML Schema, see Section 11.1.1. 752 11.1.1. EBML Schema Example 754 755 757 758 761 764 765 766 Container of data and 767 attributes representing one or many files. 768 769 771 772 An attached file. 773 774 775 778 779 Filename of the attached file. 780 781 782 785 786 MIME type of the file. 787 788 789 792 793 Modification timestamp of the file. 795 796 797 799 800 The data of the file. 801 802 803 805 11.1.2. Element 807 As an XML Document, the EBML Schema MUST use "" as the 808 top level element. The "" element MAY contain 809 "" sub-elements. 811 11.1.3. Attributes 813 Within an EBML Schema the "" element uses the following 814 attributes: 816 11.1.3.1. docType 818 The docType lists the official name of the EBML Document Type that is 819 defined by the EBML Schema; for example, "". 822 The docType attribute is REQUIRED within the "" Element. 824 11.1.3.2. version 826 The version lists a non-negative integer that specifies the version 827 of the docType documented by the EBML Schema. Unlike XML Schemas, an 828 EBML Schema documents all versions of a docType's definition rather 829 than using separate EBML Schemas for each version of a docType. EBML 830 Elements may be introduced and deprecated by using the minver and 831 maxver attributes of "". 833 The version attribute is REQUIRED within the "" Element. 835 11.1.4. Element 837 Each "" defines one EBML Element through the use of several 838 attributes that are defined in Section 11.1.3. EBML Schemas MAY 839 contain additional attributes to extend the semantics but MUST NOT 840 conflict with the definitions of the "" attributes defined 841 within this document. 843 The "" nodes contain a description of the meaning and use of 844 the EBML Element stored within one or more "" sub- 845 elements and zero or one "" sub-element. All 846 "" nodes MUST be sub-elements of the "". 848 11.1.5. Attributes 850 Within an EBML Schema the "" uses the following attributes 851 to define an EBML Element: 853 11.1.5.1. name 855 The name provides the human-readable name of the EBML Element. The 856 value of the name MUST be in the form of characters "A" to "Z", "a" 857 to "z", "0" to "9", "-" and ".". 859 The name attribute is REQUIRED. 861 11.1.5.2. path 863 The path defines the allowed storage locations of the EBML Element 864 within an EBML Document. This path MUST be defined with the full 865 hierarchy of EBML Elements separated with a "/". The top EBML 866 Element in the path hierarchy being the first in the value. The 867 syntax of the path attribute is defined using this Augmented Backus- 868 Naur Form (ABNF) [RFC5234] with the case sensitive update [RFC7405] 869 notation: 871 The path attribute is REQUIRED. 873 EBMLFullPath = EBMLElementOccurrence "(" EBMLMasterPath ")" 874 EBMLMasterPath = [EBMLParentPath] EBMLElementPath 875 EBMLParentPath = EBMLFixedParent EBMLLastParent 876 EBMLFixedParent = *(EBMLPathAtom) 877 EBMLElementPath = EBMLPathAtom / EBMLPathAtomRecursive 878 EBMLPathAtom = PathDelimiter EBMLAtomName 879 EBMLPathAtomRecursive = "(1*(" EBMLPathAtom "))" 880 EBMLLastParent = EBMLPathAtom / EBMLVariableParent 881 EBMLVariableParent = "(" VariableParentOccurrence "\)" 882 EBMLAtomName = 1*(EBMLNameChar) 883 EBMLNameChar = ALPHA / DIGIT / "-" / "." 884 PathDelimiter = "\" 885 EBMLElementOccurrence = [EBMLMinOccurrence] "*" [EBMLMaxOccurrence] 886 EBMLMinOccurrence = 1*DIGIT 887 EBMLMaxOccurrence = 1*DIGIT 888 VariableParentOccurrence = [PathMinOccurrence] "*" [PathMaxOccurrence] 889 PathMinOccurrence = 1*DIGIT 890 PathMaxOccurrence = 1*DIGIT 891 The "*", "(" and ")" symbols are interpreted as defined in [RFC5234]. 893 The EBMLPathAtom part of the EBMLElementPath MUST be equal to the 894 name attribute of the EBML Schema. 896 The starting PathDelimiter of the path corresponds to the root of the 897 EBML Document. 899 The EBMLElementOccurrence part is interpreted as an ABNF Variable 900 Repetition. The repetition amounts correspond to how many times the 901 EBML Element can be found in its Parent Element. 903 The EBMLMinOccurrence represents the minimum permitted number of 904 occurrences of this EBML Element within its Parent Element. Each 905 instance of the Parent Element MUST contain at least this many 906 instances of this EBML Element. If the EBML Element has an empty 907 EBMLParentPath then EBMLMinOccurrence refers to constraints on the 908 occurrence of the EBML Element within the EBML Document. If 909 EBMLMinOccurrence is not present then that EBML Element has an 910 EBMLMinOccurrence value of 0. The semantic meaning of 911 EBMLMinOccurrence within an EBML Schema is analogous to the meaning 912 of minOccurs within an XML Schema. EBML Elements with 913 EBMLMinOccurrence set to "1" that also have a default value (see 914 Section 11.1.5.8) declared are not REQUIRED to be stored but are 915 REQUIRED to be interpreted, see Section 11.1.14. An EBML Element 916 defined with a EBMLMinOccurrence value greater than zero is called a 917 Mandatory EBML Element. 919 The EBMLMaxOccurrence represents the maximum permitted number of 920 occurrences of this EBML Element within its Parent Element. Each 921 instance of the Parent Element MUST contain at most this many 922 instances of this EBML Element. If the EBML Element has an empty 923 EBMLParentPath then EBMLMaxOccurrence refers to constraints on the 924 occurrence of the EBML Element within the EBML Document. If 925 EBMLMaxOccurrence is not present then there is no upper bound for the 926 permitted number of occurrences of this EBML Element within its 927 Parent Element resp. within the EBML Document depending on whether 928 the EBMLParentPath of the EBML Element is empty or not. The semantic 929 meaning of EBMLMaxOccurrence within an EBML Schema path is analogous 930 to the meaning of maxOccurs within an XML Schema. 932 The VariableParentOccurrence part is interpreted as an ABNF Variable 933 Repetition. The repetition amounts correspond to the amount of 934 unspecified Parent Element levels there can be between the 935 EBMLFixedParent and the actual EBMLElementPath. 937 If the path contains an EBMLPathAtomRecursive part, the EBML Element 938 can occur within itself recursively (see the Section 11.1.5.11). 940 As an example, a "path" of "1*(\Segment\Info)" means the element Info 941 is found inside the Segment elements at least once and with no 942 maximum iteration. An element SeekHead with path 943 "0*2(\Segment\SeekHead)" may not be found at all in its Segment 944 parent, once or twice but no more than that. 946 11.1.5.3. id 948 The Element ID encoded as a Variable Size Integer expressed in 949 hexadecimal notation prefixed by a 0x that is read and stored in big- 950 endian order. To reduce the risk of false positives while parsing 951 EBML Streams, the Element IDs of the Root Element and Top-Level 952 Elements SHOULD be at least 4 octets in length. Element IDs defined 953 for use at Root Level or directly under the Root Level MAY use 954 shorter octet lengths to facilitate padding and optimize edits to 955 EBML Documents; for instance, the Void Element uses an Element ID 956 with a one octet length to allow its usage in more writing and 957 editing scenarios. 959 The id attribute is REQUIRED. 961 11.1.5.4. minOccurs 963 An integer expressing the minimum permitted number of occurrences of 964 this EBML Element within its Parent Element. The minOccurs value 965 MUST be equal to the EBMLMinOccurrence value of the path. 967 The minOccurs attribute is OPTIONAL. If the minOccurs attribute is 968 not present then that EBML Element has a minOccurs value of 0. 970 11.1.5.5. maxOccurs 972 An integer expressing the maximum permitted number of occurrences of 973 this EBML Element within its Parent Element. The maxOccurs value 974 MUST be equal to the EBMLMaxOccurrence value of the path. 976 The maxOccurs attribute is OPTIONAL. If the maxOccurs attribute is 977 not present then that EBML Element has no maximum occurrence, similar 978 to unbounded in the XML world. 980 11.1.5.6. range 982 A numerical range for EBML Elements which are of numerical types 983 (Unsigned Integer, Signed Integer, Float, and Date). If specified 984 the value of the EBML Element MUST be within the defined range. See 985 Section 11.1.5.6.1 for rules applied to expression of range values. 987 The range attribute is OPTIONAL. If the range attribute is not 988 present then any value legal for the type attribute is valid. 990 11.1.5.6.1. Expression of range 992 The range attribute MUST only be used with EBML Elements that are 993 either signed integer, unsigned integer, float, or date. The 994 expression defines the upper, lower, exact or excluded value of the 995 EBML Element and optionally an upper boundary value combined with a 996 lower boundary. The range expression may contain whitespace (using 997 the ASCII 0x20 character) for readability but whitespace within a 998 range expression MUST NOT convey meaning. 1000 To set a fixed value for the range, the value is used as the 1001 attribute value. For example "1234" means the EBML element always 1002 has the value 1234. The value can be prefixed with "not" to indicate 1003 that the fixed value MUST NOT be used for that Element. For example 1004 "not 1234" means the Element can use all values of its type except 1005 1234. 1007 For an exclusive lower boundary the ">" sign is used and the ">=" 1008 sign is used for an inclusive lower boundary. For example ">3" 1009 meaning the Element value MUST be greater than 3 or ">=0x1p+0" 1010 meaning the Element value MUST be greater than or equal to the 1011 floating value 1.0, see Section 11.1.13. 1013 For an exclusive upper boundary the "<" sign is used and the "<=" 1014 sign is used for an inclusive upper boundary. For example "<-2" 1015 meaning the Element value MUST be less than -2 or "<=10" meaning the 1016 Element value MUST be less than or equal to the 10. 1018 The lower and upper bounds can be combined into an expression to form 1019 a closed boundary. The lower boundary coming first followed by the 1020 upper boundary, separated by a comma. For example ">3,<= 20" means 1021 the Element value MUST be greater than 3 and less than or equal to 1022 20. 1024 A special form of lower and upper bounds using the "-" separator is 1025 possible, meaning the Element value MUST be greater than or to the 1026 first value and MUST be less than or equal to the second value. For 1027 example "1-10" is equivalent to ">=1,<=10". If the upper boundary is 1028 negative, only the latter form MUST be used. 1030 11.1.5.7. length 1032 A value to express the valid length of the Element Data as written 1033 measured in octets. The length provides a constraint in addition to 1034 the Length value of the definition of the corresponding EBML Element 1035 Type. This length MUST be expressed as either a non-negative integer 1036 or a range (see Section 11.1.5.6.1) that consists of only non- 1037 negative integers and valid operators. 1039 The length attribute is OPTIONAL. If the length attribute is not 1040 present for that EBML Element then that EBML Element is only limited 1041 in length by the definition of the associated EBML Element Type. 1043 11.1.5.8. default 1045 If an Element is mandatory (has a EBMLMinOccurrence value greater 1046 than zero) but not written within its Parent Element or stored as an 1047 Empty Element, then the EBML Reader of the EBML Document MUST 1048 semantically interpret the EBML Element as present with this 1049 specified default value for the EBML Element. EBML Elements that are 1050 Master Elements MUST NOT declare a default value. EBML Elements with 1051 a minOccurs value greater than 1 MUST NOT declare a default value. 1053 The default attribute is OPTIONAL. 1055 11.1.5.9. type 1057 The type MUST be set to one of the following values: "integer" 1058 (signed integer), "uinteger" (unsigned integer), "float", "string", 1059 "date", "utf-8", "master", or "binary". The content of each type is 1060 defined within Section 7. 1062 The type attribute is REQUIRED. 1064 11.1.5.10. unknownsizeallowed 1066 A boolean to express if an EBML Element is permitted to be Unknown- 1067 Sized Element (having all VINT_DATA bits of Element Data Size set to 1068 1). EBML Elements that are not Master Elements MUST NOT set 1069 unknownsizeallowed to true. An EBML Element that is defined with an 1070 unknownsizeallowed attribute set to 1 MUST also have the 1071 unknownsizeallowed attribute of its Parent Element set to 1. 1073 The unknownsizeallowed attribute is OPTIONAL. If the 1074 unknownsizeallowed attribute is not used then that EBML Element is 1075 not allowed to use an unknown Element Data Size. 1077 11.1.5.11. recursive 1079 A boolean to express if an EBML Element is permitted to be stored 1080 recursively. In this case the EBML Element MAY be stored within 1081 another EBML Element that has the same Element ID. Which itself can 1082 be stored in an EBML Element that has the same Element ID, and so on. 1084 EBML Elements that are not Master Elements MUST NOT set recursive to 1085 true. 1087 If the path contains an EBMLPathAtomRecursive part then the recursive 1088 value MUST be true and false otherwise. 1090 The recursive attribute is OPTIONAL. If the recursive attribute is 1091 not present then the EBML Element MUST NOT be used recursively. 1093 11.1.5.12. recurring 1095 A boolean to express if an EBML Element is defined as an Identically 1096 Recurring Element or not. 1098 The recurring attribute is OPTIONAL. If the recurring attribute is 1099 not present then the EBML Element is not an Identically Recurring 1100 Element. 1102 11.1.5.13. minver 1104 The minver (minimum version) attribute stores a non-negative integer 1105 that represents the first version of the docType to support the EBML 1106 Element. 1108 The minver attribute is OPTIONAL. If the minver attribute is not 1109 present, then the EBML Element has a minimum version of "1". 1111 11.1.5.14. maxver 1113 The maxver (maximum version) attribute stores a non-negative integer 1114 that represents the last or most recent version of the docType to 1115 support the element. maxver MUST be greater than or equal to minver. 1117 The maxver attribute is OPTIONAL. If the maxver attribute is not 1118 present then the EBML Element has a maximum version equal to the 1119 value stored in the version attribute of "". 1121 11.1.6. Element 1123 The "" element provides additional information about 1124 the EBML Element. 1126 11.1.7. Attributes 1127 11.1.7.1. lang 1129 A lang attribute which is set to the [RFC5646] value of the language 1130 of the element's documentation. 1132 The lang attribute is OPTIONAL. 1134 11.1.7.2. purpose 1136 A purpose attribute distinguishes the meaning of the documentation. 1137 Values for the sub-element's purpose attribute MUST include one of 1138 the following: "definition", "rationale", "usage notes", and 1139 "references". 1141 The purpose attribute is REQUIRED. 1143 11.1.8. Element 1145 The "" element provides information about restrictions 1146 to the allowable values for the EBML Element which are listed in 1147 "" elements. 1149 11.1.9. Element 1151 The "" element stores a list of values allowed for storage in 1152 the EBML Element. The values MUST match the type of the EBML Element 1153 (for example "" cannot be a valid value for a EBML 1154 Element that is defined as an unsigned integer). An "" element 1155 MAY also store "" elements to further describe the 1156 "". 1158 11.1.10. Attributes 1160 11.1.10.1. label 1162 The label provides a concise expression for human consumption that 1163 describes what the value of the "" represents. 1165 The label attribute is OPTIONAL. 1167 11.1.10.2. value 1169 The value represents data that MAY be stored within the EBML Element. 1171 The value attribute is REQUIRED. 1173 11.1.11. XML Schema for EBML Schema 1175 1176 1180 1181 1182 1183 1185 1186 1187 1188 1189 1190 1191 1193 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1214 1215 1216 1217 1218 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1242 11.1.12. Identically Recurring Elements 1244 An Identically Recurring Element is an EBML Element that MAY occur 1245 within its Parent Element more than once but that each recurrence 1246 within that Parent Element MUST be identical both in storage and 1247 semantics. Identically Recurring Elements are permitted to be stored 1248 multiple times within the same Parent Element in order to increase 1249 data resilience and optimize the use of EBML in transmission. For 1250 instance a pertinent Top-Level Element could be periodically resent 1251 within a data stream so that an EBML Reader which starts reading the 1252 stream from the middle could better interpret the contents. 1253 Identically Recurring Elements SHOULD include a CRC-32 Element as a 1254 Child Element; this is especially recommended when EBML is used for 1255 long-term storage or transmission. If a Parent Element contains more 1256 than one copy of an Identically Recurring Element which includes a 1257 CRC-32 Element as a Child Element then the first instance of the 1258 Identically Recurring Element with a valid CRC-32 value should be 1259 used for interpretation. If a Parent Element contains more than one 1260 copy of an Identically Recurring Element which does not contain a 1261 CRC-32 Element or if CRC-32 Elements are present but none are valid 1262 then the first instance of the Identically Recurring Element should 1263 be used for interpretation. 1265 11.1.13. Textual expression of floats 1267 When a float value is represented textually in an EBML Schema, such 1268 as within a default or range value, the float values MUST be 1269 expressed as Hexadecimal Floating-Point Constants as defined in the 1270 C11 standard [ISO.9899.2011] (see section 6.4.4.2 on Floating 1271 Constants). The following table provides examples of expressions of 1272 float ranges. 1274 +-------------------+-----------------------------------------+ 1275 | as decimal | as Hexadecimal Floating-Point Constants | 1276 +-------------------+-----------------------------------------+ 1277 | 0.0 | "0x0p+1" | 1278 | 0.0-1.0 | "0x0p+1-0x1p+0" | 1279 | 1.0-256.0 | "0x1p+0-0x1p+8" | 1280 | 0.857421875 | "0x1.b7p-1" | 1281 | -1.0--0.857421875 | "-0x1p+0--0x1.b7p-1" | 1282 +-------------------+-----------------------------------------+ 1284 Within an expression of a float range, as in an integer range, the - 1285 (hyphen) character is the separator between the minimal and maximum 1286 value permitted by the range. Hexadecimal Floating-Point Constants 1287 also use a - (hyphen) when indicating a negative binary power. 1288 Within a float range, when a - (hyphen) is immediately preceded by a 1289 letter p, then the - (hyphen) is a part of the Hexadecimal Floating- 1290 Point Constant which notes negative binary power. Within a float 1291 range, when a - (hyphen) is not immediately preceded by a letter p, 1292 then the - (hyphen) represents the separator between the minimal and 1293 maximum value permitted by the range. 1295 11.1.14. Note on the use of default attributes to define Mandatory EBML 1296 Elements 1298 If a Mandatory EBML Element has a default value declared by an EBML 1299 Schema and the value of the EBML Element is equal to the declared 1300 default value then that EBML Element is not required to be present 1301 within the EBML Document if its Parent Element is present. In this 1302 case, the default value of the Mandatory EBML Element MUST be read by 1303 the EBML Reader although the EBML Element is not present within its 1304 Parent Element. 1306 If a Mandatory EBML Element has no default value declared by an EBML 1307 Schema and its Parent Element is present then the EBML Element MUST 1308 be present as well. If a Mandatory EBML Element has a default value 1309 declared by an EBML Schema and its Parent Element is present and the 1310 value of the EBML Element is NOT equal to the declared default value 1311 then the EBML Element MUST be present. 1313 This table clarifies if a Mandatory EBML Element MUST be written, 1314 according to if the default value is declared, if the value of the 1315 EBML Element is equal to the declared default value, and if the 1316 Parent Element is used. 1318 +---------------+---------------+---------------+-------------------+ 1319 | Is the | Is the value | Is the Parent | Then is storing | 1320 | default value | equal to | Element | the EBML Element | 1321 | declared? | default? | present? | REQUIRED? | 1322 +---------------+---------------+---------------+-------------------+ 1323 | Yes | Yes | Yes | No | 1324 | Yes | Yes | No | No | 1325 | Yes | No | Yes | Yes | 1326 | Yes | No | No | No | 1327 | No | n/a | Yes | Yes | 1328 | No | n/a | No | No | 1329 +---------------+---------------+---------------+-------------------+ 1331 11.2. EBML Header Elements 1333 This document contains definitions of all EBML Elements of the EBML 1334 Header. 1336 11.2.1. EBML Element 1338 name: EBML 1340 path: "1*1(\EBML)" 1342 id: 0x1A45DFA3 1344 minOccurs: 1 1346 maxOccurs: 1 1348 type: Master Element 1350 description: Set the EBML characteristics of the data to follow. 1351 Each EBML Document has to start with this. 1353 11.2.2. EBMLVersion Element 1355 name: EBMLVersion 1357 path: "1*1(\EBML\EBMLVersion)" 1359 id 0x4286 1360 minOccurs: 1 1362 maxOccurs: 1 1364 range: not 0 1366 default: 1 1368 type: Unsigned Integer 1370 description: The version of EBML specifications used to create the 1371 EBML Document. The version of EBML defined in this document is 1, so 1372 EBMLVersion SHOULD be 1. 1374 11.2.3. EBMLReadVersion Element 1376 name: EBMLReadVersion 1378 path: "1*1(\EBML\EBMLReadVersion)" 1380 id: 0x42F7 1382 minOccurs: 1 1384 maxOccurs: 1 1386 range: 1 1388 default: 1 1390 type: Unsigned Integer 1392 description: The minimum EBML version an EBML Reader has to support 1393 to read this EBML Document. The EBMLReadVersion Element MUST be less 1394 than or equal to EBMLVersion. 1396 11.2.4. EBMLMaxIDLength Element 1398 name: EBMLMaxIDLength 1400 path: "1*1(\EBML\EBMLMaxIDLength)" 1402 id 0x42F2 1404 minOccurs: 1 1406 maxOccurs: 1 1407 range: >=4 1409 default: 4 1411 type: Unsigned Integer 1413 description: The EBMLMaxIDLength Element stores the maximum permitted 1414 length in octets of the Element IDs to be found within the EBML Body. 1415 An EBMLMaxIDLength Element value of four is RECOMMENDED, though 1416 larger values are allowed. 1418 11.2.5. EBMLMaxSizeLength Element 1420 name: EBMLMaxSizeLength 1422 path: "1*1(\EBML\EBMLMaxSizeLength)" 1424 id 0x42F3 1426 minOccurs: 1 1428 maxOccurs: 1 1430 range: not 0 1432 default: 8 1434 type: Unsigned Integer 1436 description: The EBMLMaxSizeLength Element stores the maximum 1437 permitted length in octets of the expressions of all Element Data 1438 Sizes to be found within the EBML Body. The EBMLMaxSizeLength 1439 Element documents an upper bound for the "length" of all Element Data 1440 Size expressions within the EBML Body and not an upper bound for the 1441 "value" of all Element Data Size expressions within the EBML Body. 1442 EBML Elements that have an Element Data Size expression which is 1443 larger in octets than what is expressed by EBMLMaxSizeLength Element 1444 are invalid. 1446 11.2.6. DocType Element 1448 name: DocType 1450 path: "1*1(\EBML\DocType)" 1452 id 0x4282 1454 minOccurs: 1 1455 maxOccurs: 1 1457 length: >0 1459 type: String 1461 description: A string that describes and identifies the content of 1462 the EBML Body that follows this EBML Header. 1464 11.2.7. DocTypeVersion Element 1466 name: DocTypeVersion 1468 path: "1*1(\EBML\DocTypeVersion)" 1470 id 0x4287 1472 minOccurs: 1 1474 maxOccurs: 1 1476 range: not 0 1478 default: 1 1480 type: Unsigned Integer 1482 description: The version of DocType interpreter used to create the 1483 EBML Document. 1485 11.2.8. DocTypeReadVersion Element 1487 name: DocTypeReadVersion 1489 path: "1*1(\EBML\DocTypeReadVersion)" 1491 id 0x4285 1493 minOccurs: 1 1495 maxOccurs: 1 1497 range: not 0 1499 default: 1 1501 type: Unsigned Integer 1502 description: The minimum DocType version an EBML Reader has to 1503 support to read this EBML Document. The value of the 1504 DocTypeReadVersion Element MUST be less than or equal to the value of 1505 the DocTypeVersion Element. 1507 11.2.9. DocTypeExtension Element 1509 name: DocTypeExtension 1511 path: "0*(\EBML\DocTypeExtension)" 1513 id 0x4281 1515 minOccurs: 0 1517 type: Master Element 1519 description: A DocTypeExtension adds extra Elements to the main 1520 DocType+DocTypeVersion tuple it's attached to. An EBML Reader MAY 1521 know these extra Elements and how to use them. A DocTypeExtension 1522 MAY be used to iterate between experimental Elements before they are 1523 integrated in a regular DocTypeVersion. Reading one DocTypeExtension 1524 version of a DocType+DocTypeVersion tuple doesn't imply one should be 1525 able to read upper versions of this DocTypeExtension. 1527 11.2.10. DocTypeExtensionName Element 1529 name: DocTypeExtensionName 1531 path: "1*1(\EBML\DocTypeExtension\Name)" 1533 id 0x4283 1535 minOccurs: 1 1537 maxOccurs: 1 1539 length: >0 1541 type: String 1543 description: The name of the DocTypeExtension to identify it from 1544 other DocTypeExtension of the same DocType+DocTypeVersion tuple. A 1545 DocTypeExtensionName value MUST be unique within the EBML Header. 1547 11.2.11. DocTypeExtensionVersion Element 1549 name: DocTypeExtensionVersion 1551 path: "1*1(\EBML\DocTypeExtension\Version)" 1553 id 0x4284 1555 minOccurs: 1 1557 maxOccurs: 1 1559 range: not 0 1561 type: Unsigned Integer 1563 description: The version of the DocTypeExtension. Different 1564 DocTypeExtensionVersion values of the same 1565 DocType+DocTypeVersion+DocTypeExtensionName tuple MAY contain 1566 completely different sets of extra Elements. An EBML Reader MAY 1567 support multiple versions of the same DocTypeExtension, only one or 1568 none. 1570 11.3. Global Elements 1572 EBML defines these Global Elements which MAY be stored within any 1573 Master Element of an EBML Document as defined by their Element Path. 1575 11.3.1. CRC-32 Element 1577 name: CRC-32 1579 path: "*1((1*\)\CRC-32)" 1581 id: 0xBF 1583 minOccurs: 0 1585 maxOccurs: 1 1587 length: 4 1589 type: Binary 1591 description: The CRC-32 Element contains a 32-bit Cyclic Redundancy 1592 Check value of all the Element Data of the Parent Element as stored 1593 except for the CRC-32 Element itself. When the CRC-32 Element is 1594 present, the CRC-32 Element MUST be the first ordered EBML Element 1595 within its Parent Element for easier reading. All Top-Level Elements 1596 of an EBML Document that are Master Elements SHOULD include a CRC-32 1597 Element as a Child Element. The CRC in use is the IEEE-CRC-32 1598 algorithm as used in the [ISO.3309.1979] standard and in section 1599 8.1.1.6.2 of [ITU.V42.1994], with initial value of 0xFFFFFFFF. The 1600 CRC value MUST be computed on a little endian bitstream and MUST use 1601 little endian storage. 1603 11.3.2. Void Element 1605 name: Void 1607 path: "*((*\)\Void)" 1609 id: 0xEC 1611 minOccurs: 0 1613 type: Binary 1615 description: Used to void data or to avoid unexpected behaviors when 1616 using damaged data. The content is discarded. Also used to reserve 1617 space in a sub-element for later use. 1619 12. Considerations for Reading EBML Data 1621 The following scenarios describe events to consider when reading EBML 1622 Documents and the recommended design of an EBML Reader. 1624 If a Master Element contains a CRC-32 Element that doesn't validate, 1625 then the EBML Reader MAY ignore all contained data except for 1626 Descendant Elements that contain their own valid CRC-32 Element. 1628 If a Master Element contains more occurrences of a Child Master 1629 Element than permitted according to the maxOccurs and recurring 1630 attributes of the definition of that Element then the occurrences in 1631 addition to maxOccurs MAY be ignored. 1633 If a Master Element contains more occurrences of a Child Element that 1634 is not a Master Element than permitted according to the maxOccurs 1635 attribute of the definition of that Element then all but the instance 1636 of that Element with the smallest byte offset from the beginning of 1637 its Parent Element SHOULD be ignored. 1639 13. Terminating Elements 1641 Null Octets, which are octets with all bits set to zero, MAY follow 1642 the value of a String Element or UTF-8 Element to serve as a 1643 terminator. An EBML Writer MAY terminate a String Element or UTF-8 1644 Element with Null Octets in order to overwrite a stored value with a 1645 new value of lesser length while maintaining the same Element Data 1646 Size (this can prevent the need to rewrite large portions of an EBML 1647 Document); otherwise the use of Null Octets within a String Element 1648 or UTF-8 Element is NOT RECOMMENDED. An EBML Reader MUST consider 1649 the value of the String Element or UTF-8 Element to be terminated 1650 upon the first read Null Octet and MUST ignore any data following the 1651 first Null Octet within that Element. A string value and a copy of 1652 that string value terminated by one or more Null Octets are 1653 semantically equal. 1655 The following table shows examples of semantics and validation for 1656 the use of Null Octets. Values to represent Stored Values and the 1657 Semantic Meaning as represented as hexadecimal values. 1659 +---------------------+---------------------+ 1660 | Stored Value | Semantic Meaning | 1661 +---------------------+---------------------+ 1662 | 0x65 0x62 0x6D 0x6C | 0x65 0x62 0x6D 0x6C | 1663 | 0x65 0x62 0x00 0x6C | 0x65 0x62 | 1664 | 0x65 0x62 0x00 0x00 | 0x65 0x62 | 1665 | 0x65 0x62 | 0x65 0x62 | 1666 +---------------------+---------------------+ 1668 14. Guidelines for Updating Elements 1670 An EBML Document can be updated without requiring that the entire 1671 EBML Document be rewritten. These recommendations describe 1672 strategies to change the Element Data of a written EBML Element with 1673 minimal disruption to the rest of the EBML Document. 1675 14.1. Reducing a Element Data in Size 1677 There are three methods to reduce the size of Element Data of a 1678 written EBML Element. 1680 14.1.1. Adding a Void Element 1682 When an EBML Element is changed to reduce its total length by more 1683 than one octet, an EBML Writer SHOULD fill the freed space with a 1684 Void Element. 1686 14.1.2. Extending the Element Data Size 1688 The same value for Element Data Size MAY be written in variable 1689 lengths, so for minor reductions in octet length the Element Data 1690 Size MAY be written to a longer octet length to fill the freed space. 1692 For example, the first row of the following table depicts a String 1693 Element that stores an Element ID (3 octets), Element Data Size (1 1694 octet), and Element Data (4 octets). If the Element Data is changed 1695 to reduce the length by one octet and if the current length of the 1696 Element Data Size is less than its maximum permitted length, then the 1697 Element Data Size of that Element MAY be rewritten to increase its 1698 length by one octet. Thus before and after the change the EBML 1699 Element maintains the same length of 8 octets and data around the 1700 Element does not need to be moved. 1702 +-------------+------------+-------------------+--------------+ 1703 | Status | Element ID | Element Data Size | Element Data | 1704 +-------------+------------+-------------------+--------------+ 1705 | Before edit | 0x3B4040 | 0x84 | 0x65626D6C | 1706 | After edit | 0x3B4040 | 0x4003 | 0x6D6B76 | 1707 +-------------+------------+-------------------+--------------+ 1709 This method is RECOMMENDED when the Element Data is reduced by a 1710 single octet; for reductions by two or more octets it is RECOMMENDED 1711 to fill the freed space with a Void Element. 1713 Note that if the Element Data length needs to be rewritten as 1714 shortened by one octet and the Element Data Size could be rewritten 1715 as a shorter VINT then it is RECOMMENDED to rewrite the Element Data 1716 Size as one octet shorter, shorten the Element Data by one octet, and 1717 follow that Element with a Void Element. For example, the following 1718 table depicts a String Element that stores an Element ID (3 octets), 1719 Element Data Size (2 octets, but could be rewritten in one octet), 1720 and Element Data (3 octets). If the Element Data is to be rewritten 1721 to a two octet length, then another octet can be taken from Element 1722 Data Size so that there is enough space to add a two octet Void 1723 Element. 1725 +--------+------------+-----------------+-------------+-------------+ 1726 | Status | Element ID | Element Data | Element | Void | 1727 | | | Size | Data | Element | 1728 +--------+------------+-----------------+-------------+-------------+ 1729 | Before | 0x3B4040 | 0x4003 | 0x6D6B76 | | 1730 | After | 0x3B4040 | 0x82 | 0x6869 | 0xEC80 | 1731 +--------+------------+-----------------+-------------+-------------+ 1733 14.1.3. Terminating Element Data 1735 For String Elements and UTF-8 Elements the length of Element Data MAY 1736 be reduced by adding Null Octets to terminate the Element Data (see 1737 Section 13). 1739 In the following table, a four octets long Element Data is changed to 1740 a three octet long value followed by a Null Octet; the Element Data 1741 Size includes any Null Octets used to terminate Element Data so 1742 remains unchanged. 1744 +-------------+------------+-------------------+--------------+ 1745 | Status | Element ID | Element Data Size | Element Data | 1746 +-------------+------------+-------------------+--------------+ 1747 | Before edit | 0x3B4040 | 0x84 | 0x65626D6C | 1748 | After edit | 0x3B4040 | 0x84 | 0x6D6B7600 | 1749 +-------------+------------+-------------------+--------------+ 1751 Note that this method is NOT RECOMMENDED. For reductions of one 1752 octet, the method for Extending the Element Data Size SHOULD be used. 1753 For reduction by more than one octet, the method for Adding a Void 1754 Element SHOULD be used. 1756 14.2. Considerations when Updating Elements with Cyclic Redundancy 1757 Check (CRC) 1759 If the Element to be changed is a Descendant Element of any Master 1760 Element that contains a CRC-32 Element (see Section 11.3.1) then the 1761 CRC-32 Element MUST be verified before permitting the change. 1762 Additionally the CRC-32 Element value MUST be subsequently updated to 1763 reflect the changed data. 1765 15. Backward and Forward Compatibility 1767 Elements of an EBML format SHOULD be designed with backward and 1768 forward compatibility in mind. 1770 15.1. Backward Compatibility 1772 Backward compatibility of new EBML Elements can be achieved by using 1773 default values for mandatory elements. The default value MUST 1774 represent the state that was assumed for previous versions of the 1775 EBML Schema, without this new EBML Element. If such a state doesn't 1776 make sense for previous versions, then the new EBML Element SHOULD 1777 NOT be mandatory. 1779 Non mandatory EBML Elements can be added in a new EBMLDocTypeVersion. 1780 Since they are not mandatory they won't be found in older versions of 1781 the EBMLDocTypeVersion, just as they might not be found in newer 1782 versions. This causes no compatibility issue. 1784 15.2. Forward Compatibility 1786 EBML Elements MAY be marked as deprecated in a new EBMLDocTypeVersion 1787 using the maxver attribute of the EBML Schema. If such an Element is 1788 found in an EBML Document with newer version of the 1789 EBMLDocTypeVersion it SHOULD be discarded. 1791 16. Security Considerations 1793 EBML itself does not offer any kind of security and does not provide 1794 confidentiality. EBML does not provide any kind of authorization. 1795 EBML only offers marginally useful and effective data integrity 1796 options, such as CRC elements. 1798 Even if the semantic layer offers any kind of encryption, EBML itself 1799 could leak information at both the semantic layer (as declared via 1800 the DocType Element) and within the EBML structure (the presence of 1801 EBML Elements can be derived even with an unknown semantic layer 1802 using a heuristic approach; not without errors, of course, but with a 1803 certain degree of confidence). 1805 An EBML Document that has the following issues may still be handled 1806 by the EBML Reader and the data accepted as such, depending on how 1807 strict the EBML Reader wants to be: 1809 o Invalid Element IDs that are longer than the limit stated in the 1810 EBMLMaxIDLength Element of the EBML Header. 1812 o Invalid Element IDs that are not encoded in the shortest-possible 1813 way. 1815 o Invalid Element Data Size values that are longer than the limit 1816 stated in the EBMLMaxSizeLength Element of the EBML Header. 1818 Element IDs that are unknown to the EBML Reader MAY be accepted as 1819 valid EBML IDs in order to skip such elements. 1821 EBML Elements with a string type may contain extra data after the 1822 first 0x00. These data MUST be discarded according to the Section 13 1823 rules. 1825 An EBML Reader may discard some or all data if the following errors 1826 are found in the EBML Document: 1828 o Invalid Element Data Size values (e.g. extending the length of the 1829 EBML Element beyond the scope of the Parent Element; possibly 1830 triggering access-out-of-bounds issues). 1832 o Very high lengths in order to force out-of-memory situations 1833 resulting in a denial of service, access-out-of-bounds issues etc. 1835 o Missing EBML Elements that are mandatory in a Master Element and 1836 have no declared default value, making the semantic invalid at 1837 that Master Element level. 1839 o Usage of invalid UTF-8 encoding in EBML Elements of UTF-8 type 1840 (e.g. in order to trigger access-out-of-bounds or buffer overflow 1841 issues). 1843 o Usage of invalid data in EBML Elements with a date type, 1844 trigerring bogus date accesses. 1846 Side channel attacks could exploit: 1848 o The semantic equivalence of the same string stored in a String 1849 Element or UTF-8 Element with and without zero-bit padding, making 1850 comparison at the semantic level invalid. 1852 o The semantic equivalence of VINT_DATA within Element Data Size 1853 with two different lengths due to left-padding zero bits, making 1854 comparison at the semantic level invalid. 1856 o Data contained within a Master Element which is not itself part of 1857 a Child Element can trigger incorrect parsing behavior in EBML 1858 Readers. 1860 o Extraneous copies of Identically Recurring Element, making parsing 1861 unnecessarily slow to the point of not being usable. 1863 o Copies of Identically Recurring Element within a Parent Element 1864 that contain invalid CRC-32 Elements. EBML Readers not checking 1865 the CRC-32 might use the version of the element with mismatching 1866 CRC-32. 1868 o Use of Void Elements which could be used to hide content or create 1869 bogus resynchronzation points seen by some EBML Reader and not 1870 others. 1872 An EBML Reader MAY use the data if it considers it doesn't create any 1873 security issue. 1875 17. IANA Considerations 1877 17.1. CELLAR EBML Element ID Registry 1879 This document creates a new IANA Registry called "CELLAR EBML Element 1880 ID Registry". 1882 Element IDs are described in section Element ID. Element IDs are 1883 encoded using the VINT mechanism described in section Section 4 can 1884 be between one and five octets long. Five octet long Element IDs are 1885 possible only if declared in the header. 1887 This IANA Registry only applies to Elements that can be contained in 1888 the EBML Header, thus including Global Elements. Elements only found 1889 in the EBML Body have their own set of independent Element IDs and 1890 are not part of this IANA Registry. 1892 The VINT Data value of one-octet Element IDs MUST be between 0x01 and 1893 0x7E. These items are valuable because they are short, and need to 1894 be used for commonly repeated elements. Values from 1 to 126 are to 1895 be allocated according to the "RFC Required" policy [RFC8126]. 1897 The VINT Data value of two-octet Element IDs MUST be between 0x007F 1898 and 0x3FFE. Numbers are to be allocated within this range according 1899 to the "Specification Required" policy [RFC8126]. 1901 The numbers 0x3FFF and 0x4000 are RESERVED. 1903 The VINT Data value of three-octet Element IDs MUST be between 0x4001 1904 and 0x1FFFFE. Numbers may be allocated within this range according 1905 to the "First Come First Served" policy [RFC8126]. 1907 The numbers 0x1FFFFF and 0x200000 are RESERVED. 1909 Four-octet Element IDs are numbers between 0x101FFFFF and 0x1FFFFFFE. 1910 Four-octet Element IDs are somewhat special in that they are useful 1911 for resynchronizing to major structures in the event of data 1912 corruption or loss. As such four-octet Element IDs are split into 1913 two categories. Four-octet Element IDs whose lower three octets (as 1914 encoded) would make printable 7-bit ASCII values (0x20 to 0x7F) MUST 1915 be allocated by the "Specification Required" policy. Sequential 1916 allocation of values is not required: specifications SHOULD include a 1917 specific request, and are encouraged to do early allocations. 1919 To be clear about the above category: four-octet Element IDs always 1920 start with hex 0x10 to 0x1F, and that octet may be chosen so that the 1921 entire number has some desirable property, such as a specific CRC. 1923 The other three octets, when ALL having values between 0x21 (33, 1924 ASCII !) and 0x7E (126, ASCII ~), fall into this category. 1926 Other four-octet Element IDs may be allocated by the "First Come 1927 First Served" policy. 1929 The numbers 0xFFFFFFF and 0x1000000 are RESERVED. 1931 Five octet Element IDs (values from 0x10000001 upwards) are RESERVED 1932 according to the "Experimental Use" policy [RFC8126]: they may be 1933 used by anyone at any time, but there is no coordination. 1935 ID Values found in this document are assigned as initial values as 1936 follows: 1938 +------------+-------------------------+----------------------------+ 1939 | ID | Element Name | Reference | 1940 +------------+-------------------------+----------------------------+ 1941 | 0x1A45DFA3 | EBML | Described in Section | 1942 | | | 11.2.1 | 1943 | 0x4286 | EBMLVersion | Described in Section | 1944 | | | 11.2.2 | 1945 | 0x42F7 | EBMLReadVersion | Described in Section | 1946 | | | 11.2.3 | 1947 | 0x42F2 | EBMLMaxIDLength | Described in Section | 1948 | | | 11.2.4 | 1949 | 0x42F3 | EBMLMaxSizeLength | Described in Section | 1950 | | | 11.2.5 | 1951 | 0x4282 | DocType | Described in Section | 1952 | | | 11.2.6 | 1953 | 0x4287 | DocTypeVersion | Described in Section | 1954 | | | 11.2.7 | 1955 | 0x4285 | DocTypeReadVersion | Described in Section | 1956 | | | 11.2.8 | 1957 | 0x4281 | DocTypeExtension | Described in Section | 1958 | | | 11.2.9 | 1959 | 0x4283 | DocTypeExtensionName | Described in Section | 1960 | | | 11.2.10 | 1961 | 0x4284 | DocTypeExtensionVersion | Described in Section | 1962 | | | 11.2.11 | 1963 | 0xBF | CRC-32 | Described in Section | 1964 | | | 11.3.1 | 1965 | 0xEC | Void | Described in Section | 1966 | | | 11.3.2 | 1967 +------------+-------------------------+----------------------------+ 1969 17.2. CELLAR EBML DocType Registry 1971 This document creates a new IANA Registry called "CELLAR EBML DocType 1972 Registry". 1974 DocType values are described in Section 11.1.3.1. DocTypes are ASCII 1975 strings, defined in Section 7.4, which label the official name of the 1976 EBML Document Type. The strings may be allocated according to the 1977 "First Come First Served" policy. 1979 The use of ASCII corresponds to the types and code already in use, 1980 the value is not meant to be visible to the user. 1982 DocType string values of "matroska" and "webm" are RESERVED to the 1983 IETF for future use. These can be assigned via the "IESG Approval" 1984 or "RFC Required" policies [RFC8126]. 1986 18. References 1988 18.1. Normative References 1990 [IEEE.754.1985] 1991 Institute of Electrical and Electronics Engineers, 1992 "Standard for Binary Floating-Point Arithmetic", 1993 IEEE Standard 754, August 1985. 1995 [ISO.3309.1979] 1996 International Organization for Standardization, "Data 1997 communication - High-level data link control procedures - 1998 Frame structure", ISO Standard 3309, 1979. 2000 [ISO.9899.2011] 2001 International Organization for Standardization, 2002 "Programming languages - C", ISO Standard 9899, 2011. 2004 [ITU.V42.1994] 2005 International Telecommunications Union, "Error-correcting 2006 Procedures for DCEs Using Asynchronous-to-Synchronous 2007 Conversion", ITU-T Recommendation V.42, 1994. 2009 [RFC0020] Cerf, V., "ASCII format for network interchange", STD 80, 2010 RFC 20, DOI 10.17487/RFC0020, October 1969, 2011 . 2013 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2014 Requirement Levels", BCP 14, RFC 2119, 2015 DOI 10.17487/RFC2119, March 1997, 2016 . 2018 [RFC3339] Klyne, G. and C. Newman, "Date and Time on the Internet: 2019 Timestamps", RFC 3339, DOI 10.17487/RFC3339, July 2002, 2020 . 2022 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 2023 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 2024 2003, . 2026 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 2027 Specifications: ABNF", STD 68, RFC 5234, 2028 DOI 10.17487/RFC5234, January 2008, 2029 . 2031 [RFC5646] Phillips, A., Ed. and M. Davis, Ed., "Tags for Identifying 2032 Languages", BCP 47, RFC 5646, DOI 10.17487/RFC5646, 2033 September 2009, . 2035 [RFC7405] Kyzivat, P., "Case-Sensitive String Support in ABNF", 2036 RFC 7405, DOI 10.17487/RFC7405, December 2014, 2037 . 2039 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 2040 Writing an IANA Considerations Section in RFCs", BCP 26, 2041 RFC 8126, DOI 10.17487/RFC8126, June 2017, 2042 . 2044 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2045 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2046 May 2017, . 2048 [W3C.REC-xml-20081126] 2049 Bray, T., Paoli, J., Sperberg-McQueen, M., Maler, E., and 2050 F. Yergeau, "Extensible Markup Language (XML) 1.0 (Fifth 2051 Edition)", World Wide Web Consortium Recommendation REC- 2052 xml-20081126, November 2008, 2053 . 2055 18.2. Informative References 2057 [W3C.REC-xmlschema-0-20010502] 2058 Fallside, D., "XML Schema Part 0: Primer", World Wide Web 2059 Consortium Recommendation REC-xmlschema-0-20010502, May 2060 2001, 2061 . 2063 18.3. URIs 2065 [1] https://github.com/Matroska-Org/matroska-specification/ 2067 Authors' Addresses 2069 Steve Lhomme 2071 Email: slhomme@matroska.org 2073 Dave Rice 2075 Email: dave@dericed.com 2077 Moritz Bunkus 2079 Email: moritz@bunkus.org