Question: : create cipher text (encrypt) and decrypt a message using ARM assembly, in the process the student will learn to process commands, encryption vector and

: create cipher text (encrypt) and decrypt a message using ARM assembly, in the process the student will learn to process commands, encryption vector and utilize stack for functions and the heap for arrays, create output files and write the resulting string to output file. 1. Use ARM assembly to read integers from a command file, then read string of ASCII characters from the message file and save it into a dynamically allocated array in memory (not static allocation). 2. Exclusive OR (XOR) encryption vector with each character of the message string and create a cipher text message (or decrypted) string and write the new string into an output file. Implementation: 1. The command file (inputCommand.txt) will include two integer numbers, the first integer number is the command for encrypt/decrypt (0 = encrypt, 1 = decrypt, any other values must generate error). The second integer will be encryption/decryption vector the valid rang will be 1 to 127 inclusive any other value must be considered an error. 2. The message text will be in the message file (messageInput.txt) (it can be either plain text or cipher text). 3. To encrypt: the command file must have the first integer = 0, and the second integer value within the range of the vector, example: 0 126 After reading the command file, the program will open the message file and read the message into a dynamically allocated array, then XOR the vector with each character of the message and output the result into another array (output array), then output the output array string to output file. 4. To decrypt: the command file must have the first integer = 1, and the second integer value within the range of the vector, example: 1 126 (note: must be the same vector value that was used for encryption). After reading the command file, the program will open the message file and read the message into a dynamically allocated array, then XOR the vector with each character of the message and output the result into another array (output array), then output the output array string to output file.

.equ SWI_Open, 0x66 @open file .equ SWI_Close,0x68 @close a file .equ SWI_PrStr,0x69 @write a null ending string .equ SWI_RdInt,0x6c @read an int .equ SWI_PrInt,0x6b @print an int .equ Stdout, 1 @set output target to stdout .equ SWI_Exit,0x11 @exit .global _start .text

_start: ldr r4, =0

@=================open a file for reading===========================

ldr r0,=InFileName @set name for output file mov r1,#0 @mode is input swi SWI_Open @open file bcs InFileError

mov r2, r0 @ save file handle in r2 swi SWI_RdInt @ read an integer from the file bcs EFileError @ if no integer was found, file is empty

@=========================read integers until end of file================= RLoop: mov r0, r2 @ recover file handler in r0 swi SWI_RdInt @ read integer into r0 bcs EofOneReached @ check if end reached

@ ====== End of File==================================================

EofOneReached: mov r0, r2 @ recover file handler in r0 swi SWI_Close

@======final printout================================================= EofReached:

printInvalid: cmp r10, #0 @ if no invalid numbers were found, exit the program beq Exit

mov r0, #Stdout @ print invalid number ldr r1, =InvalidMsg swi SWI_PrStr mov r1, r10 swi SWI_PrInt ldr r1, =NL swi SWI_PrStr

Exit: swi 0x11

InFileError: mov R0, #Stdout ldr R1,=FileOpenError swi SWI_PrStr bal Exit

EFileError: mov R0, #Stdout ldr R1,=EmptyFileError swi SWI_PrStr

mov r0, r2 @ recover file handler in r0 swi SWI_Close @ close file

bal Exit

.data .align InputFileHandle: .skip 4 InFileName: .asciz "Cipher.dat" FileOpenError: .asciz "Failed to open file " EmptyFileError: .asciz "Error: file is empty " NL: .asciz " " InvalidMsg: .asciz "Not applicable: " .end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!