Henry Carrasco

SecurePack

Wraps any Windows program in a signed container and decides, with no network, whether it is allowed to run.

Year
2026
My role
System design, cryptography and full development
Team
solo
Sector
Software distribution and protection
  • C#
  • .NET
  • Cryptography
  • Windows
  • PowerShell
The protection step of the wizard: the three licence modes with their trade-off written beside each one, hardware-change tolerance and content encryption

The problem

What was wrong

Once you hand a program to a client, the file stops being under your control: it gets copied to another machine and keeps running just the same. What exists to prevent that splits into two families, and both fail at the same point: either they require a permanent connection — and the client cuts internet access on day one, which is entirely their right — or they put the password inside the very binary you deliver, which is locking a door and taping the key to the frame. I wanted execution control that works offline, that does not touch a single byte of the original software, and whose real ceiling I could write down without overselling it.

The constraints

  • No network. The whole validation happens on the client machine, which may have internet deliberately cut off: a design that depends on their connectivity protects nothing.
  • No touching other people’s software. The program goes in as it is and comes out byte for byte identical. No recompiling, patching or injecting into something I did not write.
  • The verifier has to run on .NET Framework 3.5 over CLR 2.0: part of the estate is a freshly installed Windows 7 where nothing else is available.
  • Zero external dependencies in what gets delivered. Every third-party library is attack surface and weight in a binary that travels to other people’s machines.
  • Whoever carries the key must not be able to alter it. The technician doing the install is precisely who needs to be controlled.

What I built

The solution

  • Three actors separated by design: the issuer generates and signs, the verifier only checks against the public key, and transport — email, USB, clipboard — decides nothing. The client machine never generates a key: it generates a request.
  • A container format of my own, `.spkg`: a fixed-length header, a canonical CBOR manifest signed with ECDSA P-256, and a payload encrypted with AES-256-GCM using each file’s canonical path as authenticated data.
  • The cryptographic layer on CNG, the one Windows already ships: ECDSA, ECDH, AES-GCM, HKDF and HMAC without a single third-party library in the delivered binary.
  • The core — contracts, cryptography, format, domain and verifier — written once and compiled for .NET 8 and .NET Framework 3.5, with no branches or copies, and shared vectors proving both builds produce the same bytes.
  • Three licence modes that travel inside the signed manifest, so the client cannot change them. In strict mode the content is bound to the licence: without it the package is not a locked executable, it is an inert encrypted blob.
  • A clock resistant to being turned back, activation state sealed with DPAPI and HMAC in two locations, and hardware machine identity with matching that tolerates one changed component but never two.
  • A catalogue of 29 error codes with cause and action, a command-line tool with 14 commands, and a graphical interface with a seven-step wizard.

Seeing it work

Screenshots

How I did it

My part and my decisions

Separating what I designed from what I implemented does not take anything away: it is what lets you tell whether I can carry a design or only execute one.

01

What was mine

What I designed

The whole system before writing it: the separation into three actors, the container format, the key-wrapping scheme, the three licence modes, the hardware-change tolerance rule and the threat model with its ceiling. Eight versions of the planning document, each one closing decisions before any code was touched.

What I implemented

The eleven projects in the solution: contracts and canonical CBOR, the cryptographic layer, the format reader and writer, the domain, machine identity, the issuer, the packager, the verifier, both launchers and the command line. 87 C# files. Plus the graphical interface, the parity vectors and the delivery script.

Who I worked with

A personal project, from end to end. No reviewer, so the rules — verify before interpreting, zero dependencies in what ships, no symmetric secrets inside the client’s binary — had to be written down and defended in a document before they existed in code. It is the only way I know for a rule to survive the week when it gets in the way.

What I learned here

That in applied cryptography the format design matters more than the choice of algorithm. Anyone can pick AES and ECDSA; where the signature goes, what enters the authenticated data and in what order the file is read is what decides whether the system holds. Also that writing down what it does NOT stop is part of the job: a protection document that only lists what it blocks is useless for deciding, and it invites you to promise too much.

02

Technical decisions

The signature is verified before the manifest is interpreted

The natural thing is to parse the manifest and check the signature afterwards, because you need the fields to know what you signed. I ruled it out: that turns the parser into the first surface an attacker touches, fed with data they control. Before verifying, only the fixed header lengths are read and checked to fit inside the file. Nothing else. The price is a more rigid format; the gain is that a tampered `.spkg` never reaches the code that understands it.

A canonical CBOR of my own instead of JSON

What gets signed has to be identical bytes on .NET 8 and on CLR 2.0, and JSON gives no such guarantee without a separate specification: key order, whitespace and number formatting all depend on the serializer. I wrote a deterministic CBOR canonicalisation and a reader that rejects anything non-canonical, with the tests pinning that definition. It costs a module of my own, and it pays for itself the day two different runtimes have to agree byte for byte.

What is missing: signing the launcher with Authenticode

Today the launcher the client receives ships unsigned, and that leaves a door the threat model itself names: someone can build their own launcher with their own key and their own package. What it does not give them is opening mine — without my signature my `.spkg` fails verification — but the defence against binary substitution is the Authenticode signature. The path is built and in the right order; the certificate is what is missing.

03

What broke, and how I fixed it

The same bytes on two runtimes fifteen years apart

The first version compiled for .NET 8 and .NET Framework 3.5 from the same source and everything looked fine, until a manifest signed on one failed to validate on the other. The cause was not the cryptography: it was serialization differences that looked reasonable on each platform. I fixed it by pushing canonicalisation down to explicit rules and creating a shared vectors project that generates cases on net8 and checks them on net35. Since then parity is not a hope, it is a test that fails if someone breaks it.

Signing at the wrong moment breaks the signature

The launcher carries a footer with the build secret and who it trusts, appended at the end of the executable. Signing with Authenticode before appending it left the signature broken, because the Authenticode hash covers those bytes. It sounds obvious put that way and it cost me an afternoon. The tool now enforces the order — append the footer, then sign — instead of leaving it to whoever uses it to remember.

How it holds up

Security, errors, performance and maintainability

What keeps a system standing after it is written. Where I have not measured it, I say so.

Security
It is the purpose of the system, not a layer on top: signature checked before anything is interpreted, constant-time secret comparison, hard depth and size limits in the reader, the canonical path as authenticated data so a file cannot be moved within the package, and path validation on extraction to close directory escape. Raw hardware values never leave the machine: only hashes travel.
Errors
Twenty-nine `SP-Ennnn` codes, each with a cause and an action. No stray exception reaches the face of whoever is using the tool, and a validation failure can be diagnosed over the phone by reading out a code.
Performance
The launcher the client receives is 131 KB and starts without downloading anything: all validation is local and amounts to cryptography over a few megabytes, with hardware-accelerated AES since it goes through CNG. Chunked encryption exists so a large package does not have to fit in memory at once.
Maintainability
The core is written once and compiled for both platforms, with no branches or duplicated files; the shared vectors warn if they ever stop matching. 125 tests — 99 on .NET 8 and 26 parity tests on .NET 3.5 — and the architecture, the format and the threat model are written in the repository, not in my head.

Outcome

What changed

The full cycle works end to end on a single machine: package a multi-file program, deliver it as one executable, request the key, issue it, activate it and run offline with the content bound to the licence, with the verifier running on .NET 3.5. What ships is 131 KB with no dependencies. And the part of the project I value most is not what it stops but having written down, in the same repository, what it does not: an administrator sitting at the machine can copy the decrypted content while the program runs, and no wrapper solves that.