Detached Signatures and Signature Formats
What you'll learn: How signatures can be stored separately from data or embedded within it, and the standard formats used in real-world systems.
Two Ways to Package a Signature
When you digitally sign data (like a document or software package), you have two fundamental choices for storing that signature:
Embedded signatures bundle the signature and the original data together into a single file. Think of this like signing a physical document and then laminating it with the original—everything stays together as one unit.
Detached signatures keep the signature in a separate file from the data being signed. Imagine signing a physical document and keeping your signature on a separate authentication certificate. The data file remains unchanged, while the signature lives in its own .sig or similar file.
Why Choose Detached?
Detached signatures are essential when:
- You can't or don't want to modify the original file (like signed executables or read-only archives)
- You need to verify data without extracting it from a container
- Multiple parties sign the same document independently
Common Signature Formats
PGP/GPG signatures are widely used for email, software packages, and file signing. They support both detached (.asc or .sig files) and embedded formats.
CMS/PKCS#7 is the standard for enterprise systems, email (S/MIME), and document signing. It supports detached signatures for flexibility and embedded for convenience.
Both formats encode the signature algorithm used (like RSA-PSS or ECDSA), the signer's certificate chain, and optionally timestamps.
Choosing the Right Format
Use detached when the original file must remain unchanged or when space matters. Use embedded when you want a single, self-contained signed artifact that's easier to distribute.
Key takeaway: Detached signatures keep data and signature separate for flexibility, while embedded signatures bundle them together; PGP and CMS/PKCS#7 are the most common formats supporting both approaches.