xref: /openbsd-src/lib/libcrypto/sm3/sm3.h (revision 515aa502ddfbfa9d16fb6d4368077c2ccf35cf3d)
1 /*	$OpenBSD: sm3.h,v 1.2 2025/01/25 17:59:44 tb Exp $	*/
2 /*
3  * Copyright (c) 2018, Ribose Inc
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #ifndef HEADER_SM3_H
19 #define HEADER_SM3_H
20 
21 #include <stddef.h>
22 #include <openssl/opensslconf.h>
23 
24 #ifdef  __cplusplus
25 extern "C" {
26 #endif
27 
28 #define SM3_DIGEST_LENGTH 32
29 #define SM3_WORD unsigned int
30 
31 #define SM3_CBLOCK 64
32 #define SM3_LBLOCK (SM3_CBLOCK / 4)
33 
34 typedef struct SM3state_st {
35 	SM3_WORD A, B, C, D, E, F, G, H;
36 	SM3_WORD Nl, Nh;
37 	SM3_WORD data[SM3_LBLOCK];
38 	unsigned int num;
39 } SM3_CTX;
40 
41 int SM3_Init(SM3_CTX *c);
42 int SM3_Update(SM3_CTX *c, const void *data, size_t len);
43 int SM3_Final(unsigned char *md, SM3_CTX *c);
44 
45 #ifdef  __cplusplus
46 }
47 #endif
48 
49 #endif /* HEADER_SM3_H */
50