[FFmpeg-devel] [PATCH] xtea: fix CBC mode when src=dst

Michael Niedermayer michaelni at gmx.at
Sun Sep 30 17:50:34 CEST 2012


On Sun, Sep 30, 2012 at 04:13:26PM +0200, Giorgio Vazzana wrote:
> Hello,
> 
> the documentation for the function:
> 
> void av_xtea_crypt(struct AVXTEA *ctx, uint8_t *dst, const uint8_t *src,
>                    int count, uint8_t *iv, int decrypt);
> 
> states that src can be equal to dst. In this case, when using CBC
> mode, the decryption will fail, because for a block different from the
> first one the wrong initialization vector is used. The correct
> initialization vector should be the ciphertext of the previous block,
> which we need to save before it's overwritten. Wikipedia has a nice
> picture that should make this clear:
> https://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29
> 
> I've written a small program that demonstrates the issue. A patch like
> the one attached should be enough to fix the problem. Please comment.

integrated the test code, applied and simplified the patch

thanks alot, i had not realized this problem last i looked at the code

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120930/0e508a4f/attachment.asc>


More information about the ffmpeg-devel mailing list