Question: Please write it in x86 assembly language. Description Alex and Sila are espionage agents working for the Top Secret Agency (TSA). Sometimes they discuss sensitive


Please write it in x86 assembly language.
Description Alex and Sila are espionage agents working for the Top Secret Agency (TSA). Sometimes they discuss sensitive intelligence information that needs to be kept secret from the Really Bad Guys (RBG). Alex and Sila have decided to use a simple obfuscation algorithm that should be good enough to confuse the RBG. As the TSA's resident programmer you've been assigned to write a MASM procedure that will implement the requested behavior. Your code must be capable of encrypting and decrypting messages (and meet the other requirements given in this document). This final project is written less like an academic assignment and more like a real-life programming task. This might seem daunting at first but don't despair! Algorithm Details Ankur and Sila's algorithm is a simple substitution cipher. If you are not familiar with substitution ciphers, I suggest reading the Wikipedia page (available here). For this implementation, the key consists of 26 lowercase English letters. The following example demonstrates the obfuscation algorithm that Ankur and Sila are requesting. Suppose that you are provided the following 26 character secret key: efbcdghijklmnopqrstuvwxyza. Each character listed in the key corresponds to a character from the English alphabet. In other words, the key is a map that tells you how to take the original text (also known as plaintext) and replace each letter with the encrypted character. In order to understand the key, consider the alphabetical arrangement of the English alphabet beginning with a, b, c, d, e, f, (and so on). Now reconsider the key, which starts with e, f, b, c, d, g, (and so on). Using the key from above, we can map each letter as follows: Original Character --> Encrypted Replacement b --> C--> b d --> e --> d f -->S g--> i --> ; (some entries skipped) X -->y y --> z Z --> a For example, every "a" in the original message is to be enciphered as an "e". Every "b" in the original message should be replaced with the letter "f". Each character in the original message maps to a specific replacement character. Now suppose that you are trying to encrypt the following plaintext message: the contents of this message will be a mystery. Using the secret key from above, the corresponding ciphertext is: uid bpoudout pg uijt ndttehd xjmm fd e nztudsz. Note that only the letters have been changed! Other aspects of the message such as punctuation and spacing should be be left unchanged. In order to decrypt the message, you can use the same key (in reverse) to process the ciphertext and convert it to plaintext. The key will always consist of exactly 26 characters (containing every letter of the English alphabet arranged in a random order). A character can NEVER appear twice within the same key. General Overview You are going to be writing a MASM procedure named compute which will be called from a MAIN procedure (that you do not control). Your MASM procedure has several modes of operation, depending on how it is called. Please read this overview and then look at the Example Usage section below. The compute procedure will be capable of several operations, namely: . A default "decoy" mode of operation where the procedure accepts two 16-bit operands by value and one operand by OFFSET. The procedure will calculate the sum of the two operands and will store the result into memory at the OFFSET specified. o Accepts 3 parameters on the stack - 16 bit signed WORD operand . 16 bit signed WORD operand . 32 bit OFFSET of a signed DWORD (the sum will be placed into the specified DWORD) An encryption mode Accepts 3 parameters on the stack . 32 bit OFFSET of a BYTE array (this array contains a 26 character key) . 32 bit OFFSET of a BYTE array (this array contains the plaintext message to be encrypted) . 32 bit OFFSET of a signed DWORD (the dereferenced value initially contains the integer - 1) . Note that the plaintext message will be in a BYTE array that ends with a NULL character indicating the end of the message) . This operational mode will encrypt the requested message. By the time your function returns, the original plaintext message array will be overwritten with the correctly encrypted message. A decryption mode - Accepts 3 parameters on the stack . 32 bit OFFSET of a BYTE array (this array contains a 26 character key) . 32 bit OFFSET of a BYTE array (this array contains the encrypted message that is to be decoded) . 32 bit OFFSET of a signed DWORD (the dereferenced value initially contains the integer -2) . Note that the encrypted message will be in a BYTE array that ends with a NULL character (indicating the end of the message) . This operational mode will decrypt the requested message. By the time your function returns, the encrypted characters (inside the array) will be overwritten with the decrypted message. A key generation mode (OPTIONAL) - THIS SPECIFIC MODE IS EXTRA CREDIT o Accepts 2 parameters on the stack . 32 bit OFFSET of a BYTE array (this array contains space for exactly 26 characters) . 32 bit OFFSET of signed DWORD (the dereferenced value initially contains the integer -3) . In this mode, your code will utilize the Irvine random number library. You must generate a 26 character string containing all the lowercase letters of the English alphabet. . The letters must be arranged in a random order. . If this function is called multiple times, the order of the characters must be different each time. Your randomly generated character string will be placed into BYTE array specified by the stack parameter. Description Alex and Sila are espionage agents working for the Top Secret Agency (TSA). Sometimes they discuss sensitive intelligence information that needs to be kept secret from the Really Bad Guys (RBG). Alex and Sila have decided to use a simple obfuscation algorithm that should be good enough to confuse the RBG. As the TSA's resident programmer you've been assigned to write a MASM procedure that will implement the requested behavior. Your code must be capable of encrypting and decrypting messages (and meet the other requirements given in this document). This final project is written less like an academic assignment and more like a real-life programming task. This might seem daunting at first but don't despair! Algorithm Details Ankur and Sila's algorithm is a simple substitution cipher. If you are not familiar with substitution ciphers, I suggest reading the Wikipedia page (available here). For this implementation, the key consists of 26 lowercase English letters. The following example demonstrates the obfuscation algorithm that Ankur and Sila are requesting. Suppose that you are provided the following 26 character secret key: efbcdghijklmnopqrstuvwxyza. Each character listed in the key corresponds to a character from the English alphabet. In other words, the key is a map that tells you how to take the original text (also known as plaintext) and replace each letter with the encrypted character. In order to understand the key, consider the alphabetical arrangement of the English alphabet beginning with a, b, c, d, e, f, (and so on). Now reconsider the key, which starts with e, f, b, c, d, g, (and so on). Using the key from above, we can map each letter as follows: Original Character --> Encrypted Replacement b --> C--> b d --> e --> d f -->S g--> i --> ; (some entries skipped) X -->y y --> z Z --> a For example, every "a" in the original message is to be enciphered as an "e". Every "b" in the original message should be replaced with the letter "f". Each character in the original message maps to a specific replacement character. Now suppose that you are trying to encrypt the following plaintext message: the contents of this message will be a mystery. Using the secret key from above, the corresponding ciphertext is: uid bpoudout pg uijt ndttehd xjmm fd e nztudsz. Note that only the letters have been changed! Other aspects of the message such as punctuation and spacing should be be left unchanged. In order to decrypt the message, you can use the same key (in reverse) to process the ciphertext and convert it to plaintext. The key will always consist of exactly 26 characters (containing every letter of the English alphabet arranged in a random order). A character can NEVER appear twice within the same key. General Overview You are going to be writing a MASM procedure named compute which will be called from a MAIN procedure (that you do not control). Your MASM procedure has several modes of operation, depending on how it is called. Please read this overview and then look at the Example Usage section below. The compute procedure will be capable of several operations, namely: . A default "decoy" mode of operation where the procedure accepts two 16-bit operands by value and one operand by OFFSET. The procedure will calculate the sum of the two operands and will store the result into memory at the OFFSET specified. o Accepts 3 parameters on the stack - 16 bit signed WORD operand . 16 bit signed WORD operand . 32 bit OFFSET of a signed DWORD (the sum will be placed into the specified DWORD) An encryption mode Accepts 3 parameters on the stack . 32 bit OFFSET of a BYTE array (this array contains a 26 character key) . 32 bit OFFSET of a BYTE array (this array contains the plaintext message to be encrypted) . 32 bit OFFSET of a signed DWORD (the dereferenced value initially contains the integer - 1) . Note that the plaintext message will be in a BYTE array that ends with a NULL character indicating the end of the message) . This operational mode will encrypt the requested message. By the time your function returns, the original plaintext message array will be overwritten with the correctly encrypted message. A decryption mode - Accepts 3 parameters on the stack . 32 bit OFFSET of a BYTE array (this array contains a 26 character key) . 32 bit OFFSET of a BYTE array (this array contains the encrypted message that is to be decoded) . 32 bit OFFSET of a signed DWORD (the dereferenced value initially contains the integer -2) . Note that the encrypted message will be in a BYTE array that ends with a NULL character (indicating the end of the message) . This operational mode will decrypt the requested message. By the time your function returns, the encrypted characters (inside the array) will be overwritten with the decrypted message. A key generation mode (OPTIONAL) - THIS SPECIFIC MODE IS EXTRA CREDIT o Accepts 2 parameters on the stack . 32 bit OFFSET of a BYTE array (this array contains space for exactly 26 characters) . 32 bit OFFSET of signed DWORD (the dereferenced value initially contains the integer -3) . In this mode, your code will utilize the Irvine random number library. You must generate a 26 character string containing all the lowercase letters of the English alphabet. . The letters must be arranged in a random order. . If this function is called multiple times, the order of the characters must be different each time. Your randomly generated character string will be placed into BYTE array specified by the stack parameter
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
