From f449f278dd3c70e479a035f50a9bb817a9b433ba Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 17:24:08 +0200 Subject: Adding upstream version 3.2.6. Signed-off-by: Daniel Baumann --- src/libdnssec/digest.h | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/libdnssec/digest.h (limited to 'src/libdnssec/digest.h') diff --git a/src/libdnssec/digest.h b/src/libdnssec/digest.h new file mode 100644 index 0000000..76709aa --- /dev/null +++ b/src/libdnssec/digest.h @@ -0,0 +1,76 @@ +/* Copyright (C) 2021 CZ.NIC, z.s.p.o. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +/*! + * \file + * + * \addtogroup digest + * + * \brief Data hashing operations. + * + * @{ + */ + +#pragma once + +#include "libdnssec/binary.h" +#include "libdnssec/error.h" + +typedef enum { + DNSSEC_DIGEST_INVALID = 0, + DNSSEC_DIGEST_SHA384 = 1, + DNSSEC_DIGEST_SHA512 = 2, +} dnssec_digest_t; + +struct dnssec_digest_ctx; +typedef struct dnssec_digest_ctx dnssec_digest_ctx_t; + +/*! + * \brief Initialize digest context. + * + * \param algorithm Hasing algorithm to be used. + * \param out_ctx Output: context structure to be initialized. + * + * \return DNSSEC_E* + */ +int dnssec_digest_init(dnssec_digest_t algorithm, dnssec_digest_ctx_t **out_ctx); + +/*! + * \brief Digest data. + * + * \param ctx Digest context. + * \param data Data to be hashed. + * + * \note This function may be invoked repeatedly for single digest context, + * hashing all data as concatenated. + * + * \return DNSSEC_E* + * + * \note If error is returned, the digest context is automatically disposed. + */ +int dnssec_digest(dnssec_digest_ctx_t *ctx, dnssec_binary_t *data); + +/*! + * \brief Finalize digest, dispose digest context and return the hash. + * + * \param ctx Digest context. + * \param out Output: computed hash. + * + * \return DNSSEC_E* + */ +int dnssec_digest_finish(dnssec_digest_ctx_t *ctx, dnssec_binary_t *out); + +/*! @} */ -- cgit v1.2.3