aboutsummaryrefslogtreecommitdiffstats
path: root/libar2_hash_buf_size.c
blob: 3010a8a484cc8ab3c2856687380caceeb3fbd6d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* See LICENSE file for copyright and license details. */
#include "common.h"


size_t
libar2_hash_buf_size(const struct libar2_argon2_parameters *params)
{
	if (params->hashlen <= 64)
		return params->hashlen;
	if (params->hashlen > SIZE_MAX - 31 ||
	    ((params->hashlen + 31) | 31) == SIZE_MAX) {
		errno = EOVERFLOW;
		return 0;
	}
	return ((params->hashlen + 31) | 31) + 1;
}