in reply to Is this a secure way to prevent cookie tampering
Notice that I XORed the IV embedded in the ciphertext with 4, and that resulted in the decrypted plaintext being XORed with 4 as well. Combine this with Tweaking CRCs and you can undetectably alter the first few bytes of the cookie.use Crypt::CBC; my $cbc = Crypt::CBC->new("Blowfish"); my $msg = $cbc->encrypt("foo"); print $cbc->decrypt($msg), "\n"; my $msg2 = $msg ^ (("\0" x 8) . "\4"); print $cbc->decrypt($msg2), "\n"; __OUTPUT__ foo boo
I second the recommendation for proper MACs like Digest::EMAC or Digest::HMAC. You can easily get bitten if you try to cook up your own ad-hoc scheme with CRC.
|
---|