aboutsummaryrefslogtreecommitdiffstats
path: root/libhashsum_init_blake_hasher.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2024-08-24 20:39:01 +0200
committerMattias Andrée <maandree@kth.se>2024-08-24 20:39:01 +0200
commit2bc752da4a803cf6c03fb84bb90bc6e468981526 (patch)
tree5223412269afd9af411f918b51a66a433f235af0 /libhashsum_init_blake_hasher.c
parentAdd BLAKE via libblake>=1.1 (this version introduced libblake_init()) (diff)
downloadlibhashsum-2bc752da4a803cf6c03fb84bb90bc6e468981526.tar.gz
libhashsum-2bc752da4a803cf6c03fb84bb90bc6e468981526.tar.bz2
libhashsum-2bc752da4a803cf6c03fb84bb90bc6e468981526.tar.xz
Add support for salt for BLAKE
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libhashsum_init_blake_hasher.c')
-rw-r--r--libhashsum_init_blake_hasher.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/libhashsum_init_blake_hasher.c b/libhashsum_init_blake_hasher.c
index 645ab95..7b6d78e 100644
--- a/libhashsum_init_blake_hasher.c
+++ b/libhashsum_init_blake_hasher.c
@@ -4,17 +4,28 @@
int
-libhashsum_init_blake_hasher(struct libhashsum_hasher *this, size_t hashbits)
+libhashsum_init_blake_hasher(struct libhashsum_hasher *this, size_t hashbits, const void *salt, size_t salybytes)
{
+ if (salt) {
+ if (hashbits == 224U || hashbits == 256U) {
+ if (salybytes != 16U)
+ goto einval;
+ } else if (hashbits == 384U || hashbits == 512U) {
+ if (salybytes != 32U)
+ goto einval;
+ }
+ }
+
if (hashbits == 224U)
- return libhashsum_init_blake224_hasher(this);
+ return libhashsum_init_blake224_hasher(this, salt);
if (hashbits == 256U)
- return libhashsum_init_blake256_hasher(this);
+ return libhashsum_init_blake256_hasher(this, salt);
if (hashbits == 384U)
- return libhashsum_init_blake384_hasher(this);
+ return libhashsum_init_blake384_hasher(this, salt);
if (hashbits == 512U)
- return libhashsum_init_blake512_hasher(this);
+ return libhashsum_init_blake512_hasher(this, salt);
+einval:
errno = EINVAL;
return -1;
}
@@ -22,10 +33,12 @@ libhashsum_init_blake_hasher(struct libhashsum_hasher *this, size_t hashbits)
#else
int
-libhashsum_init_blake_hasher(struct libhashsum_hasher *this, size_t hashbits)
+libhashsum_init_blake_hasher(struct libhashsum_hasher *this, size_t hashbits, const void *salt, size_t salybytes)
{
(void) this;
(void) hashbits;
+ (void) salt;
+ (void) saltbytes;
errno = ENOSYS;
return -1;
}