[FFmpeg-devel] [PATCH] fate: replace custom md5 tests with those from RFC 1321

James Almer jamrial at gmail.com
Thu Dec 24 03:35:57 CET 2015


On 11/3/2015 2:18 PM, James Almer wrote:
> On 11/3/2015 4:44 AM, Clément Bœsch wrote:
>> On Tue, Nov 03, 2015 at 04:09:43AM -0300, James Almer wrote:
>>> Signed-off-by: James Almer <jamrial at gmail.com>
>>> ---
>>>  libavutil/md5.c    | 23 ++++++++++-------------
>>>  tests/ref/fate/md5 | 12 +++++++-----
>>>  2 files changed, 17 insertions(+), 18 deletions(-)
>>>
>>> diff --git a/libavutil/md5.c b/libavutil/md5.c
>>> index 876bd55..2a77304 100644
>>> --- a/libavutil/md5.c
>>> +++ b/libavutil/md5.c
>>> @@ -217,19 +217,16 @@ static void print_md5(uint8_t *md5)
>>>  
>>>  int main(void){
>>>      uint8_t md5val[16];
>>> -    int i;
>>> -    volatile uint8_t in[1000]; // volatile to workaround http://llvm.org/bugs/show_bug.cgi?id=20849
>>> -    // FIXME remove volatile once it has been fixed and all fate clients are updated
>>> -
>>> -    for (i = 0; i < 1000; i++)
>>> -        in[i] = i * i;
>>> -    av_md5_sum(md5val, in, 1000); print_md5(md5val);
>>> -    av_md5_sum(md5val, in,   63); print_md5(md5val);
>>> -    av_md5_sum(md5val, in,   64); print_md5(md5val);
>>> -    av_md5_sum(md5val, in,   65); print_md5(md5val);
>>> -    for (i = 0; i < 1000; i++)
>>> -        in[i] = i % 127;
>>> -    av_md5_sum(md5val, in,  999); print_md5(md5val);
>>> +
>>> +    av_md5_sum(md5val, "",    0); print_md5(md5val);
>>> +    av_md5_sum(md5val, "a",   1); print_md5(md5val);
>>> +    av_md5_sum(md5val, "abc", 3); print_md5(md5val);
>>> +    av_md5_sum(md5val, "message digest",             14); print_md5(md5val);
>>> +    av_md5_sum(md5val, "abcdefghijklmnopqrstuvwxyz", 26); print_md5(md5val);
>>> +    av_md5_sum(md5val, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
>>> +                       "fghijklmnopqrstuvwxyz0123456789",          62); print_md5(md5val);
>>> +    av_md5_sum(md5val, "1234567890123456789012345678901234567890"
>>> +                       "1234567890123456789012345678901234567890", 80); print_md5(md5val);
>>
>> Is it really OK to only test ASCII?
> 
> I don't see why not. We're doing that for every other hash algorithm as described
> in their respective RFCs for that matter.

Ping.

This is both getting rid of that volatile hack for an old clang version and using
the actual test vectors defined in the RFC for md5, so IMO it's indeed ok.


More information about the ffmpeg-devel mailing list