xref: /openbsd/lib/libcrypto/sm4/sm4.h (revision 515aa502)
1 /*	$OpenBSD: sm4.h,v 1.2 2025/01/25 17:59:44 tb Exp $	*/
2 /*
3  * Copyright (c) 2017, 2019 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_SM4_H
19 #define HEADER_SM4_H
20 
21 #include <stdint.h>
22 
23 #include <openssl/opensslconf.h>
24 
25 #ifdef  __cplusplus
26 extern "C" {
27 #endif
28 
29 #define SM4_DECRYPT     0
30 #define SM4_ENCRYPT     1
31 
32 #define SM4_BLOCK_SIZE    16
33 #define SM4_KEY_SCHEDULE  32
34 
35 typedef struct sm4_key_st {
36 	unsigned char opaque[128];
37 } SM4_KEY;
38 
39 int SM4_set_key(const uint8_t *key, SM4_KEY *ks);
40 void SM4_decrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks);
41 void SM4_encrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks);
42 
43 #ifdef  __cplusplus
44 }
45 #endif
46 
47 #endif /* HEADER_SM4_H */
48