Skip to main content

How to Backdoor (Classic) McEliece and How to Guard Against Backdoors

  • Conference paper
  • First Online:
Post-Quantum Cryptography (PQCrypto 2022)

Abstract

We show how to backdoor the McEliece cryptosystem such that a backdoored public key is indistinguishable from a usual public key, but allows to efficiently retrieve the underlying secret key.

For good cryptographic reasons, McEliece uses a small random seed \(\boldsymbol{\delta }\) that generates via some pseudo random generator (PRG) the randomness that determines the secret key. Our backdoor mechanism works by encoding an encryption of \(\boldsymbol{\delta }\) into the public key. Retrieving \(\boldsymbol{\delta }\) then allows to efficiently recover the (backdoored) secret key. Interestingly, McEliece can be used itself to encrypt \(\boldsymbol{\delta }\), thereby protecting our backdoor mechanism with strong post-quantum security guarantees.

Our construction also works for the current Classic McEliece NIST standard proposal for non-compressed secret keys, and therefore opens the door for widespread maliciously backdoored implementations.

Fortunately, our backdoor mechanism can be detected by the owner of the (backdoored) secret key if \(\boldsymbol{\delta }\) is stored after key generation as specified by the Classic McEliece proposal. Thus, our results provide strong advice for implementers to store \(\boldsymbol{\delta }\) inside the secret key and use \(\boldsymbol{\delta }\) to guard against backdoor mechanisms.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    The statistical distance between two discrete distributions with probability mass functions p and q defined over the same set \(\mathcal {X}\) is given by \(d(p,q)=\frac{1}{2}\sum _{x\in \mathcal {X}} \left|p(x)-q(x) \right|\).

References

  1. Albrecht, M.R., et al.: Classic McEliece: conservative code-based cryptography (2020). https://classic.mceliece.org/nist/mceliece-20201010.pdf

  2. Bellare, M., Paterson, K.G., Rogaway, P.: Security of symmetric encryption against mass surveillance. In: Garay, J.A., Gennaro, R. (eds.) CRYPTO 2014. LNCS, vol. 8616, pp. 1–19. Springer, Heidelberg (2014). https://doi.org/10.1007/978-3-662-44371-2_1

    Chapter  Google Scholar 

  3. Bernstein, D.J., Lange, T., Niederhagen, R.: Dual EC: a standardized back door. In: Ryan, P.Y.A., Naccache, D., Quisquater, J.-J. (eds.) The New Codebreakers. LNCS, vol. 9100, pp. 256–281. Springer, Heidelberg (2016). https://doi.org/10.1007/978-3-662-49301-4_17

    Chapter  Google Scholar 

  4. Classic McEliece Comparison Task Force: Classic McEliece vs. NTS-KEM (2018). https://classic.mceliece.org/nist/vsntskem-20180629.pdf

  5. Crépeau, C., Slakmon, A.: Simple backdoors for RSA key generation. In: Joye, M. (ed.) CT-RSA 2003. LNCS, vol. 2612, pp. 403–416. Springer, Heidelberg (2003). https://doi.org/10.1007/3-540-36563-X_28

    Chapter  MATH  Google Scholar 

  6. Kreher, D.L., Stinson, D.R.: Combinatorial Algorithms: Generation, Enumeration, and Search. CRC Press (1999)

    Google Scholar 

  7. Kwant, R., Lange, T., Thissen, K.: Lattice Klepto - turning post-quantum crypto against itself. In: Adams, C., Camenisch, J. (eds.) SAC 2017. LNCS, vol. 10719, pp. 336–354. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-72565-9_17

    Chapter  Google Scholar 

  8. Loidreau, P., Sendrier, N.: Weak keys in the McEliece public-key cryptosystem. IEEE Trans. Inf. Theory 47(3), 1207–1211 (2001). https://doi.org/10.1109/18.915687

    Article  MathSciNet  MATH  Google Scholar 

  9. Nojima, R., Imai, H., Kobara, K., Morozov, K.: Semantic security for the McEliece cryptosystem without random oracles. Des. Codes Crypt. 49, 289–305 (2008). https://doi.org/10.1007/s10623-008-9175-9

    Article  MathSciNet  MATH  Google Scholar 

  10. Rogaway, P.: Nonce-based symmetric encryption. In: Roy, B., Meier, W. (eds.) FSE 2004. LNCS, vol. 3017, pp. 348–358. Springer, Heidelberg (2004). https://doi.org/10.1007/978-3-540-25937-4_22

    Chapter  MATH  Google Scholar 

  11. Simmons, G.J.: The prisoners’ problem and the subliminal channel. In: Chaum, D. (ed.) CRYPTO 1983, pp. 51–67. Plenum Press, New York (1983)

    Google Scholar 

  12. Simmons, G.J.: The subliminal channel and digital signatures. In: Beth, T., Cot, N., Ingemarsson, I. (eds.) EUROCRYPT 1984. LNCS, vol. 209, pp. 364–378. Springer, Heidelberg (1985). https://doi.org/10.1007/3-540-39757-4_25

    Chapter  Google Scholar 

  13. Yang, Z., Xie, T., Pan, Y.: Lattice Klepto revisited. In: Sun, H.M., Shieh, S.P., Gu, G., Ateniese, G. (eds.) ASIACCS 2020, pp. 867–873. ACM Press (2020). https://doi.org/10.1145/3320269.3384768

  14. Young, A., Yung, M.: The dark side of “Black-Box’’ cryptography or: should we trust capstone? In: Koblitz, N. (ed.) CRYPTO 1996. LNCS, vol. 1109, pp. 89–103. Springer, Heidelberg (1996). https://doi.org/10.1007/3-540-68697-5_8

    Chapter  Google Scholar 

  15. Young, A., Yung, M.: Kleptography: using cryptography against cryptography. In: Fumy, W. (ed.) EUROCRYPT 1997. LNCS, vol. 1233, pp. 62–74. Springer, Heidelberg (1997). https://doi.org/10.1007/3-540-69053-0_6

    Chapter  Google Scholar 

  16. Young, A., Yung, M.: Kleptography from standard assumptions and applications. In: Garay, J.A., De Prisco, R. (eds.) SCN 2010. LNCS, vol. 6280, pp. 271–290. Springer, Heidelberg (2010). https://doi.org/10.1007/978-3-642-15317-4_18

    Chapter  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Carl Richard Theodor Schneider .

Editor information

Editors and Affiliations

A A Appendix: A Simpler (But Flawed) SETUP Mechanism

A A Appendix: A Simpler (But Flawed) SETUP Mechanism

We consider the Vanilla McEliece key generation and describe a simpler attempt at constructing a backdoor. This construction does not even yield a weak SETUP because the backdoor can be efficiently detected by just considering the public keys. The distinguisher may be interesting in its own right and is also described below.

1.1 A.1 A.1 A Flawed SETUP

A description of the original and our simpler (but flawed) backdoored key generation \(\widetilde{\textsf{KGen}}_\texttt{V}^\texttt{F}\) can be found in Fig. 10.

The matrices S and H are generated exactly as in the non-backdoored scheme. The key difference is that instead of applying a random permutation P, we choose a permutation \(\widetilde{P}\) that permutes the columns of \(\textsf{pk}\) such that \(\textsf{pk}\)’s first row contains the ciphertext \(\boldsymbol{c} \in \textbf{F}_2^{\ell }\). This is done by choosing the permutation matrix as the combination of a purely random P and a permutation \(P'\) that sends the bits of \(\boldsymbol{c}\) to the desired coordinates.

Fig. 10.
figure 10

Original and backdoored Vanilla McEliece key generation

Notice that \(\widetilde{\textsf{KGen}}_{\texttt{V}}^{\texttt{F}}\) works provided that

  1. 1.

    \(\boldsymbol{c} \in \textbf{F}_2^{\ell }\) can be encoded in the first row \(\boldsymbol{v} = \textsf{Row}_1(SHP)\) of the public key, and

  2. 2.

    \(P'\) is efficiently computable.

We briefly sketch why these statements hold. Regarding the first statement, notice that \(\boldsymbol{c}\in \mathbb {F}_2^\ell \) can be encoded in the first row of the public key if the Hamming weight of \(\boldsymbol{v}\) lies in the interval \([\ell , n-\ell ]\). A simple Chernoff bound shows that under reasonable assumptions (such as \(\ell \le \frac{1}{4}n\)), the probability that this holds is exponentially close to 1.

Regarding the second statement, we can compute \(P'\) in an insertion-sort fashion: Iterating through the first \(\ell \) entries of the first row of SHP from left to right, if an entry differs from the corresponding one in \(\boldsymbol{c}\), we swap this column with the first column to the right with the same entry in the first row.

1.2 B.2 A.2 The distinguisher

In order for the described backdoored keys to be indistinguishable from non-backdoored ones, it is clearly necessary that the ciphertexts of the adversary’s encryption scheme look like random bitstrings. So let us assume that the adversary’s scheme provides indistinguishability from random bits under a chosen plaintext attack (see Definition 1). Under this condition, does the described backdoored scheme provide a SETUP mechanism? Perhaps surprisingly, it turns out that it does not even provide a weak SETUP. To see this, for a public key \(\textsf{pk}\) sampled from \(\textsf{KGen}\) or \(\widetilde{\textsf{KGen}}_{\texttt{V}}^{\texttt{F}}\), we consider the random variables

$$ X:=\textsf{wt}\left( v_1\dots v_\ell \right) ,~~~Y:=\textsf{wt}\left( \boldsymbol{v}\right) , $$

where \(\boldsymbol{v}=v_1\dots v_n:= \textsf{Row}_1(\textsf{pk})\), and we make the following observation:

Lemma 1

If , then \(X\mid Y=w ~\sim ~ \textsf{Binom}(\ell ,\frac{1}{2})\).

If , then \(X\mid Y=w ~\sim ~ \textsf{Hypergeom}(n,w,\ell )\).

Proof

First suppose . Then the first \(\ell \) entries of \(\textsf{Row}_1(\textsf{pk})\) are given by an encryption of a random seed \(\boldsymbol{\delta }\). Since \(\textsf{Enc}_{\textsf{pk}_\mathcal {A}}\) provides random ciphertexts, \(\boldsymbol{c}\) is uniformly distributed among all \(\ell \)-bit strings (or at least computationally indistinguishable from it). Hence \(X=\textsf{wt}\left( \boldsymbol{c}\right) \) is binomially distributed as required, independent of the Hamming weight of \(\textsf{Row}_1(\textsf{pk})\).

Now suppose where \(\textsf{sk}=(C,S,H,P)\). Observe that \(\textsf{pk}\) is obtained from SH by randomly permuting its columns. This means that the first \(\ell \) entries of \(\textsf {Row}_1(\textsf{pk})\) are obtained by randomly sampling without replacement from the entries in the first row of SH. Hence \(X\mid \textsf{wt}\left( \textsf {Row}_1(SH)\right) =w \sim \textsf {Hypergeom}(n,w,\ell )\). As permuting the columns of SH does not change the Hamming weight of its first row, we have \(\textsf{wt}\left( \textsf{Row}_1(\textsf{pk})\right) =\textsf{wt}\left( \textsf{Row}_1(SH)\right) \). This implies the claim.    \(\square \)

Hence the conditional distributions of \(X\mid Y=w\) differ noticeably in the backdoored and non-backdoored case. A maximum-likelihood distinguisher can thus be used to distinguish backdoored from non-backdoored keys with non-negligible advantage.

Fig. 11.
figure 11

Distinguishing backdoored and non-backdoored public keys. \(p^{\textsf{Binom}}_{\ell ,\frac{1}{2}}\) and \(p^{\textsf{Hypergeom}}_{n,w,\ell }\) denote the probability mass functions of the binomial respectively hypergeometric distribution.

This observation can be used to construct a distinguisher. Our distinguisher \(\mathcal {D}\) described in Fig. 11 is inspired by Lemma 1 and requires only the public key and the ciphertext length of the adversary’s encryption scheme. It is basically a maximum-likelihood distinguisher that, given a public key \(\textsf{pk}\), considers the Hamming weight of the first \(\ell \) bits of its first row. Depending on whether this \(\ell \)-bit string has a higher probability of occurrence assuming \(\textsf{Binom}(\ell ,\frac{1}{2})\) or \(\textsf{Hypergeom}(n,\textsf{wt}\left( \textsf{Row}_1(\textsf{pk})\right) ,\ell )\) as the underlying distribution, the distinguisher outputs that the public key is backdoored or, respectively, non-backdoored.

Lemma 1 implies that the distinguishing advantage of \(\mathcal {D}\) is given by the statistical distanceFootnote 1 between the distributions \(\textsf{Hypergeom}(n,\textsf{wt}\left( \textsf{Row}_1(\textsf{pk})\right) ,\ell )\) and \(\textsf{Binom}(\ell ,\frac{1}{2})\). Notice that it depends on \(\textsf{wt}\left( \textsf{Row}_1(\textsf{pk})\right) \). It is minimal for \(\textsf{wt}\left( \textsf{Row}_1(\textsf{pk})\right) =\frac{n}{2}\), however even in this case it is far from negligible for reasonable n and \(\ell \) occurring for practical McEliece parameter sets. For example, applying the Randomized Niederreiter scheme described in Sect. 5 to the highest Classic McEliece Category 5 parameter set (see Table 1), even in the favourable case that half the entries in the first row of the public key equal one respectively zero, the distinguishing advantage is about 0.071. It thus clearly does not even provide a weak SETUP because we can distinguish backdoored and non-backdoored keys from just the public keys.

Intuitively speaking, the problem with this attempt at a backdoor construction is the following: In the non-backdoored scheme, the distribution of the first \(\ell \) bits of the first row of \(\textsf{pk}\) is in fact dependent on the Hamming weight of the entire row. For example, if there happen to be in total more ones than zeros in the first row of \(\textsf{pk}\) or equivalently of the associated SH, then applying a random permutation to the columns of SH also results in a bias towards more ones than zeros in the first \(\ell \) bits. This is in contrast with the backdoored scheme for which the first \(\ell \) bits of the first row of the resulting \(\textsf{pk}\) are always uniformly distributed since they are completely determined by the ciphertext \(\boldsymbol{c}\) — which is indistinguishable from a random bitstring by assumption.

Rights and permissions

Reprints and permissions

Copyright information

© 2022 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Hemmert, T., May, A., Mittmann, J., Schneider, C.R.T. (2022). How to Backdoor (Classic) McEliece and How to Guard Against Backdoors. In: Cheon, J.H., Johansson, T. (eds) Post-Quantum Cryptography. PQCrypto 2022. Lecture Notes in Computer Science, vol 13512. Springer, Cham. https://doi.org/10.1007/978-3-031-17234-2_2

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-17234-2_2

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-17233-5

  • Online ISBN: 978-3-031-17234-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics