skills/encryption-pattern/SKILL.md
Security pattern for implementing encryption and decryption operations. Use when encrypting data for confidentiality, selecting encryption algorithms (AES, RSA), configuring cipher modes (GCM, CBC), choosing key lengths, or implementing symmetric/asymmetric encryption. Specialization of Cryptographic action pattern addressing confidentiality requirements.
npx skillsauth add igbuend/grimbard encryption-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.
Encrypt a message (data elements and/or action requests) to ensure its confidentiality with respect to entities that do not possess the correct decryption key.
| Role | Type | Responsibility | |------|------|----------------| | EntityA | Entity | Wants to encrypt one or more data elements and/or action requests | | EntityB | Entity | Wants to decrypt received ciphertext (may be same as EntityA) | | Encrypter | Cryptographic Primitive | Library providing encryption action | | Decrypter | Cryptographic Primitive | Library providing decryption action |
Note: Encrypter and Decrypter roles can be performed by a single library instance. Similarly, EntityA and EntityB can be the same entity.
EntityA → [encrypt(plaintext, keyInfo, config)] → Encrypter
Encrypter → [ciphertext] → EntityA
EntityB → [decrypt(ciphertext, keyInfo, config)] → Decrypter
Decrypter → [plaintext] → EntityB
Recommendation: Use symmetric ciphers for encrypting data. Use asymmetric ciphers only where appropriate (key exchange, small data).
| Algorithm | Key Length | Status | |-----------|------------|--------| | AES | 128 bits | Minimum recommended | | AES | 256 bits | Recommended for long-term (30-50 years) | | DES | 56 bits | Deprecated - never use | | 3DES/TDEA | 168 bits | Deprecated - decrypt legacy only | | Salsa/ChaCha | Variable | Use with caution (less studied than AES) |
Preferred: AES with minimum 128-bit key length. Use AES-256 for long-term protection.
| Mode | Status | Notes | |------|--------|-------| | GCM | Recommended | Authenticated encryption | | CCM | Recommended | Authenticated encryption | | CBC | Acceptable | Requires separate MAC | | CTR | Acceptable | Stream mode, needs MAC | | ECB | Never use | Reveals patterns in plaintext |
Critical: Always use authenticated encryption modes (GCM, CCM) when possible. They provide both confidentiality AND integrity.
| Algorithm | Key Length | Status | |-----------|------------|--------| | RSA | 3072 bits | Recommended (≈ AES-128 security) | | RSA | 2048 bits | Minimum acceptable | | RSA-PKCS#1 v1.5 | Any | Avoid (padding oracle attacks) |
Note: RSA-3072 provides security strength comparable to AES-128.
Specialization of Cryptographic action.Reuse existing libraries:
Specialization of Cryptographic action.Use keys for single purpose:
Specialization of Cryptographic action.Design for change:
General consensus: Use authenticated encryption modes for symmetric ciphers.
Benefits:
If Entity must provide random values (nonces, initialization vectors):
Since plaintext needed encryption, it is likely sensitive:
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.