Decrypting an encrypted aes 256 cbc text with random IV, decrypts the string
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
This may be a basic question but bear with me.
I started encrypting a text with aes 256 cbc mode generating a random iv of 16 bytes and a key.
text = 'hi I am learning encryption.';
Then I created another random iv and tried to decrypt the encrypted text. ( I know we are supposed to use the same iv we used for encryption to decrypt the ciphered text).
The result came as
(some rubbish text) encryption.
Then I padded the main text with 16 random characters, encrypted it and decrypted it I get my actual text padded with some junk text at the start.
I am unable to figure out why it messes with the first 16 bytes of text and then successfully extracts the remaining.
Can you explain?
aes cbc initialization-vector
New contributor
add a comment |Â
up vote
1
down vote
favorite
This may be a basic question but bear with me.
I started encrypting a text with aes 256 cbc mode generating a random iv of 16 bytes and a key.
text = 'hi I am learning encryption.';
Then I created another random iv and tried to decrypt the encrypted text. ( I know we are supposed to use the same iv we used for encryption to decrypt the ciphered text).
The result came as
(some rubbish text) encryption.
Then I padded the main text with 16 random characters, encrypted it and decrypted it I get my actual text padded with some junk text at the start.
I am unable to figure out why it messes with the first 16 bytes of text and then successfully extracts the remaining.
Can you explain?
aes cbc initialization-vector
New contributor
Dupe crypto.stackexchange.com/questions/1129/⦠(2011) and crypto.stackexchange.com/questions/2865/⦠(2012)
â dave_thompson_085
53 mins ago
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
This may be a basic question but bear with me.
I started encrypting a text with aes 256 cbc mode generating a random iv of 16 bytes and a key.
text = 'hi I am learning encryption.';
Then I created another random iv and tried to decrypt the encrypted text. ( I know we are supposed to use the same iv we used for encryption to decrypt the ciphered text).
The result came as
(some rubbish text) encryption.
Then I padded the main text with 16 random characters, encrypted it and decrypted it I get my actual text padded with some junk text at the start.
I am unable to figure out why it messes with the first 16 bytes of text and then successfully extracts the remaining.
Can you explain?
aes cbc initialization-vector
New contributor
This may be a basic question but bear with me.
I started encrypting a text with aes 256 cbc mode generating a random iv of 16 bytes and a key.
text = 'hi I am learning encryption.';
Then I created another random iv and tried to decrypt the encrypted text. ( I know we are supposed to use the same iv we used for encryption to decrypt the ciphered text).
The result came as
(some rubbish text) encryption.
Then I padded the main text with 16 random characters, encrypted it and decrypted it I get my actual text padded with some junk text at the start.
I am unable to figure out why it messes with the first 16 bytes of text and then successfully extracts the remaining.
Can you explain?
aes cbc initialization-vector
aes cbc initialization-vector
New contributor
New contributor
edited 5 hours ago
New contributor
asked 5 hours ago
Suman Lama
1085
1085
New contributor
New contributor
Dupe crypto.stackexchange.com/questions/1129/⦠(2011) and crypto.stackexchange.com/questions/2865/⦠(2012)
â dave_thompson_085
53 mins ago
add a comment |Â
Dupe crypto.stackexchange.com/questions/1129/⦠(2011) and crypto.stackexchange.com/questions/2865/⦠(2012)
â dave_thompson_085
53 mins ago
Dupe crypto.stackexchange.com/questions/1129/⦠(2011) and crypto.stackexchange.com/questions/2865/⦠(2012)
â dave_thompson_085
53 mins ago
Dupe crypto.stackexchange.com/questions/1129/⦠(2011) and crypto.stackexchange.com/questions/2865/⦠(2012)
â dave_thompson_085
53 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
Here is the picture for CBC decryption ($oplus$ is the XOR operation of each bit/byte at the same position of the input blocks):
As you can see only the first block is altered by the IV.
During encryption every block is changed because the ciphertext will propagate the uniqueness of the IV over all subsequent blocks. However, during decryption only the first block is XOR'ed with the IV to get back the first block of plaintext.
If that block is random then the result will also be random. The rest of the blocks is unaffected.
If you change just a single bit of the original IV, then only that particular bit in the plaintext block will be affected.
Thank you. It actually makes good sense now. I guess I hadn't understood the encryption step better. I missed the fact that during encryption only first block is XOR-ed with IV.
â Suman Lama
3 hours ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
Here is the picture for CBC decryption ($oplus$ is the XOR operation of each bit/byte at the same position of the input blocks):
As you can see only the first block is altered by the IV.
During encryption every block is changed because the ciphertext will propagate the uniqueness of the IV over all subsequent blocks. However, during decryption only the first block is XOR'ed with the IV to get back the first block of plaintext.
If that block is random then the result will also be random. The rest of the blocks is unaffected.
If you change just a single bit of the original IV, then only that particular bit in the plaintext block will be affected.
Thank you. It actually makes good sense now. I guess I hadn't understood the encryption step better. I missed the fact that during encryption only first block is XOR-ed with IV.
â Suman Lama
3 hours ago
add a comment |Â
up vote
3
down vote
accepted
Here is the picture for CBC decryption ($oplus$ is the XOR operation of each bit/byte at the same position of the input blocks):
As you can see only the first block is altered by the IV.
During encryption every block is changed because the ciphertext will propagate the uniqueness of the IV over all subsequent blocks. However, during decryption only the first block is XOR'ed with the IV to get back the first block of plaintext.
If that block is random then the result will also be random. The rest of the blocks is unaffected.
If you change just a single bit of the original IV, then only that particular bit in the plaintext block will be affected.
Thank you. It actually makes good sense now. I guess I hadn't understood the encryption step better. I missed the fact that during encryption only first block is XOR-ed with IV.
â Suman Lama
3 hours ago
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
Here is the picture for CBC decryption ($oplus$ is the XOR operation of each bit/byte at the same position of the input blocks):
As you can see only the first block is altered by the IV.
During encryption every block is changed because the ciphertext will propagate the uniqueness of the IV over all subsequent blocks. However, during decryption only the first block is XOR'ed with the IV to get back the first block of plaintext.
If that block is random then the result will also be random. The rest of the blocks is unaffected.
If you change just a single bit of the original IV, then only that particular bit in the plaintext block will be affected.
Here is the picture for CBC decryption ($oplus$ is the XOR operation of each bit/byte at the same position of the input blocks):
As you can see only the first block is altered by the IV.
During encryption every block is changed because the ciphertext will propagate the uniqueness of the IV over all subsequent blocks. However, during decryption only the first block is XOR'ed with the IV to get back the first block of plaintext.
If that block is random then the result will also be random. The rest of the blocks is unaffected.
If you change just a single bit of the original IV, then only that particular bit in the plaintext block will be affected.
edited 1 hour ago
answered 4 hours ago
Maarten Bodewes
48.2k567179
48.2k567179
Thank you. It actually makes good sense now. I guess I hadn't understood the encryption step better. I missed the fact that during encryption only first block is XOR-ed with IV.
â Suman Lama
3 hours ago
add a comment |Â
Thank you. It actually makes good sense now. I guess I hadn't understood the encryption step better. I missed the fact that during encryption only first block is XOR-ed with IV.
â Suman Lama
3 hours ago
Thank you. It actually makes good sense now. I guess I hadn't understood the encryption step better. I missed the fact that during encryption only first block is XOR-ed with IV.
â Suman Lama
3 hours ago
Thank you. It actually makes good sense now. I guess I hadn't understood the encryption step better. I missed the fact that during encryption only first block is XOR-ed with IV.
â Suman Lama
3 hours ago
add a comment |Â
Suman Lama is a new contributor. Be nice, and check out our Code of Conduct.
Suman Lama is a new contributor. Be nice, and check out our Code of Conduct.
Suman Lama is a new contributor. Be nice, and check out our Code of Conduct.
Suman Lama is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcrypto.stackexchange.com%2fquestions%2f62626%2fdecrypting-an-encrypted-aes-256-cbc-text-with-random-iv-decrypts-the-string%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Dupe crypto.stackexchange.com/questions/1129/⦠(2011) and crypto.stackexchange.com/questions/2865/⦠(2012)
â dave_thompson_085
53 mins ago