| 1 | /* |
| 2 | * Copyright (c) 2025 Björn Esser <besser82 at fedoraproject.org> |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 6 | * purpose with or without fee is hereby granted. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
| 17 | #ifndef _CRYPT_ALG_SM3_H |
| 18 | #define _CRYPT_ALG_SM3_Hcxx . . $ `lib/alg-sm3.h:18:9`! |
| 19 | |
| 20 | #include "crypt-port.h"cxx . . $ `<file>/lib/crypt-port.h`/ |
| 21 | |
| 22 | #include <stdint.h> |
| 23 | |
| 24 | /* Context structure for SM3 operations. */ |
| 25 | typedef structcxx . . $ $anonymous_type_50e5df6d771a4f96_0# |
| 26 | { |
| 27 | uint32_tcxx . . $ uint32_t# statecxx . . $ $anonymous_type_50e5df6d771a4f96_0#state.[8]; |
| 28 | uint64_tcxx . . $ uint64_t# countcxx . . $ $anonymous_type_50e5df6d771a4f96_0#count.; |
| 29 | uint8_tcxx . . $ uint8_t# bufcxx . . $ $anonymous_type_50e5df6d771a4f96_0#buf.[64]; |
| 30 | } sm3_ctxcxx . . $ sm3_ctx#; |
| 31 | |
| 32 | /** |
| 33 | * sm3_init(ctx): |
| 34 | * Initialize the SM3 context ${ctx}. |
| 35 | */ |
| 36 | extern void sm3_initcxx . . $ `lib/crypt-port.h:407:9`!(sm3_ctxcxx . . $ sm3_ctx# *); |
| 37 | |
| 38 | /** |
| 39 | * sm3_update(ctx, in, len): |
| 40 | * Input ${len} bytes from ${in} into the SM3 context ${ctx}. |
| 41 | */ |
| 42 | extern void sm3_updatecxx . . $ `lib/crypt-port.h:408:9`!(sm3_ctxcxx . . $ sm3_ctx# *, const void *, size_t); |
| 43 | |
| 44 | /** |
| 45 | * sm3_final(digest, ctx): |
| 46 | * Output the SM3 hash of the data input to the context ${ctx} into the |
| 47 | * buffer ${digest}. |
| 48 | */ |
| 49 | extern void sm3_finalcxx . . $ `lib/crypt-port.h:409:9`!(uint8_tcxx . . $ uint8_t#[32], sm3_ctxcxx . . $ sm3_ctx# *); |
| 50 | |
| 51 | /** |
| 52 | * sm3_hash(in, len, digest, ctx): |
| 53 | * Compute the SM3 hash of ${len} bytes from ${in} and write it to ${digest}, |
| 54 | * using the prepared context ${ctx}. |
| 55 | */ |
| 56 | extern void sm3_hashcxx . . $ `lib/crypt-port.h:410:9`!(const void *, size_t, uint8_tcxx . . $ uint8_t#[32], sm3_ctxcxx . . $ sm3_ctx# *); |
| 57 | |
| 58 | /** |
| 59 | * sm3_buf(in, len, digest): |
| 60 | * Compute the SM3 hash of ${len} bytes from ${in} and write it to ${digest}. |
| 61 | */ |
| 62 | extern void sm3_bufcxx . . $ `lib/crypt-port.h:411:9`!(const void *, size_t, uint8_tcxx . . $ uint8_t#[32]); |
| 63 | #endif /* _CRYPT_ALG_SM3_H */ |