PSP Research Project Working Group ~lucidiot, Ed. Internet-Draft PSP Research Project Intended status: Standards Track February 5, 2020 Expires: August 8, 2020 Sony Compact XML Format draft-cxml-01 Abstract The Sony Compact XML Format is defined from the results of a reverse engineering project on the Internet Radio feature provided by the PlayStation Portable (PSP) consoles. The name is unofficial and extrapolated from the "CXML" magic header. Compact XML allows both encoding and decoding an XML file with its tag tree structure, without requiring consumers to know the schema when decoding, and using specific types such as binary files as values in XML elements and attributes. This specification could open new ways to read through other system files on a PSP or a PlayStation 3 (PS3). Status of This Memo This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at https://datatracker.ietf.org/drafts/current/. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." This Internet-Draft will expire on August 8, 2020. Copyright Notice Copyright (c) 2020 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents ~lucidiot Expires August 8, 2020 [Page 1] Internet-Draft Compact XML Format February 2020 (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 1.1. Notational Conventions . . . . . . . . . . . . . . . . . 2 1.2. Terminology . . . . . . . . . . . . . . . . . . . . . . . 3 1.3. Design Overview . . . . . . . . . . . . . . . . . . . . . 3 2. File Structure . . . . . . . . . . . . . . . . . . . . . . . 3 2.1. File Header . . . . . . . . . . . . . . . . . . . . . . . 3 2.2. Tree . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.2.1. Element . . . . . . . . . . . . . . . . . . . . . . . 5 2.2.2. Attribute . . . . . . . . . . . . . . . . . . . . . . 6 2.3. ID Table . . . . . . . . . . . . . . . . . . . . . . . . 6 2.4. String Table . . . . . . . . . . . . . . . . . . . . . . 6 2.5. Integer Array Table . . . . . . . . . . . . . . . . . . . 6 2.6. Float Array Table . . . . . . . . . . . . . . . . . . . . 6 2.7. File Table . . . . . . . . . . . . . . . . . . . . . . . 6 3. Encoding and Decoding . . . . . . . . . . . . . . . . . . . . 6 4. Research Opportunities . . . . . . . . . . . . . . . . . . . 6 5. Security Considerations . . . . . . . . . . . . . . . . . . . 7 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 7 7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 8 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 8 8.1. Normative References . . . . . . . . . . . . . . . . . . 8 8.2. Informative References . . . . . . . . . . . . . . . . . 8 Appendix A. Warranty Exclusion Statement . . . . . . . . . . . . 8 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 8 1. Introduction TODO 1.1. Notational Conventions The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here. ~lucidiot Expires August 8, 2020 [Page 2] Internet-Draft Compact XML Format February 2020 1.2. Terminology ASCII: Coded Character Set -- 7-bit American Standard Code for Information Interchange, ANSI X3.4-1986 [ASCII] DTD: Document Type Definition [XML] PS3: Abbreviation of PlayStation 3 PSP: Abbreviation of PlayStation Portable schema: A specific XML tree structure that MAY be defined by a DTD. XML: eXtensible Markup Language [XML] 1.3. Design Overview TODO 2. File Structure A Compact XML file is structured in a succession of components, henceforth referenced as "blocks", some of which are optional: * A File Header that include magic numbers, a version number, and offsets and sizes of every other block * A Tree that describes the XML tree structure * An OPTIONAL String Table that holds element and attribute names and values * An OPTIONAL Integer Array Table that holds values for elements and attributes of the integer array type * An OPTIONAL Float Array Table that holds values of the float array type * An OPTIONAL File Table that holds arbitrary binary or text files as values of elements or attributes. Each block is described in more detail below. 2.1. File Header ~lucidiot Expires August 8, 2020 [Page 3] Internet-Draft Compact XML Format February 2020 The file header MUST use the following structure: 0 bytes 4 8 0 bits 32 64 ├─────┴─────┴─────┴─────┼─────┴─────┴─────┴─────┤ │ Magic Header │ Version Number │ ├───────────────────────┼───────────────────────┤ │ Tree Offset │ Tree Size │ ├───────────────────────┼───────────────────────┤ │ ID Table Offset │ ID Table Size │ ├───────────────────────┼───────────────────────┤ │ String Table Offset │ String Table Size │ ├───────────────────────┼───────────────────────┤ │Int Array Table Offset │ Int Array Table Size │ ├───────────────────────┼───────────────────────┤ │Float Array Tbl. Offset│Float Array Table Size │ ├───────────────────────┼───────────────────────┤ │ File Table Offset │ File Table Size │ ├───────────────────────┴───────────────────────┤ │ Padding │ └───────────────────────────────────────────────┘ Figure 1 The Magic Header MUST be an ASCII-encoded 4-byte string. Specific Magic Headers MAY be used to distinguish specific XML schemas. The default value for a Magic Header is "CXML". The Version Number MUST be an unsigned 32-bit little endian integer. Its value for the current version of this RFC MUST be 256, or 0100 in hexadecimal notation. Offsets and sizes MUST be unsigned 32-bit little endian integers and MUST express their values in bytes. All fields in this structure are REQUIRED. If an optional block is absent, its size MUST be zero, and its offset SHOULD be the offset of the next block, or of the byte after the last byte of the file if there are no more blocks following it. Blocks SHOULD be written to the file in the order provided by this header structure. This file header allows for a theoretical maximum file size of 8,589,934,592 bytes, although a PSP would be restricted by its Memory Stick's file system, FAT32 [FAT32]. ~lucidiot Expires August 8, 2020 [Page 4] Internet-Draft Compact XML Format February 2020 2.2. Tree The Tree block describes the XML element tree structure, an element's attributes, and the 32-bit integer or floating point values on attributes of those types. Although a Tree block could be optional and a Tree's size in the File Header could be set to zero, implementations MAY NOT support this case, as this would be interpreted as a completely empty file, without an XML root element. The Tree is a sequence of elements. Each element is followed by zero or more attributes. 2.2.1. Element Elements MUST use the following structure: 0 bytes 4 8 0 bits 32 64 ├─────┴─────┴─────┴─────┼─────┴─────┴─────┴─────┤ │Str. Table Name Offset │ Attribute Count │ ├───────────────────────┼───────────────────────┤ │ Parent Offset │Previous Element Offset│ ├───────────────────────┼───────────────────────┤ │ Next Element Offset │ First Child Offset │ ├───────────────────────┼───────────────────────┘ │ Last Child Offset │ └───────────────────────┘ Figure 2 Every field in this structure MUST be an unsigned 32-bit integer in little endian. The String Table Name Offset is the relative offset in the String Table, in bytes, of the string associated with the element's name. The Attribute Count is the number of attributes for this element. The Parent Offset is the relative offset in the Tree, in bytes, of the parent element that holds this element. If this element is a root element and does not have a parent, the Parent Offset MUST be set to 0xFFFFFFFF (all bits at 1). The Previous Element Offset and Next Element Offset are the relative offsets in the Tree, in bytes, of the previous and next elements. If ~lucidiot Expires August 8, 2020 [Page 5] Internet-Draft Compact XML Format February 2020 there is no previous or next element, the corresponding offsets MUST be set to 0xFFFFFFFF (all bits at 1). The First Child Offset and Last Child Offset are the relative offsets in the Tree, in bytes, of the first and last child elements. If there are no children, both offsets MUST be set to 0xFFFFFFFF (all bits at 1). If there is only one children, both offsets MUST be the same. Note that elements holding character data are indistinguishable from attributes, because they would be represented as an attribute on their parent element. This makes a Compact XML structure closer to JSON than to XML. 2.2.2. Attribute TODO 2.3. ID Table TODO 2.4. String Table TODO 2.5. Integer Array Table TODO 2.6. Float Array Table TODO 2.7. File Table TODO 3. Encoding and Decoding TODO 4. Research Opportunities TODO ~lucidiot Expires August 8, 2020 [Page 6] Internet-Draft Compact XML Format February 2020 5. Security Considerations TODO 6. IANA Considerations This document registers the "application/vnd.sony.cxml" media type. Type name: application Subtype name: vnd.sony.cxml Required parameters: n/a Optional parameters: n/a Encoding considerations: Binary. See Section 3 of this RFC. Security considerations: See Section 5 of this RFC. Interoperability considerations: This document specifies the format of conforming files and the interpretation thereof, as understood from the reverse engineering process. Interoperability can therefore not be fully guaranteed for devices other than the PSP. Published specification: TBD Applications that use this media type: n/a Additional information: Magic numbers: 43 58 4d 4c 00 01 00 00 See Section 2.1 of this RFC. File extension(s): n/a Macintosh file type code(s): n/a Fragment identifier considerations: n/a Person & email address to contact for further information: See Author's Address section. Intended usage: Limited Use Use of this format SHOULD be restricted to platform-specific projects on the PlayStation Portable. Restrictions on usage: none ~lucidiot Expires August 8, 2020 [Page 7] Internet-Draft Compact XML Format February 2020 Author: Sony Computer Entertainment Inc. Change controller: See Author's Address section. 7. Acknowledgements The author would like to thank valentintintin for their valuable help in the research that went into learning about this file format. 8. References 8.1. Normative References [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, . [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017, . [XML] World Wide Web Consortium, "Extensible Markup Language (XML) 1.1, Second Edition", August 2006, . 8.2. Informative References [ASCII] Cerf, V., "ASCII format for Network Interchange", RFC 20, October 1969. [FAT32] Microsoft Corporation, "Microsoft Extensible Firmware Initiative FAT32 File System Specification", Version 1.03, December 2000. Appendix A. Warranty Exclusion Statement This document and the information contained herein is provided on an "AS IS" basis and TILDE.TOWN DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Author's Address ~lucidiot Expires August 8, 2020 [Page 8] Internet-Draft Compact XML Format February 2020 ~lucidiot (editor) PSP Research Project tilde.town 104.248.107.166 The Internet Email: lucidiot@brainshit.fr URI: https://tilde.town/~lucidiot/ ~lucidiot Expires August 8, 2020 [Page 9]