aboutsummaryrefslogtreecommitdiffstats
path: root/libhashsum_init_sha2_hasher.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2024-08-24 11:38:07 +0200
committerMattias Andrée <maandree@kth.se>2024-08-24 11:38:07 +0200
commitdadf0cb089c36b0d49483b50cac97d017cd9389e (patch)
tree70053cf96f04efea0da5fb5c3289352e7c74a1ce /libhashsum_init_sha2_hasher.c
parentMake algorithms optional (diff)
downloadlibhashsum-dadf0cb089c36b0d49483b50cac97d017cd9389e.tar.gz
libhashsum-dadf0cb089c36b0d49483b50cac97d017cd9389e.tar.bz2
libhashsum-dadf0cb089c36b0d49483b50cac97d017cd9389e.tar.xz
Add libhashsum_hasher.algorithm_string
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libhashsum_init_sha2_hasher.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libhashsum_init_sha2_hasher.c b/libhashsum_init_sha2_hasher.c
index 9246e48..b76f059 100644
--- a/libhashsum_init_sha2_hasher.c
+++ b/libhashsum_init_sha2_hasher.c
@@ -62,21 +62,27 @@ libhashsum_init_sha2_hasher(struct libhashsum_hasher *this, unsigned algobits, s
if (algobits == 32U && hashbits == 224U) {
this->algorithm = LIBHASHSUM_SHA_224;
algo = LIBSHA2_224;
+ this->algorithm_string = "SHA-224";
} else if (algobits == 32U && hashbits == 256U) {
this->algorithm = LIBHASHSUM_SHA_256;
algo = LIBSHA2_256;
+ this->algorithm_string = "SHA-256";
} else if (algobits == 64U && hashbits == 384U) {
this->algorithm = LIBHASHSUM_SHA_384;
algo = LIBSHA2_384;
+ this->algorithm_string = "SHA-384";
} else if (algobits == 64U && hashbits == 512U) {
this->algorithm = LIBHASHSUM_SHA_512;
algo = LIBSHA2_512;
+ this->algorithm_string = "SHA-512";
} else if (algobits == 64U && hashbits == 224U) {
this->algorithm = LIBHASHSUM_SHA_512_224;
algo = LIBSHA2_512_224;
+ this->algorithm_string = "SHA-512/224";
} else if (algobits == 64U && hashbits == 256U) {
this->algorithm = LIBHASHSUM_SHA_512_256;
algo = LIBSHA2_512_256;
+ this->algorithm_string = "SHA-512/256";
} else {
errno = EINVAL;
return -1;