skills/digital-signature-pattern/SKILL.md
Security pattern for implementing digital signatures. Use when implementing document signing, code signing, certificate signing, non-repudiation, or verifying authenticity and integrity of messages using asymmetric cryptography (RSA, ECDSA, Ed25519).
npx skillsauth add igbuend/grimbard digital-signature-patternInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Create and verify digital signatures to ensure data integrity, authenticity, and non-repudiation using asymmetric cryptography.
| Role | Type | Responsibility | |------|------|----------------| | EntityA | Entity | Creates digital signatures | | EntityB | Entity | Verifies digital signatures | | Signature Generator | Cryptographic Primitive | Creates signatures | | Signature Verifier | Cryptographic Primitive | Verifies signatures |
EntityA → [sign(message, private_key)] → Signature Generator
Signature Generator → [signature] → EntityA
EntityA → [message + signature] → EntityB
EntityB → [verify(message, signature, public_key)] → Signature Verifier
Signature Verifier → [valid/invalid] → EntityB
| Aspect | Digital Signature | MAC | |--------|------------------|-----| | Key type | Asymmetric (public/private) | Symmetric (shared) | | Non-repudiation | Yes | No | | Verification key | Public (distributable) | Secret (shared) | | Performance | Slower | Faster | | Use case | External parties, legal | Internal, performance |
Use digital signatures when non-repudiation required or verifiers shouldn't be able to create signatures.
| Variant | Status | Notes | |---------|--------|-------| | RSA-PSS | Recommended | Probabilistic padding | | RSA-PKCS#1 v1.5 | Acceptable | Deterministic, widely supported |
Key sizes:
| Algorithm | Curve | Status | |-----------|-------|--------| | Ed25519 | Curve25519 | Recommended (modern) | | ECDSA | P-256 | Recommended | | ECDSA | P-384 | High security | | ECDSA | P-521 | Highest security |
Key sizes:
Never: MD5, SHA-1
Critical: Private key security = signature trustworthiness
Verifier must trust public key belongs to signer:
Typically, signature is over hash of message:
Library usually handles this—verify behavior.
Some signature schemes are malleable (valid signature can be modified to create another valid signature). Use signature schemes that prevent malleability or handle at application layer.
| Mistake | Impact | Fix | |---------|--------|-----| | Weak key size | Forgery possible | Use recommended sizes | | MD5/SHA-1 | Collision attacks | Use SHA-256+ | | Private key exposure | Full compromise | Secure storage (HSM) | | Skipping verification | Accept forged data | Always verify | | Trusting unverified public key | Accept attacker's signature | Establish key authenticity |
development
Security anti-pattern for Cross-Site Scripting vulnerabilities (CWE-79). Use when generating or reviewing code that renders HTML, handles user input in web pages, uses innerHTML/document.write, or builds dynamic web content. Covers Reflected, Stored, and DOM-based XSS. AI code has 86% XSS failure rate.
development
Security anti-pattern for XPath injection vulnerabilities (CWE-643). Use when generating or reviewing code that queries XML documents, constructs XPath expressions, or handles user input in XML operations. Detects unescaped quotes and special characters in XPath queries.
development
Security anti-pattern for weak password hashing (CWE-327, CWE-759). Use when generating or reviewing code that stores or verifies user passwords. Detects use of MD5, SHA1, SHA256 without salt, or missing password hashing entirely. Recommends bcrypt, Argon2, or scrypt.
development
Security anti-pattern for weak encryption (CWE-326, CWE-327). Use when generating or reviewing code that encrypts data, handles encryption keys, or uses cryptographic modes. Detects DES, ECB mode, static IVs, and custom crypto implementations.