1 /*	$OpenBSD: sm3.h,v 1.1 2018/11/11 06:53:31 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 #ifdef OPENSSL_NO_SM3
29 #error SM3 is disabled.
30 #endif
31 
32 #define SM3_DIGEST_LENGTH 32
33 #define SM3_WORD unsigned int
34 
35 #define SM3_CBLOCK 64
36 #define SM3_LBLOCK (SM3_CBLOCK / 4)
37 
38 typedef struct SM3state_st {
39 	SM3_WORD A, B, C, D, E, F, G, H;
40 	SM3_WORD Nl, Nh;
41 	SM3_WORD data[SM3_LBLOCK];
42 	unsigned int num;
43 } SM3_CTX;
44 
45 int SM3_Init(SM3_CTX *c);
46 int SM3_Update(SM3_CTX *c, const void *data, size_t len);
47 int SM3_Final(unsigned char *md, SM3_CTX *c);
48 
49 #ifdef  __cplusplus
50 }
51 #endif
52 
53 #endif /* HEADER_SM3_H */
54