xref: /dflybsd-src/crypto/libressl/include/openssl/sm4.h (revision 72c3367655e64985522b7a48ddfab613e869dc68)
1*72c33676SMaxim Ag /*	$OpenBSD: sm4.h,v 1.1 2019/03/17 17:42:37 tb Exp $	*/
2*72c33676SMaxim Ag /*
3*72c33676SMaxim Ag  * Copyright (c) 2017, 2019 Ribose Inc
4*72c33676SMaxim Ag  *
5*72c33676SMaxim Ag  * Permission to use, copy, modify, and/or distribute this software for any
6*72c33676SMaxim Ag  * purpose with or without fee is hereby granted, provided that the above
7*72c33676SMaxim Ag  * copyright notice and this permission notice appear in all copies.
8*72c33676SMaxim Ag  *
9*72c33676SMaxim Ag  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*72c33676SMaxim Ag  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*72c33676SMaxim Ag  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*72c33676SMaxim Ag  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*72c33676SMaxim Ag  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*72c33676SMaxim Ag  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*72c33676SMaxim Ag  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*72c33676SMaxim Ag  */
17*72c33676SMaxim Ag 
18*72c33676SMaxim Ag #ifndef HEADER_SM4_H
19*72c33676SMaxim Ag #define HEADER_SM4_H
20*72c33676SMaxim Ag 
21*72c33676SMaxim Ag #include <stdint.h>
22*72c33676SMaxim Ag 
23*72c33676SMaxim Ag #include <openssl/opensslconf.h>
24*72c33676SMaxim Ag 
25*72c33676SMaxim Ag #ifdef  __cplusplus
26*72c33676SMaxim Ag extern "C" {
27*72c33676SMaxim Ag #endif
28*72c33676SMaxim Ag 
29*72c33676SMaxim Ag #ifdef OPENSSL_NO_SM4
30*72c33676SMaxim Ag #error SM4 is disabled.
31*72c33676SMaxim Ag #endif
32*72c33676SMaxim Ag 
33*72c33676SMaxim Ag #define SM4_DECRYPT     0
34*72c33676SMaxim Ag #define SM4_ENCRYPT     1
35*72c33676SMaxim Ag 
36*72c33676SMaxim Ag #define SM4_BLOCK_SIZE    16
37*72c33676SMaxim Ag #define SM4_KEY_SCHEDULE  32
38*72c33676SMaxim Ag 
39*72c33676SMaxim Ag typedef struct sm4_key_st {
40*72c33676SMaxim Ag 	unsigned char opaque[128];
41*72c33676SMaxim Ag } SM4_KEY;
42*72c33676SMaxim Ag 
43*72c33676SMaxim Ag int SM4_set_key(const uint8_t *key, SM4_KEY *ks);
44*72c33676SMaxim Ag void SM4_decrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks);
45*72c33676SMaxim Ag void SM4_encrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks);
46*72c33676SMaxim Ag 
47*72c33676SMaxim Ag #ifdef  __cplusplus
48*72c33676SMaxim Ag }
49*72c33676SMaxim Ag #endif
50*72c33676SMaxim Ag 
51*72c33676SMaxim Ag #endif /* HEADER_SM4_H */
52