--- libavutil/Makefile | 1 + libavutil/hash.c | 41 +++++++++++++++++++++++++++++++++++++++++ tests/fate/libavutil.mak | 4 ++++ tests/ref/fate/hash | 45 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 tests/ref/fate/hash
diff --git a/libavutil/Makefile b/libavutil/Makefile index 934564f..58df75a 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -186,6 +186,7 @@ TESTPROGS = adler32 \ file \ fifo \ float_dsp \ + hash \ hmac \ lfg \ lls \ diff --git a/libavutil/hash.c b/libavutil/hash.c index 7037b0d..3515e7f 100644 --- a/libavutil/hash.c +++ b/libavutil/hash.c @@ -237,3 +237,44 @@ void av_hash_freep(AVHashContext **ctx) av_freep(&(*ctx)->ctx); av_freep(ctx); } + +#ifdef TEST +// LCOV_EXCL_START + +int main(int argc, char *argv[]) +{ + struct AVHashContext *ctx = NULL; + int i, j; + for(i = 0; i < NUM_HASHES; i++) { + uint8_t src[64], dst[64]; + memset(src, 0, 64); + memset(dst, 0, 64); + if(av_hash_alloc(&ctx, av_hash_names(i)) == 0) { + av_hash_init(ctx); + av_hash_update(ctx, src, 64); + av_hash_final_hex(ctx, dst, 64); + printf("%s hex: %s\n", av_hash_names(i), dst); + + memset(dst, 0, 64); + av_hash_final_bin(ctx, dst, 64); + printf("%s bin: ", av_hash_names(i)); + for(j = 0; j < av_hash_get_size(ctx); j++) { + printf("%#x ", dst[j]); + } + printf("\n"); + + memset(dst, 0, 64); + av_hash_final_b64(ctx, dst, 64); + printf("%s b64: %s\n", av_hash_names(i), dst); + av_hash_freep(&ctx); + } + } + + if(av_hash_alloc(&ctx, "FOO") != AVERROR(EINVAL)) { + printf("Invalid hash type 'FOO'\n"); + } + return 0; +} + +// LCOV_EXCL_STOP +#endif diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak index a89bc1d..5d8e0e2 100644 --- a/tests/fate/libavutil.mak +++ b/tests/fate/libavutil.mak @@ -75,6 +75,10 @@ fate-float-dsp: CMD = run libavutil/float_dsp-test $(CPUFLAGS:%=-c%) fate-float-dsp: CMP = null fate-float-dsp: REF = /dev/null +FATE_LIBAVUTIL += fate-hash +fate-hash: libavutil/hash-test$(EXESUF) +fate-hash: CMD = run libavutil/hash-test + FATE_LIBAVUTIL += fate-hmac fate-hmac: libavutil/hmac-test$(EXESUF) fate-hmac: CMD = run libavutil/hmac-test diff --git a/tests/ref/fate/hash b/tests/ref/fate/hash new file mode 100644 index 0000000..0a40a6d --- /dev/null +++ b/tests/ref/fate/hash @@ -0,0 +1,45 @@ +MD5 hex: 3b5d3c7d207e37dceeedd301e35e2e58 +MD5 bin: 0x90 0x2c 0xb9 0x4f 0xf1 0x89 0xc5 0x50 0x92 0x30 0xa9 0x67 0xeb 0xd9 0x2f 0xe2 +MD5 b64: VSrlzoSomOWmBL6fzSKY3w== +murmur3 hex: 6e484695e1d7b4e37d838791cc263395 +murmur3 bin: 0x6e 0x48 0x46 0x95 0xe1 0xd7 0xb4 0xe3 0x7d 0x83 0x87 0x91 0xcc 0x26 0x33 0x95 +murmur3 b64: bkhGleHXtON9g4eRzCYzlQ== +RIPEMD128 hex: 082bfa9b829ef3a9e220dcc54e4c6383 +RIPEMD128 bin: 0x9f 0x6a 0xaf 0xf2 0x15 0x23 0x5e 0x3b 0x1b 0xf3 0x5c 0x27 0x97 0x8c 0x1c 0xa9 +RIPEMD128 b64: +E5c8OVnvwZuSxwl1dvm1g== +RIPEMD160 hex: 9b8ccc2f374ae313a914763cc9cdfb47bfe1c229 +RIPEMD160 bin: 0xb5 0x1a 0x86 0x4e 0x27 0x4d 0xd0 0xe1 0x81 0x4d 0x83 0xce 0xd2 0x87 0x76 0xfc 0x95 0xed 0x8e 0x19 +RIPEMD160 b64: KQ4zIlTgLSLuYI370iB7aPaE7vs= +RIPEMD256 hex: 26ba693759787f275f47dd5ab16e78c2fcd763b004fd05fc554e354223d6eab +RIPEMD256 bin: 0x6e 0x9 0xbc 0x95 0xf2 0x4a 0xe 0x47 0xe7 0x2 0x2e 0xf3 0x5e 0xc1 0x2e 0x92 0xaa 0xfc 0xb6 0x97 0xd9 0xf8 0x1 0xb7 0xdd 0x90 0xde 0x48 0x78 0xc1 0x70 0xe2 +RIPEMD256 b64: SYuOSwaw29uyTVH17HBmsmHszKbjR/1LkfqRg0kgaZA= +RIPEMD320 hex: 409a3111ffd3d4c8058ff5c231401c1d47210a5d22e6c90bf95d45c1c95c528 +RIPEMD320 bin: 0x6b 0x2a 0x54 0x88 0x49 0x24 0xf6 0x66 0xc3 0x5c 0xad 0x9c 0x22 0xd1 0x68 0x9c 0xfc 0x36 0xe6 0x37 0x22 0x53 0x7 0xa 0x1c 0xd9 0x3f 0x67 0x5 0x91 0xcd 0x49 0x3f 0xed 0x5b 0xda 0x1b 0x2d 0xff 0x9e +RIPEMD320 b64: DdHUsKRNZwkUcZeoLAUQL5eYXmVA/kWAVJg5m3K6h890A/5qEZA90Q== +SHA160 hex: c8d7d0ef0eedfa82d2ea1aa592845b9a6d4b02b7 +SHA160 bin: 0xf3 0xce 0x87 0xc9 0x60 0x2e 0xbf 0xcc 0x2b 0x8b 0xf2 0xbd 0x23 0xff 0x71 0x51 0x5a 0xb4 0xc8 0xeb +SHA160 b64: Df5J/BOWO6TxCM/jjnilhVr2Rg8= +SHA224 hex: 750d81a39c18d3ce27ff3e5ece30b0088f12d8fd0450fe435326294b +SHA224 bin: 0xdb 0x15 0x26 0xe7 0x50 0xa9 0x3a 0x17 0xe3 0x39 0x80 0xd 0x78 0x1b 0xea 0xdd 0x3a 0xd3 0xad 0xf2 0x21 0xa2 0x93 0x1e 0x5e 0xf0 0xaf 0xeb +SHA224 b64: eKAYArOrj3lSGq6JuHuz2mA7n/6br5IS4lvbKA== +SHA256 hex: f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4 +SHA256 bin: 0x2a 0xb6 0xfe 0xb6 0x12 0x12 0xae 0x85 0x95 0xcd 0x6c 0xea 0x34 0x12 0xde 0x6a 0x65 0x2d 0x1d 0x10 0xfe 0x72 0xe0 0x3 0xc8 0xdc 0x7 0x48 0x97 0x3f 0xbe 0xef +SHA256 b64: 8Ml2zhm3uO5qDve7hxccZMSf+f05ajkn44qt7lOxaJA= +SHA512/224 hex: 1319d9b322452068e6f43c0ed3da115fbeccc169711dbbaee2846f90 +SHA512/224 bin: 0x1e 0x23 0x1c 0x4a 0x99 0xbf 0xc9 0xbb 0x71 0xdb 0x2e 0x3c 0x3d 0x7d 0xae 0x6c 0x81 0xdb 0x8 0x5e 0x1c 0xc1 0xb5 0x3c 0x97 0xcb 0xc0 0x23 +SHA512/224 b64: 1PoO1DhAMSWs2UsdQbEmGEDAag42/XAP8NOdPA== +SHA512/256 hex: 8aeecfa0b9f2ac7818863b1362241e4f32d06b100ae9d1c0fbcc4ed61b91b17 +SHA512/256 bin: 0x6c 0x81 0xe1 0xd6 0x38 0xbb 0x5f 0xb8 0x67 0xf8 0x39 0xf1 0x2 0x34 0x53 0x5b 0x23 0x6d 0x46 0x92 0x36 0x96 0x55 0x6e 0xb1 0x10 0xd 0x7e 0xff 0x13 0x22 0x95 +SHA512/256 b64: hVmJjdKZl1QhgEqepeVqKX/cQthbHh2wYbgBAycPHXI= +SHA384 hex: c516aa8d3b457c636c6826937099c0d23a13f2c3701a388b3c8fe4bc2073281 +SHA384 bin: 0x44 0xd1 0x9d 0x22 0x20 0xbd 0x6a 0xdc 0xa2 0x12 0xe8 0xe5 0xa9 0x3b 0x17 0x2b 0xc4 0x3d 0xa9 0x3e 0xb1 0x42 0x34 0xd2 0x5 0xf1 0xb6 0x98 0x5b 0x60 0x5b 0x23 0xe5 0xe3 0x76 0x55 0xc5 0xa0 0xf4 0x1c 0x8f 0xaf 0x2a 0xe2 0x9f 0xd8 0xbc 0xb9 +SHA384 b64: CEVqXPGH8CJR+SoL2BUpX5wYC6CakYX5nYpSp1m/LlhMkiK1IxJPdbyt2ZlT1QE +SHA512 hex: 7be9fda48f4179e611c698a73cff09faf72869431efee6eaad14de0cb44bbf6 +SHA512 bin: 0x7 0x1 0x7 0x6b 0xb9 0x52 0x4c 0x21 0x31 0xf3 0xae 0xfa 0x57 0x6 0x39 0xc2 0xdb 0xee 0xa6 0x9b 0xed 0x59 0x4a 0xe 0x28 0x5b 0xd9 0xee 0x7 0x4c 0xa2 0x35 0x99 0x4e 0x65 0x7d 0xbc 0xd5 0x95 0xa8 0xef 0xe7 0x4c 0xf2 0xa9 0x1c 0x13 0x1f 0x6f 0xca 0x85 0x15 0x9b 0x6b 0x15 0x96 0x5a 0xc7 0x61 0xd5 0x83 0x7e 0x60 0xf0 +SHA512 b64: PQn0eqpM16ExXzwWsKsb3dCCugTv2dckkVYl8DA8VM+EiHXx3QlKtxwc8negSlC +CRC32 hex: 758d6336 +CRC32 bin: 0x75 0x8d 0x63 0x36 +CRC32 b64: dY1jNg== +adler32 hex: 00400001 +adler32 bin: 0 0x40 0 0x1 +adler32 b64: AEAAAQ== -- 2.5.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel