Question: Please write your code in R and submit your script and results for each of the following. Use the functions expand() and S1_function() to do
Please write your code in R and submit your script and results for each of the following. Use the functions expand() and S1_function() to do the following:
S1_function <- function(values){ b <- values tempval <- unbinary(substr(b,nchar(b)-3+1,nchar(b))) tempval b <- strsplit(b,"") b <- unlist(b) b <- as.integer(b) b if(b[1]==0){ tempRet <- s11[tempval] print (tempRet) if(b[1]==1){ tempRet <- s12[tempVal] print(tempRet) } } s1_function('1101')?
Create a second function for substitution box S2_function() that replicates the S1_function() your wrote for homework 4 except that it uses the following substitution boxes: S11 contains the binary of the numbers (4, 0, 6, 5, 7, 1, 3 2) and S12 contains those for (5, 3, 0, 7, 6, 2, 1, 4).?
Create a round function called round1() that takes a binary character vector of length 12 and key K of length 9 and does the following: (20 points total)
Divide the block into two equal halves called L0 and R0.
Create two sub keys K1 containing the first 8 digits of K and K2 that contains the last 8 digits of K.
Expand R0 from 6 t o 8 bits and call it ER0.
Take the XOR of the result of ER0 with K1. Store the first 4 bits in a variable called block1 and the last 4 bits in a variable called block2.
Call S1_function with block1 as its parameter.
Call S2_function with block2 as its parameter.
Concatenate the results of e) and f) and store the result in a variable called FR0.
Take the XOR of FR0 and L0 and store the results in R1.
Store R0 to L1.
Return L1 concatenated to R1.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
