Assignment title: Information
ThefirstpartoftheMBCisbasedaroundthefollowingscheme:
Dear Bob,
I am going to send you 1024 puzzles. Each puzzle is a cryptogram whose plaintext
starts out with 128 zero bits (16-bytes), followed by a unique 16-bit (2-byte) puzzle
number, and then a 64-bit (8-byte) key. The cryptograms have been encrypted using
the DES standard with a key whose final 48 bits are zeros.
Please pick one cryptogram at random and break it by brute force, trying all 216 keys
ending in 48 zeros. You know you have broken it when you find a key that yields
a plaintext starting with 128 zero bits. After breaking the cryptogram, extract the
64-bit key and use it as our shared key. As your first message send me back the
puzzle number in plaintext, so I know which key you are going to use.
Yours sincerely,
Alice
Part1: ImplementMerkle’sPuzzles
YoushouldimplementtheaboveschemeinJava.Yourimplementationshouldbestructuredas
youseefit,butshouldcontainthefollowingfunctionality.
Question1:PuzzleGeneration:FirstlyyoushouldwritecodethatAlicecouldusetogenerate
1024 random puzzles. Once the puzzles have been generated, you should encrypt each of the
puzzlesusingadifferentDESkey(endingin48zeros!).
Question 2:
PuzzleStorage:Onceyouhaveencryptedthepuzzlesyoushouldwritethemtoafile.Todothis,
youcanrepresenttheencryptedpuzzlesi nASCII.Eachencryptedpuzzleshouldbewrittento
itsownline.AnexamplepuzzlefileJTQSPWJEFE.
Question 3: Puzzle Cracking: Next, you should implement functionality that allows Bob to
readintheencryptedmessages. Yourcodeshouldthenchoosearandommessageandcrackit,
bytryingall216 keys.
Question4: Keylookup: Finally,implementfunctionalitythatallowsAlicetolookupthekey
thatcorrespondstoagivenpuzzlenumber. Thisshouldbefairlystraightforwardsifyouhave
usedagoodimplementationstructure.
Part2: DemonstrateMerkle’sPuzzlesWorking
Question 5: DemonstrateSuccessfulKeyExchange:
Youshouldextend thecodeyou havewrittenwithamainclassthat demonstratesthatAlice
andBobcanshareasecretkeyandcommunicateusingit. Forexample,yourprogramshould
generateaseriesofpuzzlesandstoretheminafile. Yourprogramshouldthenreadinthepuzzles
andcrackoneofthem. Oncecracked,BobshouldthensendamessagetoAlicewiththepuzzle
number(thismayjustinvolvereturningapuzzlenumberandpassingittoanotherfunction).
Finally,AliceshouldsendanencryptedmessagetoBobusingthekeythatcorrespondstothe
puzzle number. Bob should be able to successfully decrypt the message. Please note: this
part mainly involves calling your previously implemented functions and printing
certain information to the screen at the relevant places.Part 3: Programming Style and Documentation
Question 6:
You should use an appropriate class structure for capturing the above scheme. You should
alsousesuitablevariablenames,methodsandcomments. Finally,youshouldincludesuitable
JavaDocforallyourmethodsandclasses.
HintsandTips
"Javafilenamed“CryptoLib.java”.Thisfilecontainsanumberofhelpermethodsthatyoumay
wanttouseforworkingwithbytearraysinJava.Inparticularitcontains:
• methods for converting small integers (up to 65, 535) to byte arrays and back.
• methods for converting byte arrays into SecretKey’s that can be used with the Java DES
Library explored in the labs.
• methods for converting byte arrays (e.g. keys) into strings (base 64) and back.
*OTJEFFBDIQV[[MF
UIFSFTIPVMECFBSBOEPNMZHFOFSBUFE%&4LFZ5IJTLFZDBOCFDSFBUFEVTJOHUIF
CVJMUJOMJCSBSZNFUIPETUIBUXFFYQMPSFEJOMBCBOETUPSFECZHFUUJOHUIFCZUFTPGUIFLFZ
5PFODSZQUFBDIQV[[MF
UIFSFTIPVMECFB%&4LFZUIBUJTCBTFEPOBCZUFBSSBZUIBUFOETJO[FSPT
)FSFZPVDBOOPUVTFUIFCVJMUJOMJCSBSJFTUPDSFBUFTVDIBLFZ BTZPVXBOUJUUPCFCBTFEPOTPNFWFSZ
TQFDJGJDVOEFSMZJOHEBUB
)FODF
UIJTLFZDBOCFDSFBUFECZVTJOHUIFNFUIPE*IBWFQSPWJEFEXJUIJO
UIF$SZQUP-JCDMBTT"MTPOPUF
UIBUGSPNUIJTNFUIPEZPVXJMMHFUCBDLB4FDSFU,FZPCKFDUUIBUIBTCFFO
CVJMUVTJOHUIFVOEFSMZJOHCZUFBSSBZTQFDJGJDBUJPO5IJT,FZNBZOPUFOEJO[FSPTJGZPVMPPLBUJU
CVU ZPV LOPX UIBU JT IBT CFFO DSFBUFE VTJOH CZUF EBUB UIBU EPFT FOE JO [FSPT 8IJDI JT FOPVHI
JOGPSNBUJPOGPS#PCUPCSVUFGPSDFBUUBDLUIFLFZ
"MPOHXJUIUIJT
ZPVTIPVMEOPUFUIBUXIFODSBDLJOHLFZT
ZPVNBZmOEUIBUEJČFSFOULFZTDBOBMMCF
VTFE UP TVDDFTTGVMMZ DSBDL B QV[[MF 5IJT JT EVF UP B OVNCFS PG CJUT XJUIJO B %&4 LFZ CFJOH VTFE BT
iQBSJUZwCJUT5IFTFCJUTBSFFTTFOUJBMMZOPUVTFEXJUIJOUIFFČFDUJWFCJULFZ
'JOBMMZ
UIF MJCSBSZ DBMM DJQIFSEP'JOBM
GSPN MBC %&4
XJMM UISPX B #BE1BEEJOH&YDFQUJPO XIFO
HJWFOBOJMMGPSNBUUFELFZ:PVTIPVMEUBLFUIJTFYDFQUJPOBTSFQSFTFOUJOHBLFZCFJOHJODPSSFDU
Submission
You should submit all your source code files along with a README file that provides informationonhowtorunyourprogramalongwithanyotherinformationyouwantthemarkerto
know.