diff --git a/.github/workflows/cmake-windows.yml b/.github/workflows/cmake-windows.yml new file mode 100644 index 000000000..7d640b5d4 --- /dev/null +++ b/.github/workflows/cmake-windows.yml @@ -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}} diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 944cf0106..9d30a5131 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -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 strategy: matrix: - os: [ ubuntu-latest, windows-latest, macos-latest ] + os: [ ubuntu-latest, macos-latest ] runs-on: ${{ matrix.os }} steps: diff --git a/src/tls.c b/src/tls.c index e800d818a..4ae04ab34 100644 --- a/src/tls.c +++ b/src/tls.c @@ -2320,7 +2320,13 @@ void tls_cleanup(TLS_CONNECT *conn) int tls_set_socket(TLS_CONNECT *conn, tls_socket_t sock) { 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) { error_print(); 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 //return -1; } +#endif conn->sock = sock; return 1; } diff --git a/tests/sm9test.c b/tests/sm9test.c index b8281dceb..be9d4686f 100644 --- a/tests/sm9test.c +++ b/tests/sm9test.c @@ -757,8 +757,8 @@ int test_sm9_z256_exchange() uint8_t idA[5] = {0x41, 0x6C, 0x69, 0x63, 0x65}; uint8_t idB[3] = {0x42, 0x6F, 0x62}; 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_point_mul_generator(&(msk.Ppube), msk.ke); if (sm9_exch_master_key_extract_key(&msk, (char *)idA, sizeof(idA), &keyA) < 0) goto err; ++j; diff --git a/tools/tlcp_client.c b/tools/tlcp_client.c index 6380ad4c7..24c1be26e 100644 --- a/tools/tlcp_client.c +++ b/tools/tlcp_client.c @@ -254,14 +254,21 @@ int tlcp_client_main(int argc, char *argv[]) FD_ZERO(&fds); FD_SET(conn.sock, &fds); if (read_stdin) +#ifdef WIN32 + FD_SET(_fileno, &fds); +#else FD_SET(STDIN_FILENO, &fds); - +#endif if (select(conn.sock + 1, &fds, NULL, NULL, NULL) < 0) { fprintf(stderr, "%s: select error\n", prog); goto end; } +#ifdef WIN32 + if (read_stdin && FD_ISSET(_fileno, &fds)) { +#else if (read_stdin && FD_ISSET(STDIN_FILENO, &fds)) { +#endif if (fgets(buf, sizeof(buf), stdin)) { if (tls_send(&conn, (uint8_t *)buf, strlen(buf), &len) != 1) {