Download the PHP package k2gl/sshsig without Composer
On this page you can find all versions of the php package k2gl/sshsig. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package sshsig
Short Description Pure-PHP SSHSIG signing and verification, compatible with ssh-keygen -Y.
License MIT
Homepage https://github.com/k2gl/sshsig
Informations about the package sshsig
k2gl/sshsig
Sign and verify files with SSH keys in PHP, in the OpenSSH SSHSIG format that ssh-keygen -Y sign/verify produces (the signatures Git uses for commit and tag signing). Verifying checks
the signer against an allowed_signers file; signing emits bytes ssh-keygen -Y verify
accepts. No dependencies.
Fail-closed by design: anything malformed, unsupported, cryptographically invalid, or unauthorized throws — nothing is ever silently treated as verified.
Install
Requires PHP 8.1+ with ext-sodium (Ed25519) and ext-openssl (RSA and ECDSA) — both are
bundled with most PHP builds.
Usage
Verify a signature against an allowed_signers file
This is the equivalent of ssh-keygen -Y verify -f allowed_signers -I <identity> -n <namespace>.
Check a signature without authorizing the signer
The equivalent of ssh-keygen -Y check-novalidate -n <namespace>: confirm the signature is
structurally sound and cryptographically valid under its own embedded key, then inspect it.
Sign a message
Produce an SSHSIG signature (the ssh-keygen -Y sign operation). Provide the signing key —
Ed25519 (a 64-byte libsodium secret key) or an OpenSSL RSA/ECDSA private key:
$signer->publicKey() returns the matching SshPublicKey (e.g. to build an allowed_signers
line). The default hash is sha512; pass hashAlgorithm: 'sha256' to switch.
Inspect or build allowed_signers in memory
Design
- Fail-closed. Every failure path throws a
K2gl\Sshsig\Exception\SshsigException(InvalidSignatureException,UnsupportedAlgorithmException,SignatureVerificationFailed,SignerNotAllowedException). A returned value always means verified. - Spec-accurate. Implements OpenSSH
PROTOCOL.sshsig: theSSHSIGmagic preamble, version 1, theto-be-signedblob (namespace + reserved + hash algorithm + message hash), and the armor. - Algorithms.
ssh-ed25519,rsa-sha2-256,rsa-sha2-512,ecdsa-sha2-nistp256/384/521;sha256andsha512message hashing. The legacy SHA-1ssh-rsasignature algorithm is refused. allowed_signers. Principals pattern-lists,namespaces=,valid-after/valid-beforevalidity windows, andcert-authorityentries (parsed and recorded; certificate-chain verification is not yet performed).- Signing.
SshsigSignerover a pluggableSigningKey(Ed25519 via ext-sodium; RSA and ECDSA via ext-openssl), producing armor byte-compatible withssh-keygen -Y verify.OpensshPrivateKey::fromFile()/::fromString()load an unencryptedssh-ed25519key straight from theopenssh-key-v1containerssh-keygenwrites by default; encrypted containers and RSA/ECDSA containers are refused (fail-closed) rather than partially read. - Zero dependencies. Pure PHP over
ext-sodiumandext-openssl; nophpseclib. - Verified against OpenSSH. The test suite verifies real
ssh-keygen -Y signoutput for every supported algorithm, plus tampered, wrong-namespace, unauthorized, and malformed cases.
License
MIT. See LICENSE.