Question

In: Computer Science

. Write a program which encodes any string using the XOR instruction.  Test it using your <first...

. Write a program which encodes any string using the XOR instruction.  Test it using your <first name last name> in the data segment to produce cipher text and then decode using the program to get plain text.  Use the last two digits of your student id as the key.  Print plane text from the data segment, print the cipher text, and then print the plain text upon execution.  Submit the asm/list file and screenshots that shows the output of your code.

What are the strengths and weaknesses of this encryption method (25% of points, Typewritten answer required)?

Solutions

Expert Solution

The program for the above problem with the output window screenshot with two different string is given below-

encryptDecrypt(char*):

push rbp

mov rbp, rsp

sub rsp, 32

mov QWORD PTR [rbp-24], rdi

mov BYTE PTR [rbp-5], 82

mov rax, QWORD PTR [rbp-24]

mov rdi, rax

call strlen

mov DWORD PTR [rbp-12], eax

mov DWORD PTR [rbp-4], 0

.L3:

mov eax, DWORD PTR [rbp-4]

cmp eax, DWORD PTR [rbp-12]

jge .L4

mov eax, DWORD PTR [rbp-4]

movsx rdx, eax

mov rax, QWORD PTR [rbp-24]

add rax, rdx

movzx eax, BYTE PTR [rax]

mov edx, DWORD PTR [rbp-4]

movsx rcx, edx

mov rdx, QWORD PTR [rbp-24]

add rdx, rcx

xor al, BYTE PTR [rbp-5]

mov BYTE PTR [rdx], al

mov eax, DWORD PTR [rbp-4]

movsx rdx, eax

mov rax, QWORD PTR [rbp-24]

add rax, rdx

movzx eax, BYTE PTR [rax]

movsx eax, al

mov edi, eax

call putchar

add DWORD PTR [rbp-4], 1

jmp .L3

.L4:

nop

leave

ret

.LC0:

.string "Encrypted String: "

.LC1:

.string "Decrypted String: "

main:

push rbp

mov rbp, rsp

sub rsp, 32

movabs rax, 2334393380863435085

movabs rdx, 7306916077306274156

mov QWORD PTR [rbp-32], rax

mov QWORD PTR [rbp-24], rdx

mov BYTE PTR [rbp-16], 0

mov edi, OFFSET FLAT:.LC0

mov eax, 0

call printf

lea rax, [rbp-32]

mov rdi, rax

call encryptDecrypt(char*)

mov edi, 10

call putchar

mov edi, OFFSET FLAT:.LC1

mov eax, 0

call printf

lea rax, [rbp-32]

mov rdi, rax

call encryptDecrypt(char*)

mov eax, 0

leave

ret

__static_initialization_and_destruction_0(int, int):

push rbp

mov rbp, rsp

sub rsp, 16

mov DWORD PTR [rbp-4], edi

mov DWORD PTR [rbp-8], esi

cmp DWORD PTR [rbp-4], 1

jne .L9

cmp DWORD PTR [rbp-8], 65535

jne .L9

mov edi, OFFSET FLAT:_ZStL8__ioinit

call std::ios_base::Init::Init() [complete object constructor]

mov edx, OFFSET FLAT:__dso_handle

mov esi, OFFSET FLAT:_ZStL8__ioinit

mov edi, OFFSET FLAT:_ZNSt8ios_base4InitD1Ev

call __cxa_atexit

.L9:

nop

leave

ret

_GLOBAL__sub_I_encryptDecrypt(char*):

push rbp

mov rbp, rsp

mov esi, 65535

mov edi, 1

call __static_initialization_and_destruction_0(int, int)

pop rbp

ret

The strength is that it can encrypt the string which is impossible for brute force method and it is done with XOR instruction. The weakness is that by using the same key repeatedly the XOR cipher can be broken.


Related Solutions

Using python: Given a string x, write a program to check if its first character is...
Using python: Given a string x, write a program to check if its first character is the same as its last character. If yes, the code should output "True"
Write a program to remove extra blanks from text files. Your program should replace any string...
Write a program to remove extra blanks from text files. Your program should replace any string of two or more blanks with one single blank. It should work as follows: * Create a temporary file. * Copy from the input file to the temporary file, but do not copy extra blanks. * Copy the contents of the temporary file back into the original file. * Remove the temporary file. Your temporary file must have a different name than any existing...
​Write a recursive method, vowels, that returns the number of vowels in a string. Also, write a program to test your method.
Write a recursive method, vowels, that returns the number of vowels in a string. Also, write a program to test your method.(JAVA Code)
Write instruction(s) in C to get bits 4 and 7 of Port-C, then compute the “XOR...
Write instruction(s) in C to get bits 4 and 7 of Port-C, then compute the “XOR (exclusive OR)” of these two bits and write the result of the “XOR operation” to bit 4 of Port-D.
Write instruction(s) in C to get bits 4 and 7 of Port-C, then compute the “XOR...
Write instruction(s) in C to get bits 4 and 7 of Port-C, then compute the “XOR (exclusive OR)” of these two bits and write the result of the “XOR operation” to bit 4 of Port-D.
Write a MIPS assembly program that prompts the user first for a string, then for a...
Write a MIPS assembly program that prompts the user first for a string, then for a character. The program should then search the string for the character and print out the number of times the character appears in the string. You can use as many restrictions as you want, just be sure to list them. You must allocate space in the .data segment of your program for the user string.
Write a C++ Program to print the first letter of your first and last name using...
Write a C++ Program to print the first letter of your first and last name using stars. Note: 1) Using nested For Loop 2) The number of lines is given by user. 3) Using one Outer loop to print your letters. 4) Print the letters beside each other.
Write a Python program which prompts the user to input a string. Then, print the string...
Write a Python program which prompts the user to input a string. Then, print the string in reverse to the terminal Sample output Please enter a word: "zeus" The reverse of zeus is suez Hint: There are several ways to accomplish this. Recall that a string is an itterable object and therefore can be used with a for loop
Assignment Write a program using turtle graphics which writes your initials, or any other three unique...
Assignment Write a program using turtle graphics which writes your initials, or any other three unique letters, to the display. Look to your program for lab 1 for reminders of how to use turtle graphics. Functions that must be written: def drawLetter (x, y, letterColor): Write three functions, one for three unique letters. Personally, I would write drawA, drawR, and drawS. Each function must draw that letter to the screen. The x and y values determine the upper left-hand location...
Write a program that takes a string input from the user and then outputs the first...
Write a program that takes a string input from the user and then outputs the first character, then the first two, then the first three, etc until it prints the entire word. After going up to the full word, go back down to a single letter. LastNameUpDown. Input: Kean Output: K Ke Kea Kean Kea Ke K
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT