mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-09 07:23:56 +08:00
Add SM3 ASM
This commit is contained in:
@@ -8,7 +8,6 @@ option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
|
|||||||
|
|
||||||
include_directories(include)
|
include_directories(include)
|
||||||
|
|
||||||
#enable_language(ASM)
|
|
||||||
|
|
||||||
|
|
||||||
set(src
|
set(src
|
||||||
@@ -76,6 +75,14 @@ set(src
|
|||||||
src/tls13.c
|
src/tls13.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
option(ENABLE_SM3_AVX_BMI2 "Enable SM3 AVX+BMI2 assembly implementation" OFF)
|
||||||
|
|
||||||
|
|
||||||
|
if (ENABLE_SM3_AVX_BMI2)
|
||||||
|
enable_language(ASM)
|
||||||
|
list(APPEND src src/sm3_avx_bmi2.s)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
list(APPEND src src/u_time.c)
|
list(APPEND src src/u_time.c)
|
||||||
list(APPEND src src/rand_win.c)
|
list(APPEND src src/rand_win.c)
|
||||||
@@ -247,4 +254,4 @@ if (CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
|||||||
target_compile_options(gmssl PRIVATE /wd4996)
|
target_compile_options(gmssl PRIVATE /wd4996)
|
||||||
target_compile_options(gmssl-bin PRIVATE /wd4996)
|
target_compile_options(gmssl-bin PRIVATE /wd4996)
|
||||||
# target_compile_options(gmssl PRIVATE /wd4996)
|
# target_compile_options(gmssl PRIVATE /wd4996)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ static uint32_t K[64] = {
|
|||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef ENABLE_SM3_AVX_BMI2
|
||||||
void sm3_compress_blocks(uint32_t digest[8], const uint8_t *data, size_t blocks)
|
void sm3_compress_blocks(uint32_t digest[8], const uint8_t *data, size_t blocks)
|
||||||
{
|
{
|
||||||
uint32_t A;
|
uint32_t A;
|
||||||
@@ -293,7 +294,7 @@ void sm3_compress_blocks(uint32_t digest[8], const uint8_t *data, size_t blocks)
|
|||||||
data += 64;
|
data += 64;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void sm3_init(SM3_CTX *ctx)
|
void sm3_init(SM3_CTX *ctx)
|
||||||
{
|
{
|
||||||
@@ -311,7 +312,7 @@ void sm3_init(SM3_CTX *ctx)
|
|||||||
void sm3_update(SM3_CTX *ctx, const uint8_t *data, size_t data_len)
|
void sm3_update(SM3_CTX *ctx, const uint8_t *data, size_t data_len)
|
||||||
{
|
{
|
||||||
size_t blocks;
|
size_t blocks;
|
||||||
|
|
||||||
ctx->num &= 0x3f;
|
ctx->num &= 0x3f;
|
||||||
if (ctx->num) {
|
if (ctx->num) {
|
||||||
size_t left = SM3_BLOCK_SIZE - ctx->num;
|
size_t left = SM3_BLOCK_SIZE - ctx->num;
|
||||||
|
|||||||
Reference in New Issue
Block a user