Skip to main content

Randomized Stopping Times and Provably Secure Pseudorandom Permutation Generators

  • Conference paper
  • First Online:

Part of the book series: Lecture Notes in Computer Science ((LNSC,volume 10311))

Abstract

Conventionally, key-scheduling algorithm (KSA) of a cryptographic scheme runs for predefined number of steps. We suggest a different approach by utilization of randomized stopping rules to generate permutations which are indistinguishable from uniform ones. We explain that if the stopping time of such a shuffle is a Strong Stationary Time and bits of the secret key are not reused then these algorithms are immune against timing attacks.

We also revisit the well known paper of Mironov [15] which analyses a card shuffle which models KSA of RC4. Mironov states that expected time till reaching uniform distribution is \(2n H_n - n\) while we prove that \(n H_n+ n\) steps are enough (by finding a new strong stationary time for the shuffle).

Nevertheless, both cases require \(O(n \log ^2 n)\) bits of randomness while one can replace the shuffle used in RC4 (and in Spritz) with a better shuffle which is optimal and needs only \(O(n \log n)\) bits.

Authors were supported by Polish National Science Centre contract number DEC-2013/10/E/ST1/00359.

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

Buying options

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

Learn about institutional subscriptions

Notes

  1. 1.

    It is known [2] that optimal SST for top to random initially marks second from the bottom card.

References

  1. Albrecht, M.R., Paterson, K.G.: Lucky microseconds: a timing attack on Amazon’s s2n implementation of TLS. In: Fischlin, M., Coron, J.-S. (eds.) EUROCRYPT 2016. LNCS, vol. 9665, pp. 622–643. Springer, Heidelberg (2016). doi:10.1007/978-3-662-49890-3_24

    Chapter  Google Scholar 

  2. Aldous, D., Diaconis, P.: Shuffling cards and stopping times. Am. Math. Mon. 93(5), 333–348 (1986)

    Article  MathSciNet  MATH  Google Scholar 

  3. Aldous, D., Diaconis, P.: Strong uniform times and finite random walks. Adv. Appl. Math. 8, 69–97 (1987)

    Article  MathSciNet  MATH  Google Scholar 

  4. AlFardan, N., Bernstein, D.J., Paterson, K.G., Poettering, B., Schuldt, J.C.N.: On the security of RC4 in TLS. In: Presented as Part of the 22nd USENIX Security Symposium (USENIX Security 13), Washington, D.C., pp. 305–320. USENIX (2013)

    Google Scholar 

  5. Ankele, R., Kölbl, S., Rechberger, C.: State-recovery analysis of spritz. In: Lauter, K., Rodríguez-Henríquez, F. (eds.) LATINCRYPT 2015. LNCS, vol. 9230, pp. 204–221. Springer, Cham (2015). doi:10.1007/978-3-319-22174-8_12

    Chapter  Google Scholar 

  6. Banik, S., Isobe, T.: Cryptanalysis of the full spritz stream cipher. In: Peyrin, T. (ed.) FSE 2016. LNCS, vol. 9783, pp. 63–77. Springer, Heidelberg (2016). doi:10.1007/978-3-662-52993-5_4

    Chapter  Google Scholar 

  7. Diaconis, P., Shahshahani, M.: Generating a random permutation with random transpositions. Zeitschrift fur Wahrscheinlichkeitstheorie und Verwandte Gebiete 57(2), 159–179 (1981)

    Article  MathSciNet  MATH  Google Scholar 

  8. Fill, J.A.: An interruptible algorithm for perfect sampling via Markov chains. Ann. Appl. Probab. 8(1), 131–162 (1998)

    Article  MathSciNet  MATH  Google Scholar 

  9. Fluhrer, S., Mantin, I., Shamir, A.: Weaknesses in the key scheduling algorithm of RC4. In: Vaudenay, S., Youssef, A.M. (eds.) SAC 2001. LNCS, vol. 2259, pp. 1–24. Springer, Heidelberg (2001). doi:10.1007/3-540-45537-X_1

    Chapter  Google Scholar 

  10. Fluhrer, S.R., McGrew, D.A.: Statistical analysis of the alleged RC4 keystream generator. In: Goos, G., Hartmanis, J., Leeuwen, J., Schneier, B. (eds.) FSE 2000. LNCS, vol. 1978, pp. 19–30. Springer, Heidelberg (2001). doi:10.1007/3-540-44706-7_2

    Chapter  Google Scholar 

  11. Ge, Q., Yarom, Y., Cock, D., Heiser, G.: A Survey of Microarchitectural Timing Attacks and Countermeasures on Contemporary Hardware. IACR Eprint (2016)

    Google Scholar 

  12. Golić, J.D.: Linear statistical weakness of alleged RC4 keystream generator. In: Fumy, W. (ed.) EUROCRYPT 1997. LNCS, vol. 1233, pp. 226–238. Springer, Heidelberg (1997). doi:10.1007/3-540-69053-0_16

    Google Scholar 

  13. Mantin, I., Shamir, A.: A practical attack on broadcast RC4. In: Matsui, M. (ed.) FSE 2001. LNCS, vol. 2355, pp. 152–164. Springer, Heidelberg (2002). doi:10.1007/3-540-45473-X_13

    Chapter  Google Scholar 

  14. Matthews, P.: A strong uniform time for random transpositions. J. Theoret. Probab. 1(4), 411–423 (1988)

    Article  MathSciNet  MATH  Google Scholar 

  15. Mironov, I.: (Not so) random shuffles of RC4. In: Yung, M. (ed.) CRYPTO 2002. LNCS, vol. 2442, pp. 304–319. Springer, Heidelberg (2002). doi:10.1007/3-540-45708-9_20

    Chapter  Google Scholar 

  16. Mossel, E., Peres, Y., Sinclair, A.: Shuffling by semi-random transpositions. In: Foundations of Computer Science, pp. 572–581 (2004)

    Google Scholar 

  17. Naor, M., Reingold, O.: On the construction of pseudo-random permutations. In: Proceedings of the Twenty-Ninth Annual ACM Symposium on Theory of Computing - STOC 1997, pp. 189–199. ACM Press, New York (1997)

    Google Scholar 

  18. Pereida García, C., Brumley, B.B., Yarom, Y.: Make sure DSA signing exponentiations really are constant-time

    Google Scholar 

  19. Propp, J.G., Wilson, D.B.: Exact sampling with coupled Markov chains and applications to statistical mechanics. Random Struct. Algorithms 9, 223–252 (1996)

    Article  MathSciNet  MATH  Google Scholar 

  20. Schuldt, J.C.N., Rivest, R.L.: Spritz–a spongy RC4-like stream cipher and hash function (2014)

    Google Scholar 

  21. Paul, S., Preneel, B.: A new weakness in the RC4 keystream generator and an approach to improve the security of the cipher. In: Roy, B., Meier, W. (eds.) FSE 2004. LNCS, vol. 3017, pp. 245–259. Springer, Heidelberg (2004). doi:10.1007/978-3-540-25937-4_16

    Chapter  Google Scholar 

  22. Standaert, F.-X., Pereira, O., Yu, Y., Quisquater, J.-J., Yung, M., Oswald, E.: Leakage resilient cryptography in practice. In: Sadeghi, A.-R., Naccache, D. (eds.) Towards Hardware-Intrinsic Security, pp. 99–134. Springer, Heidelberg (2010). doi:10.1007/978-3-642-14452-3_5

    Chapter  Google Scholar 

  23. Maitra, S., Paul, G.: Analysis of RC4 and proposal of additional layers for better security margin. In: Chowdhury, D.R., Rijmen, V., Das, A. (eds.) INDOCRYPT 2008. LNCS, vol. 5365, pp. 27–39. Springer, Heidelberg (2008). doi:10.1007/978-3-540-89754-5_3

    Chapter  Google Scholar 

  24. Yarom, Y., Genkin, D., Heninger, N.: CacheBleed: a timing attack on OpenSSL constant time RSA. CHES (2016)

    Google Scholar 

  25. Zoltak, B.: VMPC one-way function and stream cipher. In: Roy, B., Meier, W. (eds.) FSE 2004. LNCS, vol. 3017, pp. 210–225. Springer, Heidelberg (2004). doi:10.1007/978-3-540-25937-4_14

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Filip Zagorski .

Editor information

Editors and Affiliations

Appendices

Appendix

A Sign Distinguisher Advantage

Fig. 3.
figure 3

The advantage (\(\epsilon \)) of Sign distinguisher of RC4 after discarding initial k bytes.

B Detailed Proof of Lemma 3

Proof

Define \(T_k\) to be the first time when k cards are marked (thus \(T\equiv T_n\)). Let \(d=\lceil (n-1)/2\rceil \). Then \(T_d\) is the running time of the first phase and \(\left( T_n - T_d\right) \) is the running time of the second phase. Denote \(Y_k := T_{k+1}-T_k\).

Assume that there are \(k<d\) marked cards at a certain step. Then the new card will be marked in next step if we choose two unmarked cards what happens with probability:

$$p_a(k)= {(n-k)^2\over n^2}.$$

Thus \(Y_k\) is a geometric random variable with parameter \(p_a(k)\) and

$$ \begin{array}{lllllllll} E[T_d] &{} = &{} \displaystyle \sum _{k=0}^{d-1} E[Y_k] = \sum _{k=0}^{d-1} {1\over p_a(k)}=\sum _{k=0}^{d-1} {n^2\over (n-k)^2} = n^2 \sum _{k=n-d+1}^n{1\over k^2} \\[14pt] &{} = &{}\displaystyle n^2\left( H_n^{(2)}-H_{n-d}^{(2)}\right) = n^2 \left( \frac{1}{n} + O\left( \frac{1}{n^2}\right) \right) = n + O(1). \end{array} $$

Now assume that there are \(k\ge d\) cards marked at a certain step. Then, the new card will be marked in next step with probability:

$$p_b(k)= {(n-k)(k+1)\over n^2}$$

and \(Y_k\) is a geometric random variable with parameter \(p_a(k)\). Thus:

$$ \begin{array}{lllllllll} E[T_n-T_d] &{} = &{} \displaystyle \sum _{k=0}^{d-1} E[Y_k] = \sum _{k=d}^{n-1} {1\over p_b(k)}=\sum _{k=d}^{n-1} {n^2\over (n-k)(k+1)} \\ &{} = &{} \displaystyle {n^2 \over n+1} \sum _{k=d}^{n-1} \left( {1\over n-k} + {1\over k+1}\right) = {n^2 \over n+1} \left( {\sum _{k=1}^{n-d} \frac{1}{k}} + {\sum _{k=d+1}^{n} \frac{1}{k}} \right) \\ &{} = &{} \displaystyle {n^2\over n+1} \left( H_{n-d} + H_n - H_d \right) = {n^2\over n+1} H_n + {n^2\over n+1} \left( H_{n-d} - H_d \right) \\ &{} = &{} nH_n - \frac{n}{n+1}H_n + {n^2\over n+1} \left( H_{n-d} - H_d \right) = nH_n + O(H_n) + O(1) = nH_n + O(H_n). \end{array} $$

For variance we have:

$$ \begin{array}{lllllllll} Var[T_d] &{} = &{} \displaystyle \sum _{k=0}^{d-1} Var[Y_k] = \sum _{k=0}^{d-1} \frac{1-p_a(k)}{\left( p_a(k)\right) ^2} = \sum _{k=0}^{d-1} \frac{1-\frac{(n-k)^2}{n^2}}{\left( \frac{(n-k)^2}{n^2}\right) ^2} \approx \int _{0}^{\frac{n}{2}} \frac{1-\frac{(n-x)^2}{n^2}}{\left( \frac{(n-x)^2}{n^2}\right) ^2} dx = \frac{4}{3} n. \\[24pt] Var[T_n-T_d] &{}=&{} \displaystyle \sum _{k=d}^{n-1} Var[Y_k] = \sum _{k=d}^{n-1} \frac{1-p_b(k)}{\left( p_b(k)\right) ^2} = \sum _{k=d}^{n-1} \frac{1 - \frac{(n-k)(k+1)}{n^2}}{\frac{(n-k)^2 (k+1)^2}{n^4}} \\[24pt] &{} = &{} \displaystyle n^2 \sum _{k=d}^{n-1} \frac{n(n-1)+k(1-n)+k^2}{(n-k)^2 (k+1)^2} \approx n^2 \cdot \frac{1}{2} \sum _{k=0}^{n-1} \frac{n(n-1)+k(1-n)+k^2}{(n-k)^2 (k+1)^2} \\[24pt] &{} \approx &{} \displaystyle \frac{n^2}{2} \left[ \left( \frac{2}{n} - \frac{4}{n^2} \right) H_n + 3 H_n^{(2)} \right] \sim \frac{\pi ^2}{4}n^2. \\ \end{array} $$

Finally

$$Var[T_n] = Var[T_d]+Var[T_n-T_d] \sim \frac{\pi ^2}{4}n^2. $$

\(\square \)

C Experimental Results

The expected running time of \({\textsf {KSA}}^{**}_\texttt {RTRT}\) (i.e., with Random-to-Random Transpositions shuffling) is known:

  • with ST=StoppingRuleKLZ it is \(n(H_n+1)\)

  • with stopping rule used in [15] it is \(2n H_n-n\)

For both stopping rules applied to Cyclic-to-Random Transpositions no precise results on expected running times are known. Instead we estimated them via simulations, simply running 10.000 of them. The results are given in Fig. 4.

Fig. 4.
figure 4

Simulations’ results for Mironov’s and StoppingRuleKLZ stopping rules.

Fig. 5.
figure 5

Example run of top-to-random shuffle with “reused randomness” which is taken from the key K of the length equal to three 8-value bytes (9-bits). Let us assume that the running time of SST was exactly 8. Conditioning on the number of steps one can figure out that the first word of the key must be equal to 111 while the second part \(K[2] \in \{110, 111\}\) with the same probability. Finally \(K[3] \in \{101, 110, 111\}\) and for the step i: \(K[i] = K[i \bmod 3]\). So now, instead of possible \(2^9 = 512\) permutations which can be generated from 9 bits of key, only 6 are possible (based on the fact that SST has stopped exactly after 8 steps).

D Timing-Attacks and \({\textsf {KSA}}^{**}\)

Example 1

(Top to random shuffle T2R – timing attack – re-used randomness). Consider algorithm \({\textsf {KSA}}^{**}_\texttt {T2R,ST}\) with shuffling procedure corresponding to Top-To-Random card shuffling (put the card S[1] which is currently on top to the position j defined by the randomness in the current round) and following stopping time ST:

  • before the start of the algorithm, mark the last card (i.e., the card n is markedFootnote 1),

  • stop one step after the marked card reaches the top of the deck.

The sample execution of the algorithm is given in Fig. 5.

Example 2

(Top-to-random – timing attack – fresh randomness). Let us now consider a very similar situation with one important difference. Now no portion of the key is re-used. An example run of the algorithm is presented on the Fig. 6. Based on the knowledge on the number of performed steps, one can learn some information about the secret key (i.e., \(K[1] = 000\), K[2] is either 110 or 111) but still no adversary can learn anything about the resulting permutation because any information is generated with exactly the same probability.

Fig. 6.
figure 6

Example run of top-to-random shuffle with “fresh randomness” taken from the key K of the length equal to 8 8-value bytes (24-bits). Conditioning on the number of steps of the SST (in this case 8) one can find out that: out of the possible \(2^{24}\) keys only (exactly) 8! keys are possible (due to the fact that SST stopped after 8 steps) and every of 8! permutations are possible (based on the fact that SST has stopped exactly after 8 steps) – moreover each permutation with exactly the same probability. SST leaks bits of the key i.e., \(K[1] = 111\) but does not leak any information about the produced permutation.

E Spritz Definition

Fig. 7.
figure 7

Building blocks of Spritz

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Springer International Publishing AG

About this paper

Cite this paper

Kulis, M., Lorek, P., Zagorski, F. (2017). Randomized Stopping Times and Provably Secure Pseudorandom Permutation Generators. In: Phan, RW., Yung, M. (eds) Paradigms in Cryptology – Mycrypt 2016. Malicious and Exploratory Cryptology. Mycrypt 2016. Lecture Notes in Computer Science(), vol 10311. Springer, Cham. https://doi.org/10.1007/978-3-319-61273-7_8

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-61273-7_8

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-61272-0

  • Online ISBN: 978-3-319-61273-7

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics