mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-07 12:33:39 +08:00
Fix Visual Studio compiling errors
This commit is contained in:
@@ -1,11 +1,16 @@
|
|||||||
cmake_minimum_required(VERSION 3.0)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
project(GmSSL)
|
project(GmSSL)
|
||||||
|
|
||||||
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
|
|
||||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
|
||||||
|
|
||||||
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
|
if (WIN32)
|
||||||
|
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||||
|
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||||
|
else()
|
||||||
|
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
|
||||||
|
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
|
||||||
include_directories(include)
|
include_directories(include)
|
||||||
|
|
||||||
#enable_language(ASM)
|
#enable_language(ASM)
|
||||||
|
|||||||
@@ -25,6 +25,10 @@
|
|||||||
#include <gmssl/x509.h>
|
#include <gmssl/x509.h>
|
||||||
#include <gmssl/error.h>
|
#include <gmssl/error.h>
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include "u_time.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
const char *x509_version_name(int version)
|
const char *x509_version_name(int version)
|
||||||
{
|
{
|
||||||
@@ -97,7 +101,11 @@ int x509_time_to_der(time_t tv, uint8_t **out, size_t *outlen)
|
|||||||
int ret;
|
int ret;
|
||||||
struct tm tm_val;
|
struct tm tm_val;
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
GMSSL_gmtime(&tv, &tm_val);
|
||||||
|
#else
|
||||||
gmtime_r(&tv, &tm_val);
|
gmtime_r(&tv, &tm_val);
|
||||||
|
#endif
|
||||||
if (tm_val.tm_year < 2050 - 1900) {
|
if (tm_val.tm_year < 2050 - 1900) {
|
||||||
if ((ret = asn1_utc_time_to_der(tv, out, outlen)) != 1) {
|
if ((ret = asn1_utc_time_to_der(tv, out, outlen)) != 1) {
|
||||||
if (ret < 0) error_print();
|
if (ret < 0) error_print();
|
||||||
@@ -136,7 +144,11 @@ int x509_validity_add_days(time_t *not_after, time_t not_before, int days)
|
|||||||
error_print();
|
error_print();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#ifdef WIN32
|
||||||
|
GMSSL_gmtime(¬_before, &tm_val);
|
||||||
|
#else
|
||||||
gmtime_r(¬_before, &tm_val);
|
gmtime_r(¬_before, &tm_val);
|
||||||
|
#endif
|
||||||
tm_val.tm_mday += days;
|
tm_val.tm_mday += days;
|
||||||
*not_after = mktime(&tm_val);
|
*not_after = mktime(&tm_val);
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -84,9 +84,9 @@ struct {
|
|||||||
int test_hmac(const DIGEST *digest, const char *key_hex, const char *data_hex, const char *hmac_hex)
|
int test_hmac(const DIGEST *digest, const char *key_hex, const char *data_hex, const char *hmac_hex)
|
||||||
{
|
{
|
||||||
HMAC_CTX ctx;
|
HMAC_CTX ctx;
|
||||||
uint8_t key[strlen(key_hex)/2];
|
uint8_t key = malloc(strlen(key_hex)/2); // FIXME: malloc
|
||||||
uint8_t data[strlen(data_hex)/2];
|
uint8_t data = malloc(strlen(data_hex)/2);
|
||||||
uint8_t hmac[strlen(hmac_hex)/2];
|
uint8_t hmac = malloc(strlen(hmac_hex) / 2);
|
||||||
uint8_t buf[64];
|
uint8_t buf[64];
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
@@ -103,6 +103,9 @@ int test_hmac(const DIGEST *digest, const char *key_hex, const char *data_hex, c
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
printf("ok\n");
|
printf("ok\n");
|
||||||
|
if (key) free(key);
|
||||||
|
if (data) free(data);
|
||||||
|
if (hmac) free(hmac);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user