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

Michael Niedermayer michael at niedermayer.cc
Thu Dec 24 13:47:48 CET 2015


On Wed, Dec 23, 2015 at 11:35:57PM -0300, James Almer wrote:
> 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.

i think its better to keep some test that tests values outside
the alphanum range

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151224/6b2e4a65/attachment.sig>


More information about the ffmpeg-devel mailing list