17d004720Schristos /* 2*b0d17251Schristos * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved. 37d004720Schristos * Copyright 2017 Ribose Inc. All Rights Reserved. 47d004720Schristos * 5*b0d17251Schristos * Licensed under the Apache License 2.0 (the "License"). You may not use 67d004720Schristos * this file except in compliance with the License. You can obtain a copy 77d004720Schristos * in the file LICENSE in the source distribution or at 87d004720Schristos * https://www.openssl.org/source/license.html 97d004720Schristos */ 107d004720Schristos 117d004720Schristos #ifndef OSSL_CRYPTO_SM4_H 127d004720Schristos # define OSSL_CRYPTO_SM4_H 13*b0d17251Schristos # pragma once 147d004720Schristos 157d004720Schristos # include <openssl/opensslconf.h> 167d004720Schristos # include <openssl/e_os2.h> 177d004720Schristos 187d004720Schristos # ifdef OPENSSL_NO_SM4 197d004720Schristos # error SM4 is disabled. 207d004720Schristos # endif 217d004720Schristos 227d004720Schristos # define SM4_ENCRYPT 1 237d004720Schristos # define SM4_DECRYPT 0 247d004720Schristos 257d004720Schristos # define SM4_BLOCK_SIZE 16 267d004720Schristos # define SM4_KEY_SCHEDULE 32 277d004720Schristos 287d004720Schristos typedef struct SM4_KEY_st { 297d004720Schristos uint32_t rk[SM4_KEY_SCHEDULE]; 307d004720Schristos } SM4_KEY; 317d004720Schristos 32*b0d17251Schristos int ossl_sm4_set_key(const uint8_t *key, SM4_KEY *ks); 337d004720Schristos 34*b0d17251Schristos void ossl_sm4_encrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks); 357d004720Schristos 36*b0d17251Schristos void ossl_sm4_decrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks); 377d004720Schristos 387d004720Schristos #endif 39