write python code
Example 3: key length > block size
Input data:
Message: “Hello” → x48656C6C 6F
Secret Key: “Y0S5INaG35isu0FJNlEPQeC5V9VCb5jPQ6cVBVVTKRov0Un7Wv6kDsVzfTdx5djqg9bQakXf3vxf5IU1sOnjZoUzKu” → x59305335 494E6147 33356973 7530464A 4E6C4550 51654335 56395643 62356A50 51366356 42565654 4B526F76 30556E37 5776366B 4473567A 66546478 35646A71 67396251 616B5866 33767866 35495531 734F6E6A 5A6F557A 4B75
Constants for our case hash algorithm (SHA1) with block size 64 bytes:
ipad (in HEX): x36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 (x36 repeated 64 time)
opad (in HEX): x5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C (x5C repeated 64 time)
Steps of creating HMAC (you could use the calculator to verify the result):
- If the key length > block size, we first hash the key, and then add 0s until its length becomes 64 bytes. In our case, with a key length of 90 bytes, we perform SHA1(Key). SHA1(Key) = 20e82c4d0379ee74fbe125e3b5be8b3f634a06e7.
Currently, the length of SHA1(Key) is 20 bytes, so we add 0s until the length becomes 64 bytes.
So K0 = 20E82C4D 0379EE74 FBE125E3 B5BE8B3F 634A06E7 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 - We need to perform the operation K0 XOR ipad.
How to make XOR operation you can see hereor use the calculator.
K0 XOR ipad =
16DE1A7B 354FD842 CDD713D5 8388BD09 557C30D1 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 - Now, append the message (K0 XOR ipad || message) to K0 XOR ipad.
(K0 XOR ipad) || message = 16DE1A7B 354FD842 CDD713D5 8388BD09 557C30D1 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 48656C6C 6F - We put the result of the previous operation into the SHA-1 hash.
Please note that you need to specify to the calculator that your data is in HEX (use this calculator). Also, you should remove all spaces (remember spaces are added here for readability but should not be included when hashing). In other words, you should input into the hash function:
16de1a7b354fd842cdd713d58388bd09557c30d1363636363636363636363636363636363636363636363636363636363636363636363636363636363636363648656c6c6f
sha1(K0 XOR ipad || message) = a79535b0b1fd1d5aff741fc0e1bbd2c627076c60 - Perform the operation K0 XOR opad.
K0 XOR opad = 7CB47011 5F25B228 A7BD79BF E9E2D763 3F165ABB 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C - Append to the result of the previous operation the wich hash obtained in step 4.
(K0 XOR opad) || (sha1(K0 XOR ipad || message)) =7CB47011 5F25B228 A7BD79BF E9E2D763 3F165ABB 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C 5C5C5C5C A79535B0 B1FD1D5A FF741FC0 E1BBD2C6 27076C60 - Put the result of step 6 into the SHA-1 hash.
HMAC = 45fac385c1a6c3404593b8943c3d1da70da0594b

Step by stepSolved in 2 steps with 2 images

- Start And Stop!Write an HLA Assembly language program that prompts for two specific int8 values named start and stop and then displays a repeated digit pattern starting with that number. The repeated digit pattern should show all the numbers beginning with the start value and then adding 1, 2, 3, 4, ... to this value until you hit a number greater than the stop value. Shown below is a sample program dialogue.Gimme a decimal value to use as a start: 6Gimme a decimal value to use as a stop: 78Here's your answer: 6_7_9_12_16_21_27_34_42_51_61_72_84Gimme a decimal value to use as a start: 8Gimme a decimal value to use as a stop: 31Here's your number: 8_9_11_14_18_23_29_36(Hint: The digit pattern is too large to store into any datatype we have learned to date so I am expecting that you will use a loop to print individual digits, rather than store the complete number in a variable.)arrow_forwardWRITE THE FOLLOWING PROGRAM IN HIGH LEVEL ASSEMBLY LANGUAGE (HLA)arrow_forwardPROGRAM 5: Big Number!Write an HLA Assembly language program that prompts for a specific int8 value named n and then displays a repeated digit pattern starting with that number. The repeated digit pattern should show all the odd numbers from 1 up to that number followed by all the even numbers from 2 up to that number. Shown below is a sample program dialogue. Gimme a integer value to use as n: 6The big number is: 135246Gimme a integer value to use as n: 11The big number is 1357911246810 (Hint: I would recommend you write it first in C or Visual Basic and then translate your lines of code, one-by-one, into a assembly statements, just like our good friend mr. compiler does.)(Hint: Since we don't really know how to do much math at this point, start your first loop at 1 and the second loop at 2 and then increment by 2 in each loop until you reach n...)arrow_forward
- What does the following Python code do? import serial #Import Serial Library arduinoSerialData = serial.Serial('com11,9600) #Create Serial port object called arduinoSerialData while (1==1): if (arduinoSerialData.inWaiting()>0): myData = arduinoSerialData.readline() print myData O Nothing O Read data from the serial port and plot it on an x-y graph. O Read data from the serial port and displays it on the screen. O Reads data once from the serial port and displays one piece of data on the screen.arrow_forwardBSWAP 28FDh = ? ROL,4 28FDh= ?arrow_forward