Description
1. Here is a Python dictionary of the relative frequency of letters in English text:
{ “A”: .08167, “B”: .01492, “C”: .02782, “D”: .04253, “E”: .12702, “F”: .02228,
“G”: .02015, “H”: .06094, “I”: .06996, “J”: .00153, “K”: .00772, “L”: .04025,
“M”: .02406, “N”: .06749, “O”: .07507, “P”: .01929, “Q”: .00095, “R”: .05987,
“S”: .06327, “T”: .09056, “U”: .02758, “V”: .00978, “W”: .02360, “X”: .00150,
“Y”: .01974, “Z”: .00074 }
Here is some plaintext:
ethicslawanduniversitypolicieswarningtodefendasystemyouneedtobeabletot
hinklikeanattackerandthatincludesunderstandingtechniquesthatcanbeusedt
ocompromisesecurityhoweverusingthosetechniquesintherealworldmayviolate
thelawortheuniversitysrulesanditmaybeunethicalundersomecircumstancesev
enprobingforweaknessesmayresultinseverepenaltiesuptoandincludingexpuls
ioncivilfinesandjailtimeourpolicyineecsisthatyoumustrespecttheprivacya
ndpropertyrightsofothersatalltimesorelseyouwillfailthecourseactinglawf
ullyandethicallyisyourresponsibilitycarefullyreadthecomputerfraudandab
useactcfaaafederalstatutethatbroadlycriminalizescomputerintrusionthisi
soneofseverallawsthatgovernhackingunderstandwhatthelawprohibitsifindou
btwecanreferyoutoanattorneypleasereviewitsspoliciesonresponsibleuseoft
echnologyresourcesandcaenspolicydocumentsforguidelinesconcerningproper
The population variance of a finite population X of size N and mean µ is given by
Var(X) = 1
N
N
∑
i=1
(xi − µ)
2
.
(a) What is the population variance of the relative letter frequencies in English text?
(b) What is the population variance of the relative letter frequencies in the given plaintext?
(c) For each of the following keys — yz, xyz, wxyz, vwxyz, uvwxyz — encrypt the plaintext
with a Vigenère cipher and the given key, then calculate and report the population
variance of the relative letter frequencies in the resulting ciphertext. Describe and briefly
explain the trend in this sequence of variances.
(d) Viewing a Vigenère key of length k as a collection of k independent Caesar ciphers,
calculate the mean of the frequency variances of the ciphertext for each one. (E.g., for
key yz, calculate the frequency variance of the even numbered ciphertext characters
and the frequency variance of the odd numbered ciphertext characters. Then take their
mean.) Report the result for each key in part (c). Is the mean variance like those
observed in part (b)? Part (c)? Briefly explain.
(e) Consider the ciphertext that was produced with key uvwxyz. In part (d), you calculated
the mean of six variances for this key. Revisit that ciphertext, and calculate the mean of
the frequency variances that arise if you had assumed that the key had length 2, 3, 4,
and 5. Does this suggest a variant to the Kasiski attack? (Don’t say no!) Briefly explain.
2. Here is some ciphertext that was produced with a Vigenère cipher:
TUSQIQEGBFQTDHTUSZIXENQGXKGAAFHKMRXRRBJBGSFUWVEHPLVBWPZXHBIUBGETNZOBGI
DHBHLZMNNBGBGIIEVRZRISSCOTNAEQVLUZRDVBGMDHTUSOWUITUOWBGIHBFVMRSFGVHZZR
GRFVJNVESCUBGIIEFLLDVSJOVANKRROWBGETGVHGVIRRKLTKMNTHRNZGERJHVSLEGSUZNV
OSHKMCSOEWIBGIIEADASIRFVHIQXSJSUMRXENRBIRXHRMZIKOEQPHAHHEGVHUAYTNFRLSL
EUCUADSFECKIMVESIVMCXHRKDGZRDUSVBNSDFKHISMNTOQLSVEZPOQMKIAOIMZVTUOWEZW
GEWHDNYSGCVMDXHRBOMFSLNGOIHHHVGKIMHSBBKQRIYRGDVCWAAUVWLIWBFGASLAGKHVSW
OSHLVSLETZRWLYNGWOPDWUSTHZDHHVAVMKJTBPHTDHAAROMFSLNGSIRWEQWQIMHTUSUMRX
OBRJQLPIGVHLVERSZHNSELYOOWMIHVGNVDISFVRWJENQVHEZWWECWPVMTUVLURILSVHZDM
SNHKQMKUAVHIQHOSVHAZMDNBHTEAIYZJWTRDRFJZNYNQOQLZHWNFILZVEACWEHXHGVDBGI
PYIQODHIAPXBHXSRSPMCXOUWPBGETUSGZZKGRRKQRJERHOQJILROGWUIRGVHBGVEFVRTCE
NQOWWMGENPOQMHNRGVKZQEHDRVGMMRJHVTTOAULUKMGYWQARSNJVRPZHWNZNMCYNNTUIHH
IAADVXHERDSTZGEFCIBGIWBFOLZVATCUVGEDOFRCFLTGCUKGISSFRUCYNUOUZNAAARQWVL
EJSQBZLENREMZVIAURVDELBTWIMHEYZDLZRWVHKIMSTUSUEDRTNHWPDVENFDVCKIZZLASY
MOZLVFFEUWQLRXRBJHBNSVRFWIJIHVAKMBSUYRVMDROGVLVFFUGHKMCMMSZDUDSFGVHBNV
CUSVJTXISHKMBSMCOQGGELGSGBGIRRGHMLIDNBHVCPEFGZPHWPRFRNUSIPSVIKPAOCXBGM
MNAXZLYRBTZWQHSVBQWSSNTIHBGETUSKICIVRFKMZVDOSIWQINBHKQMKAFGDQKIDGVHKNQ
PNBBVNVWVHKASSOQHKMHVPNGVIFIAARBMSWTROGQKCFROUOQIWBBWPDHWNFIIRLEJSQBNR
MBGWWEELYPHKZYSRVHSMIWACZBGETGVHZDGOHZGJDROGIUVHRGOOFSZPLGVHXZXHFPHPHR
Assume that encrypting with the key letter A results in no change, B results in an increment by
one place in the alphabet, C results in an increment by two places, and so on.
What is the key? (Show your work.)
3. Briefly, what is “snakeoil cryptography”? How does it relate to the exercise above?
2
Submission Template
Please submit three files to Canvas: P1.txt, P2.txt, and P3.txt. P1.txt and P2.txt will contain
both the code and solutions used for the respective problem. If you used the same code for both
problems, please repeat the code in both documents (it makes it easier for us to grade!). Make
sure your files are .txt files and not .rtf files, and check to make sure they display properly on
Canvas. Also be sure to comment your code with clear explanations and to cite any references used.
Filename: P1.txt
# Problem 1
part_a_var_english=0.0000000
part_b_var_plaintext=0.0000000
part_c_var_ciphertexts=[0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000]
part_c_explain=”briefly_describe_and_explain_trend …”
part_d_means=[0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000]
part_d_explain=”briefly_compare_and_explain_results …”
part_e_means=[0.0000000, 0.0000000, 0.0000000, 0.0000000]
part_e_explain=”briefly_explain_attack_variant …”
show_your_work_here …
Filename: P2.txt
# Problem 2
key=XXXXXXXXXX
show_your_work_here …
Filename: P3.txt
# Problem 3
briefly_answer_the_questions …
3

