Cryptography · Study deck

Why Cryptography Matters for IoT

Picture a remote command crossing a site bridge before it opens a valve.

Shield Shelly is your guide for this deck.

cryptographyconfidentialityintegrity
Encryption Principles And Crypto Basics cover: Shelly arranging plain message, locked cipher, key, and shield objects to explain encryption as protective transformation.
iotclass.org

After studying this chapter

Learning objectives

Turn a security claim into a named job, a boundary, and a failure test.

  • Confidentiality, integrity, authentication, and freshness have different security jobs.The valve command needs a decision about each property instead of assuming that encryption alone establishes safe acceptance.
  • The required message property determines the appropriate primitive.A public firmware image can need a signature for origin while remaining readable to anyone who downloads the artifact.
  • The plaintext boundary identifies who may read decrypted data.An authorised gateway may terminate a protected link, while an end-to-end payload can remain opaque through the same forwarding point.
  • Nonce handling, key ownership, and negative tests need recorded evidence.Changed packets, wrong senders, replayed commands, and receiver restart must fail safely before the valve can act on missing proof.

I am reviewing a remote command before it opens a valve across the site bridge. I need separate evidence that the command is private, unchanged, current, and from the right controller.

iotclass.org

Major section

Start With the Job, Not the Cipher

Before a valve moves, verify more than the presence of encryption.

  • A private command can still lack integrity, sender proof, or freshness.The statement that encryption is present does not establish whether the valve should trust this controller or this copy of the command.
  • Each unwanted case needs a control that rejects acceptance.The review must challenge changed, copied, replayed, expired, and wrong-sender commands instead of stopping at a successful encrypted exchange.
  • Receiver restart tests must challenge saved state and freshness.A restarted device can expose counter-reset or replay behaviour that was absent while the command channel ran continuously.
  • Missing proof requires the defined local safe state.The actuator must not turn an unverified command into physical action simply because the channel carries ciphertext.

I send the known valve command, then change it and replay an old copy. I also restart the receiver and use the wrong sender to see which control rejects each case before the valve moves.

iotclass.org

Major section

Four jobs behind command acceptance

Separate the security properties before combining their controls.

  • Confidentiality keeps the protected message unreadable to excluded readers.The review still needs a named plaintext boundary because an authorised gateway may read data after terminating a protected link.
  • Integrity lets the receiver detect a changed message.A temperature value altered in transit can trigger a false alarm even when the original sensor reading was useful.
  • Authentication establishes the sender identity needed by the receiver.The command path must know which controller may issue an instruction rather than accepting any endpoint that answers.
  • Freshness prevents acceptance of an old valid message as new.A previously authenticated valve command can still verify unless a sequence number, counter, or replay window rejects the old delivery.

I am separating the four claims behind the valve command. I give each claim its own failure test before deciding which controls the channel needs to combine.

iotclass.org

Major section

The parcel’s four protective features

The parcel analogy assigns a different job to each protective feature.

  • The locked box is the confidentiality part of the parcel analogy.Its purpose is private contents, leaving tamper evidence, sender proof, and an old delivery’s rejection to other controls.
  • The tamper-evident seal is the integrity check.The seal can reveal unwanted opening or change, which is a different promise from hiding the contents inside the box.
  • The sender’s signature is the authentication part of the analogy.The chapter uses this mark to represent proof of who prepared the parcel rather than proof that nobody can read the contents.
  • The dated single-use label is the freshness control.The label must prevent the same parcel from being resent later, just as an old valid command needs explicit replay rejection.

I picture the chapter’s parcel with a locked box, tamper-evident seal, signature, and dated single-use label. I give each feature a different job so one successful check cannot stand in for all four.

iotclass.org

Major section

Temperature telemetry needs a property-by-property review

The required protection depends on the consequences of each message path.

  • Temperature telemetry may need confidentiality when it reveals occupancy.The review must identify who may read the measurement rather than treating all telemetry as harmless public data.
  • A changed temperature value can require integrity protection.An altered measurement can trigger a false alarm, so secrecy alone does not establish that the reported value remained unchanged.
  • The receiver must know which sensor supplied the reading.Authentication is needed when the cloud’s trust in the report depends on the identity of its source.
  • Replayed readings need freshness checks despite valid original authentication.An old reading can be resent during an outage, so a valid sender proof does not establish a current measurement.

I am reviewing a temperature reading sent over MQTT. I consider occupancy exposure, a false alarm from a changed value, the reporting sensor’s identity, and an old reading replayed during an outage.

iotclass.org

Major section

Readable firmware and the limits of an AES claim

An algorithm name leaves the mode, keys, and readable-data boundary unresolved.

  • A readable firmware image can still have a valid origin signature.Signing establishes a different property from secrecy, so public access to the image does not remove the need to verify its origin.
  • Encryption without tamper detection can leave an integrity gap.The chapter’s encrypted telemetry example can hide data while still failing to detect a changed message.
  • The gateway’s decryption role and key owner need documentation.A protected link can legitimately expose plaintext at an authorised gateway, while another design withholds the inner-payload key.
  • An AES claim still needs a mode and nonce plan.The cipher name alone does not establish the protection boundary, who holds the keys, or which negative tests the design passes.

I have a signed firmware image that anyone can download and read. I compare its origin guarantee with an encrypted telemetry link, then record the mode, key owner, and place where plaintext appears.

iotclass.org

Major section

Match Primitives and Build the Hybrid Channel

Follow peer authentication through shared-secret derivation to protected traffic and key retirement.

  • Peer authentication must precede trust in the key-establishment result.The first stage needs the device, gateway, or service identity checked before its shared-secret material can support a protected channel.
  • ECDH or approved provisioning supplies material for HKDF-scoped keys.The derivation stage must bind separate traffic keys to protocol, role, direction, and session context rather than reusing one key across purposes.
  • AEAD protects traffic with nonce and tag checks.Telemetry, commands, and updates need authenticated record protection after identity and key setup have prepared the channel.
  • The lifecycle branch requires rekey, revocation, recovery, and retirement evidence.A channel review must show key rollover and compromised-credential handling instead of ending at the first successful protected record.
The hybrid pattern separates peer identity and key setup from high-volume AEAD traffic protection, then records the key lifecycle evidence needed for rekey, revoke, recover, and retire decisions.
The hybrid pattern separates peer identity and key setup from high-volume AEAD traffic protection, then records the key lifecycle evidence needed for rekey, revoke, recover, and retire decisions.
iotclass.org

Major section

What each primitive can establish

Choose a primitive by its promise and by what it leaves unproved.

  • Encryption can hide content within its defined boundary.It does not establish tamper rejection or sender proof unless the chosen mode also provides authentication.
  • AEAD provides confidentiality and tamper rejection for protected traffic.The ciphertext and associated data need verification, while identity still depends on how the keys or certificates are bound to peers.
  • A bare hash cannot establish who sent a message.Anyone can recompute the digest, so an unkeyed fingerprint needs a keyed MAC or signature when origin matters.
  • HMAC and signatures can authenticate data that remains readable.A signature supports public verification, while an HMAC establishes possession of a shared key without providing confidentiality.

I am choosing a tool for the building sensor’s command channel. I write the promise beside each primitive and leave the other acceptance questions visible rather than letting one match complete the security review.

iotclass.org

Activity 1 · Match

✎ Choose the primitive by its job

I want you to match each tool to the promise it can actually support.

On paper, match encryption, AEAD, hash, HMAC, and signature to: public verification; shared-key sender proof; unreadable content; an unkeyed fingerprint; private traffic with tamper rejection.

3 minutes · Pen and paper · Answer: Activity 1

Your answer
iotclass.org

Major section

Authenticated setup and keys with one purpose

Key setup prepares protection; traffic still needs an authenticated mode.

  • Peers need authentication before their shared-secret material is trusted.An answering gateway or service endpoint must not gain trust merely by participating in a key exchange.
  • Approved agreement or provisioning can establish the secret material.The setup must avoid sending reusable keys inside messages and still needs a secure mode to protect later traffic.
  • Derived traffic keys need protocol, role, direction, and session context.Labels and context keep a key for one purpose from being confused with another within the channel.
  • The lifecycle record needs tested rollover and credential revocation.The channel must limit key lifetime and retire compromised credentials rather than assuming the original setup remains acceptable forever.

I am setting up the building sensor’s protected channel through its gateway. I verify the peers before deriving traffic keys, then record which context and lifecycle each key belongs to.

iotclass.org

Major section

Firmware acceptance and command freshness

Firmware protection and command protection require different acceptance checks.

  • Firmware needs signatures over metadata and image bytes before installation.Verification must also precede boot, so a signed download channel alone cannot establish trust in the executable artifact.
  • Update, rollback, and recovery paths need the same acceptance policy.Every executable update path must have signature validation, a version policy, and recovery behaviour rather than an unsigned bypass.
  • A command channel needs authenticated sender identity and tamper rejection.The building sensor’s proposed encrypted messages do not by themselves prove who may issue a configuration command.
  • Freshness checks must prevent old commands becoming new physical actions.A correctly authenticated command can be replayed unless the receiver has a sequence number, counter, or replay window.

I am reviewing both a firmware update and a remote command for the device. I keep the signature and version policy on every executable update path, while the command also needs a current authorised sender.

iotclass.org

Major section

Identity anchors and separate key responsibilities

Turn the threat-to-control map into tests for each message path.

  • AEAD requires nonce uniqueness per key and tag verification before use.A modified command must fail before the device releases plaintext or turns its contents into an action.
  • Gateway and service identities need a documented trust anchor.The chapter also requires renewal and recovery planning instead of trusting any endpoint that answers the device.
  • A keyed MAC supports shared-key possession checks on readable data.An unkeyed hash cannot establish that the sender held the secret required by this integrity-without-secrecy path.
  • Password storage, session derivation, and device identity are separate responsibilities.Hashing a password once must not silently turn that result into a long-term device key.

I turn the command-channel proposal into a threat-to-control record. I include the identity anchor and renewal plan, then separate readable authenticated data from password storage and traffic-key derivation.

iotclass.org

Major section

The encrypted command proposal’s missing checks

Review the proposed encrypted sensor-command channel against the claims it still needs.

  • Encryption can hide the command body within the protected boundary.An observer on the link or broker may be excluded from the contents, but that does not complete the command acceptance policy.
  • Sender authentication must establish the authorised command source.The channel needs evidence about which controller may configure the building sensor rather than only a ciphertext capture.
  • Changed commands must fail verification before the device acts.Confidentiality alone cannot establish tamper rejection, so the receiver needs an authenticated acceptance check.
  • Replayed commands need freshness rejection and a key-lifecycle plan.The review must include old-command tests and compromised-credential handling before the proposed channel can be accepted.

I am reviewing the building sensor team’s proposal to use encrypted messages through a gateway. I keep asking which sender may configure the sensor and whether changed or old commands can still be accepted.

iotclass.org

Major section

Boundaries, AEAD, and Failure Modes

Compare gateway access in the first two models, then inspect readable signed firmware.

  • Hop-by-hop protection permits an authorised gateway to decrypt and re-protect data.The first model deliberately terminates separate protected links, allowing the gateway to process plaintext for its named role.
  • End-to-end payload protection keeps inner ciphertext opaque through the gateway.The second model withholds the inner-payload key even when outer transport protection may terminate on individual hops.
  • Signed firmware remains readable while the device checks acceptance.The third model needs signer and digest, target and model, and anti-rollback checks before installation rather than confidentiality.
  • Every model needs data, trust, key, and evidence boundaries.The comparison must establish who may read, modify, forward, decrypt, sign, and publish evidence without leaking secrets.
Hop-by-hop protection deliberately authorises a gateway termination; end-to-end payload protection withholds the inner-payload key from the gateway; signed firmware remains readable because its job is origin, integrity, eligibility, and anti-rollback rather than confidentiality.
Hop-by-hop protection deliberately authorises a gateway termination; end-to-end payload protection withholds the inner-payload key from the gateway; signed firmware remains readable because its job is origin, integrity, eligibility, and anti-rollback rather than confidentiality.
iotclass.org

Major section

AEAD verification and unique nonces

AEAD needs correct tag handling and a nonce plan that survives device operation.

  • Tag verification must precede plaintext release or action.A failed authentication tag requires rejection, because acting on unverified contents would restore the tampering risk.
  • Associated data is readable but protected against undetected change.Headers or routing fields can remain visible while AEAD authenticates the fields that must not be altered.
  • A nonce must never repeat under the same AEAD key.The device’s nonce plan needs reboot and counter-reset tests so continuous operation does not hide a later reuse failure.
  • AES-GCM nonce reuse can expose relationships and enable forged tags.Repeating the nonce with the same key can break confidentiality and integrity, so a successful ordinary exchange is insufficient evidence.

I am testing the valve receiver with a changed protected command. I require tag verification before plaintext use and check that a reboot cannot repeat a nonce under the same key.

iotclass.org

Major section

Freshness, shared-key proof, and public verification

Valid authentication does not establish that a command is current.

  • An old authenticated command can remain valid without freshness checks.The receiver must reject replay through a sequence number, counter, or replay window instead of treating tag validity as current intent.
  • A counter or replay window supplies a separate acceptance control.Restart testing must show that saved or reset state does not let an old valve command become a new physical action.
  • An HMAC establishes shared-key possession without identifying which holder signed.Either shared-key holder can produce the tag, so the pair cannot prove to a third party which one created the message.
  • A digital signature supports verification through the matching public key.Only the private-key holder can create a valid signature, which supports public verification beyond the shared-key MAC’s promise.

I replay an old authenticated valve command whose tag is still valid. I add a freshness check, then distinguish what the command’s shared-key tag could prove from what a public signature could prove.

iotclass.org

Activity 2 · Predict

✎ Replay a valid command

I want you to predict what a valid tag leaves unanswered.

On paper, replay an old authenticated valve command. Predict the result if the receiver checks only its tag. Add a freshness control, then name the restart test needed for that control.

3 minutes · Pen and paper · Answer: Activity 2

Your answer
iotclass.org

Major section

Session keys, reboot tests, and lifecycle evidence

Keep a release record connecting the security objective to failure tests and key management.

  • Fresh ephemeral session keys can protect past traffic after later compromise.The chapter’s forward-secrecy case prevents a later long-term key compromise from exposing earlier session traffic.
  • Separate derived keys need labels and context for their purposes.HKDF can scope the shared material so a key for one direction or job is not confused with another.
  • Reboot tests must challenge nonce reuse, replay, and counter reset.A continuously running device can hide acceptance failures that appear only when saved or reset state is used after restart.
  • Provisioning, per-device keys, rotation, and revocation need concrete evidence.A leaked credential needs a tested retirement path in the field rather than a plan that requires reflashing every affected device.

I am checking the device’s release record after its command channel works normally. I include fresh session keys, reboot failures, per-device provisioning, and tested rotation so the security claim survives ordinary operation.

iotclass.org

Deck summary

Key takeaways

A reviewable security claim names the protection, its boundary, and evidence of rejection.

  • The message’s required properties must guide primitive selection.The command path needs separate confidentiality, integrity, sender, and freshness decisions before a named cipher can support its review.
  • The review needs plaintext boundaries and named key owners.A gateway may be authorised to decrypt a link while an end-to-end design keeps the inner payload opaque through the same boundary.
  • Tag verification must precede use, with nonce uniqueness per key.Failed tags require rejection, and reboot testing must show that saved or reset state does not repeat a nonce under the same key.
  • Release evidence needs negative tests and a tested key lifecycle.Replay, wrong peers, changed messages, and compromised credentials must have recorded rejection or recovery behaviour before field acceptance.

I return to the valve command with a record of its security jobs and failure tests. I can identify the plaintext boundary, key owners, and rejection evidence instead of approving the channel from an algorithm name.

iotclass.org

Retrieval practice

Recall check 1 of 3

Shield Shelly says: answer from memory, then check your reasoning.

Q1A vendor says "our device uses AES, so the data is secure." What is the strongest correction?

AAES is outdated, so the device cannot be secure
BEncryption already provides confidentiality, integrity, authentication, and freshness at once
CAES is not enough without a reviewable design.
DThe device is secure as long as the key is long enough
Show answer

Answer: C Naming AES is not a security claim.

iotclass.org

Retrieval practice

Recall check 2 of 3

Shield Shelly says: answer from memory, then check your reasoning.

Q2A team says its device commands are safe because the payload is encrypted, but gateway logs show old encrypted command packets can still be replayed successfully. What is the correct review conclusion?

AEncryption alone does not stop replay.
BThe design passes, because the attacker cannot read the command
CThe design only needs a longer key
DThe design should replace encryption with a plain hash
Show answer

Answer: A The design fails because hiding the command body does not stop an old valid message from being reused.

iotclass.org

Retrieval practice

Recall check 3 of 3

Shield Shelly says: answer from memory, then check your reasoning.

Q3A constrained device reuses the same nonce with the same key for two AES-GCM messages to save state. Why is this a serious failure rather than a minor optimization?

AGCM nonce reuse breaks the security claim.
BIt is fine, because the authentication tag still protects the message
CIt only weakens performance, not security
DIt is safe as long as the key is 256 bits
Show answer

Answer: A Counter-based AEAD modes such as GCM require a unique nonce per key.

iotclass.org

Print reference

Answers

Answer key.

  1. C · Naming AES is not a security claim.
  2. A · The design fails because hiding the command body does not stop an old valid message from being reused.
  3. A · Counter-based AEAD modes such as GCM require a unique nonce per key.
iotclass.org

Print reference

Activity 1 answer

Model answer.

Match: Encryption: unreadable content. AEAD: private traffic with tamper rejection. Hash: an unkeyed fingerprint. HMAC: shared-key sender proof. Signature: public verification. None of these matches alone establishes a complete replay policy.

iotclass.org

Print reference

Activity 2 answer

Model answer.

Predict: The old tag can verify, allowing the command to be accepted again without freshness checks. Add a sequence number, counter, or replay window. Restart the receiver and test that saved or reset state does not allow old commands or reuse nonces under the same key.

iotclass.org