public JsonObject loadOptionalHeader(CartV1Decryptor decryptor)
			throws CartInvalidARC4KeyException, IOException {
		byte[] encryptedOptionalHeader = null;

		if (optionalHeaderLength > 0 && optionalHeaderLength <= (readerLength -
			CartV1Constants.HEADER_LENGTH - CartV1Constants.FOOTER_LENGTH)) {
			try {
				encryptedOptionalHeader = internalReader
						.readByteArray(CartV1Constants.HEADER_LENGTH, (int) optionalHeaderLength);
			}
			catch (IOException e) {
				// ignore
			}
		}

		if (encryptedOptionalHeader == null) {
			/**
			 * Initialize the optionalHeaderData as an empty JSON object when the optional
			 * header length or position is invalid, when the length is 0 which indicates
			 * that there is no optional header, or when reading the data failed.
			 */
			optionalHeaderData = new JsonObject();
		}
		else {

			String decryptedOptionalHeader = decryptor.decryptToString(encryptedOptionalHeader);

			if (decryptedOptionalHeader != null) {
				try {
					optionalHeaderData =
						JsonParser.parseString(decryptedOptionalHeader).getAsJsonObject();
				}
				catch (IllegalStateException | JsonSyntaxException e) {
					throw new CartInvalidARC4KeyException(
						"CaRT decrypted optional header not valid JSON.");
				}

				// If parsing failed without an exception and parseString returns `null`,
				// set to empty JSON object
				if (optionalHeaderData == null) {
					optionalHeaderData = new JsonObject();
				}
			}
			else {
				throw new CartInvalidARC4KeyException("CaRT optional header decryption failed.");
			}
		}

		return optionalHeaderData();
	}
Read and decrypt optional header data and return a copy.

@param decryptor An initialize decryptor with the correct ARC4 key
@return JsonObject read and decrypted from the header. Will be empty if no
        optional header is available.
@throws CartInvalidARC4KeyException If the decryption of JSON deserialization
                                    fails.
@throws IOException                 If there is a failure to read the header data.
Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/cart/CartV1Header.java