Skip to content

Commit

Permalink
Added v6 specification
Browse files Browse the repository at this point in the history
  • Loading branch information
Le0X8 committed Dec 20, 2023
1 parent 60826af commit 40643b3
Showing 1 changed file with 106 additions and 7 deletions.
113 changes: 106 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,10 @@ HSSP Flagged is a small, but important update to HSSP Indexed. It adds flags to
| 0 | Is encrypted | If this bit is set, the file is encrypted. |
| 1 | Is compressed | If this bit is set, the file is compressed. |
| 2 | Is splitted | If this bit is set, the file is splitted. |
| 4 | Continues previous split package | If this bit is set, the file continues the previous split package. |
| 5 | Continues next split package | If this bit is set, the file continues the next split package. |
| 3 | Continues previous split package | If this bit is set, the file continues the previous split package. |
| 4 | Continues next split package | If this bit is set, the file continues the next split package. |
| 5 | F6 | Unused. |
| 6 | F7 | Unused. |
| 7 | F8 | Unused. |
| 8 | F9 | Unused. |
| 9 | F10 | Unused. |
Expand Down Expand Up @@ -377,13 +379,110 @@ A file is structured like this:
| :----: | :----: | :------------ | :--: |
| 0x0 | ? | File contents | |

### 2.6. HSSP v6 (Separated/SPRD)

| Release date |
| :----------: |
| 2023-08-31 |

This update is another big update to HSSP. It separates the index and the files, which opens possibilities for multithreaded parsing
for a massive performance boost, because files can now be decrypted and decompressed at the same time.

Because of the new chaining feature, the file structure is now much more complex than before, but because this feature, the file generation is now much more flexible.

#### 2.6.1. New features

- Index and files are now encrypted and compressed separately, also every chain now has its own checksum
- Calculation of the index length is now required
- File chaining (files can now be chained for encryption and compression) to bundle multiple files together

#### 2.6.2. Removed features

- Flags F9-F24 because they were unused
- HSSP v4 compression codes because they were longer than they should be

#### 2.6.3. File structure

##### 2.6.3.1. Header

| Offset | Length | Description | Type |
| :----: | :----: | :------------------------------------------------------------------------------------------------------------------------ | :------: |
| 0x0 | 0x4 | Magic value: `HSSP` | UTF-8 |
| 0x4 | 0x1 | File standard version (0x4) | Uint8 |
| 0x5 | 0x1 | [Flags](#2632-flags) | |
| 0x6 | 0x2 | Index length in bytes (-IE\*FC) =(IL) | Uint16LE |
| 0x8 | 0x4 | Number of contained files (=FC) | Uint32LE |
| 0xC | 0x20 | Password hash (double SHA-256) | |
| 0x2C | 0x10 | Initialization vector (IV) | |
| 0x3C | 0x2 | Used [compression algorithm](#3-compression-algorithms) | |
| 0x3E | 0x2 | Average index entry length (=IE) | Uint16LE |
| 0x40 | 0x4 | Checksum of the [index](#2633-index) | Uint32LE |
| 0x44 | 0x8 | File count of all the files, even those that are not in this package! (may be 0x0 if not splitted) | Uint64LE |
| 0x4C | 0x8 | Offset of the file that has been splitted. (0x0 if not splitted) | Uint64LE |
| 0x54 | 0x4 | Checksum of the previous package (0x0 if not splitted or not existing) | Uint32LE |
| 0x58 | 0x4 | Checksum of the next package (0x0 if not splitted or not existing) | Uint32LE |
| 0x5C | 0x4 | ID of this package (0x0 if not splitted) (0 is the first part, 1 is the second, ...) | Uint32LE |
| 0x60 | 0x10 | Comment | UTF-8 |
| 0x70 | 0x10 | Generator credits, the official JavaScript library puts `hssp 5.0.0 @ npm` in here. Acridotheres uses `acridotheres.com`. | UTF-8 |

##### 2.6.3.2. Flags

| Bit | Name | Description |
| :-: | :------------------------------- | :-------------------------------------------------------------------------- |
| 0 | Is encrypted | If this bit is set, the file is encrypted. |
| 1 | Is compressed | If this bit is set, the file is compressed. |
| 2 | Is splitted | If this bit is set, the file is splitted. |
| 3 | Continues previous split package | If this bit is set, the file continues the previous split package. |
| 4 | Continues next split package | If this bit is set, the file continues the next split package. |
| 5 | Compression before encryption | If this bit is set, the file is encrypted before instead after compression. |
| 6 | F7 | Unused. |
| 7 | F8 | Unused. |

##### 2.6.3.3. Index

The index length is calculated like this: `IE \* FC + IL`, this is now required due to index encryption & compression.

The index is structured like this:

| Offset | Length | Description | Type |
| :----------------------: | :---------: | :----------------------------------------------------------------------------------------------------------------------- | :------: |
| 0x0 | 0x8 | File length in Bytes | Uint64LE |
| 0x8 | 0x2 | Name length in Bytes (= NL) | Uint16LE |
| 0xA | NL | Name of the file | UTF-8 |
| 0xA+NL | 0x2 | Owner length in Bytes (= OL) | Uint16LE |
| 0xC+NL | OL | Owner of the file | UTF-8 |
| 0xC+NL+OL | 0x2 | Owner group length in Bytes (= GL) | Uint16LE |
| 0xE+NL+OL | GL | Owner group of the file | UTF-8 |
| 0xE+NL+OL+GL | 0x4 | Web link length in Bytes (= WL) | Uint32LE |
| 0x12+NL+OL+GL | WL | Web link of the file | UTF-8 |
| 0x12+NL+OL+GL+WL | 0x6 | File creation time as Unix timestamp (ms) | Uint48LE |
| 0x18+NL+OL+GL+WL | 0x6 | File modification time as Unix timestamp (ms) | Uint48LE |
| 0x1E+NL+OL+GL+WL | 0x6 | File access time as Unix timestamp (ms) | Uint48LE |
| 0x24+NL+OL+GL+WL | 0x1 + 1 bit | File permissions (chmod format) | binary |
| 0x25+NL+OL+GL+WL + 1 bit | 7 bit | File attributes (is folder, is hidden, is system file, enable backup, require backup, is read-only, is main file) | binary |
| 0x26+NL+OL+GL+WL | 0x1 | File attributes 2 (is encrypted, is compressed, connected for encryption, connected for compression, 4 unallocated bits) | binary |
| 0x27+NL+OL+GL+WL | 0x4 | Chain MurmurHash3 checksum | binary |
| 0x2B+NL+OL+GL+WL | 0x8 | File length after encryption & compression | Uint64LE |

Repeat this for every file.

##### 2.6.3.4. Body

The body consists of multiple files.

A file is structured like this:

| Offset | Length | Description | Type |
| :----: | :----: | :------------ | :--: |
| 0x0 | ? | File contents | |

## 3. Compression algorithms

| Name | IDXD code |
| :----------: | :-------: |
| No algorithm | `NONE` |
| LZMA | `LZMA` |
| DEFLATE | `DFLT` |
| Name | IDXD/FLGD code | SPRD code |
| :----------: | :------------: | :----------------: |
| No algorithm | `NONE` | _not used anymore_ |
| LZMA | `LZMA` | `0x4950` |
| DEFLATE | `DFLT` | `0x4446` |

## 4. Contributors

Expand Down

0 comments on commit 40643b3

Please sign in to comment.