Skip to main content

A library for decrypting LTspice®, PSpice®, and QSPICE® encrypted files

Project description

SpiceCrypt

A Python library and CLI tool for decrypting encrypted SPICE model files. SpiceCrypt supports LTspice®, PSpice®, and QSPICE® encryption formats with automatic format detection, enabling engineers to use lawfully obtained models in any simulator.

Features

  • LTspice text-based format — Custom DES variant used in encrypted .CIR, .SUB, .LIB, .ASY, and other files
  • LTspice Binary File format — Two-layer XOR stream cipher identified by the <Binary File> signature
  • PSpice Modes 0–5 — Custom DES (modes 0–2) and AES-256 ECB (modes 3–5) with $CDNENCSTART/$CDNENCFINISH delimited blocks
  • PSpice Mode 4 key recovery — Brute-force recovery of the user-supplied encryption key via a hardware-accelerated Rust extension (AES-NI / ARM Crypto)
  • QSPICE protected blocks.prot/.unprot sub-circuit protection: randomized base-16 encoding, a seed-keyed dual stream cipher, DEFLATE compression, and Windows-1252 keyword detokenization
  • Automatic format detection — All formats are detected and handled transparently
  • Streaming API — Memory-efficient processing for large files
  • No runtime dependencies — Pure Python with an optional compiled Rust extension for key recovery

Installation

Install from PyPI:

pip install spice-crypt

Or with uv:

uv tool install spice-crypt

Or add as a dependency to an existing project:

uv add spice-crypt

Updating

pip install --upgrade spice-crypt    # pip
uv tool upgrade spice-crypt          # uv tool
uv lock --upgrade-package spice-crypt # uv project dependency

Requirements

  • Python 3.10 or higher
  • No runtime dependencies for decryption
  • Rust toolchain required only to build the optional extension for Mode 4 key recovery

Command Line Usage

SpiceCrypt provides the spice-crypt command. All encryption formats are auto-detected.

# Run directly without installing
uvx spice-crypt path/to/encrypted_file.lib

# Decrypt to stdout
spice-crypt path/to/encrypted_file.lib

# Decrypt to a file
spice-crypt -o output.lib path/to/encrypted_file.lib

# Force overwrite if output file exists
spice-crypt -f -o output.lib path/to/encrypted_file.lib

# Verbose output (shows verification values)
spice-crypt --verbose path/to/encrypted_file.lib

# Suppress all error messages
spice-crypt --quiet -o output.lib path/to/encrypted_file.lib

# Process raw hex data (bypass LTspice format detection)
spice-crypt --raw path/to/hex_file.txt

# Show version
spice-crypt --version

PSpice Mode 4

Mode 4 is the only PSpice mode that uses a user-supplied encryption key. SpiceCrypt can recover this key via brute force or decrypt directly if the key is known.

# Brute-force recover the user key (~seconds on modern hardware)
spice-crypt --recover-key path/to/encrypted_file.lib

# Decrypt with a known user key
spice-crypt --user-key KEY path/to/encrypted_file.lib

Key recovery exploits a bug in PSpice's key derivation that reduces the effective keyspace from 2^256 to 2^32. See SPECIFICATIONS/pspice-attack-summary.md for details.

Python API

decrypt_stream(input_file, output_file=None, is_ltspice_file=None, user_key=None)

Stream-decrypt from a file path or file object. Supports all LTspice, PSpice, and QSPICE formats with automatic detection.

from spice_crypt import decrypt_stream

# Decrypt file to file
_, verification = decrypt_stream("encrypted.lib", "decrypted.lib")

# Decrypt file to string
plaintext, verification = decrypt_stream("encrypted.lib")

# Use file objects
with open("encrypted.lib") as infile:
    plaintext, verification = decrypt_stream(infile)

# PSpice Mode 4 with a user key
plaintext, _ = decrypt_stream("encrypted.lib", user_key=b"mykey")

Parameters:

  • input_file — File path (str/PathLike) or file object (text or binary mode).
  • output_file (optional) — File path (str) or binary-mode file object. If None, returns decrypted content as a string.
  • is_ltspice_file (bool, optional) — Whether the data is in LTspice format. If True, skip PSpice detection; if False, treat as raw hex. Auto-detected if None.
  • user_key (bytes, optional) — User key bytes for PSpice Mode 4 decryption.

Returns: (content, (v1, v2))content is the decrypted string if no output file was given, otherwise None. (v1, v2) are format-specific verification values: CRC-based checksums for LTspice text format, CRC-32 and rotate-left hash for Binary File format, (0, 0) for PSpice format, or (block_count, 0) for QSPICE format (the number of protected blocks decrypted).

decrypt(data, is_ltspice_file=None)

Decrypt an in-memory string of encrypted data. Supports LTspice text-based format, raw hex, PSpice text-based formats, and QSPICE .prot protected blocks (but not Binary File format or PSpice Mode 4 with a user key).

from spice_crypt import decrypt

with open("encrypted.lib") as f:
    data = f.read()

plaintext, (v1, v2) = decrypt(data)

Parameters:

  • data (str) — Encrypted data as a string (LTspice format, PSpice format, or raw hex).
  • is_ltspice_file (bool, optional) — Whether the data is in LTspice format. Auto-detected if None.

Returns: (plaintext, (v1, v2)) — The decrypted text and a tuple of format-specific verification values (see decrypt_stream above).

Lower-level APIs

The following classes are exported for direct use:

  • LTspiceFileParser — Text-based DES format parser
  • BinaryFileParser — Binary File format parser
  • PSpiceFileParser — PSpice format parser (modes 0–5)
  • QSpiceFileParser — QSPICE .prot protected-block parser
  • CryptoState — LTspice DES key derivation and per-block decryption
  • LTspiceDES — LTspice custom DES variant
  • PSpiceDES — PSpice custom DES variant
  • QSpiceCipher — QSPICE .prot decode, decrypt, inflate, and detokenize primitives

Supported Formats

LTspice Text-Based DES

Encrypted files contain hex-encoded ciphertext delimited by * Begin: and * End <v1> <v2> comment markers. The first 1024 bytes form a crypto table used for key derivation and as an XOR keystream source. All subsequent blocks are decrypted with a custom DES variant that uses non-standard S-boxes and permutation tables, preceded by an XOR stream cipher layer keyed from the same table.

LTspice Binary File

Binary files are identified by a 20-byte signature (\r\n<Binary File>\r\n\r\n\x1a). Decrypted with a two-layer XOR stream cipher using two 32-bit keys from the file header and a 2593-byte substitution table with prime-based stepping.

PSpice Modes 0–5

Encrypted regions are delimited by $CDNENCSTART / $CDNENCFINISH markers within otherwise plaintext files. Six encryption modes exist:

Mode Cipher Key Source
0 Custom DES Hardcoded
1–2 Custom DES Hardcoded + version
3 AES-256 ECB Hardcoded + version
4 AES-256 ECB Hardcoded XOR user key + version
5 AES-256 ECB Hardcoded + version

Modes 0–3 and 5 use key material derived entirely from constants in the PSpice binary. Mode 4 incorporates a user-supplied key, but a bug in the key derivation passes only the short key to the AES engine instead of the extended key, leaving just 4 bytes unknown and reducing the effective keyspace to 2^32. This makes the key recoverable by brute force.

QSPICE Protected Blocks

QSPICE protects sub-circuit bodies with a .prot.unprot block embedded in otherwise plaintext model files. The payload is a randomized base-16 text encoding in which each plaintext byte becomes two glyphs from a fixed 64-character alphabet. A 32-bit seed, stored in the clear at the start of the block, keys two XOR keystreams — a Mersenne Twister stream and an additive walk over a fixed 9973-byte table — that together decrypt a DEFLATE (zlib) stream. The inflated netlist is stored in the Windows-1252 code page, in which QSPICE's special device prefixes and operators (Ã, Ø, ¥, , £, ×, «, », ´, µ) are high-bit bytes; SpiceCrypt decodes these to text and rewrites the micro sign µ to the ASCII u that other tools expect. Decryption replaces each protected block with the recovered plaintext, leaving surrounding lines unchanged. Because the seed is the only key material and is stored alongside the ciphertext, the scheme provides obfuscation rather than cryptographic protection.

Specifications

Detailed technical documentation of the encryption schemes:

Purpose and Legal Basis

Many third-party component vendors distribute SPICE models exclusively as LTspice- or PSpice-encrypted files. This encryption locks the models to a single simulator, preventing their use in open-source and alternative tools such as NGSpice, Xyce, PySpice, and others. SpiceCrypt exists to restore interoperability by allowing engineers to use lawfully obtained models in the simulator of their choice.

This type of reverse engineering for interoperability is specifically permitted by law:

  • United States: 17 U.S.C. § 1201(f) permits circumvention of technological protection measures for the sole purpose of achieving interoperability between independently created programs. Section 1201(f)(2) explicitly allows distributing the tools developed for this purpose to others seeking interoperability. Additionally, § 1201(g) permits circumvention when conducted in good-faith encryption research — studying the flaws and vulnerabilities of encryption technologies — and allows dissemination of the research findings.
  • European Union: Article 6 of the Software Directive (2009/24/EC) permits decompilation and reverse engineering when it is indispensable to achieve interoperability with independently created programs. Article 6(3) provides that this right cannot be overridden by contract.

Disclaimer

The legal justifications above pertain to the underlying research, technical analysis, and release of SpiceCrypt itself. They are provided to demonstrate that this work was conducted in good faith and to outline its intended purpose. They should not be construed as legal advice.

Encrypted SPICE models are often distributed under license agreements or terms of service that end users may have accepted. It is the end user's responsibility to ensure that their use of SpiceCrypt does not violate any such agreements or any applicable laws in their jurisdiction.

SpiceCrypt is intended solely for enabling simulator interoperability with lawfully obtained models. Using it to violate intellectual property rights is immoral and is not an acceptable use of the tool.

Research Contributors

  • Joe T. Sylve, Ph.D. — Reverse engineering and documentation of the LTspice text-based DES encryption format, PSpice encryption modes, and QSPICE .prot protected blocks.
  • Lucas Gerads — Reverse engineering and documentation of the LTspice Binary File encryption format.

Trademarks

LTspice® is a registered trademark of Analog Devices, Inc.
PSpice® is a registered trademark of Cadence Design Systems, Inc.
QSPICE® is a registered trademark of Qorvo US, Inc.

License

This project is licensed under the GNU Affero General Public License v3.0 or later.

Copyright (c) 2025–2026 Joe T. Sylve, Ph.D.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spice_crypt-3.0.1.tar.gz (165.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

spice_crypt-3.0.1-cp310-abi3-win_arm64.whl (210.9 kB view details)

Uploaded CPython 3.10+Windows ARM64

spice_crypt-3.0.1-cp310-abi3-win_amd64.whl (215.0 kB view details)

Uploaded CPython 3.10+Windows x86-64

spice_crypt-3.0.1-cp310-abi3-musllinux_1_2_x86_64.whl (527.5 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

spice_crypt-3.0.1-cp310-abi3-musllinux_1_2_aarch64.whl (484.2 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

spice_crypt-3.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (314.0 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

spice_crypt-3.0.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (306.8 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

spice_crypt-3.0.1-cp310-abi3-macosx_11_0_arm64.whl (280.2 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

spice_crypt-3.0.1-cp310-abi3-macosx_10_12_x86_64.whl (289.3 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file spice_crypt-3.0.1.tar.gz.

File metadata

  • Download URL: spice_crypt-3.0.1.tar.gz
  • Upload date:
  • Size: 165.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spice_crypt-3.0.1.tar.gz
Algorithm Hash digest
SHA256 2ee3efb3aa3601f0ad9a706f90dffd529a4d62d8efef3b547036a9ab41edb33e
MD5 73f300e8b76d14e4d436f8b7c588b4f8
BLAKE2b-256 6db60a49c3c29e64e9627776b15470fa9d5f16de487c0871d3774cf0f1ff9fec

See more details on using hashes here.

Provenance

The following attestation bundles were made for spice_crypt-3.0.1.tar.gz:

Publisher: publish.yml on jtsylve/spice-crypt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spice_crypt-3.0.1-cp310-abi3-win_arm64.whl.

File metadata

  • Download URL: spice_crypt-3.0.1-cp310-abi3-win_arm64.whl
  • Upload date:
  • Size: 210.9 kB
  • Tags: CPython 3.10+, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spice_crypt-3.0.1-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 e88607ece32687b4ab387dc54a8d6d07d6b35625f38c2b59967865fae54147e0
MD5 53bcb66add5a3e9e076eff16147e96d1
BLAKE2b-256 aee53e65ba1a979438395e8b945f1bfad877f2d3d4433157e18481285c1e10fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for spice_crypt-3.0.1-cp310-abi3-win_arm64.whl:

Publisher: publish.yml on jtsylve/spice-crypt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spice_crypt-3.0.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: spice_crypt-3.0.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 215.0 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spice_crypt-3.0.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d160d0daa56c57065d3adf5c6b08186dd10e62f918505fa3783180749f1ac0b4
MD5 65147a42daff53f0844a456297f9fdb5
BLAKE2b-256 b57ec4ee1a5be79b0b929e375f8062a2cbae6fe53576a551c386e7b657cff363

See more details on using hashes here.

Provenance

The following attestation bundles were made for spice_crypt-3.0.1-cp310-abi3-win_amd64.whl:

Publisher: publish.yml on jtsylve/spice-crypt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spice_crypt-3.0.1-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for spice_crypt-3.0.1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4dbe96777588dc839bca7b5fc4fec0c774f9f99f5d58f9070db3544e81f428c6
MD5 7c7223bf842d4371ffc56dc406163dbf
BLAKE2b-256 0ea181a273c79aae413e164c5002696e7460687876fcc4df7fb7fef8cc882c33

See more details on using hashes here.

Provenance

The following attestation bundles were made for spice_crypt-3.0.1-cp310-abi3-musllinux_1_2_x86_64.whl:

Publisher: publish.yml on jtsylve/spice-crypt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spice_crypt-3.0.1-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for spice_crypt-3.0.1-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 687ef30faecab7fdafb9f8a61416e27af5f6797365494301c147cd416a864698
MD5 468e3a0cb0e3293fd9bea85b79f8cdab
BLAKE2b-256 03782a92be8e6e393f9df422a53b0bc5e0dd71b05367391a82847e3beea39674

See more details on using hashes here.

Provenance

The following attestation bundles were made for spice_crypt-3.0.1-cp310-abi3-musllinux_1_2_aarch64.whl:

Publisher: publish.yml on jtsylve/spice-crypt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spice_crypt-3.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for spice_crypt-3.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 892ae6b47fc0d90d794b1577f1378054cfcfde1565a66b3341f852c3696ec428
MD5 374deee6215ebd275bfe3d903016b231
BLAKE2b-256 b3e161c8aa317b32096860c4301d7dae8e074b48b8d02e8f9307d1833cb2c261

See more details on using hashes here.

Provenance

The following attestation bundles were made for spice_crypt-3.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on jtsylve/spice-crypt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spice_crypt-3.0.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for spice_crypt-3.0.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 705ab5ed043a2ddee18ede19b7c217b78f647363ea90c0179223532536d1b46a
MD5 130270b987b1a5b20d1aa0fc662bb179
BLAKE2b-256 a31ea4ff1e488d8e9a399c1fa786fc7e31228f173979d82affe4252d06c3b8de

See more details on using hashes here.

Provenance

The following attestation bundles were made for spice_crypt-3.0.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on jtsylve/spice-crypt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spice_crypt-3.0.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for spice_crypt-3.0.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5dd62313f7b309dc29e9aa5bbcaee433b9d5cec5cea969046fcf9334763f3c03
MD5 b4e1e3c31b2553726cf12fcd4f1b411e
BLAKE2b-256 572daab8c5c8e79fb033889cee88e3dbf5f3a5c35316be7357018c053161ffa1

See more details on using hashes here.

Provenance

The following attestation bundles were made for spice_crypt-3.0.1-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on jtsylve/spice-crypt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spice_crypt-3.0.1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for spice_crypt-3.0.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a8c0133dbbc51bce26e28936d223b56ce202bdb9d991568dd9e0e1b9d3284eb5
MD5 d5390640100d719d58ead32f3152447c
BLAKE2b-256 d8be0a5d8a38bb2aa83b078f3d1d7245d2a1e699976c9eb770f95deec354dbb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for spice_crypt-3.0.1-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: publish.yml on jtsylve/spice-crypt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page