write python code
Example 2: key length = block size
Input data:
Message: “Hello” → x48656C6C 6F
Secret Key: “4q72JHgX89z3BkFMt6cwQxL1rD28jpN5UfVhIZYPbCSeuGovRaWmA0sD9ECtX7Jf” → x34713732 4A486758 38397A33 426B464D 74366377 51784C31 72443238 6A704E35 55665668 495A5950 62435365 75476F76 5261576D 41307344 39454374 58374A66
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, then we do nothing. In our case, with a key length of 64 bytes, we proceed with no additional action.
So new key is K0 = 34713732 4A486758 38397A33 426B464D 74366377 51784C31 72443238 6A704E35 55665668 495A5950 62435365 75476F76 5261576D 41307344 39454374 58374A66 - We need to perform the operation K0 XOR ipad.
How to make XOR operation you can see hereor use the calculator.
K0 XOR ipad = 02470104 7C7E516E 0E0F4C05 745D707B 42005541 674E7A07 4472040E 5C467803 6350605E 7F6C6F66 54756553 43715940 6457615B 77064572 0F737542 6E017C50 - Now, append the message (K0 XOR ipad || message) to K0 XOR ipad.
(K0 XOR ipad) || message = 02470104 7C7E516E 0E0F4C05 745D707B 42005541 674E7A07 4472040E 5C467803 6350605E 7F6C6F66 54756553 43715940 6457615B 77064572 0F737542 6E017C50 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: 024701047C7E516E0E0F4C05745D707B42005541674E7A074472040E5C4678036350605E7F6C6F6654756553437159406457615B770645720F7375426E017C5048656C6C6F
sha1(K0 XOR ipad || message) =
5fa962fde86832f2d5935b8be0229987e510f99f - Perform the operation K0 XOR opad.
K0 XOR opad = 682D6B6E 16143B04 6465266F 1E371A11 286A3F2B 0D24106D 2E186E64 362C1269 093A0A34 1506050C 3E1F0F39 291B332A 0E3D0B31 1D6C2F18 65191F28 046B163A - Append to the result of the previous operation the wich hash obtained in step 4.
(K0 XOR opad) || (sha1(K0 XOR ipad || message)) = 682D6B6E 16143B04 6465266F 1E371A11 286A3F2B 0D24106D 2E186E64 362C1269 093A0A34 1506050C 3E1F0F39 291B332A 0E3D0B31 1D6C2F18 65191F28 046B163A 5FA962FD E86832F2 D5935B8B E0229987 E510F99F - Put the result of step 6 into the SHA-1 hash.
HMAC = 62e1eaf2a7075bceb8e0022ae7d3e3d6f7271609
to generate a solution
a solution
- The following figure is the Cipher Block Chaining (CBC) mode to encrypt large messages. Which of the followings statement is *correct* regarding this mode? IV m₁ m₂ m3 C3 m4 C4 m5 C5 If a message contains two identical 64-bit blocks, the corresponding ciphertext blocks are also identical. Switching the order of two cipher blocks will not cause any detectable error in the plaintext. Duplicating a cipher block will not cause any detectable error in the plaintext. Deleting a cipher block will cause some detectable error in the plaintext. m6 E encrypt with secret key C6arrow_forwardX value(Initial Population) 13 24 8 16 Initial population Representation as binary String 01101 fx=x² 169 f(x)/ sum of all f(x) =169/1065=0.16 Roulette Wheel (Portion that covers Each X) 16%arrow_forwardIs the given set of code words has a prefex property{00,10,01,100,101,0010}arrow_forward
- Solve using assembly language x86 processors and compatibles Prompt the user for coefficients a, b, and c of a polynomial in the form ax2 + bx + c = 0. Calculate and display the real roots of the polynomial using the quadratic formula. If any root is imaginary, display the appropriate message.arrow_forwardCrypto Complete the missing BIP39 mnemonic seed phrase and get address 3 at BIP32 derivation path m/0'/0 as the flag. nature midnight buzz toe sleep fence kiwi ivory excuse system ____ ______ You will need to make use of this, as the start of the 128 char BIP39 seed: 131c553f7fb4127e7b2b346991dd92arrow_forwardAttach File Browse My Computer QUESTION 6 A. Simplify the following expression by using the laws of logic. Suppose the bit strings of A & B are A: 0100001010, B: 0100111011. Find the bit strings of ANB AUB Attach File Browse My Computer BAAAarrow_forward
- Convert a string to hexadecimal. Input: ABC Output: 0x414243 by 8086 In emu8086arrow_forwardAnswer in c programming language. dairy.txt DAY Milk Cheese Butter Cream YogurtMonday 50 25 32 16 512Tuesday 64 12 34 62 97Wednesday 23 54 67 13 62Thursday 34 54 25 35 127Friday 76 23 54 24 120 fruits.txt DAY Banana Apple Orange Mango WatermelonMonday 60 35 32 16 30Tuesday 44 22 34 62 54Wednesday 33 14 67 13 22Thursday 24 44 35 15 42Friday 36 43 24 34 29arrow_forwardStart 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_forward