23  Encryption: Labs, Quiz, and Review

Quiz mastery targets are easiest to plan with threshold math:

\[ C_{\text{target}} = \left\lceil 0.8 \times N_{\text{questions}} \right\rceil \]

Worked example: For a 15-question quiz, target correct answers are \(\lceil 0.8 \times 15 \rceil = 12\). If a learner moves from 8/15 to 12/15, score rises from 53.3% to 80%, crossing mastery with four additional correct answers.

Learning Objectives

After completing this module, you will be able to:

  • Compare symmetric (AES) and asymmetric (RSA, ECC) encryption approaches and select the appropriate type for IoT use cases
  • Design multi-layer encryption architectures (E1-E5) based on threat models and device constraints
  • Evaluate encryption trade-offs for resource-constrained IoT devices including performance, power, and key management
  • Apply encryption concepts to real-world scenarios including medical IoT, smart grids, and OTA firmware updates
In 60 Seconds

This chapter combines hands-on encryption labs with a comprehensive quiz to consolidate understanding of IoT cryptographic principles, implementation techniques, and architectural patterns.

This hands-on chapter lets you practice cryptographic techniques for IoT security. Think of it as a locksmith training course – you learn to work with encryption tools, set up secure channels, and test your implementations in a safe environment before applying them to real systems.

23.1 Overview

This comprehensive module covers practical encryption implementation for IoT systems. The content has been organized into four focused chapters to support effective learning:

Encryption module structure showing four chapters: fundamentals covering symmetric vs asymmetric encryption, architecture covering E1-E5 multi-layer encryption, understanding checks with real-world scenarios, and comprehensive quiz for assessment
Figure 23.1: This module is structured as a learning progression: start with fundamentals, understand the architecture, work through scenarios, then test your knowledge.

23.2 Module Chapters

23.2.1 1. Encryption Fundamentals Review

Symmetric vs Asymmetric Fundamentals (~20 min)

Covers the core encryption approaches with visual comparisons and decision trees:

  • Symmetric encryption characteristics (AES speed, shared keys)
  • Asymmetric encryption for key exchange (RSA, ECC)
  • Hybrid encryption combining both approaches
  • Block cipher modes (ECB, CBC, CTR, GCM)
  • Performance considerations for constrained devices

23.2.2 2. Multi-Layer Encryption Architecture

Multi-Layer Architecture (E1-E5) (~30 min)

Deep dive into defense-in-depth encryption for IoT systems:

  • Five-layer E1-E5 architecture explained
  • Layer selection based on threat models
  • Hands-on lab implementation guide
  • Diffie-Hellman key exchange process
  • Visual reference gallery with diagrams

23.2.3 3. Understanding Checks and Scenarios

Understanding Checks and Scenarios (~35 min)

Real-world scenario-based exercises covering:

  • Medical IoT multi-layer encryption decisions
  • Smart factory OTA update security
  • Battery optimization with hardware encryption
  • Replay attack prevention in smart grids
  • RSA key distribution at manufacturing scale
  • Brute force attack feasibility analysis
  • Authenticated encryption for medical devices

23.2.4 4. Comprehensive Quiz

Comprehensive Quiz (~25 min)

Test your encryption knowledge with 13 detailed questions:

  • Shared vs per-device key security
  • Gateway trust boundary implications
  • Hybrid encryption selection
  • Block cipher mode selection
  • Digital signatures and non-repudiation
  • Key storage security ranking
  • Video resources and standards references

23.3 Learning Path

Recommended Approach:

  1. Review prerequisites - Ensure familiarity with Encryption Principles
  2. Start with fundamentals - Build understanding of symmetric vs asymmetric
  3. Study architecture - Learn E1-E5 layers and when to apply each
  4. Work through scenarios - Apply knowledge to realistic situations
  5. Test understanding - Complete the comprehensive quiz

Total Estimated Time: 2 hours for complete module

23.4 Prerequisites

Concept Why It Matters
Symmetric encryption Foundation of AES, DES
Asymmetric encryption RSA, key exchange
Hash functions Integrity verification
Digital signatures Authentication

Required Reading:

Key Concepts

  • AES-GCM: Authenticated encryption mode combining AES cipher with Galois/Counter authentication — the recommended mode for symmetric IoT encryption.
  • ECDH Key Exchange: Elliptic Curve Diffie-Hellman — establishes a shared session key between two parties using their respective ECC key pairs.
  • TLS Handshake: The negotiation sequence establishing a TLS session, including authentication, cipher suite selection, and key derivation.
  • Hash-then-Sign: A digital signature pattern where the message is hashed first, then the hash is signed with the private key — required because asymmetric operations only process small inputs.
  • Key Derivation: Using a KDF (HKDF, PBKDF2) to derive multiple keys from a single master secret, ensuring each key is used for only one purpose.

23.5 Knowledge Check

Scenario: Design encryption for a solar-powered environmental sensor with strict energy budget.

Device Specs:

  • MCU: ARM Cortex-M0+ @ 48 MHz (no hardware crypto)
  • Solar: 50 mW average
  • Battery: 100 mAh
  • Data: 32 bytes every 10 minutes

Energy Budget: 50 mW x 600 s = 30 J per 10 minutes Must allocate: MCU (20 J), radio (8 J), sensors (1 J), crypto (?? J) Available for crypto: 1 J per message

Algorithm Analysis:

Algorithm Time (ms) Current (mA) Voltage (V) Energy (mJ) Within Budget?
AES-128 (software) 5 15 3.3 0.248 Yes (25%)
AES-256 (software) 7 15 3.3 0.347 Yes (35%)
ChaCha20 3 12 3.3 0.119 Yes (12%)
RSA-2048 sign 200 30 3.3 19.8 NO (1980%)
Ed25519 sign 8 15 3.3 0.396 Yes (40%)

Decision: Use ChaCha20 for encryption + Ed25519 for authentication (every 10th message).

Daily energy:

  • Encryption: 144 messages x 0.119 mJ = 17.1 mJ
  • Signatures: 14 signatures x 0.396 mJ = 5.5 mJ
  • Total crypto: 22.6 mJ/day (meets budget)
Use Case Encryption Authentication Rationale
Battery sensor ChaCha20 HMAC Minimal energy
Mains-powered AES-256-GCM Built-in Maximum security
Medical device AES-256-GCM Ed25519 Regulatory compliance
Smart home AES-128-GCM Built-in Balance

Decision criteria:

  1. Power budget available?
  2. Regulatory requirements?
  3. Hardware acceleration?
  4. Key management capability?
Common Mistake: Over-Engineering Encryption for Low-Value Data

The Mistake: Using AES-256-GCM with Ed25519 signatures for non-sensitive data like public weather readings.

Example:

  • Weather sensor transmits temperature/humidity (public data)
  • Student uses full encryption + digital signatures
  • Energy cost: 30% of battery life
  • Security benefit: None (data is public anyway)

The Fix:

  • Public data: No encryption, just integrity check (HMAC or checksum)
  • Saves energy for useful functions
  • Focus security on private data (API keys, device identity)

Rule: Match security strength to data sensitivity.

Concept Relationships
Concept Builds On Enables Related To
Symmetric vs Asymmetric Basic encryption principles Hybrid encryption design TLS handshakes, key exchange
E1-E5 Architecture Defense-in-depth security Multi-layer IoT protection Network security, gateway trust
Key Management Cryptographic keys Secure provisioning, rotation HSMs, certificate lifecycle
Authenticated Encryption Confidentiality + integrity AES-GCM, prevent tampering AEAD modes, MAC
Forward Secrecy Ephemeral keys Past session protection ECDHE, TLS 1.3

Key Dependencies: Understanding symmetric vs asymmetric fundamentals is prerequisite to multi-layer architecture. E1-E5 layers each address different threat models and trust boundaries. Key management underpins all encryption – even perfect algorithms fail with poor key handling.

Common Pitfalls

Mistake: Using AES-CBC for confidentiality without adding a separate MAC for integrity. Why it happens: Labs often demonstrate encryption steps individually. Fix: Always use AES-GCM or ChaCha20-Poly1305 in production — these provide confidentiality and authentication in a single, efficient operation.

Mistake: Benchmarking encryption only on development PCs and assuming IoT performance scales linearly. Why it happens: Testing on actual hardware is slower and more complex. Fix: Always profile AES and ECC operations on the target MCU (e.g., STM32, ESP32) at target clock speed and voltage before finalizing algorithm selection.

Mistake: Using lab-generated certificates (self-signed, 512-bit keys) in production firmware. Why it happens: Lab defaults prioritize speed over security. Fix: Maintain separate key stores and certificate chains for lab, staging, and production; automate the distinction with environment variables or build flags.

23.6 What’s Next {#sec-enc-labs-next

If you want to… Read this
Review encryption fundamentals after the labs Encryption Review Fundamentals
Understand multi-layer encryption architecture Encryption Review Multi-Layer Architecture
Test your understanding with scenarios Encryption Review Understanding Checks
Continue to the next security module Safeguards and Protection

23.7 See Also