mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-06 16:36:16 +08:00
修复Windows编译的问题。
将Windows CI单独拿出来。在Windows环境下编译需要在cmake的时候增加-DWIN32=ON参数。
This commit is contained in:
40
.github/workflows/cmake-windows.yml
vendored
Normal file
40
.github/workflows/cmake-windows.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
name: CMake-windows
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Configure build for x86
|
||||||
|
uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
with:
|
||||||
|
arch: amd64_x86
|
||||||
|
|
||||||
|
- name: Configure CMake
|
||||||
|
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||||
|
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
||||||
|
run: cmake -B ${{github.workspace}}\build -G "NMake Makefiles" -DWIN32=ON;
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
working-directory: ${{github.workspace}}\build
|
||||||
|
# Build your program with the given configuration
|
||||||
|
run: nmake
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
working-directory: ${{github.workspace}}\build
|
||||||
|
# Execute tests defined by the CMake configuration.
|
||||||
|
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
||||||
|
run: ctest --rerun-failed --output-on-failure -C ${{env.BUILD_TYPE}}
|
||||||
2
.github/workflows/cmake.yml
vendored
2
.github/workflows/cmake.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
|||||||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
|
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
os: [ ubuntu-latest, macos-latest ]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@@ -2320,7 +2320,13 @@ void tls_cleanup(TLS_CONNECT *conn)
|
|||||||
int tls_set_socket(TLS_CONNECT *conn, tls_socket_t sock)
|
int tls_set_socket(TLS_CONNECT *conn, tls_socket_t sock)
|
||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
|
#ifdef WIN32
|
||||||
|
if( ioctlsocket(sock, FIONBIO, &flags) != 0) {
|
||||||
|
error_puts("socket in non-blocking mode");
|
||||||
|
//nginx will pass a socket in non-blocking mode
|
||||||
|
//return -1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
if ((flags = fcntl(sock, F_GETFL)) == -1) {
|
if ((flags = fcntl(sock, F_GETFL)) == -1) {
|
||||||
error_print();
|
error_print();
|
||||||
perror("fcntl error");
|
perror("fcntl error");
|
||||||
@@ -2331,6 +2337,7 @@ int tls_set_socket(TLS_CONNECT *conn, tls_socket_t sock)
|
|||||||
//nginx will pass a socket in non-blocking mode
|
//nginx will pass a socket in non-blocking mode
|
||||||
//return -1;
|
//return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
conn->sock = sock;
|
conn->sock = sock;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -757,8 +757,8 @@ int test_sm9_z256_exchange()
|
|||||||
uint8_t idA[5] = {0x41, 0x6C, 0x69, 0x63, 0x65};
|
uint8_t idA[5] = {0x41, 0x6C, 0x69, 0x63, 0x65};
|
||||||
uint8_t idB[3] = {0x42, 0x6F, 0x62};
|
uint8_t idB[3] = {0x42, 0x6F, 0x62};
|
||||||
size_t klen = 0x10;
|
size_t klen = 0x10;
|
||||||
uint8_t skA[200] = {}, skB[200] = {};
|
uint8_t skA[200];
|
||||||
|
uint8_t skB[200];
|
||||||
sm9_z256_from_hex(msk.ke, hex_kex);
|
sm9_z256_from_hex(msk.ke, hex_kex);
|
||||||
sm9_z256_point_mul_generator(&(msk.Ppube), msk.ke);
|
sm9_z256_point_mul_generator(&(msk.Ppube), msk.ke);
|
||||||
if (sm9_exch_master_key_extract_key(&msk, (char *)idA, sizeof(idA), &keyA) < 0) goto err; ++j;
|
if (sm9_exch_master_key_extract_key(&msk, (char *)idA, sizeof(idA), &keyA) < 0) goto err; ++j;
|
||||||
|
|||||||
@@ -254,14 +254,21 @@ bad:
|
|||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(conn.sock, &fds);
|
FD_SET(conn.sock, &fds);
|
||||||
if (read_stdin)
|
if (read_stdin)
|
||||||
|
#ifdef WIN32
|
||||||
|
FD_SET(_fileno, &fds);
|
||||||
|
#else
|
||||||
FD_SET(STDIN_FILENO, &fds);
|
FD_SET(STDIN_FILENO, &fds);
|
||||||
|
#endif
|
||||||
if (select(conn.sock + 1, &fds, NULL, NULL, NULL) < 0) {
|
if (select(conn.sock + 1, &fds, NULL, NULL, NULL) < 0) {
|
||||||
fprintf(stderr, "%s: select error\n", prog);
|
fprintf(stderr, "%s: select error\n", prog);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
if (read_stdin && FD_ISSET(_fileno, &fds)) {
|
||||||
|
#else
|
||||||
if (read_stdin && FD_ISSET(STDIN_FILENO, &fds)) {
|
if (read_stdin && FD_ISSET(STDIN_FILENO, &fds)) {
|
||||||
|
#endif
|
||||||
|
|
||||||
if (fgets(buf, sizeof(buf), stdin)) {
|
if (fgets(buf, sizeof(buf), stdin)) {
|
||||||
if (tls_send(&conn, (uint8_t *)buf, strlen(buf), &len) != 1) {
|
if (tls_send(&conn, (uint8_t *)buf, strlen(buf), &len) != 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user