aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/sha512.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-03-06 21:56:20 +0100
committerJames Almer <jamrial@gmail.com>2021-04-27 10:43:13 -0300
commita240097ecd4fb1639db99e7becb888ae478405cd (patch)
tree26a70d86c81463ced96d1123bb0d06621668dffd /libavutil/sha512.c
parent6e30b35b85b81c802e52a1078ec7a3097e353c6d (diff)
downloadffmpeg-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/sha512.c')
-rw-r--r--libavutil/sha512.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/libavutil/sha512.c b/libavutil/sha512.c
index 6d092a7c5c..97aaaa865c 100644
--- a/libavutil/sha512.c
+++ b/libavutil/sha512.c
@@ -239,13 +239,10 @@ av_cold int av_sha512_init(AVSHA512 *ctx, int bits)
return 0;
}
-#if FF_API_CRYPTO_SIZE_T
-void av_sha512_update(AVSHA512* ctx, const uint8_t* data, unsigned int len)
-#else
void av_sha512_update(AVSHA512* ctx, const uint8_t* data, size_t len)
-#endif
{
- unsigned int i, j;
+ unsigned int j;
+ size_t i;
j = ctx->count & 127;
ctx->count += len;
@@ -258,15 +255,19 @@ void av_sha512_update(AVSHA512* ctx, const uint8_t* data, size_t len)
}
}
#else
- if ((j + len) > 127) {
+ if (len >= 128 - j) {
+ const uint8_t *end;
memcpy(&ctx->buffer[j], data, (i = 128 - j));
sha512_transform(ctx->state, ctx->buffer);
- for (; i + 127 < len; i += 128)
- sha512_transform(ctx->state, &data[i]);
+ data += i;
+ len -= i;
+ end = data + (len & ~127);
+ len = len % 128;
+ for (; data < end; data += 128)
+ sha512_transform(ctx->state, data);
j = 0;
- } else
- i = 0;
- memcpy(&ctx->buffer[j], &data[i], len - i);
+ }
+ memcpy(&ctx->buffer[j], data, len);
#endif
}