Use this when proving data integrity and origin with digital signatures.
Digital Signatures
A digital signature is created with a private key over a hash of data, and anyone with the public key can verify that the data is unchanged and came from the key holder. It underpins certificates and code signing.
1. Digital signatures verify software, documents, containers, updates.
2. Verify before trusting.
3. Protect signing keys (HSM, keyless signing with transparency logs).
4. Timestamps for long-term validity.
5. Check revocation.
artifact → signature → verify with trusted key
Context & applicabilityCommon mistakes · platform/version boundaries
- Verifying a signature but not who owns the key (no trust chain).
- Signing a hash with a weak algorithm (SHA-1).
- Code signing keys on build servers without HSM protection.
- Not timestamping code signatures, so they become invalid when the certificate expires.
Operational reference
Fast context before you go deeper.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Sign with the private key; verify with the public key.
- The signature covers a hash of the data.
- Trust depends on how the public key is obtained.
gpg --verify file.sig file— verify signaturecosign verify --key cosign.pub <image>— container signatureGet-AuthenticodeSignature <file.exe>— Windows code signing
ReferenceWhy it matters1 section · depth on demand
Signing and verifying
openssl dgst -sha256 -sign private.key -out file.sig file
openssl dgst -sha256 -verify public.pem -signature file.sig file
Documented example, not captured output. Uses: code signing, package signatures (apt, rpm, container images with Cosign), certificates, DNSSEC, Git commit signing. Verification must also check that the public key is trusted for that purpose.
ReferenceHow it works1 section · depth on demand
In depth
Digital signatures in asymmetric cryptography use a private key to sign a hash of the data and the public key to verify it. Verification proves the data came from the key holder and was not modified.
| Algorithm | Notes |
|---|---|
| RSA-PSS / RSA PKCS#1 v1.5 | Widely used; 2048+ bits |
| ECDSA (P-256, P-384) | Smaller keys; requires good random nonces |
| Ed25519 | Fast, deterministic, simple to use correctly |
| ML-DSA, SLH-DSA | Post-quantum signatures (NIST 2024) |
ssh-keygen -Y sign -f ~/.ssh/id_ed25519 -n file release.tar.gz
ssh-keygen -Y verify -f allowed_signers -I admin@example.com -n file -s release.tar.gz.sig < release.tar.gz
A signature is only as trustworthy as the binding between public key and identity — provided by certificates, key servers or out-of-band verification.
ReferenceConfiguration & state1 section · depth on demand
Commands
openssl dgst -sha256 -sign priv.key -out file.sig file.txt
openssl dgst -sha256 -verify pub.pem -signature file.sig file.txt
ssh-keygen -Y sign -f ~/.ssh/id_ed25519 -n file file.txt
Documented example, not captured output. A signature shows the holder of the private key signed the exact bytes; it says nothing about whether that key is trusted — that is the PKI's job.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Asymmetric Cryptography → Digital Signatures. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://csrc.nist.gov/pubs/fips/186-5/final · confidence 94%