Hello! could someone help me with this problem? Thanks! Programming language: PYTHON If padding is necessary to reach a
Posted: Thu May 05, 2022 1:30 pm
Hello! could someone help me with this problem? Thanks!
Programming language: PYTHON
If padding is necessary to reach a certain block size,
you should pad with zeros on the right.
Recall that a cryptographically secure hash function
h with output length l can be
used to construct a block cipher as follows:
• split the message (file) to be encoded into blocks M1, M2, . .
. , MK of l bits;
• pad MK if necessary;
• choose an initialization vector IV and set M0 = IV ;
• to encrypt block Mi, compute h(K||Mi−1) and XOR it with Mi
(where K is the secret key).
Use the SHA-256 hash function to create an encryption algorithm
using the above approach. Note that the output of SHA-256 is always
256 bits long. Write a program which accepts a 256-bit
initialization vector and a secret key of arbitrary length, and
encrypts or decrypts a given file using the algorithm described
above. Taking IV = 111 . . . 1 and K = 0101 . . . 01, use the
program to encrypt the file gold plaintext.in.
- Given plaintext (gold_plaintext.in) : "This
is an example input file created specifically for the third
mandatory assignment in INF143A. If you are reading this, I wish
you a great Easter vacation, and good luck on the
assignment!"
Programming language: PYTHON
If padding is necessary to reach a certain block size,
you should pad with zeros on the right.
Recall that a cryptographically secure hash function
h with output length l can be
used to construct a block cipher as follows:
• split the message (file) to be encoded into blocks M1, M2, . .
. , MK of l bits;
• pad MK if necessary;
• choose an initialization vector IV and set M0 = IV ;
• to encrypt block Mi, compute h(K||Mi−1) and XOR it with Mi
(where K is the secret key).
Use the SHA-256 hash function to create an encryption algorithm
using the above approach. Note that the output of SHA-256 is always
256 bits long. Write a program which accepts a 256-bit
initialization vector and a secret key of arbitrary length, and
encrypts or decrypts a given file using the algorithm described
above. Taking IV = 111 . . . 1 and K = 0101 . . . 01, use the
program to encrypt the file gold plaintext.in.
- Given plaintext (gold_plaintext.in) : "This
is an example input file created specifically for the third
mandatory assignment in INF143A. If you are reading this, I wish
you a great Easter vacation, and good luck on the
assignment!"