diff options
| author | Kyle Evans <kevans@FreeBSD.org> | 2024-12-17 04:18:42 +0000 |
|---|---|---|
| committer | Kyle Evans <kevans@FreeBSD.org> | 2024-12-17 04:18:42 +0000 |
| commit | 736d663976d1768533badbf06581481d01fade4c (patch) | |
| tree | 8760aa186b4bc2953f0e546da6f408b4f5974dc3 /include/libecc/hash/bash256.h | |
Import libecc v0.9.7vendor/libecc/0.9.7vendor/libecc
libecc will be used privately for upcoming ECC support in pkg(7). Other
crypto consumers should continue using openssl.
Diffstat (limited to 'include/libecc/hash/bash256.h')
| -rw-r--r-- | include/libecc/hash/bash256.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/include/libecc/hash/bash256.h b/include/libecc/hash/bash256.h new file mode 100644 index 000000000000..ed55489ab8dd --- /dev/null +++ b/include/libecc/hash/bash256.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2022 - This file is part of libecc project + * + * Authors: + * Ryad BENADJILA <ryadbenadjila@gmail.com> + * Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr> + * + * This software is licensed under a dual BSD and GPL v2 license. + * See LICENSE file at the root folder of the project. + */ +#include <libecc/lib_ecc_config.h> +#ifdef WITH_HASH_BASH256 + +#ifndef __BASH256_H__ +#define __BASH256_H__ + +#include <libecc/words/words.h> +#include <libecc/utils/utils.h> +#include <libecc/hash/bash.h> + +#define BASH256_BLOCK_SIZE 128 +#define BASH256_DIGEST_SIZE 32 +#define BASH256_DIGEST_SIZE_BITS 256 + +/* Compute max hash digest and block sizes */ +#ifndef MAX_DIGEST_SIZE +#define MAX_DIGEST_SIZE 0 +#endif +#if (MAX_DIGEST_SIZE < BASH256_DIGEST_SIZE) +#undef MAX_DIGEST_SIZE +#define MAX_DIGEST_SIZE BASH256_DIGEST_SIZE +#endif + +#ifndef MAX_DIGEST_SIZE_BITS +#define MAX_DIGEST_SIZE_BITS 0 +#endif +#if (MAX_DIGEST_SIZE_BITS < BASH256_DIGEST_SIZE_BITS) +#undef MAX_DIGEST_SIZE_BITS +#define MAX_DIGEST_SIZE_BITS BASH256_DIGEST_SIZE_BITS +#endif + +#ifndef MAX_BLOCK_SIZE +#define MAX_BLOCK_SIZE 0 +#endif +#if (MAX_BLOCK_SIZE < BASH256_BLOCK_SIZE) +#undef MAX_BLOCK_SIZE +#define MAX_BLOCK_SIZE BASH256_BLOCK_SIZE +#endif + +#define BASH256_HASH_MAGIC ((word_t)(0x72839273873434aaULL)) +#define BASH256_HASH_CHECK_INITIALIZED(A, ret, err) \ + MUST_HAVE((((void *)(A)) != NULL) && ((A)->magic == BASH256_HASH_MAGIC), ret, err) + +typedef bash_context bash256_context; + +ATTRIBUTE_WARN_UNUSED_RET int bash256_init(bash256_context *ctx); +ATTRIBUTE_WARN_UNUSED_RET int bash256_update(bash256_context *ctx, const u8 *input, u32 ilen); +ATTRIBUTE_WARN_UNUSED_RET int bash256_final(bash256_context *ctx, u8 output[BASH256_DIGEST_SIZE]); +ATTRIBUTE_WARN_UNUSED_RET int bash256_scattered(const u8 **inputs, const u32 *ilens, + u8 output[BASH256_DIGEST_SIZE]); +ATTRIBUTE_WARN_UNUSED_RET int bash256(const u8 *input, u32 ilen, u8 output[BASH256_DIGEST_SIZE]); + +#endif /* __BASH256_H__ */ +#endif /* WITH_HASH_BASH256 */ |
