mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-07 12:33:39 +08:00
append
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -211,6 +211,8 @@ include/openssl/srp.h
|
|||||||
/python
|
/python
|
||||||
/build
|
/build
|
||||||
|
|
||||||
|
build/
|
||||||
|
bin/
|
||||||
.gmssl
|
.gmssl
|
||||||
CMakeFiles/
|
CMakeFiles/
|
||||||
CTestTestfile.cmake
|
CTestTestfile.cmake
|
||||||
|
|||||||
@@ -7,40 +7,44 @@
|
|||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef GMSSL_ERROR_H
|
#ifndef GMSSL_ERROR_H
|
||||||
#define GMSSL_ERROR_H
|
#define GMSSL_ERROR_H
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define GMSSL_FMT_BIN 1
|
||||||
#define GMSSL_FMT_BIN 1
|
#define GMSSL_FMT_HEX 2
|
||||||
#define GMSSL_FMT_HEX 2
|
#define GMSSL_FMT_DER 4
|
||||||
#define GMSSL_FMT_DER 4
|
#define GMSSL_FMT_PEM 8
|
||||||
#define GMSSL_FMT_PEM 8
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
|
|
||||||
#define error_print() \
|
#define error_print() \
|
||||||
do { if (DEBUG) fprintf(stderr, "%s:%d:%s():\n",__FILE__, __LINE__, __func__); } while (0)
|
do { \
|
||||||
|
if (DEBUG) \
|
||||||
|
fprintf(stderr, "%s:%d:%s():\n", __FILE__, __LINE__, __func__); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define error_print_msg(fmt, ...) \
|
#define error_print_msg(fmt, ...) \
|
||||||
do { if (DEBUG) fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, __LINE__, __func__, __VA_ARGS__); } while (0)
|
do { \
|
||||||
|
if (DEBUG) \
|
||||||
#define error_puts(str) \
|
fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, __LINE__, __func__, \
|
||||||
do { if (DEBUG) fprintf(stderr, "%s: %d: %s: %s", __FILE__, __LINE__, __func__, str); } while (0)
|
__VA_ARGS__); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define error_puts(str) \
|
||||||
|
do { \
|
||||||
|
if (DEBUG) \
|
||||||
|
fprintf(stderr, "%s: %d: %s: %s", __FILE__, __LINE__, __func__, \
|
||||||
|
str); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
void print_der(const uint8_t *in, size_t inlen);
|
void print_der(const uint8_t *in, size_t inlen);
|
||||||
void print_bytes(const uint8_t *in, size_t inlen);
|
void print_bytes(const uint8_t *in, size_t inlen);
|
||||||
@@ -48,15 +52,13 @@ void print_nodes(const uint32_t *in, size_t inlen);
|
|||||||
|
|
||||||
#define FMT_CARRAY 0x80
|
#define FMT_CARRAY 0x80
|
||||||
|
|
||||||
|
|
||||||
int format_print(FILE *fp, int format, int indent, const char *str, ...);
|
int format_print(FILE *fp, int format, int indent, const char *str, ...);
|
||||||
int format_bytes(FILE *fp, int format, int indent, const char *str, const uint8_t *data, size_t datalen);
|
int format_bytes(FILE *fp, int format, int indent, const char *str,
|
||||||
int format_string(FILE *fp, int format, int indent, const char *str, const uint8_t *data, size_t datalen);
|
const uint8_t *data, size_t datalen);
|
||||||
|
int format_string(FILE *fp, int format, int indent, const char *str,
|
||||||
|
const uint8_t *data, size_t datalen);
|
||||||
|
|
||||||
//int tls_trace(int format, int indent, const char *str, ...);
|
|
||||||
|
|
||||||
|
// int tls_trace(int format, int indent, const char *str, ...);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/tls.c
16
src/tls.c
@@ -1450,9 +1450,16 @@ int tls_record_do_recv(uint8_t *record, size_t *recordlen, tls_socket_t sock) {
|
|||||||
|
|
||||||
len = 5;
|
len = 5;
|
||||||
while (len) {
|
while (len) {
|
||||||
while ((r = tls_socket_recv(sock, record + 5 - len, len, 0)) < 0 &&
|
while ((r = tls_socket_recv(sock, record + 5 - len, len, 0)) < 0) {
|
||||||
errno == EAGAIN) {
|
if (errno == EAGAIN) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
error_print();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_print();
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
perror("tls_record_do_recv");
|
perror("tls_record_do_recv");
|
||||||
error_print();
|
error_print();
|
||||||
@@ -2261,11 +2268,10 @@ int tls_do_handshake(TLS_CONNECT *conn) {
|
|||||||
else
|
else
|
||||||
return tls12_do_accept(conn);
|
return tls12_do_accept(conn);
|
||||||
case TLS_protocol_tls13:
|
case TLS_protocol_tls13:
|
||||||
if (conn->is_client)
|
if (conn->is_client)
|
||||||
return tls13_do_connect(conn);
|
return tls13_do_connect(conn);
|
||||||
else
|
else
|
||||||
return tls13_do_accept(conn);
|
return tls13_do_accept(conn);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error_print();
|
error_print();
|
||||||
|
|||||||
Reference in New Issue
Block a user