Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:16

0001 /* sm4.h
0002 
0003    Copyright (C) 2022 Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
0004 
0005    This file is part of GNU Nettle.
0006 
0007    GNU Nettle is free software: you can redistribute it and/or
0008    modify it under the terms of either:
0009 
0010      * the GNU Lesser General Public License as published by the Free
0011        Software Foundation; either version 3 of the License, or (at your
0012        option) any later version.
0013 
0014    or
0015 
0016      * the GNU General Public License as published by the Free
0017        Software Foundation; either version 2 of the License, or (at your
0018        option) any later version.
0019 
0020    or both in parallel, as here.
0021 
0022    GNU Nettle is distributed in the hope that it will be useful,
0023    but WITHOUT ANY WARRANTY; without even the implied warranty of
0024    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0025    General Public License for more details.
0026 
0027    You should have received copies of the GNU General Public License and
0028    the GNU Lesser General Public License along with this program.  If
0029    not, see http://www.gnu.org/licenses/.
0030 */
0031 
0032 #ifndef NETTLE_SM4_H_INCLUDED
0033 #define NETTLE_SM4_H_INCLUDED
0034 
0035 #include "nettle-types.h"
0036 
0037 #ifdef __cplusplus
0038 extern "C" {
0039 #endif
0040 
0041 /* Name mangling */
0042 #define sm4_set_encrypt_key nettle_sm4_set_encrypt_key
0043 #define sm4_set_decrypt_key nettle_sm4_set_decrypt_key
0044 #define sm4_crypt nettle_sm4_crypt
0045 
0046 #define SM4_BLOCK_SIZE 16
0047 #define SM4_KEY_SIZE 16
0048 
0049 struct sm4_ctx
0050 {
0051   uint32_t rkey[32];
0052 };
0053 
0054 void
0055 sm4_set_encrypt_key(struct sm4_ctx *ctx, const uint8_t *key);
0056 
0057 void
0058 sm4_set_decrypt_key(struct sm4_ctx *ctx, const uint8_t *key);
0059 
0060 void
0061 sm4_crypt(const struct sm4_ctx *context,
0062       size_t length, uint8_t *dst,
0063       const uint8_t *src);
0064 
0065 #ifdef __cplusplus
0066 }
0067 #endif
0068 
0069 #endif /* NETTLE_SM4_H_INCLUDED */