# How do substution-permutation networks work? [duplicate]

I understand what is going on in higher level. But I don't understand what's really going on in page 3 and 4 of this slide.

Specifically,

1. How $S_0$ and $S_1$ is used? What goes in what goes out?
2. How exactly do key bits determine which s-box is to be used at each position? Position refers to what?
3. Is the function $f$ on page 4 exactly the same SP network on page 3?
4. Why split plain text into left $L$ and right $R$?
5. Why XOR $L$ with $R$ after applying $f$?
6. Why rotate after applying last $f$?
7. Why is XOR used? Why not some other bitwise operation?

Here are the preceding slides for reference.

• See my answer stackoverflow.com/a/35243292/3899583 – vojta Feb 6 '16 at 16:49
• This is an exact duplicate of a question in stackoverflow, answered there as in the comment above by @vojta – kodlu Feb 9 '16 at 12:02