diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2021-03-06 21:56:20 +0100 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2021-04-27 10:43:13 -0300 |
commit | a240097ecd4fb1639db99e7becb888ae478405cd (patch) | |
tree | 26a70d86c81463ced96d1123bb0d06621668dffd /libavutil/ripemd.c | |
parent | 6e30b35b85b81c802e52a1078ec7a3097e353c6d (diff) | |
download | ffmpeg-a240097ecd4fb1639db99e7becb888ae478405cd.tar.gz |
avutil: Switch crypto APIs to size_t
Announced in e435beb1ea5380a90774dbf51fdc8c941e486551.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavutil/ripemd.c')
-rw-r--r-- | libavutil/ripemd.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/libavutil/ripemd.c b/libavutil/ripemd.c index 89d69cc23d..b8e9761a24 100644 --- a/libavutil/ripemd.c +++ b/libavutil/ripemd.c @@ -511,13 +511,10 @@ av_cold int av_ripemd_init(AVRIPEMD *ctx, int bits) return 0; } -#if FF_API_CRYPTO_SIZE_T -void av_ripemd_update(AVRIPEMD* ctx, const uint8_t* data, unsigned int len) -#else void av_ripemd_update(AVRIPEMD* ctx, const uint8_t* data, size_t len) -#endif { - unsigned int i, j; + unsigned int j; + size_t i; j = ctx->count & 63; ctx->count += len; @@ -530,15 +527,19 @@ void av_ripemd_update(AVRIPEMD* ctx, const uint8_t* data, size_t len) } } #else - if ((j + len) > 63) { + if (len >= 64 - j) { + const uint8_t *end; memcpy(&ctx->buffer[j], data, (i = 64 - j)); ctx->transform(ctx->state, ctx->buffer); - for (; i + 63 < len; i += 64) - ctx->transform(ctx->state, &data[i]); + data += i; + len -= i; + end = data + (len & ~63); + len = len % 64; + for (; data < end; data += 64) + ctx->transform(ctx->state, data); j = 0; - } else - i = 0; - memcpy(&ctx->buffer[j], &data[i], len - i); + } + memcpy(&ctx->buffer[j], data, len); #endif } |