Update sm4_ff1

This commit is contained in:
Zhi Guan
2026-06-26 23:06:02 +08:00
parent e77378558c
commit 52f0f1619e
9 changed files with 250 additions and 419 deletions

View File

@@ -1,41 +0,0 @@
/*
* Copyright 2014-2026 The GmSSL Project. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
#ifndef GMSSL_FF1_H
#define GMSSL_FF1_H
#include <stdint.h>
#include <stddef.h>
#include <gmssl/block_cipher.h>
#ifdef __cplusplus
extern "C" {
#endif
#define FF1_MIN_DIGITS 8
#define FF1_MAX_DIGITS 18
#define FF1_MIN_TWEAK_SIZE 0
#define FF1_MAX_TWEAK_SIZE 11
#define FF1_NUM_ROUNDS 10
int ff1_init(BLOCK_CIPHER_KEY *key, const BLOCK_CIPHER *cipher, const uint8_t *raw_key);
int ff1_encrypt(const BLOCK_CIPHER_KEY *key, const char *in, size_t inlen,
const uint8_t *tweak, size_t tweaklen, char *out);
int ff1_decrypt(const BLOCK_CIPHER_KEY *key, const char *in, size_t inlen,
const uint8_t *tweak, size_t tweaklen, char *out);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2024 The GmSSL Project. All Rights Reserved.
* Copyright 2014-2026 The GmSSL Project. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
@@ -259,6 +259,21 @@ int sm4_xts_decrypt_finish(SM4_XTS_CTX *ctx, uint8_t *out, size_t *outlen);
#endif // ENABLE_SM4_XTS
#ifdef ENABLE_SM4_FF1
#define SM4_FF1_MIN_DIGITS 8
#define SM4_FF1_MAX_DIGITS 18
#define SM4_FF1_MIN_TWEAK_SIZE 0
#define SM4_FF1_MAX_TWEAK_SIZE 11
#define SM4_FF1_NUM_ROUNDS 10
int sm4_ff1_init(SM4_KEY *key, const uint8_t raw_key[SM4_KEY_SIZE]);
int sm4_ff1_encrypt(const SM4_KEY *key, const char *in, size_t inlen,
const uint8_t *tweak, size_t tweaklen, char *out);
int sm4_ff1_decrypt(const SM4_KEY *key, const char *in, size_t inlen,
const uint8_t *tweak, size_t tweaklen, char *out);
#endif // ENABLE_SM4_FF1
#ifdef __cplusplus
}
#endif

View File

@@ -18,7 +18,7 @@ extern "C" {
#define GMSSL_VERSION_NUM 30300
#define GMSSL_VERSION_STR "GmSSL 3.3.0-dev.1179"
#define GMSSL_VERSION_STR "GmSSL 3.3.0-dev.1180"
int gmssl_version_num(void);
const char *gmssl_version_str(void);