6.2 Cryptography Fundamentals: Encryption & Hashing
Key Takeaways
- The four foundational cryptographic objectives are confidentiality (preventing unauthorized disclosure), integrity (detecting unauthorized modification), authentication (verifying entity identity), and non-repudiation (preventing denial of authorship).
- Symmetric key cryptography uses a single shared secret key for encryption and decryption (e.g., AES-128, AES-256), delivering high computational throughput for bulk data but requiring secure out-of-band key distribution channels (requiring N(N-1)/2 keys for N users).
- Asymmetric key cryptography utilizes mathematically linked public-private key pairs (e.g., RSA-2048/4096, ECC P-256/384); data encrypted with the public key can only be decrypted by the private key, and data signed with the private key can be verified by anyone possessing the public key.
- Cryptographic hash functions are deterministic, one-way mathematical transformations generating fixed-size digests (e.g., SHA-256) exhibiting pre-image resistance and collision resistance; salting hashes defends against rainbow table attacks.
- Digital signatures bind identity and document integrity by hashing plaintext and encrypting the digest with the sender's private key; the recipient verifies authenticity and non-repudiation by decrypting the signature with the sender's public key and comparing it to a freshly calculated hash.
Cryptography Fundamentals: Encryption & Hashing
Quick Summary: Cryptography provides the mathematical mechanisms that safeguard electronic assets, financial records, and network communications. For CPA auditors evaluating SOC criteria and IT General Controls, cryptographic assurance depends upon understanding the functional divisions between symmetric encryption (bulk confidentiality), asymmetric encryption (key exchange and non-repudiation), cryptographic hashing (data integrity), and comprehensive key management lifecycles under standards such as NIST SP 800-57.
1. The Four Foundational Pillars of Cryptography
Every cryptographic protocol and control mechanism is engineered to satisfy one or more of four core security objectives:
- Confidentiality: Ensuring that data cannot be viewed, intercepted, or understood by unauthorized individuals or processes. Confidentiality transforms human-readable plaintext into unreadable ciphertext using cryptographic algorithms and secret encryption keys.
- Integrity: Guaranteeing that information has not been altered, corrupted, injected, or deleted in transit or storage—whether accidentally via transmission noise or maliciously by an attacker. Integrity is verified using cryptographic hash functions and Message Authentication Codes (MACs).
- Authentication: Proving the claimed identity of a communicating entity (user, machine, server, or API client). Cryptographic authentication relies on public-key digital certificates, challenge-response handshakes, or pre-shared cryptographic secrets.
- Non-Repudiation: Preventing an entity from falsely denying the authenticity of a submitted transaction, signature, message, or approval. Non-repudiation requires asymmetric public-key cryptography: because only the signer possesses the unique private signing key, a verified digital signature provides legally binding proof of origin.
| Cryptographic Objective | Primary Cryptographic Mechanism | Failure Mode / Threat Mitigated | Audit Evidence |
|---|---|---|---|
| Confidentiality | Symmetric & Asymmetric Encryption | Eavesdropping, data breach, packet sniffing | Encryption cipher suite configurations, database encryption settings |
| Integrity | Cryptographic Hashing (SHA-256), HMAC | Man-in-the-Middle tampering, data corruption | File integrity monitoring (FIM) logs, checksum verification scripts |
| Authentication | Digital Certificates (X.509), Mutual TLS | Impersonation, spoofing, rogue servers | Certificate authority trust chains, client certificate authentication logs |
| Non-Repudiation | Asymmetric Digital Signatures | Repudiation of financial wire transfers or approvals | Cryptographically signed transaction logs, digital signature audit trails |
2. Symmetric Cryptography: The Shared Secret Engine
Symmetric encryption—also known as private-key or single-key encryption—employs an identical shared secret key for both encryption and decryption:
Modern Symmetric Ciphers
- Advanced Encryption Standard (AES): Established by NIST in 2001 (FIPS 197), AES is the global gold standard for symmetric encryption. AES operates on fixed 128-bit blocks of data using key lengths of 128, 192, or 256 bits. AES-256 is universally mandated for top-secret government records, financial data at rest, and military communications. Brute-forcing an AES-256 key is computationally impossible with classical computers.
- Modes of Operation: Block ciphers require an operational mode to encrypt payloads exceeding 128 bits:
- Cipher Block Chaining (CBC): Chains ciphertext blocks using an Initialization Vector (IV); vulnerable to padding oracle attacks if improperly implemented.
- Galois/Counter Mode (GCM): Combines counter-mode encryption with Galois field authentication, providing Authenticated Encryption with Associated Data (AEAD). GCM provides both confidentiality and data integrity simultaneously with high hardware-accelerated throughput.
- Legacy / Deprecated Ciphers:
- Data Encryption Standard (DES): Uses a 56-bit key; cracked in 1997 via brute force and strictly prohibited.
- Triple DES (3DES): Applies DES three times (168-bit or 112-bit effective key); deprecated by NIST due to 64-bit block collision vulnerabilities (Sweet32 attack).
Operational Characteristics: Strengths and Critical Bottlenecks
- Strengths: Blazing computational speed. Symmetric algorithms execute in hardware-accelerated CPU instructions (e.g., Intel AES-NI), processing gigabytes of data per second with negligible latency. They are ideally suited for bulk encryption of large files, databases, and high-bandwidth network links.
- The Key Distribution Dilemma: Because sender and receiver must share the identical key, the key must be transmitted across a secure out-of-band channel before encrypted communication can commence.
- The Key Scalability Formula: In an organization of $N$ communicating participants requiring pairwise confidentiality, the total number of unique symmetric keys required is:
For an enterprise of 1,000 users, managing pairwise symmetric encryption would require 499,500 individual secret keys—an administrative impossibility without public-key cryptography.
3. Asymmetric Cryptography: Public-Key Infrastructure
Asymmetric cryptography solves the key distribution dilemma by utilizing mathematically linked key pairs: a Public Key (which is published openly to the world) and a Private Key (which must be kept strictly secret by the owner):
Core Asymmetric Algorithms
- RSA (Rivest-Shamir-Adleman): Founded on the mathematical difficulty of factoring the product of two massive prime numbers.
- Key Length Standard: NIST mandates a minimum key length of 2048 bits for general commercial use, with 3072 or 4096 bits recommended for long-term protection.
- Elliptic Curve Cryptography (ECC): Based on the algebraic structure of elliptic curves over finite fields (e.g., ECDSA, Ed25519).
- Efficiency Advantage: ECC provides equivalent cryptographic strength to RSA with drastically smaller keys. A 256-bit ECC key delivers security equivalent to a 3072-bit RSA key, requiring significantly less battery power, memory, and network bandwidth. ECC is the standard for mobile devices, IoT, and modern TLS connections.
- Diffie-Hellman Key Exchange (DH / ECDH): A mathematical protocol enabling two parties to establish a shared symmetric secret key over an insecure, eavesdropped channel without transmitting the secret itself.
Asymmetric Key Scalability
In an asymmetric cryptosystem, each user requires exactly one key pair (2 keys). For $N$ users, the total number of keys required is simply:
For 1,000 users, only 2,000 keys exist across the enterprise, and the 1,000 public keys can reside in an open, searchable corporate directory.
Hybrid Cryptosystems: Real-World Implementation
Because asymmetric algorithms are 100 to 1,000 times slower than symmetric ciphers due to intensive modular exponentiation, production systems never use asymmetric encryption to encrypt bulk files or databases. Instead, modern protocols (including TLS, SSH, and PGP) employ a hybrid cryptosystem:
- Asymmetric cryptography (or Diffie-Hellman) authenticates the parties and securely negotiates a temporary, random symmetric session key.
- Symmetric cryptography (AES-GCM) encrypts the actual data payload using the session key.
- The session key is destroyed upon session termination.
| Feature | Symmetric Cryptography | Asymmetric Cryptography |
|---|---|---|
| Keys Used | 1 shared secret key | 2 mathematically linked keys (Public & Private) |
| Computational Speed | Extremely fast (hardware-accelerated, bulk data) | Slow (mathematically intensive, small data payloads) |
| Key Length (Equivalent) | 128-bit or 256-bit (AES) | 2048-bit / 4096-bit (RSA) or 256-bit (ECC) |
| Key Scaling Formula | N(N - 1) / 2 keys | 2N keys |
| Primary Use Cases | Full disk encryption, database encryption, bulk payloads | Key exchange, digital signatures, identity certificates |
| Non-Repudiation | No (both parties hold identical key) | Yes (only one party holds the private key) |
4. Cryptographic Hash Functions and Integrity Verification
A cryptographic hash function is a mathematical algorithm that takes an arbitrary-length block of data and transforms it into a fixed-size bit string known as a hash value, message digest, or checksum:
Essential Mathematical Properties of Cryptographic Hashes
To provide security assurance, a hash function must satisfy six non-negotiable properties:
- Deterministic: The exact same input message will always generate the exact same hash output.
- Fixed Output Length: Regardless of whether the input is a single character or a 10-terabyte database backup, the hash output length is constant (e.g., SHA-256 always outputs exactly 256 bits / 64 hexadecimal characters).
- One-Way / Pre-Image Resistance: Given a hash value $h$, it is computationally impossible to invert the function to find the original message $m$ such that $H(m) = h$.
- Second Pre-Image Resistance (Weak Collision Resistance): Given a specific input $m_1$, it is computationally impossible to find a different input $m_2$ such that $H(m_1) = H(m_2)$.
- Collision Resistance (Strong Collision Resistance): It is computationally impossible to find any two arbitrary, distinct messages $m_1$ and $m_2$ that produce the identical hash digest $H(m_1) = H(m_2)$.
- The Avalanche Effect: Changing a single bit in the input message causes a dramatic, unpredictable transformation in more than 50% of the output digest bits.
Algorithm Standards: Active vs. Deprecated
- MD5 (Message Digest 5): 128-bit output. Cryptographically broken; collision attacks can generate matching hashes in seconds. Strictly prohibited on CPA audit engagements.
- SHA-1 (Secure Hash Algorithm 1): 160-bit output. Broken by Google and CWI Amsterdam in 2017 (SHAttered attack). Prohibited.
- SHA-2 Family (SHA-256, SHA-384, SHA-512): Published by NIST (FIPS 180-4). Widely deployed, robust industry standard for blockchain, TLS certificates, and integrity monitoring.
- SHA-3 Family: Published by NIST in 2015 (FIPS 202) based on the Keccak permutation. Provides cryptographic resilience against future mathematical breakthroughs against SHA-2.
Password Storage: Salting, Peppering, and Adaptive Hashes
Storing plaintext passwords in databases violates basic security criteria. However, standard hashing (e.g., standard SHA-256) is vulnerable to Rainbow Table attacks (precomputed tables of billions of hashed common passwords).
- Salting: A unique, cryptographically random string (the salt) is generated for each user and concatenated with the password before hashing: $\text{Hash} = H(\text{Password} \parallel \text{Salt})$. The salt is stored in plaintext alongside the hash. Salting completely neutralizes precomputed rainbow tables and prevents two users with identical passwords from sharing the same hash digest.
- Peppering: A secret value (the pepper) stored outside the database (e.g., in an HSM) is concatenated with the password, preventing offline cracking if the database alone is breached.
- Adaptive / Work-Factor Hashes: Fast hashes like SHA-256 allow an attacker with modern GPUs to compute billions of guesses per second. Enterprise authentication systems mandate slow, memory-hard key derivation functions such as bcrypt, PBKDF2, or Argon2, which enforce tunable computational work factors.
5. Digital Signatures: Step-by-Step Generation and Verification
A digital signature is a cryptographic construct that binds a document or message to the sender's identity, providing integrity, authentication, and non-repudiation.
Phase 1: Signature Generation (Sender)
- The sender hashes the plaintext document using SHA-256 to generate a 256-bit message digest: $\text{Digest} = H(\text{Document})$.
- The sender encrypts the digest with their Private Key, producing the Digital Signature: $\text{Signature} = E_{\text{Sender Private Key}}(\text{Digest})$.
- The sender transmits the original plaintext document alongside the attached digital signature to the recipient.
Phase 2: Signature Verification (Recipient)
- The recipient receives the plaintext document and attached digital signature.
- The recipient decrypts the digital signature using the Sender's Public Key to recover the original message digest: $\text{Recovered Digest} = D_{\text{Sender Public Key}}(\text{Signature})$.
- The recipient independently calculates the hash of the received plaintext document using the identical algorithm: $\text{Calculated Digest} = H(\text{Document})$.
- The recipient compares the recovered digest to the newly calculated digest:
- If Recovered Digest == Calculated Digest: The signature is VALID. This proves that the document was not altered in transit (integrity) and that only the holder of the sender's private key could have authored it (authentication and non-repudiation).
- If Recovered Digest != Calculated Digest: The signature is INVALID. Either the document was modified in transit or the signature was created using an unauthorized private key.
Why Asymmetric Signatures Guarantee Non-Repudiation
In a symmetric HMAC system, both parties share the secret key; therefore, either party could have generated the tag, eliminating legal non-repudiation. In a digital signature, only the sender possesses the private signing key. Because the signature can only be decrypted and validated using the sender's known public key, the sender cannot deny having authored the document.
6. Protection of Data Across the Three States
Data protection strategies differ fundamentally based on the operational state of the data:
Data at Rest
Data residing statically on physical storage media (hard drives, solid-state drives, SANs, tape backups, cloud object storage):
- Full Disk Encryption (FDE): Encrypts the entire storage drive at the hardware controller level (e.g., BitLocker, FileVault). Protects against physical laptop or drive theft; however, when the OS is running and unlocked, files are decrypted and vulnerable to malware.
- File- and Folder-Level Encryption: Encrypts individual files; protects data even if an attacker gains OS-level access.
- Database Encryption:
- Transparent Data Encryption (TDE): Automatically encrypts database files at rest on the storage volume.
- Column-Level / Application-Level Encryption: Specific sensitive columns (e.g., Social Security numbers, credit card primary account numbers) are encrypted by the application before entering the database. Even database administrators (
sa) querying the raw tables see only ciphertext.
Data in Transit (In Motion)
Data traversing internal or external networks between clients, servers, and cloud endpoints:
- Protected using cryptographic transport protocols: TLS 1.3, IPsec VPNs, and SSH/SFTP.
- Mitigates eavesdropping, man-in-the-middle tampering, and session hijacking.
Data in Use (In Processing)
Data currently loaded into volatile system memory (RAM, CPU registers, CPU cache) being processed by an active application:
- Historically, data had to be decrypted in RAM to be processed, leaving it vulnerable to memory scraping malware, kernel dumps, and rogue hypervisors.
- Confidential Computing / Hardware TEEs: Technologies such as Intel SGX (Software Guard Extensions) and AMD SEV (Secure Encrypted Virtualization) establish hardware-enforced Trusted Execution Environments (TEEs) that encrypt memory at the hardware bus level. Even an attacker with root access or cloud hypervisor control cannot inspect memory contents.
- Homomorphic Encryption: An emerging cryptographic paradigm allowing mathematical computations to be performed directly on ciphertext without decrypting it first.
7. Cryptographic Key Management Lifecycle (NIST SP 800-57)
Cryptographic algorithms (such as AES-256) are open public standards; the security of any system depends entirely on protecting the cryptographic keys (Kerckhoffs's Principle). A failure in key management renders the strongest cipher useless.
Lifecycle Stages and Controls
- Key Generation: Keys must be generated using cryptographically secure pseudorandom number generators (CSPRNG) utilizing hardware entropy sources (thermal noise, clock drift) to ensure unguessable randomness.
- Key Storage: Keys must never be hardcoded into application source code or stored in plaintext configuration files. Master keys must be stored within Hardware Security Modules (HSMs)—specialized, tamper-resistant physical appliances certified under FIPS 140-2 / FIPS 140-3 (Levels 1 through 4). HSMs zero out (destroy) keys upon detection of physical tampering.
- Key Distribution and Escrow: Transport of keys must occur using Key Encryption Keys (KEKs) or secure asymmetric wrapping.
- Key Rotation (Cryptoperiods): Every key has an authorized operational lifespan (cryptoperiod). Keys must be rotated periodically (e.g., annual rotation for data-at-rest keys) to limit the amount of data exposed if a key is compromised.
- Key Revocation and Destruction: When a key is retired or suspected of compromise, it must be permanently destroyed. In cloud environments, crypto-shredding refers to destroying the encryption key that protects data, instantly rendering the stored ciphertext permanently indecipherable without requiring multi-pass physical wiping of multi-tenant cloud storage.
Split Knowledge and Dual Control
For high-risk operations—such as generating a root CA key or recovering master encryption keys—organizations enforce Split Knowledge and Dual Control (e.g., Shamir's Secret Sharing or M-of-N quorum approval). No single administrator possesses the complete key or can perform administrative key actions alone; at least two authorized key custodians must enter their individual key components simultaneously.
A healthcare enterprise requires an integrity and authentication solution that prevents hospital physicians from later denying that they authorized high-risk prescription drug orders entered into the electronic health records system. Which cryptographic mechanism is strictly required to provide this legal non-repudiation?
An enterprise is architecting an encryption solution to protect massive, multi-terabyte financial transaction database tables at rest. The primary engineering requirements are maximum processing throughput, minimal CPU latency, and high-performance bulk decryption. Which cryptographic approach is best suited for this operational requirement?
An IT auditor is testing an automated system interface that validates digitally signed electronic vendor invoices. The interface decrypts incoming invoice digital signatures using the vendor's verified public key, recalculates the SHA-256 hash of the received invoice document, and rejects any invoice where the two values do not match. If the system rejects a submitted invoice due to a hash mismatch, which of the following represents the most direct conclusion?