Welcome to little lamb

Code » limb » release » tree

[release] / src / liblimb / hasher_sha256.h / hasher_sha256.c

/* This file is part of limb                           https://lila.oss/limb
 * Copyright (C) 2023 Olivier Brunel                          jjk@jjacky.com */
/* SPDX-License-Identifier: GPL-2.0-only */
#include <skalibs/sha256.h>
#include <limb/hasher_sha256.h>

static void hsha256_init(void *ctx);
static void hsha256_update(const void *msg, size_t mlen, void *ctx);
static void hsha256_final(void *md, void *ctx);

struct hsha256 {
    hasher h;
    SHA256Schedule ctx;
} hasher_sha256 = {
    .h.hlen = 32,
    .h.blen = 64,
    .h.init = hsha256_init,
    .h.update = hsha256_update,
    .h.final = hsha256_final,
};

static void
hsha256_init(void *ctx)
{
    sha256_init(ctx);
}

static void
hsha256_update(const void *msg, size_t mlen, void *ctx)
{
    sha256_update(ctx, msg, mlen);
}

static void
hsha256_final(void *md, void *ctx)
{
    sha256_final(ctx, md);
}