Revert "Add socket wrapper"

This reverts commit 85e745121f.
This commit is contained in:
Zhi Guan
2022-11-01 17:51:26 +08:00
parent 90aaf5ade1
commit 87081c4ca4
13 changed files with 281 additions and 105 deletions

View File

@@ -12,6 +12,13 @@
#ifndef GMSSL_TLS_H
#define GMSSL_TLS_H
#ifdef WIN32
#pragma comment (lib, "Ws2_32.lib")
#pragma comment (lib, "Mswsock.lib")
#pragma comment (lib, "AdvApi32.lib")
#include <winsock2.h>
#endif
#include <stdint.h>
#include <gmssl/sm2.h>
@@ -19,7 +26,6 @@
#include <gmssl/sm4.h>
#include <gmssl/digest.h>
#include <gmssl/block_cipher.h>
#include <gmssl/socket.h>
#ifdef __cplusplus
@@ -452,9 +458,15 @@ int tls_record_set_data(uint8_t *record, const uint8_t *data, size_t datalen);
int tls_record_print(FILE *fp, const uint8_t *record, size_t recordlen, int format, int indent);
int tlcp_record_print(FILE *fp, const uint8_t *record, size_t recordlen, int format, int indent);
int tls_record_send(const uint8_t *record, size_t recordlen, tls_socket_t sock);
int tls_record_recv(uint8_t *record, size_t *recordlen, tls_socket_t sock);
int tls12_record_recv(uint8_t *record, size_t *recordlen, tls_socket_t sock);
#ifdef WIN32
int tls_record_send(const uint8_t* record, size_t recordlen, SOCKET sock);
int tls_record_recv(uint8_t* record, size_t* recordlen, SOCKET sock);
int tls12_record_recv(uint8_t* record, size_t* recordlen, SOCKET sock);
#else
int tls_record_send(const uint8_t *record, size_t recordlen, int sock);
int tls_record_recv(uint8_t *record, size_t *recordlen, int sock);
int tls12_record_recv(uint8_t *record, size_t *recordlen, int sock);
#endif
// Handshake
@@ -740,7 +752,12 @@ typedef struct {
int is_client;
int cipher_suites[TLS_MAX_CIPHER_SUITES_COUNT];
size_t cipher_suites_cnt;
tls_socket_t sock;
#ifdef WIN32
SOCKET sock;
#else
int sock;
#endif
uint8_t enced_record[TLS_MAX_RECORD_SIZE];
size_t enced_record_len;
@@ -790,7 +807,11 @@ typedef struct {
int tls_init(TLS_CONNECT *conn, const TLS_CTX *ctx);
int tls_set_socket(TLS_CONNECT *conn, tls_socket_t sock);
#ifdef WIN32
int tls_set_socket(TLS_CONNECT* conn, SOCKET sock);
#else
int tls_set_socket(TLS_CONNECT *conn, int sock);
#endif
int tls_do_handshake(TLS_CONNECT *conn);
int tls_send(TLS_CONNECT *conn, const uint8_t *in, size_t inlen, size_t *sentlen);
int tls_recv(TLS_CONNECT *conn, uint8_t *out, size_t outlen, size_t *recvlen);