aboutsummaryrefslogtreecommitdiffstats
path: root/algorithm_output_size.c
blob: 4b287b22d62ad33908e9fd5101809f8255ab2f26 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* See LICENSE file for copyright and license details. */
#include "common.h"
#include <stdio.h>


/**
 * Get the output size of an algorithm
 * 
 * @param   algorithm  The hashing algorithm
 * @return             The number of bytes in the output, zero on error
 */
size_t
libsha2_algorithm_output_size(enum libsha2_algorithm algorithm)
{
	switch (algorithm) {
	case LIBSHA2_224:     return 28;
	case LIBSHA2_256:     return 32;
	case LIBSHA2_384:     return 48;
	case LIBSHA2_512:     return 64;
	case LIBSHA2_512_224: return 28;
	case LIBSHA2_512_256: return 32;
	default:
		errno = EINVAL;
		return 0;
	}
}