Cryptography Fundamentals for Engineers

Khimananda Oli 8 min read Database
Cryptography Fundamentals for Engineers

By Khimananda Oli | Last reviewed: August 2026

Cryptography fundamentals for engineers are no longer optional theory reserved for security specialists; they are baseline requirements for building compliant, resilient cloud infrastructure. When you configure a load balancer, rotate database credentials, or sign container images, you are making cryptographic decisions that directly impact your system's integrity and audit posture. This guide strips away the academic abstraction to focus on the applied primitives, protocols, and operational patterns you actually encounter in production environments.

What Are the Core Cryptography Fundamentals for Engineers?

At the operational level, cryptography solves three specific problems: keeping data secret, proving data hasn't changed, and verifying identity. Confusing these primitives is the most common source of security vulnerabilities I see during infrastructure audits. Encryption provides confidentiality but does not guarantee integrity; an attacker can flip bits in a ciphertext stream without knowing the key. Hashing guarantees integrity but provides zero confidentiality. Digital signatures bind identity to data.

For modern infrastructure, you must distinguish between symmetric and asymmetric operations. Symmetric algorithms (AES-256-GCM, ChaCha20-Poly1305) handle bulk data encryption because they are fast. Asymmetric algorithms (RSA-4096, ECDSA P-256/P-384, Ed25519) handle key exchange and signing because they enable trust without shared secrets. Never use raw RSA for encrypting application data; it is slow and padding-oracle attacks are subtle. Always use hybrid schemes where asymmetric crypto establishes a session key for symmetric encryption.

Applied Cryptography PrimitivesSymmetric EncryptionAES-256-GCM / ChaCha20• Bulk Data Confidentiality• Single Shared Secret• Fast & AuthenticatedAsymmetric CryptoECDSA / Ed25519 / RSA• Key Exchange (TLS)• Digital Signatures• Trust Without SharingCryptographic HashingSHA-256 / SHA-3 / BLAKE3• Integrity Verification• One-Way Function• Password Storage (w/ Salt)Hybrid Model (TLS / Envelope Encryption)Asymmetric keys negotiate session → Symmetric keys encrypt payloadNever use raw asymmetric encryption for application data
Core cryptography fundamentals for engineers: symmetric, asymmetric, and hashing primitives working together in hybrid models

In my work preparing teams for SOC 2 and ISO 27001 audits, the most frequent finding isn't weak algorithms—it's misapplied ones. Using MD5 for checksums is acceptable; using it for password storage is a critical failure. Understanding Kubernetes secrets management done right requires knowing why base64 encoding is not encryption and why etcd encryption at rest matters. Similarly, when you handle secrets in CI/CD pipelines safely, you're applying these exact primitives to prevent credential leakage during build processes.

How Does TLS 1.3 Handshake Actually Work?

TLS 1.3 is the current standard for transport security, and understanding its handshake is essential for debugging latency and certificate issues. Unlike TLS 1.2, which required two round trips, TLS 1.3 completes the handshake in one round trip (1-RTT) for new connections and zero round trips (0-RTT) for resumption. This performance gain comes from combining key exchange and authentication into the ClientHello message.

The 1-RTT Handshake Sequence

  1. ClientHello: The client sends supported cipher suites, key shares (typically X25519 or P-256), and signature algorithms. Crucially, it includes the key share upfront, not in a separate ServerKeyExchange step.
  2. ServerHello + EncryptedExtensions: The server selects parameters, provides its key share, and immediately switches to encrypted communication. Everything after ServerHello is encrypted, including the certificate.
  3. Certificate + CertificateVerify: The server proves ownership of the private key by signing the handshake transcript. This replaces the old ServerKeyExchange signature.
  4. Finished: Both parties confirm the handshake integrity. Application data can flow immediately after the server's Finished message.

This design eliminates downgrade attacks and removes support for legacy, broken ciphers. TLS 1.3 only supports AEAD (Authenticated Encryption with Associated Data) ciphers: AES-128-GCM, AES-256-GCM, and ChaCha20-Poly1305. CBC mode and RC4 are gone. If you're still seeing TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA in your logs, something is misconfigured or running outdated software.

TLS 1.3 Handshake (1-RTT)ClientServerClientHello(Key Share + Cipher Suites)ServerHello(Selected Params + Key Share){EncryptedExtensions}{Certificate + Verify}{Finished}{Finished}← 1 RTT Complete →{ } = Encrypted with Handshake Keys | Application Data flows immediately after Server Finished
TLS 1.3 reduces handshake latency to 1-RTT by combining key exchange and authentication, a critical improvement over TLS 1.2

A common mistake in 2026 is disabling TLS 1.3 "for compatibility." Modern browsers and cloud providers have supported it for years. Disabling it forces fallback to weaker ciphers and adds latency. When configuring Nginx or HAProxy, explicitly set ssl_protocols TLSv1.3 TLSv1.2; and prefer server-side cipher ordering. For deeper network configuration context, see the Ubuntu security hardening guide which covers TLS stack tuning alongside OS-level controls.

When Should You Use Hashing Versus Encryption?

This distinction causes more production incidents than almost any other cryptographic confusion. Encryption is reversible; hashing is not. If you need to retrieve the original data, use encryption. If you need to verify data or store credentials, use hashing. Never encrypt passwords; hash them with a memory-hard function.

CriterionEncryption (AES-GCM, ChaCha20)Hashing (SHA-256, Argon2id)
ReversibilityReversible with correct keyOne-way; computationally infeasible to reverse
Primary Use CaseData confidentiality (at rest/in transit)Integrity checks, password storage, deduplication
Output LengthSame as input + tag overheadFixed length regardless of input size
Key RequiredYes (symmetric or asymmetric)No (except HMAC/KDF variants)
Password StorageNEVER — key compromise exposes all passwordsALWAYS — use Argon2id or bcrypt with salt
Tamper DetectionAEAD provides authentication, but decryption neededInstant comparison without secret material

For password hashing in 2026, Argon2id is the recommended algorithm. It resists both GPU parallelization and side-channel attacks by requiring configurable memory and time costs. Bcrypt remains acceptable for legacy systems but lacks memory hardness. SHA-256 alone is never appropriate for passwords, even with salt; it's too fast and allows billions of guesses per second on commodity hardware.

# Generate Argon2id hash with recommended parameters
# Memory: 64 MiB, Iterations: 3, Parallelism: 4
echo -n "user_password" | argon2 salt_value -id -t 3 -m 16 -p 4

# Verify hash programmatically (Python example)
from argon2 import PasswordHasher
ph = PasswordHasher(time_cost=3, memory_cost=65536, parallelism=4)
hash = ph.hash("user_password")
ph.verify(hash, "user_password")  # Returns True or raises exception

For integrity verification of files, container images, or API payloads, SHA-256 or BLAKE3 are appropriate. BLAKE3 offers superior performance on modern CPUs while maintaining security margins. When signing artifacts for supply chain security, combine hashing with asymmetric signatures using tools like Sigstore Cosign, not bare hashes.

How Do You Manage Keys and Secrets in Production?

Cryptographic strength is irrelevant if keys are stored in plaintext configuration files or committed to Git. Proper key management separates the data encryption key (DEK) from the key encryption key (KEK). This envelope encryption pattern is foundational to AWS KMS, GCP Cloud KMS, Azure Key Vault, and HashiCorp Vault.

Envelope Encryption Workflow

  • Generate DEK locally: Create a random symmetric key in application memory. Never transmit the plaintext DEK.
  • Encrypt data with DEK: Use AES-256-GCM to encrypt your payload. Store the ciphertext and nonce/tag alongside the data.
  • Encrypt DEK with KEK: Call the KMS API to encrypt the DEK. The KMS never sees your data, only the small DEK.
  • Store encrypted DEK: Persist the encrypted DEK next to the ciphertext. Discard the plaintext DEK from memory immediately.
  • Decrypt on read: Retrieve encrypted DEK → call KMS to decrypt → use recovered DEK to decrypt data → wipe DEK from memory.

This pattern limits blast radius. Compromising the database gives an attacker only encrypted data and encrypted DEKs. They cannot decrypt without also compromising the KMS, which has separate access controls, audit logging, and rotation policies. For Kubernetes environments, integrate external secrets operators to inject decrypted values at runtime rather than storing them in etcd. The secrets management with HashiCorp Vault guide details dynamic secret generation and lease-based revocation, which further reduces exposure windows.

Envelope Encryption PatternApplicationPlaintext DataCiphertext + NonceAES-256-GCM Local EncryptStorage LayerEncrypted DEKCiphertext + NoncePersist TogetherKMS / HSMMaster KEKHardware BackedAudit LoggedAuto-RotationEncrypt DEKKMS APIStore CiphertextSecurity BoundaryDatabase breach exposes only encrypted data + encrypted DEKsDecryption requires separate KMS compromise + valid IAM permissions
Envelope encryption separates data protection from key management, limiting blast radius in breach scenarios

Key rotation deserves special attention. Rotate KEKs annually or after suspected compromise. With envelope encryption, rotating the KEK doesn't require re-encrypting terabytes of data—only re-encrypting the small DEKs. Automate this process; manual rotation fails under pressure. For Nepal-based fintech or healthtech companies handling sensitive data under local regulatory expectations, envelope encryption with region-local KMS endpoints satisfies data residency requirements while maintaining global security standards.

Applying Cryptography Fundamentals for Engineers in Production

Mastering cryptography fundamentals for engineers means moving beyond textbook definitions to operational discipline. Start by auditing your current stack: verify TLS versions and cipher suites with nmap --script ssl-enum-ciphers, check password hashing algorithms against Argon2id/bcrypt standards, and confirm all secrets use envelope encryption or a managed secrets service. Remove every instance of plaintext credentials in code, configs, and environment variables. Implement automated scanning with tools like Gitleaks and Trivy in your CI pipeline to catch regressions before deployment.

Security is not a feature you add later; it's an architectural constraint you design around from day one. Whether you're securing a Laravel API, hardening a Kubernetes cluster, or preparing for your first SOC 2 audit, these cryptographic primitives form the foundation of trust. If your team needs hands-on guidance implementing these patterns or preparing infrastructure for compliance review, reach out to discuss your specific architecture. Getting cryptography right prevents breaches that no amount of monitoring can fix after the fact.

Frequently Asked Questions

Symmetric encryption uses one shared key for both encryption and decryption, making it fast for bulk data. Asymmetric encryption uses public-private key pairs for secure key exchange and digital signatures but is computationally slower.

Use Argon2id or bcrypt with appropriate cost factors. Never use MD5 or SHA-256 alone for passwords. These memory-hard functions resist GPU-based attacks and include built-in salting mechanisms specifically designed for credential storage security.

Always use cryptographically secure pseudorandom number generators like os.urandom in Python or random_bytes in PHP. Standard math library random functions are predictable and unsuitable for security tokens, keys, or nonces in production systems.

Yes, AES-GCM provides authenticated encryption.

Minimum 3072 bits for RSA, though 4096 is safer for long-term security. Many organizations now prefer ECDSA with P-256 or Ed25519 curves, which offer equivalent security with smaller keys and better performance for TLS and signing operations.

Rotate data encryption keys annually or after suspected compromise. Master keys in KMS should rotate every three years. Implement automatic rotation policies in AWS KMS or HashiCorp Vault to minimize manual overhead and reduce exposure windows.

Salts prevent rainbow table attacks by ensuring identical passwords produce different hashes. Each user gets a unique, randomly generated salt stored alongside the hash. This forces attackers to compute separate tables per account rather than using precomputed lookup tables.

No, never roll custom cryptography.

TLS 1.3 removes legacy cipher suites, mandates forward secrecy, and reduces handshake latency to one round trip. It eliminates vulnerable algorithms like RC4 and CBC mode ciphers while simplifying configuration and reducing attack surface compared to TLS 1.2 deployments.

Forward secrecy ensures past sessions remain secure even if long-term private keys are later compromised. Achieved through ephemeral key exchanges like ECDHE, it prevents mass surveillance and limits damage from key theft in breach scenarios.

Always verify the full chain to a trusted root CA, check expiration dates, and validate hostname matching. Use standard libraries rather than custom validation logic. Pin certificates only when necessary, as pinning breaks during routine certificate renewals.

Accepting none algorithm, storing secrets in code, missing expiration claims, and skipping signature verification are frequent errors. Always enforce RS256 or ES256, use short-lived tokens with refresh rotation, and validate all claims server-side before trusting payload data.

Shor's algorithm threatens RSA and ECC by solving factoring and discrete log problems efficiently. NIST has standardized post-quantum algorithms like ML-KEM and ML-DSA. Engineers should begin testing hybrid modes now to prepare for migration timelines expected around 2028.

Use truffleHog for secret scanning, testssl.sh for TLS configuration checks, and cryptolint for code analysis. Integrate these into CI to catch weak algorithms, hardcoded keys, and misconfigured certificates before deployment reaches staging or production environments.

TODO: write this answer during review — the model returned fewer than 15 FAQs.