Open angeloped opened 5 years ago
This is perfectly normal, if you decrypt the message the message you get garbage, which when re-encrypted gets you the original encrypted message. That's called symmetric encryption.
CTR more is a simple exor of data blocks and “encrypted key” so you can easily change order of encrypt and decrypt operations above and you always get the plaintext at the end. ;)
Please keep in mind that AES and the common modes of operation are cryptographic primitives. They are very low level. You should not use them directly if you do not understand what they are designed for and have not researched how to correctly use them. There are many cases of improperly using them that have resulted in leaking information via side-channel attacks. At a minimum, please read the Wikipedia entries on block ciphers and the common modes of operation.
https://www.youtube.com/watch?v=NHuibtoL_qk is a great video explaining the maths behind AES.
I decrypt the text then I send to the recipient. The recipient will decrypt it with different/wrong key. The decrypted text will be encrypted using his key. His encrypted message will resend to me.
(since I don't have his key to decrypt his message, I will use mine)
I decrypted his encrypted message using MY KEY. And that message was also my message to him.
I think the issue was started in line: 25