R02A · COMIC CLASSROOM

Side Channels & Key Leakage: Why Protect a Key That Never Leaves the Chip?

Follow an encrypted access log from a lab door lock. Learn what keys protect, how computation can leave clues, and how DPA and CPA test key guesses. Distinguish implementation leakage from mathematical attacks.

MY Academy · 2026-10-11

15 min read

Side Channel1/2

MY is evaluating a lab door lock. It encrypts access logs before storing them. Functional tests show correct encryption and decryption, and the device offers no key-export command. Is that enough to sign a report saying the key cannot leak? This fictional scenario follows the risks of using a key. It is not a report of a vendor vulnerability.

Why look for the key after obtaining the file?

1/14 — Ciphertext, the matching data key, and the original records have different roles. Blocking export answers only one question.
1/14 — Ciphertext, the matching data key, and the original records have different roles. Blocking export answers only one question.

An access log may reveal who entered a room and when. Copying storage does not necessarily reveal those records: the copy may contain only ciphertext. Encryption changes the representation of the data. An authorized user follows the decryption procedure with the matching key to recover it. Protecting the content is the purpose of this operation.[1]

An attacker may therefore pursue the data key. With that key and the necessary format and parameters, the protected records may become readable. The impact is limited by the key’s role. Reading past logs, installing firmware, and opening a physical door may require different secrets and authorization paths. We must identify the role before judging the damage.

Blocking export prevents software from directly asking the chip to hand over its key. That is a useful restriction. The chip must still use the key internally to decrypt records. Its circuits consume energy and its operations take time. MY now asks whether observable activity could reveal something about the secret. An export-command check cannot answer that question.[2]

We will connect observation to inference, without pretending that a waveform simply spells out a key. Nor will we assume every device is vulnerable. We must establish what data the observer has, what activity they can observe, and whether the analysis describes the circuit. Those conditions stay with the lock evaluation throughout the lesson.

What can different keys let someone do?

2/14 — Assess data confidentiality, message authentication, and digital signatures separately.
2/14 — Assess data confidentiality, message authentication, and digital signatures separately.

MY places three cards beside the lock. The first is a data key, which protects record contents. The second is a message authentication code key, or MAC key. It produces a tag that a receiver checks using the same MAC key. The third is a signing private key. It creates digital signatures that can be checked with the corresponding public key.[1][4][5]

Losing the data key first threatens the confidentiality of the corresponding data. Losing the MAC key may allow unauthorized tags. Losing a signing private key may allow impersonation of that signer. The protocol still determines the consequences. Message formats, version restrictions, and the receiver’s authorization policy all affect what an attacker can actually achieve.

Suppose the lock protects its logs with a device data key, while the manufacturer keeps a separate firmware-signing private key. Obtaining one lock’s data key does not imply the ability to sign firmware for every product. Separating those roles gives us a checkable threat boundary. Managing different purposes separately also helps contain the impact of a compromise.

MY records each secret’s name, purpose, and users before investigating computation. Otherwise, a peak observed later might be attributed to the wrong secret. A data key, an authentication key, and a signing nonce do not carry the same security meaning. We need that distinction before interpreting a signal.

How can security survive a public algorithm?

3/14 — Public rules and protected secrets can coexist. The algorithm itself still needs to be secure.
3/14 — Public rules and protected secrets can coexist. The algorithm itself still needs to be secure.

Knowing the rules does not mean knowing a secret input. The AES specification publicly describes its transformations. Anyone can read it or build an implementation. A key changes the cryptographic computation; security does not depend on hiding the published steps. Selecting and protecting those keys is part of the security design.[1]

Kerckhoffs’s principle expresses this design direction: assess security assuming that the adversary knows the system and algorithm. Security must not depend on those rules remaining hidden. This is a principle, not a theorem proving a particular product secure. Published rules also allow scrutiny and interoperable implementations.[3]

The principle does not make algorithm choice irrelevant. A weak algorithm can fail despite careful key storage. A protocol can also misuse an otherwise suitable key. MY therefore examines the algorithm, how it is used, and how it is implemented. Key secrecy is essential, but it is not a complete product evaluation.

An observer knowing that the lock uses AES is not itself a vulnerability. The important question is whether that knowledge lets them predict a secret-dependent intermediate and test it against observable activity. Public rules supply a computable hypothesis. We now investigate whether the implementation exposes evidence for that hypothesis.

What can be observed without reading the key?

4/14 — Timing, power, and electromagnetic signals are channels. Access depends on the device and observation conditions.
4/14 — Timing, power, and electromagnetic signals are channels. Access depends on the device and observation conditions.

Decrypting one log takes time. Switching circuits consume energy and produce electromagnetic activity. If observable activity depends on a secret, an adversary may use it to infer that secret. Analysis of these incidental signals is called side-channel analysis. Functional computation can be completely correct while such leakage exists.[2]

Different channels require different access. Timing may sometimes be observed through remote responses, although network delays add noise. Power and local electromagnetic observations generally require proximity or suitable measurement access. Enclosures, power delivery, and background computation affect visibility. Remote timing access does not automatically grant equally useful electromagnetic traces.

Separate a channel from an analysis method. Power is a source of observations. Simple, differential, and correlation power analysis—SPA, DPA, and CPA—are ways to use them. SPA may inspect recognizable operation patterns directly. The latter methods use multiple observations to test secret-dependent hypotheses.[2][6]

MY records which public inputs the observer controls and which operations can be observed repeatedly. This lesson does not change voltage to make the chip compute incorrectly. That is the separate threat of fault injection. Mixing passive observation with active disturbance would confuse both the defenses and their evaluation conditions.

Why use Hamming weight as a model?

5/14 — 0011 and 1100 each contain two ones. Equal HW does not identify a unique value.
5/14 — 0011 and 1100 each contain two ones. Equal HW does not identify a unique value.

Take the four-bit word 0011. It contains two ones, so its Hamming weight, or HW, is 2. The word 1100 also has HW 2. HW compresses a full value into one count. That makes comparison simple, but discards the positions of the ones.

A model related to data HW can approximate leakage in some circuits. It does not say that each one always consumes a fixed extra amount of power. The data path and switching conditions matter. MY uses HW as a simplified, testable hypothesis. If the circuit does not fit, the model must change.[6]

Even an observation that accurately reflects HW cannot distinguish every value. A count of 2 could match 0011, 0101, or 1010. This explains why multiple inputs and observations matter. Different inputs generate different intermediate values for each secret candidate. Comparing a sequence of predictions may eliminate candidates that one observation cannot separate.

Bit tiles let us inspect the abstraction without pretending to simulate a chip. Next, we place data in a register whose state changes. Counting ones may omit the activity that happens between the old and new values. That distinction will also matter when selecting the interactive lab’s model.

How do counting ones and counting changes differ?

6/14 — Changing 0011 to 1100 flips all four bits, so HD is 4.
6/14 — Changing 0011 to 1100 flips all four bits, so HD is 4.

A register holds 0011 and then stores 1100. Both words have two ones, yet all four positions change. Comparing only their weights misses that activity. Hamming distance, or HD, compares corresponding positions and counts differences. Here, HD is 4.

XOR the two words first. Different positions become ones; equal positions become zeros. Counting the ones in that result gives the distance: HD(a,b) = HW(a XOR b). This bit relationship separates a model of data content from a model of a transition.[6]

Switching activity is a useful starting point for understanding dynamic power. Four bit changes do not guarantee four times the measured power, however. Loads can differ by bit. Combinational logic may switch several times before settling, and background circuitry may be active. HD remains an approximation tied to a structure and an observation point.

The interactive lab fixes the old HD state at 0101 to make the relationship visible. A real device need not do that. Assuming the wrong old state can break a prediction even when the new-value formula is correct. MY therefore asks where the reference state comes from, as well as whether HW or HD is appropriate.

Engineer extension

Engineer extension: HW and HD are approximations. Models may need unequal bit weights, register reuse, or combinational glitches. The toy experiment’s fixed old state is not a real data-path assumption.

How can someone predict activity without the key?

7/14 — A public input and candidate secret give a candidate intermediate. The prediction must still be tested against observations.
7/14 — A public input and candidate secret give a candidate intermediate. The prediction must still be tested against observations.

MY processes different public inputs while keeping the lock’s key fixed. The analyst chooses a candidate for a small part of the key and calculates an intermediate using known rules. The real key is unknown, but each candidate produces its own prediction. These are calculations outside the device, not commands that read its secret.

A common AES teaching example targets an output of a first-round S-box, a nonlinear substitution. For known input byte p and candidate key byte k, calculate v = SBox(p XOR k). A model such as HW(v) then predicts activity. This choice requires observable leakage corresponding to that intermediate and the appropriate input conditions.[1][6]

One byte has 256 candidates. That does not mean 256 operations recover a complete AES key. Candidate count and observation count are different. Each candidate is evaluated across the same input set and compared with observations. Recovering and validating a complete secret requires more work, and the implementation may not expose the required information.

Our interactive lab reduces the secret to four bits and 16 candidates. A public teaching substitution table and synthetic observations stay in the browser. The model explains inference; it does not evaluate AES strength. Appropriate masking may prevent an unmasked intermediate from corresponding to a single observable quantity. The defense lesson will examine that mechanism.

Why does DPA divide observations into two groups?

8/14 — Group by a predicted intermediate bit, then compare means. The groups are not defined by measured power.
8/14 — Group by a predicted intermediate bit, then compare means. The groups are not defined by measured power.

We now have public inputs paired with observations. For one candidate key, the analyst computes an intermediate for every input. They select one bit of that intermediate. Observations predicted to have bit 0 enter one group; those predicted to have bit 1 enter another. This is one classical differential power analysis, or DPA, construction.[2]

Average the traces in each group and subtract the means. If the selected bit affects an observation point, the group means may differ there. Unrelated variation may partly cancel through averaging. No individual trace is labeled correct or incorrect. Many observations collectively test whether the hypothesis produces a recognizable difference.

A new candidate can produce a new grouping. Some wrong candidates remain correlated with the actual intermediate and create ghost peaks. Limited samples and unequal group sizes also affect the comparison. The largest difference therefore does not prove the secret. Analysts need additional data, observation points, and an appropriate way to validate a candidate.

MY does not treat collecting more observations as an unconditional remedy. Misaligned operations or defenses that change the relationship between an intermediate and power may invalidate the grouping. The lab retains group counts and means so readers can inspect their origin. It demonstrates a synthetic single observation point, not a physical trace evaluation.

How does CPA compare predictions with observations?

9/14 — Correlation measures how predictions and observations vary together. It is not the probability that a guess is correct.
9/14 — Correlation measures how predictions and observations vary together. It is not the probability that a guess is correct.

Correlation power analysis, or CPA, produces a sequence of predictions for each candidate. With an HW model, it counts ones in each predicted intermediate. The same inputs have a sequence of observations. CPA asks whether the observations rise or fall with the predictions. This differs from comparing two group means in DPA.[6]

Imagine predictions that vary high, low, low, high across inputs. Similar changes in the observations make that candidate worth investigating. A correlation coefficient describes the relationship. Positive values indicate same-direction variation; negative values indicate opposite-direction variation. Either may matter depending on measurement polarity. Our lab shows signed values and ranks their absolute magnitudes.

A correlation of 0.8 is not an 80% chance of a correct key. It describes a linear relationship in these data. Wrong candidates can score highly through related predictions. A correct candidate can score poorly under a mismatched model. Constant predictions or observations make the coefficient undefined. The interface must show that condition rather than inventing a zero score.

MY records the ranking together with the model and data conditions. It answers which hypothesis fits this comparison best, not whether the entire lock is secure. Masking or a different internal representation can change what the model predicts. We must recheck that relationship. The lab after the next section lets readers change those conditions themselves.

Engineer extension

Engineer extension: this model uses Pearson correlation at one synthetic observation point. r = Σ((h−mean h)(y−mean y)) / √(Σ(h−mean h)² Σ(y−mean y)²). It is undefined if either variance is zero. Real time series involve multiple observation points and comparisons, which this lab does not validate.

Does a high peak establish the secret?

10/14 — Noise, sample size, and model mismatch can change rankings. An absent peak does not establish security.
10/14 — Noise, sample size, and model mismatch can change rankings. An absent peak does not establish security.

A striking peak can guide an investigation without settling it. A small sample may happen to be favorable, or background activity may be mistaken for a secret-dependent signal. Repeating the comparison with different data helps assess stability. Real validation also needs an independent check appropriate to the protocol, rather than repeated inspection of the same chart.

The lab lets readers choose the synthetic source model separately from the analysis model. If the source uses HD from a fixed old state while the analysis counts ones in the new value, they describe different activity. Even noise-free observations can favor a wrong candidate. More data need not repair a fundamentally wrong hypothesis.

Small samples can leave candidates close together. Noise may change their ranking. A fixed seed makes our synthetic observations reproducible, and a button selects another data set. Each comparison has its own conditions. The lab supplies neither a universal trace count nor a conversion from recovering a four-bit toy secret to breaking a product.

An absent peak also requires restraint. It might reflect effective protection, or an unsuitable model or observation point. MY can report the result under the tested method and conditions. A useful evaluation records scope, positive controls, and untested risks so others can understand the strength of that statement.

Interactive lab: which hypothesis fits?

This four-bit teaching model is not AES. Its key is fixed at 7 for checking. All observations are generated in your browser; no real device data are measured or uploaded.

Start with an HW source and HW analysis, then change the source to HD. Watch the rankings change. DPA groups by the predicted intermediate’s lowest bit; it does not use the analysis-model selector.

The HD reference state is 0101. CPA ranks |r|; DPA ranks the absolute difference of group means. These scores are not comparable across methods and are not success probabilities.

Inspect the first 16 intermediates, predictions and observations
Intermediate v = S(input XOR candidate); S is a public four-bit teaching substitution.
InputvPredictionObserved
Public substitution table and limits

S = [12, 5, 6, 11, 9, 0, 10, 13, 3, 14, 15, 8, 4, 7, 1, 2]

Only one synthetic observation point is compared. The lowest-bit DPA selector need not be optimal for each source. Trace alignment, glitches, masking and higher-order leakage are not modeled. A top candidate is not a real key recovery, and an absent peak does not prove product security.

Do AES and SHA protect the same secrets?

11/14 — Plain SHA has no key. HMAC combines a secret key with hash computation.
11/14 — Plain SHA has no key. HMAC combines a secret key with hash computation.

AES uses a secret key. Key-dependent intermediates can offer clues if an implementation leaks them. Recovering a key from a vulnerable implementation does not itself break the mathematical design of AES. Evaluation must separately assess whether the algorithm is suitable and whether its implementation exposes secrets.[1]

Plain SHA is a hash function. It maps a message to a digest and does not take a SHA private key. Hashing a public firmware file is therefore different from an operation that exposes a secret key. If the input contains sensitive information, leakage of that input or internal state can still matter. Keyless does not mean all processed data are public.[7]

HMAC combines a secret key with a hash function to produce a message authentication code. SHA can be a component of that construction. Its purpose includes message authentication, and computation involving its secret state needs evaluation. The keyless interface of plain SHA does not remove HMAC’s key-protection requirement.[4]

A collision involves different inputs with the same digest. A preimage problem asks for an input matching a given digest. A side channel uses observable activity from a computation. Their inputs and objectives differ. MY identifies the function before choosing a test, rather than collapsing those separate questions into a claim that SHA has been broken.

What needs protection beyond an RSA / ECC private key?

12/14 — Secret scalars and ECDSA signing nonces also enter sensitive computations.
12/14 — Secret scalars and ECDSA signing nonces also enter sensitive computations.

RSA private operations use a secret exponent, and common implementations may use secret factors. ECC secret-scalar operations perform point computations controlled by a secret number. Secret-dependent paths or data activity may offer timing or power clues. Those are implementation questions. Merely choosing RSA or ECC does not establish protection.[2][8]

Each ECDSA signature also uses a secret value often called a signing nonce. This differs from a publicly transmitted IV in an encryption mode. Sufficient knowledge about the signing nonce can endanger the long-term private key. Generation bias, improper reuse across different messages, and leakage during use require separate attention.[5]

RFC 6979 defines deterministic nonce generation from the private key and message. It can reduce reliance on fresh randomness at signing time, but its computations still process secrets. Deterministic generation is not a side-channel certificate. Key generation and randomness required by particular defenses do not all disappear.[5]

Ordinary projective coordinates primarily concern ECC representation and computational efficiency. Randomized projective coordinates are one possible protection direction, with conditions and remaining risks. RSA uses measures such as blinding, not elliptic-curve coordinates. MY records regular schedules, constant-time behavior, and data randomization separately. None of these names alone guarantees resistance to DPA or CPA.[8][9]

Engineer extension

Engineer extension: distinguish ordinary from randomized projective coordinates. Randomization addresses only some representation-related leakage. Scalar control, coordinate conversion, and other intermediates still require evaluation. The next lesson develops equivalent scaling and blinding.

Do Shor and power analysis take the same route?

13/14 — Mathematical attacks and implementation leakage are separate routes. Coordinate randomization does not address Shor.
13/14 — Mathematical attacks and implementation leakage are separate routes. Coordinate randomization does not address Shor.

Power analysis observes activity from an implementation. Shor’s algorithm addresses mathematical problems. A sufficiently capable quantum computer could use it for factorization and discrete logarithms, affecting the foundations of RSA and ECC. That route does not require a power trace from the lock.[10]

The defenses therefore differ. Constant-time computation or randomized internal representations can address particular implementation leakages. They do not change the factorization problem for a public RSA modulus or replace ECC’s discrete-logarithm foundation. Quantum mathematical threats require separate assessment of post-quantum cryptography, or PQC, and system migration.[10]

Generic quantum search of the Grover type is relevant to AES key search and hash preimage search. It is different from Shor. Ideal query counts also do not directly determine attack time; physical resources and machine capability matter. Hash collisions present another problem and must not inherit a preimage-search claim automatically.[10]

MY separates two evaluation columns: observable leakage from the present implementation, and the algorithm’s longer-term migration plan. We link to the existing Shor lesson rather than repeat its derivation. Distinguishing attack routes prevents a claim that adding masking resolves quantum risk.

What can we now conclude about the lock?

14/14 — Correct functionality and blocked export are useful. Leakage during use needs its own evidence.
14/14 — Correct functionality and blocked export are useful. Leakage during use needs its own evidence.

MY will no longer sign an absolute no-leakage statement simply because decryption works and export is unavailable. He identifies the data key and other secrets, then lists controlled inputs and observation access. Relevant computations are matched to possible channels. Tested and untested conditions are recorded so another person can examine the conclusion.

Defenses must address the specific problem. Constant-time design addresses secret dependence in timing or access patterns, but does not automatically remove data-dependent power. Suitable masking changes how observable intermediates relate to secrets. Some blinding or randomized representations vary sensitive internal values across operations. These measures incur costs and require implementation validation.[8][9]

Product documentation can name the evaluated version, secret types, and observation conditions. It should explain methods, data limits, and uncovered scope. A certificate or one experiment without a peak cannot replace evaluation of every threat. Junior engineers and marketing teams can use these questions without first learning to operate measurement equipment.

Now change one condition. Suppose the lock only hashes a public firmware file with plain SHA. MY should not pursue a nonexistent SHA private key. He must still check the firmware’s trust source and authorization: a public digest alone does not identify who approved it. The next lesson explains masking, RSA blinding, and randomized ECC coordinates, including their remaining risks.

What to retain

Identify the secret and the adversary’s access before evaluating its use. HW and HD are different models. DPA compares group means; CPA compares correlation. Every result depends on observation and model conditions. Separate mathematical threats from implementation leakage.

Glossary

  • Side channel: incidental activity from normal computation that may reveal clues about a secret.
  • HW: the number of ones in a word. HD: the number of differing bit positions between words.
  • DPA: here, the classical form that groups by a predicted bit and compares group means.
  • CPA: comparison of correlation between candidate leakage predictions and observations.
  • Signing nonce: the secret value used for an ECDSA signature, unlike a public IV.
  • PQC: post-quantum cryptography, aimed at resistance to known quantum attacks.

Learning check

1. What are HW(0011) and HD(0011,1100)?

They are 2 and 4. The first counts ones in one word; the second counts differing positions.

2. Does CPA correlation 0.8 mean an 80% probability of recovering the key?

No. It describes a linear relationship in these predictions and observations. Validate the candidate independently and check model and data conditions.

3. Does blocked key export rule out power leakage?

No. Export restrictions limit direct reads, but the key is still used internally. Evaluate observable activity during those computations.

4. Can an HW analysis of an HD source with no reliable peak establish product security?

No. The model may be wrong, and observation access and samples are limited. Check the model and retain unevaluated risks; an absent peak is not acceptance evidence.

5. Would hashing public firmware with plain SHA expose a SHA private key? Does masking address Shor?

Plain SHA has no secret key; first identify any other sensitive inputs. Masking addresses particular implementation leakage. Shor affects RSA / ECC’s mathematical foundations, requiring separate PQC migration planning.

Primary sources

  1. NIST FIPS 197 — Advanced Encryption Standard (2023 update)
  2. Kocher, Jaffe & Jun — Differential Power Analysis (1999)
  3. Stanford CS155 — Cryptography, Kerckhoffs’s principle
  4. NIST — HMAC definition
  5. RFC 6979 — Deterministic DSA and ECDSA (2013), §2.4 and §4
  6. Brier, Clavier & Olivier — Correlation Power Analysis with a Leakage Model (2004)
  7. NIST FIPS 180-4 — Secure Hash Standard (2015)
  8. Coron — Resistance Against Differential Power Analysis For Elliptic Curve Cryptosystems (1999)
  9. OpenTitan AES masking; OpenSSL RSA blinding · OpenSSL RSA
  10. NIST — Post-Quantum Cryptography FAQ

#SideChannel #KeyProtection #DPA #CPA #HardwareSecurity