\documentclass[11pt]{article}
\usepackage{amsmath, alltt, amssymb, xspace, times, epsfig, fancyhdr}

\setlength{\evensidemargin}{0in} \setlength{\oddsidemargin}{0in}
\setlength{\textwidth}{6.5in} \setlength{\textheight}{8.5in}
\setlength{\topmargin}{0in} \setlength{\headheight}{0in}

\newcommand{\Zn}{\ensuremath{\mathbb{Z}_n}\xspace}
\newcommand{\Zns}{\ensuremath{\mathbb{Z}_n^*}\xspace}
\newcommand{\Zp}{\ensuremath{\mathbb{Z}_p}\xspace}
\newcommand{\Zps}{\ensuremath{\mathbb{Z}_p^*}\xspace}
\newcommand{\Zq}{\ensuremath{\mathbb{Z}_q}\xspace}

\newcommand{\smod}{\ensuremath{\mathrm{mod}\;}}

\newcommand{\DD}{\ensuremath{\mathcal{D}}\xspace}

 \lhead{}
 \chead{}
 \rhead{}
 \lfoot{}
 \cfoot{\small More on the back.  Turn Over.}
 \rfoot{}
 \renewcommand{\headrulewidth}{0pt}



%\title{CS355: Introduction to Cryptography}
\begin{document}
%\author{Ninghui Li}
%\date{}
%\maketitle

\thispagestyle{empty}

\noindent \textbf{CS355: Cryptography\hspace*{\fill}Fall 2005}
\begin{center}
{\LARGE Homework \#2}
\end{center}

\paragraph{Due date \& time:} 10:30am on September 30, 2005.
Hand in at the beginning of class (preferred), or email to the TA
(wangq@purdue.edu) by the due time.

\vspace*{-0.1in}\paragraph{The Late Policy and Additional
Instructions for HW1 still apply.  Ask for clarifications if you
have questions about them.\\}

\thispagestyle{fancy}


\begin{description}

 \item[Problem 1 (5 pts)] Exercise 19 in Section 2.13 of the textbook (On page 57).

 \item[Problem 2 (5 pts)] Exercise 20 in Section 2.13 of the textbook (On page 57).

 \item[Problem 3 (5 pts)] Exercise 11 in Section 3.13 of the textbook (On page 105).

 \item[Problem 4 (10 pts)] Exercise 15 in Section 3.13 of the textbook (On page 105).

 \item[Problem 5 (15 pts)] Exercise 16 in Section 3.13 of the textbook (on pages 105--106).

 \item[Problem 6 (5 pts)] Calculate $\phi(64)$,  $\phi(100)$, and $\phi(120)$.

 \item[Problem 7 (15 pts)] Exercise 17 in Section 3.13 of the textbook (On page 106).

 \item[Problem 8 (15 pts)] Exercise 20 in Section 3.13 of the textbook (On pages 106 -- 107).

 \item[Problem 9 (10 pts)] Let $a$ be a positive integer whose
base-10 representation is $a=(a_{k-1}\cdots a_1a_0)_{10}$.  Let $b$
be the sum of the decimal digits of a; that is, let
$b:=a_0+a_1+\cdots+a_{k-1}$.  Show that $a\equiv b\: (\smod 9)$.
From this, justify the usual ``rules of thumb'' for determining
divisibility by $9$ and $3$: a is divisible by $9$ (respectively,
$3$) if and only if the sum of the decimal digits of $a$ is
divisible by $9$ (respectively, $3$).

 \item[Problem 10 (15 pts)]  We now describe a variation of
the RC4 stream cipher, which instead of working with bytes, uses
2-bit blocks. The internal state \texttt{S} has $8$ bits, and is
maintained as $4$ blocks of $2$ bits each: \texttt{S[0]},
\texttt{S[1]}, \texttt{S[2]}, \texttt{S[3]}.  The initialization
process divides the key into blocks of $2$ bits each and stores them
in \texttt{K[0]}, \texttt{K[1]}, \texttt{K[2]}, \texttt{K[3]}. It
then does the following:
\begin{verbatim}
    for i:=0 to 3 do
        S[i] := i;
    end for
    j := 0;
    for i:=0 to 3 do
        j := (j + S[i] + K[i mod L]) mod 4;
        swap (S[i], S[j]);
    end for
\end{verbatim}

\begin{description}
 \item[a.]
Given the initial key such that \texttt{K[0]=3}, \texttt{K[1]=2},
\texttt{K[2]=3}, \texttt{K[3]=1}.  What is the internal state in
\texttt{S}, i.e., what are the values of \texttt{S[0], S[1], S[2],
S[3]}.

 \item[b.]
Write out the algorithm that outputs the two-bit sequences to be
used in encryption.

 \item[c.]
Give the first $8$ blocks of outputs.

 \item[d.]
What is the number of possible internal states in the above cipher?

 \item[e.]
What is the number of possible internal states in the actual RC4
cipher?

\end{description}

\end{description}



\end{document}
