mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-08 23:13:38 +08:00
Support DLL in MSVC
This commit is contained in:
@@ -4,8 +4,6 @@ project(GmSSL)
|
|||||||
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||||
|
|
||||||
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
|
|
||||||
|
|
||||||
include_directories(include)
|
include_directories(include)
|
||||||
|
|
||||||
set(src
|
set(src
|
||||||
@@ -109,7 +107,6 @@ endif()
|
|||||||
|
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
# list(APPEND src src/u_time.c)
|
|
||||||
list(APPEND src src/rand_win.c)
|
list(APPEND src src/rand_win.c)
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
list(APPEND src src/rand_apple.c)
|
list(APPEND src src/rand_apple.c)
|
||||||
@@ -119,10 +116,18 @@ else()
|
|||||||
list(APPEND src src/rand_unix.c)
|
list(APPEND src src/rand_unix.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
|
||||||
|
|
||||||
|
if (CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
||||||
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # set before add_library
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(gmssl ${src})
|
add_library(gmssl ${src})
|
||||||
|
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
target_link_libraries(gmssl dl)
|
target_link_libraries(gmssl dl)
|
||||||
target_link_libraries(gmssl "-framework Security")
|
target_link_libraries(gmssl "-framework Security")
|
||||||
|
|||||||
@@ -81,18 +81,14 @@ SM9 Public API
|
|||||||
#define SM9_HEX_SEP '\n'
|
#define SM9_HEX_SEP '\n'
|
||||||
|
|
||||||
typedef uint64_t sm9_bn_t[8];
|
typedef uint64_t sm9_bn_t[8];
|
||||||
extern const sm9_bn_t SM9_ZERO;
|
|
||||||
extern const sm9_bn_t SM9_ONE;
|
|
||||||
extern const sm9_bn_t SM9_P;
|
|
||||||
extern const sm9_bn_t SM9_N;
|
|
||||||
|
|
||||||
#define sm9_bn_init(r) sm9_bn_set_zero(r)
|
#define sm9_bn_init(r) sm9_bn_set_zero(r)
|
||||||
#define sm9_bn_clean(r) sm9_bn_set_zero(r)
|
#define sm9_bn_clean(r) sm9_bn_set_zero(r)
|
||||||
#define sm9_bn_set_zero(r) sm9_bn_copy((r), SM9_ZERO)
|
|
||||||
#define sm9_bn_set_one(r) sm9_bn_copy((r), SM9_ONE)
|
|
||||||
#define sm9_bn_is_zero(a) (sm9_bn_cmp((a), SM9_ZERO) == 0)
|
|
||||||
#define sm9_bn_is_one(a) (sm9_bn_cmp((a), SM9_ONE) == 0)
|
|
||||||
|
|
||||||
|
void sm9_bn_set_zero(sm9_bn_t r);
|
||||||
|
void sm9_bn_set_one(sm9_bn_t r);
|
||||||
|
int sm9_bn_is_zero(const sm9_bn_t a);
|
||||||
|
int sm9_bn_is_one(const sm9_bn_t a);
|
||||||
void sm9_bn_set_word(sm9_bn_t r, uint32_t a);
|
void sm9_bn_set_word(sm9_bn_t r, uint32_t a);
|
||||||
void sm9_bn_copy(sm9_bn_t r, const sm9_bn_t a);
|
void sm9_bn_copy(sm9_bn_t r, const sm9_bn_t a);
|
||||||
int sm9_bn_rand_range(sm9_bn_t r, const sm9_bn_t range);
|
int sm9_bn_rand_range(sm9_bn_t r, const sm9_bn_t range);
|
||||||
|
|||||||
@@ -77,6 +77,26 @@ const SM9_TWIST_POINT _SM9_Ppubs = {
|
|||||||
const SM9_TWIST_POINT *SM9_Ppubs = &_SM9_Ppubs;
|
const SM9_TWIST_POINT *SM9_Ppubs = &_SM9_Ppubs;
|
||||||
|
|
||||||
|
|
||||||
|
void sm9_bn_set_zero(sm9_bn_t r)
|
||||||
|
{
|
||||||
|
sm9_bn_copy(r, SM9_ZERO);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sm9_bn_set_one(sm9_bn_t r)
|
||||||
|
{
|
||||||
|
sm9_bn_copy(r, SM9_ONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sm9_bn_is_zero(const sm9_bn_t a)
|
||||||
|
{
|
||||||
|
return (sm9_bn_cmp(a, SM9_ZERO) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sm9_bn_is_one(const sm9_bn_t a)
|
||||||
|
{
|
||||||
|
return (sm9_bn_cmp(a, SM9_ONE) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
void sm9_bn_to_bytes(const sm9_bn_t a, uint8_t out[32])
|
void sm9_bn_to_bytes(const sm9_bn_t a, uint8_t out[32])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -23,6 +23,9 @@
|
|||||||
#include <gmssl/error.h>
|
#include <gmssl/error.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern const sm9_bn_t SM9_ZERO;
|
||||||
|
extern const sm9_bn_t SM9_N;
|
||||||
|
|
||||||
// generate h1 in [1, n-1]
|
// generate h1 in [1, n-1]
|
||||||
int sm9_hash1(sm9_bn_t h1, const char *id, size_t idlen, uint8_t hid)
|
int sm9_hash1(sm9_bn_t h1, const char *id, size_t idlen, uint8_t hid)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
#include <gmssl/asn1.h>
|
#include <gmssl/asn1.h>
|
||||||
#include <gmssl/error.h>
|
#include <gmssl/error.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern const sm9_bn_t SM9_ZERO;
|
||||||
|
extern const sm9_bn_t SM9_N;
|
||||||
extern const SM9_POINT *SM9_P1;
|
extern const SM9_POINT *SM9_P1;
|
||||||
extern const SM9_TWIST_POINT *SM9_P2;
|
extern const SM9_TWIST_POINT *SM9_P2;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user