atakoute_CS3626Sp01_Assignment03

docx

School

Kennesaw State University *

*We aren’t endorsed by this school

Course

3626

Subject

Computer Science

Date

Apr 3, 2024

Type

docx

Pages

10

Uploaded by PresidentMooseMaster1069

Report
- 1 - CS3626 Homework 03 Spring 2024 DES Total Points: 25 Be as brief as possible and use your own words when describing concepts.   SHOW ALL WORK for Questions requiring calculations and algorithms. Q-1: Using the algorithm given below encrypt the following ASCII message using the ASCII key given below: Message: ‘X4zr’ (You’ll need to encrypt 2 blocks to complete this message) Algorithm: Feistel Block Size: 16 bits Number of Rounds: 2 Key Round 1 = ‘B’ Key Round 2 = ‘e’ Function: F = (((RE i * Key) >> 4) + RE i ) mod 2 8 NOTE: * is regular multiplication operator and + is LOGICAL OR Operator, i = round number (where, when i = 0; LE 0 , RE 0 are inputs to round 1) >> means bit-shift right meaning binary value 01001111 >> 4 becomes 00000100: 1111 bits shifted out and zeros shifted in. SHOW FEISTEL STRUCTURE below with the values of LE i , RE i , the result of F and the result of F LE i for each round and block of encryption. K1 = 0100 0010, K2 = 0110 0101 1st block: 0101 1000 0011 0100 L 0 : 0101 1000 R 0 : 0011 0100 R0 * K1 = 3432 equivalents to 110101101000 R0*K1>>4 = 1101 0110 (R0*K1)>>4 + R0 = 1111 0110 Hence F1 = 1111 0110 R1 = F1 ⊕L0 = 1010 1110 L1: 0011 0100 R1: 1010 1110 R1 equivalents to and K2 equivalents to R1 * K2 = 17574 equivalents to 1000 1001 0100 110 (R1*K2)>>4 = 1000 1001 010 (R1*K2)>>4 + R1 = 10011101110 equivalents to 1262 and 1262(mod 256) = 238 equivalents to 1110 1110 Hence F2 = 1110 1110 R2 = F2 ⊕L1 = 1101 1010 L2: 1010 1110 R2: 1101 1010 Last Swap give: L3: 1101 1010 R3: 1010 1110 After the first round we got: 1101 1010 1010 1110 equivalents to DAAE 2nd block: 0111 1010 0111 0010
- 2 - L 0 : 0111 1010 R 0 : 0111 0010 R0 * K1 = 7524 equivalents to 1110101100100 R0*K1>>4 = 111010110 (R0*K1)>>4 + R0 = 111110110 equivalents to 502 and 502 mod 256 = 246 246 equivalents to 1111 0110 Hence F1 = 1111 0110 R1 = F1 ⊕L0 = 1000 1100 L1: 0111 0010 R1: 1000 1100 R1 equivalents to 140 and K2 equivalents to 101 R1 * K2 = 14140 (R1*K2)>>4 = 1101110011 (R1*K2)>>4 + R1 = 1111111111 equivalents to 1023 and (1023 mod 256) = 255 equivalents to 1111 1111 Hence F2 = 1111 1111 R2 = F2 ⊕L1 = 1000 1101 L2: 1000 1100 R2: 1000 1101 Last Swap: L3: 1000 1101 R3: 1000 1100 After the second round we got: 1000 1101 1000 1100 equivalents to 8D8C What is the transmitted ciphertext (provide in hexadecimal): DAAE8D8C 6 points FYI, YOUR PROJECT WILL IMPLEMENT FEISTEL using Galois Field Math in Function F, should you wish to start Feistel Implementation now with a regular function and later replacing F with Galois F.
- 3 - Q-2: What is the result of the following inputs to these DES (sort-of) functions: Input[16-bits]: 0x3C1D [MSB = bit position 1 left to right] Expansion Box: First input bit position [14] represents output position [1], that is counting from 1 not 0. 14 16 3 6 8 13 5 15 13 9 14 7 8 11 4 12 10 2 10 2 1 7 5 12 What is output (in hexadecimal) of the expansion box function: F6A303 2 points Q-3: The output above is broken into 6-bit segments and sent from left to right to the following four DES S-Boxes in order S1, S2, S3 and S4. What is the resulting Output (in hexadecimal): 64F8 2 points Q-4: The output above is then circular bit shifted left by 5 bits. What is the resulting shifted Output (in hexadecimal): 9F0C 2 points
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
- 4 - Q-5: Upgrade your Caesar algorithm to Vigenere to encrypt and decrypt. Also upgrade it to allow changing the hard coding of the ASCII alphabet (if not already done). E.g. set a variable (however your language does this) to define an alphabet. As an example, for C++ std::vector or std::string is recommended, such as: std::string alphabet = “abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789”; where a = 0, b = 1, c = 2 etc… --- being changed and rebuilt to use this alphabet --- std::string alphabet = “0123456789abcdefghijklmnopqrstuvwxyz”; where ‘0’ = 0, ‘1’ = 1, ‘a’ = 10 etc… Upgrade your vigenere code to read from an input file and an output file. These can be supplied as arguments or hard-coded (but arguments will work better for future assignments), e.g. vigenere <input_file> <key> <output_filename> <e = encrypt | d = decrypt> Example execution on command line: ./vigenere plaintext.txt mykeyisthis cyphertext.txt e ****************** Example BEGIN Example **************************** Using the alphabet: std::string alphabet = “abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789” NOTE: PASS through any values not in your alphabet. For example: if KEY = “box” Message: I have a dot.number(1) Comma, Colon: and parenthesis Cyphertext result: J vxws x eCQ.oIJcsO(2) QLnAx, DCIpB: xor MbFBoHEfGFt Spaces are not in alphabet and pass through, punctuation and spaces do as well in this example. ****************** Example END Example **************************** ------------------ BEGIN ASSIGNMENT REQUIRED RESPONSE INSTRUCTIONS -------------------- Response 1: Using plain1.txt as input file------------------------------------------------------------------------------------- Alphabet “abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789” The underscore above ( _ ) between z and A is meant to represent the SPACE character (0x20). Use Key: Key Any plaintext value not in alphabet is just copied through untouched. Any key value not in alphabet should generate an error and exit. Key is indexed only on valid alphabet characters, a character outside the alphabet does not cause key to move to next character in key. Using this key = “Key” and alphabet above encrypt plain1.txt and provide the cypher output here: dsL1hFXeQOwXb5qB,FrH,3sayPODFXtR3DPOuROr ODfB7:XjRha6qE,D1nEXB4. Hint: do you see the text?: ,D1nEXB4 Response 2: Using cypher2.txt as input file.---------------------------------------------------------------------------------- Next, change the alphabet to: std::string alphabet = “aeiouycdx_IVXLCDMK012”; // the _ here is a SPACE (0x20) Using this alphabet and key = “Key” decrypt cypher2.txt and provide the plaintext output here: Region:_MCMXLCV__Hawking_Text:_X121_Use_CHROMA_V2 Hint: CHROMA V2 Provide source-code per instructions below. Keep this code it will be revisited. 8 points
- 5 - More Examples: here is another short example, see if your algorithm matches, For vigenere, when the letter is not in the alphabet for the key, exit the program and error out. When a letter in the plaintext is not in the alphabet, pass it through but do not count it as a character against the key (that is keep the current key index, skipping over non alphabet characters in plaintext, and use it for the next valid alphabet character). Do this both for encryption and decryption [since passthrough can put non-alphabet characters in cyphertext]. key = box alphabet = [a-z] { lowercase only in other words} message = "GrancisBacons" Encryption is then: *boxbo*xboxbo K // where * means skip over plaintext and don't use up that key element either. GranciSBacons +P // Input has capital letters that are just passed through. _____________ GsokdwSBxdckt =C // The G S B are passed through and the key does not index up on those chars. that is to say if only lower case are counted: boxboxboxb K ranciacons +P ___________ sokdwxdckt =C
- 6 - Q-6: Upgrade your frequency analyzer to provide the a sorted from most frequent to least frequent output characters. Allow all possible extended-ASCII character values from 0 – 255. Note: 0 = NULL. Plain Text File = SherlockHolmes.txt [see D2L files] Provide the frequency spectral output of SherlockHolmes.txt here with counts sorted (either descending or ascending). My Output: ’(space character)- 1036511 of 6488666 e - 628234 of 6488666 t - 444459 of 6488666 a - 395872 of 6488666 o - 382683 of 6488666 n - 362397 of 6488666 i - 348464 of 6488666 s - 326238 of 6488666 r - 303977 of 6488666 h - 287323 of 6488666 d - 211677 of 6488666 l - 195904 of 6488666 c - 138853 of 6488666 u - 137114 of 6488666 \n- 128457 of 6488666 m - 120829 of 6488666 f - 116374 of 6488666 w - 94576 of 6488666 g - 93732 of 6488666 p - 89967 of 6488666 y - 88196 of 6488666 , - 77675 of 6488666 b - 67206 of 6488666 . - 58672 of 6488666 v - 50525 of 6488666 k - 31160 of 6488666
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
- 7 - " - 26108 of 6488666 I - 17174 of 6488666 - - 17127 of 6488666 T - 16282 of 6488666 A - 12217 of 6488666 ' - 10018 of 6488666 x - 9196 of 6488666 P - 8946 of 6488666 S - 8659 of 6488666 H - 7358 of 6488666 N - 6621 of 6488666 W - 6255 of 6488666 M - 6234 of 6488666 C - 6119 of 6488666 B - 5962 of 6488666 E - 5584 of 6488666 R - 5578 of 6488666 1 - 5572 of 6488666 _ - 5488 of 6488666 j - 5114 of 6488666 F - 4501 of 6488666 q - 4422 of 6488666 ! - 4345 of 6488666 O - 4184 of 6488666 ? - 4155 of 6488666 D - 4029 of 6488666 z - 3651 of 6488666 ; - 3511 of 6488666 G - 3184 of 6488666 0 - 3064 of 6488666
- 8 - 2 - 3053 of 6488666 L - 2744 of 6488666 8 - 2527 of 6488666 3 - 2492 of 6488666 4 - 2417 of 6488666 Y - 2285 of 6488666 5 - 2192 of 6488666 9 - 1999 of 6488666 6 - 1993 of 6488666 7 - 1890 of 6488666 : - 1855 of 6488666 V - 1853 of 6488666 = - 1764 of 6488666 ( - 1748 of 6488666 ) - 1748 of 6488666 K - 1638 of 6488666 U - 1618 of 6488666 J - 1322 of 6488666 # - 742 of 6488666 X - 614 of 6488666 * - 489 of 6488666 [ - 435 of 6488666 ] - 435 of 6488666 | - 408 of 6488666 Q - 149 of 6488666 Z - 145 of 6488666 / - 132 of 6488666 $ - 110 of 6488666 + - 91 of 6488666 - 12 of 6488666
- 9 - & - 8 of 6488666 % - 8 of 6488666 @ - 8 of 6488666 > - 3 of 6488666 < - 2 of 6488666 ~ - 2 of 6488666 ^ - 2 of 6488666 Most common: 1036511( ‘ ’ space character) - 6488666 of 6488666 As an example phrases.txt produces the sorted spectrum: (Note: 0 results were suppressed and in this example values were left out to demonstrate here. If character was unprintable, it was replaced with hexadecimal value e.g. 0x00a, 0x00d - you are not required to do this but it helps make the output less messy) Sample Output of Frequency: - 3981 of 21964 e - 2297 of 21964 a - 2113 of 21964 i - 1207 of 21964 t - 1070 of 21964 n - 1031 of 21964 0x00a - 990 of 21964 0x00d - 990 of 21964 . . (Median results omitted for clarity) . . - 2 of 21964 B - 1 of 21964 C - 1 of 21964 M - 1 of 21964 Most common: 3981(' ' = 20) - 21964 of 21964 Provide source-code per instructions below. Keep this code it will be revisited. 5 points
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
- 1 Submission Guidelines: No handwritten submission is accepted, always submit answers as text within this or similar document file with any support images embedded in the file. EXCEPTION : If asked for source code implementation you can submit those individually and as separate files in ASCII format in their original file format .cpp, .java, .py, .cs etc. or even as a .txt file will be acceptable. Do not insert code into the submission document file. It ruins spacing which makes .python and some languages (perl, awk etc.) difficult to test build. Do not submit ZIP files… ever… for anything in D2L. The system is extremely unhelpful with regards to those filetypes and grading. You may include your freehand drawing/image and handwritten scans in the submission. However, the writing and images must be clearly legible. Though, it is best to present non-handwritten submissions, generally, as is done in the professional setting. If asked, show all work/calculations/graphs etc. in the determination of the problem. Please complete your entire work in a single Word Document and Save the file as: yournetid_CS3502_Assignment01.docx (e.g. ogarcia5_CS3502_Assignment01.docx.) and upload your file in D2L. Please observe the submission due date and time. After the due date there is a 50% penalty for the next 24 hours. Any submission after 24 hours of the due date will be graded at 0%. If you include a reference or an image taken from other sources, please cite them appropriately. APA is preferred but cite them so they can be found. NOTE: verbatim copying or even paraphrasing is plagiarism so if the source used constitutes your answer rather than simply supporting the answer, it will be considered invalid. This is especially true of source code implementation answers. If you resubmit, please make sure to attach the file again. Your latest submission before the due date will be the one graded.