PHPackages                             k2gl/dsse - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. k2gl/dsse

ActiveLibrary[Security](/categories/security)

k2gl/dsse
=========

Sign and verify DSSE (Dead Simple Signing Envelope) payloads in PHP, with pluggable keys

1.3.3(2w ago)02.5k↑273.9%5MITPHPPHP &gt;=8.1CI passing

Since May 30Pushed 2w ago1 watchersCompare

[ Source](https://github.com/k2gl/dsse)[ Packagist](https://packagist.org/packages/k2gl/dsse)[ Docs](https://github.com/k2gl/dsse)[ RSS](/packages/k2gl-dsse/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (6)Dependencies (8)Versions (9)Used By (5)

k2gl/dsse
=========

[](#k2gldsse)

[![CI](https://camo.githubusercontent.com/7ebbcb15b7d5a0bfd4ecf176dda4d269818e7862da10cc9c518ae46ffb976f61/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6b32676c2f647373652f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4349266c6f676f3d676974687562)](https://github.com/k2gl/dsse/actions/workflows/ci.yml)[![Latest Stable Version](https://camo.githubusercontent.com/12b91eb759d27976b13bb68c4a2e3c3e07df880978ed18bd5ee3b58727fd90f9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b32676c2f647373653f6c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/k2gl/dsse)[![Total Downloads](https://camo.githubusercontent.com/f0d19137b0d7da92fe9a04ba3ee2873a523374522dbdab0c1778930f74d0cb8a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b32676c2f647373653f6c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/k2gl/dsse)[![PHPStan Level](https://camo.githubusercontent.com/01c58e66f2fafb70c17613ff2b1da3f549aade3a735b076da5cd9e5c04b945a5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230392d3261356561373f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://phpstan.org)[![License](https://camo.githubusercontent.com/bbb2fd72ec4813f697919d6ce205858ce95ed8bb35ceecbd08fd5f4ba9bbb1ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6b32676c2f647373653f636f6c6f723d79656c6c6f77677265656e)](https://packagist.org/packages/k2gl/dsse)

Sign and verify DSSE (Dead Simple Signing Envelope) payloads in PHP with pluggable keys. It's the envelope Sigstore, in-toto, SLSA and npm provenance use to wrap a signed payload.

It gives you the three pieces of the spec and nothing else:

- **PAE** — the exact, binary-safe byte string that gets signed.
- **Envelope** — the JSON envelope (`payload` / `payloadType` / `signatures`) with lossless (de)serialization.
- **Signer / Verifier** — tiny interfaces so you can plug in any key (or a remote KMS/HSM). ECDSA (P-256/384/521), Ed25519, and RSA (PKCS#1 v1.5) implementations are included.

Install
-------

[](#install)

```
composer require k2gl/dsse
```

Requires PHP 8.1+. The bundled signers use `ext-openssl` (ECDSA P-256/384/521, RSA) and `ext-sodium` (Ed25519); both ship with PHP by default. The core (`Pae`, `Envelope`) needs neither.

Usage
-----

[](#usage)

### PAE — what actually gets signed

[](#pae--what-actually-gets-signed)

```
use K2gl\Dsse\Pae;

Pae::encode('http://example.com/HelloWorld', 'hello world');
// "DSSEv1 29 http://example.com/HelloWorld 11 hello world"
```

Lengths are **byte** counts, so the encoding is unambiguous for any payload, including binary data.

### Sign

[](#sign)

```
use K2gl\Dsse\Envelope;
use K2gl\Dsse\EcdsaP256Signer;

$signer   = EcdsaP256Signer::fromPem($privateKeyPem, keyId: 'k1');
$envelope = Envelope::sign('hello world', 'http://example.com/HelloWorld', $signer);

echo $envelope->toJson();
// {"payload":"aGVsbG8gd29ybGQ=","payloadType":"http://example.com/HelloWorld","signatures":[{"keyid":"k1","sig":"..."}]}
```

`Envelope::sign()` accepts several signers to produce a multi-signature envelope.

### Verify

[](#verify)

```
use K2gl\Dsse\Envelope;
use K2gl\Dsse\EcdsaP256Verifier;
use K2gl\Dsse\Exception\SignatureVerificationFailed;

$envelope = Envelope::fromJson($json);

try {
    $payload = $envelope->verify(EcdsaP256Verifier::fromPem($publicKeyPem));
    // $payload === 'hello world'
} catch (SignatureVerificationFailed) {
    // no signature matched any supplied verifier
}
```

The envelope is accepted if **any** signature verifies against **any** verifier you pass, mirroring the spec's verification model. Pass several verifiers to accept a set of trusted keys.

### Ed25519

[](#ed25519)

```
use K2gl\Dsse\Ed25519Signer;
use K2gl\Dsse\Ed25519Verifier;

$keypair  = sodium_crypto_sign_keypair();
$signer   = new Ed25519Signer(sodium_crypto_sign_secretkey($keypair), 'ed-1');
$verifier = new Ed25519Verifier(sodium_crypto_sign_publickey($keypair));
```

### ECDSA P-384 / P-521 and RSA

[](#ecdsa-p-384--p-521-and-rsa)

The other bundled algorithms follow the same `fromPem()` pattern:

```
use K2gl\Dsse\EcdsaP384Signer;
use K2gl\Dsse\EcdsaP384Verifier;
use K2gl\Dsse\RsaSigner;
use K2gl\Dsse\RsaVerifier;

$signer   = EcdsaP384Signer::fromPem($p384PrivateKeyPem);
$verifier = EcdsaP384Verifier::fromPem($p384PublicKeyPem);

// RSASSA-PKCS1-v1_5; hash algorithm defaults to sha256 (sha384/sha512 also supported)
$rsaSigner   = RsaSigner::fromPem($rsaPrivateKeyPem, hashAlgorithm: 'sha512');
$rsaVerifier = RsaVerifier::fromPem($rsaPublicKeyPem, hashAlgorithm: 'sha512');
```

`EcdsaP521Signer` / `EcdsaP521Verifier` work identically.

### Loading a key without knowing its algorithm

[](#loading-a-key-without-knowing-its-algorithm)

When a key arrives as a PEM file or a JWK from a JWKS endpoint, `PublicKey` picks the right verifier for you — RSA, ECDSA (P-256/384/521) or Ed25519 — so you don't have to branch on the algorithm yourself:

```
use K2gl\Dsse\PublicKey;

$verifier = PublicKey::fromPem($publicKeyPem); // detects the algorithm and curve
$verifier = PublicKey::fromJwk($jwk);          // EC / RSA / OKP (Ed25519)

$payload = $envelope->verify($verifier);
```

RSA keys carry no hash, so these verify with SHA-256; for another hash use `RsaVerifier::fromPem($pem, hashAlgorithm: 'sha512')` directly.

`KeyId` computes the two identifiers commonly used for a signature's `keyId`:

```
use K2gl\Dsse\KeyId;

KeyId::sha256Spki($publicKeyPem); // hex SHA-256 of the DER key (cosign / Sigstore style)
KeyId::jwkThumbprint($jwk);       // RFC 7638 base64url thumbprint
```

### Plugging in your own key backend

[](#plugging-in-your-own-key-backend)

Implement two methods to sign with a KMS/HSM or any other scheme:

```
use K2gl\Dsse\Signer;

final class KmsSigner implements Signer
{
    public function sign(string $message): string { /* sign PAE bytes, return raw signature */ }
    public function keyId(): ?string { return 'arn:aws:kms:...'; }
}
```

Design
------

[](#design)

- **Crypto-agnostic core.** `Pae` and `Envelope` carry no cryptography; signing is delegated to `Signer` / `Verifier`, so you control the algorithm and key storage.
- **Raw signatures.** The bundled ECDSA signers emit raw `r||s` signatures (64/96/132 bytes for P-256/384/521) (the form DSSE/JOSE/WebCrypto/Sigstore use), converting to and from OpenSSL's DER internally. The verifier accepts both raw `r||s` and ASN.1 DER signatures, detecting the encoding automatically — so DER signatures (OpenSSL native, Sigstore bundles) verify without any extra wiring.
- **Strict and typed.** `declare(strict_types=1)` throughout, analysed at PHPStan level 9; every exception implements `DsseException`.

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

Based on the DSSE specification (Apache-2.0) by the Secure Systems Lab; this is an independent, clean-room PHP implementation.

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance96

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

8

Last Release

20d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6bc4aa529c7f13ea593297497f6eae20d5c07f476baa0a551960d7e6ff1e5413?d=identicon)[k2gl](/maintainers/k2gl)

---

Top Contributors

[![k2gl](https://avatars.githubusercontent.com/u/2846079?v=4)](https://github.com/k2gl "k2gl (27 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

signaturesigningEd25519ECDSAenvelopeattestationsupply-chaindssepaein-totosigstoreslsa

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/k2gl-dsse/health.svg)

```
[![Health](https://phpackages.com/badges/k2gl-dsse/health.svg)](https://phpackages.com/packages/k2gl-dsse)
```

###  Alternatives

[phpseclib/phpseclib

PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.

5.6k465.6M1.6k](/packages/phpseclib-phpseclib)[simplito/elliptic-php

Fast elliptic curve cryptography

2302.4M275](/packages/simplito-elliptic-php)[ionux/phactor

Phactor is a high-performance PHP implementation of the elliptic curve math functions required to generate &amp; verify private/public (asymmetric) EC keypairs and ECDSA signatures based on secp256k1 curve parameters. This library also includes a class to generate Service Identification Numbers (SINs) based on the published Identity Protocol v1 spec.

5387.3k30](/packages/ionux-phactor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
