summaryrefslogtreecommitdiff
path: root/libavutil/aes.c
Commit message (Collapse)AuthorAgeFilesLines
* avutil/aes: Don't use out-of-bounds indexAndreas Rheinhardt2022-10-241-1/+1
| | | | | | | | | | | | | | | Up until now, av_aes_init() uses a->round_key[0].u8 + t as dst of memcpy where it is intended for t to greater than 16 (u8 is an uint8_t[16]); given that round_key itself is an array, it is actually intended for the dst to be in a latter round_key member. To do this properly, just cast a->round_key to unsigned char*. This fixes the srtp, aes, aes_ctr, mov-3elist-encrypted, mov-frag-encrypted and mov-tenc-only-encrypted FATE-tests with (Clang-)UBSan. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/aes: Don't use misaligned pointersAndreas Rheinhardt2022-10-241-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The AES code uses av_aes_block, a union consisting of uint64_t[2], uint32_t[4], uint8_t[4][4] and uint8_t[16]. subshift() performs byte-wise manipulations of two av_aes_blocks, but when encrypting, it does so with a shift of two bytes; more precisely, it uses "av_aes_block *s1 = (av_aes_block *) (s0[0].u8 - s)" and lateron uses the uint8_t[16] member to access s0. Yet av_aes_block requires to be suitably aligned for the uint64_t[2] member, which s0[0].u8 - 2 is certainly not. This is in violation of 6.3.2.3 (7) of C11. UBSan reports this in the aes_ctr, mov-3elist-encrypted, mov-frag-encrypted, mov-tenc-only-encrypted and srtp tests. Furthermore, there is another issue here: The pointer points outside of s0; this works, because all the accesses lateron use an index >= 3. (Clang-)UBSan reports this as "runtime error: index -2 out of bounds for type 'uint8_t[16]'". This commit fixes both of these issues: The latter issue is fixed by applying an offset of "+ 3" during the cast and subtracting this from the indices used lateron. The former issue is solved by not casting to av_aes_block* at all; instead simply cast to unsigned char*. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Remove unnecessary libavutil/(avutil|common|internal).h inclusionsAndreas Rheinhardt2022-02-241-2/+6
| | | | | | | | | | Some of these were made possible by moving several common macros to libavutil/macros.h. While just at it, also improve the other headers a bit. Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Merge commit 'd12b5b2f135aade4099f4b26b0fe678656158c13'Derek Buitenhuis2016-05-111-84/+0
|\ | | | | | | | | | | | | | | * commit 'd12b5b2f135aade4099f4b26b0fe678656158c13': build: Split test programs off into separate files Some conversions done by: James Almer <jamrial@gmail.com> Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
| * build: Split test programs off into separate filesDiego Biurrun2016-04-071-75/+0
| | | | | | | | | | This avoids spurious library rebuilds when only the test program code is changed and simplifies the build system.
* | avutil/aes: Remove duplicate includeMichael Niedermayer2016-04-231-1/+0
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | Merge commit '3b08d9d932eef09403074d5af31e10d8011e840b'Derek Buitenhuis2016-04-211-19/+20
|\ \ | |/ | | | | | | | | | | * commit '3b08d9d932eef09403074d5af31e10d8011e840b': testprogs: K&R formatting cosmetics Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
| * testprogs: K&R formatting cosmeticsDiego Biurrun2016-03-241-18/+19
| |
| * lavu: Drop deprecated context size variablesVittorio Giovara2015-08-281-4/+0
| | | | | | | | Deprecated in 10/2012.
* | lavu/aes: test CBC functionalityRodger Combs2015-10-281-5/+14
| |
* | lavu/aes: add runtime dispatch for crypt functionRodger Combs2015-10-281-17/+32
| |
* | lavu/aes: move AVAES to separate internal headerRodger Combs2015-10-281-15/+1
| |
* | avutil: use EINVAL instead of -1 for the return code of crypto related init ↵Ganesh Ajjanagadde2015-10-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | functions These functions return an error typically when the key size is an incorrect number. AVERROR(EINVAL) is more specific than -1. Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | avutil/aes: Fix typesMichael Niedermayer2015-06-191-2/+2
| | | | | | | | | | | | Fixes "warning: argument #2 is incompatible with prototype:" Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avutil/aes: Add () to protect the ROT() argumentsMichael Niedermayer2015-02-171-2/+2
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avutil/aes: Rename crypt()Michael Niedermayer2015-01-281-3/+3
| | | | | | | | | | | | | | This avoids a potential conflict with the equally named function from XOPEN It also could reduce confusion in debugger backtraces Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit 'fb0c9d41d685abb58575c5482ca33b8cd457c5ec'Michael Niedermayer2014-01-261-0/+1
|\ \ | |/ | | | | | | | | | | | | | | | | | | * commit 'fb0c9d41d685abb58575c5482ca33b8cd457c5ec': avutil: remove timer.h include from internal.h Conflicts: libavcodec/ffv1dec.c libavutil/internal.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * avutil: remove timer.h include from internal.hJanne Grunau2014-01-251-0/+1
| | | | | | | | Added libavutil/timer.h include to all files with {START,STOP}_TIMER.
* | lavu: keep context size variablesMichael Niedermayer2012-10-281-2/+0
| | | | | | | | | | | | | | | | They are essential to be able to use the utils without av_malloc() That is for example use with malloc(), memalign(), some other private allocation function, on the stack or others. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit 'e002e3291e6dc7953f843abf56fc14f08f238b21'Michael Niedermayer2012-10-121-0/+7
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'e002e3291e6dc7953f843abf56fc14f08f238b21': Use the new aes/md5/sha/tree allocation functions avutil: Add functions for allocating opaque contexts for algorithms svq3: fix pointer type warning svq3: replace unsafe pointer casting with intreadwrite macros parseutils-test: various cleanups Conflicts: doc/APIchanges libavcodec/svq3.c libavutil/parseutils.c libavutil/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * avutil: Add functions for allocating opaque contexts for algorithmsMartin Storsjö2012-10-111-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | The current API where the plain size is exposed is not of much use - in most cases it is allocated dynamically anyway. If allocated e.g. on the stack via an uint8_t array, there's no guarantee that the struct's members are aligned properly (unless the array is overallocated and the opaque pointer within it manually aligned to some unspecified alignment). Signed-off-by: Martin Storsjö <martin@martin.st>
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2011-12-221-1/+1
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * qatar/master: (27 commits) asfdec: add side data to ASFStream packet instead of output packet. idroqdec: set AVFMTCTX_NOHEADER and create streams as they occur. nellymoserdec: Indicate that the decoder can handle changed parameters libavcodec: Apply parameter change side data when decoding audio flvdec: Add param change side data if the sample rate or channels have changed libavformat: Add a utility function for adding parameter change side data libavcodec: Define a side data type for parameter changes aacdec: Handle new extradata passed as side data flvdec: Export new AAC/H.264 extradata as side data on the next packet libavcodec: Define a side data type for new extradata flacdec: skip all track indices at once instead of looping. mxf: Add PictureEssenceCoding UL for V210. mxfdec: consider QuantizationBits between 17 and 24 to be pcm_s24* mxfenc: Add support for MPEG-2 MP@HL-14 in mxf container. mxf: H.264/MPEG-4 AVC Intra support configure: Show whether the safe bitstream reader is enabled x86: Tighten register constraints for decode_significance*_x86. Replace Subversion revisions in comments by Git hashes. h264_cabac: synchronize decode_significance_*_x86 conditionals w32threads: wait for the waked thread in pthread_cond_signal. ... Conflicts: libavcodec/avcodec.h libavcodec/version.h libavformat/flvdec.c libavformat/utils.c tests/ref/lavfi/pixdesc tests/ref/lavfi/pixfmts_copy tests/ref/lavfi/pixfmts_null tests/ref/lavfi/pixfmts_scale tests/ref/lavfi/pixfmts_vflip Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * Replace Subversion revisions in comments by Git hashes.Diego Biurrun2011-12-211-1/+1
| |
* | Add coverage exclusions for test code.Reimar Döffinger2011-12-051-0/+2
| | | | | | | | | | | | | | | | For some of the code e.g. doing timing measurements there is no real point in running regression testing on it, thus it should not be counted against coverage. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2011-11-111-4/+4
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * qatar/master: (29 commits) doc: update libavfilter documentation tls: Use the URLContext as logging context aes: Avoid illegal read and don't generate more key than we use. mpc7: Fix memset call in mpc7_decode_frame function atrac1: use correct context for av_log() apedec: consume the whole packet when copying to the decoder buffer. apedec: do not needlessly copy s->samples to nblocks. apedec: check output buffer size after calculating actual output size apedec: remove unneeded entropy decoder normalization. truespeech: use memmove() in truespeech_update_filters() vorbisdec: remove AVCODEC_MAX_AUDIO_FRAME_SIZE check vorbisdec: remove unneeded buf_size==0 check vorbisdec: return proper error codes instead of made-up ones http: Don't add a Range: bytes=0- header for POST sunrast: Check for invalid/corrupted bitstream http: Change the chunksize AVOption into chunked_post http: Add encoding/decoding flags to the AVOptions avconv: remove some codec-specific hacks crypto: add decoding flag to options. tls: use AVIO_FLAG_NONBLOCK instead of deprecated URL_FLAG_NONBLOCK ... Conflicts: doc/libavfilter.texi libavcodec/atrac1.c libavcodec/sunrast.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * aes: Avoid illegal read and don't generate more key than we use.Alex Converse2011-11-101-4/+4
| |
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2011-07-051-15/+26
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * qatar/master: (36 commits) ARM: allow unaligned buffer in fixed-point NEON FFT4 fate: test more FFT etc sizes dca: set AVCodecContext frame_size for DTS audio YASM: Shut up unused variable compiler warning with --disable-yasm. x86_32: Fix build on x86_32 with --disable-yasm. iirfilter: add fate test doxygen: Add qmul docs. ogg: propagate return values and return more meaningful error values H.264: fix overreads of qscale_table Remove unused static tables and static inline functions. eval: clear Parser instances before using dct-test: remove 'ref' function pointer from tables build: Remove deleted 'check' target from .PHONY list. oggdec: Abort Ogg header parsing when encountering a data packet. Add LGPL license boilerplate to files lacking it. mxfenc: small typo fix doxygen: Fix documentation for some VP8 functions. sha: use AV_RB32() instead of assuming buffer can be cast to uint32_t* des: allow unaligned input and output buffers aes: allow unaligned input and output buffers ... Conflicts: libavcodec/dct-test.c libavcodec/libvpxenc.c libavcodec/x86/dsputil_mmx.c libavcodec/x86/h264_qpel_mmx.c libavfilter/x86/gradfun.c libavformat/oggdec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * aes: allow unaligned input and output buffersMans Rullgard2011-07-041-15/+26
| | | | | | | | Signed-off-by: Mans Rullgard <mans@mansr.com>
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2011-07-041-20/+31
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * qatar/master: (40 commits) H.264: template left MB handling H.264: faster fill_decode_caches H.264: faster write_back_* H.264: faster fill_filter_caches H.264: make filter_mb_fast support the case of unavailable top mb Do not include log.h in avutil.h Do not include pixfmt.h in avutil.h Do not include rational.h in avutil.h Do not include mathematics.h in avutil.h Do not include intfloat_readwrite.h in avutil.h Remove return statements following infinite loops without break RTSP: Doxygen comment cleanup doxygen: Escape '\' in Doxygen documentation. md5: cosmetics md5: use AV_WL32 to write result md5: add fate test md5: include correct headers md5: fix test program doxygen: Drop array size declarations from Doxygen parameter names. doxygen: Fix parameter names to match the function prototypes. ... Conflicts: libavcodec/x86/dsputil_mmx.c libavformat/flvenc.c libavformat/oggenc.c libavformat/wtv.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * aes: fix for big endian systemsMans Rullgard2011-07-031-1/+5
| | | | | | | | | | | | | | This was missed in 5d20f19 since CONFIG_SMALL was always broken for big endian. Signed-off-by: Mans Rullgard <mans@mansr.com>
| * aes: fix invalid array indexing in init codeMans Rullgard2011-07-031-14/+22
| | | | | | | | | | | | This makes the code work with clang/x86_32 and removes several warnings. Signed-off-by: Mans Rullgard <mans@mansr.com>
| * aes: use direct assignments instead of memcpy() or loopsMans Rullgard2011-07-031-6/+5
| | | | | | | | Signed-off-by: Mans Rullgard <mans@mansr.com>
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2011-07-011-100/+157
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * qatar/master: cosmetics: fix some then/than typos doxygen: Include libavcodec and libavformat examples into the documentation avutil: elaborate documentation for av_get_random_seed Add support for aac streams in mp4/mov without extradata. aes: whitespace cosmetics adler32: whitespace cosmetics swscale: fix another yuv range conversion overflow in 16bit scaling. Fix cpu flags test program opt-test: Add missing braces to silence compiler warnings. build: Eliminate obsolete test targets. udp: Fix a compilation warning swscale: Unbreak build with --enable-small base64: add fate test aes: improve test program and add fate test adler32: make test program more useful and add fate test swscale: fix yuv range correction when using 16-bit scaling. aacenc: Make chan_map const correct Conflicts: Makefile doc/examples/muxing-example.c libavformat/udp.c libavutil/random_seed.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * aes: whitespace cosmeticsMans Rullgard2011-06-301-87/+132
| | | | | | | | Signed-off-by: Mans Rullgard <mans@mansr.com>
| * aes: improve test program and add fate testMans Rullgard2011-06-301-21/+33
| | | | | | | | Signed-off-by: Mans Rullgard <mans@mansr.com>
| * Replace FFmpeg with Libav in licence headersMans Rullgard2011-03-191-4/+4
|/ | | | Signed-off-by: Mans Rullgard <mans@mansr.com>
* aes: fix array index out of bounds warningMåns Rullgård2010-07-041-1/+1
| | | | Originally committed as revision 24048 to svn://svn.ffmpeg.org/ffmpeg/trunk
* Make mix function more readable.Reimar Döffinger2010-07-021-4/+5
| | | | | | Compiler output unchanged with gcc 4.4. Originally committed as revision 24006 to svn://svn.ffmpeg.org/ffmpeg/trunk
* Change AES code to be strict-aliasing-safe.Reimar Döffinger2010-06-301-32/+42
| | | | | | | | | Makes it give correct results with e.g. gcc 4.4. For unknown reasons the generate asm code also changes on e.g. gcc 4.3, making the code a bit larger but also a bit faster. Originally committed as revision 23896 to svn://svn.ffmpeg.org/ffmpeg/trunk
* Pass subshift an argument of the proper type.Reimar Döffinger2010-06-281-1/+1
| | | | | | No changes in generated code. Originally committed as revision 23856 to svn://svn.ffmpeg.org/ffmpeg/trunk
* Use a consistent type for multbl array function parameters.Reimar Döffinger2010-06-281-3/+3
| | | | Originally committed as revision 23855 to svn://svn.ffmpeg.org/ffmpeg/trunk
* cosmetics: Rename prn variable to prng (Pseudo Random Number Generator).Diego Biurrun2009-04-101-3/+3
| | | | Originally committed as revision 18422 to svn://svn.ffmpeg.org/ffmpeg/trunk
* Replace random() usage in test programs by av_lfg_*().Diego Biurrun2009-03-201-3/+4
| | | | Originally committed as revision 18070 to svn://svn.ffmpeg.org/ffmpeg/trunk
* Make AES test program compile again: Setting the av_log_level variableDiego Biurrun2009-03-201-1/+1
| | | | | | needs to be replaced by a call to av_log_set_level(). Originally committed as revision 18055 to svn://svn.ffmpeg.org/ffmpeg/trunk
* Add "const" to AES function arguments where possible without generatingReimar Döffinger2009-01-281-7/+7
| | | | | | more warnings. Originally committed as revision 16847 to svn://svn.ffmpeg.org/ffmpeg/trunk
* Change semantic of CONFIG_*, HAVE_* and ARCH_*.Aurelien Jacobs2009-01-131-3/+3
| | | | | | They are now always defined to either 0 or 1. Originally committed as revision 16590 to svn://svn.ffmpeg.org/ffmpeg/trunk
* Fix test program compilation, random() needs to be undefined.Diego Biurrun2008-01-081-0/+2
| | | | Originally committed as revision 11470 to svn://svn.ffmpeg.org/ffmpeg/trunk
* main() --> main(void)Diego Biurrun2007-11-231-1/+1
| | | | Originally committed as revision 11079 to svn://svn.ffmpeg.org/ffmpeg/trunk
* Document aes init code writing on purpose beyond round_key array into state ↵Reimar Döffinger2007-07-181-0/+2
| | | | | | array. Originally committed as revision 9734 to svn://svn.ffmpeg.org/ffmpeg/trunk
* Move comment to a slightly better place.Diego Biurrun2007-07-021-2/+2
| | | | Originally committed as revision 9462 to svn://svn.ffmpeg.org/ffmpeg/trunk