implementing-aes-encryption-for-data-at-rest
AES (Advanced Encryption Standard) is a symmetric block cipher standardized by NIST (FIPS 197) used to protect classified and sensitive data. This skill covers implementing AES-256 encryption in GCM m
What this skill does
# Implementing AES Encryption for Data at Rest ## Overview AES (Advanced Encryption Standard) is a symmetric block cipher standardized by NIST (FIPS 197) used to protect classified and sensitive data. This skill covers implementing AES-256 encryption in GCM mode for encrypting files and data stores at rest, including proper key derivation, IV/nonce management, and authenticated encryption. ## When to Use - When deploying or configuring implementing aes encryption for data at rest capabilities in your environment - When establishing security controls aligned to compliance requirements - When building or improving security architecture for this domain - When conducting security assessments that require this implementation ## Prerequisites - Familiarity with cryptography concepts and tools - Access to a test or lab environment for safe execution - Python 3.8+ with required dependencies installed - Appropriate authorization for any testing activities ## Objectives - Implement AES-256-GCM encryption and decryption for files - Derive encryption keys from passwords using PBKDF2 and Argon2 - Manage initialization vectors (IVs) and nonces securely - Encrypt and decrypt entire directory trees - Implement authenticated encryption to detect tampering - Handle large files with streaming encryption ## Key Concepts ### AES Modes of Operation | Mode | Authentication | Parallelizable | Use Case | |------|---------------|----------------|----------| | GCM | Yes (AEAD) | Yes | Network data, file encryption | | CBC | No | Decrypt only | Legacy systems, disk encryption | | CTR | No | Yes | Streaming encryption | | CCM | Yes (AEAD) | No | IoT, constrained environments | ### Key Derivation Never use raw passwords as encryption keys. Always derive keys using: - **PBKDF2**: NIST-approved, widely supported (minimum 600,000 iterations as of 2024) - **Argon2id**: Winner of Password Hashing Competition, memory-hard - **scrypt**: Memory-hard, good alternative to Argon2 ### Nonce/IV Management - GCM requires a 96-bit (12-byte) nonce that must NEVER be reused with the same key - Generate nonces using `os.urandom()` (CSPRNG) - Store nonce alongside ciphertext (it is not secret) ## Workflow 1. Install the `cryptography` library: `pip install cryptography` 2. Generate or derive an encryption key 3. Create a random nonce for each encryption operation 4. Encrypt data using AES-256-GCM with the key and nonce 5. Store nonce + ciphertext + authentication tag together 6. For decryption, extract nonce, verify tag, and decrypt ## Encrypted File Format ``` [salt: 16 bytes][nonce: 12 bytes][ciphertext: variable][tag: 16 bytes] ``` ## Security Considerations - Always use authenticated encryption (GCM, CCM) to prevent tampering - Never reuse a nonce with the same key (catastrophic in GCM) - Use at least 256-bit keys for long-term data protection - Securely wipe keys from memory after use when possible - Rotate encryption keys periodically per organizational policy - For disk-level encryption, consider XTS mode (AES-XTS) ## Validation Criteria - [ ] AES-256-GCM encryption produces valid ciphertext - [ ] Decryption recovers original plaintext exactly - [ ] Authentication tag detects any ciphertext modification - [ ] Key derivation uses sufficient iterations/parameters - [ ] Nonces are never reused for the same key - [ ] Large files (>1GB) can be processed via streaming - [ ] Encrypted file format includes all necessary metadata
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.