Fix for WPAS certificate size difference. Fix so BIO_METHOD is compatible. Moved BIO stuff into bio.h.

This commit is contained in:
David Garske
2019-09-25 06:57:52 -07:00
parent a5f9d38c0d
commit 606b76d06e
5 changed files with 72 additions and 61 deletions

View File

@ -1465,7 +1465,7 @@ int wolfSSL_BIO_meth_set_gets(WOLFSSL_BIO_METHOD *biom,
int wolfSSL_BIO_meth_set_ctrl(WOLFSSL_BIO_METHOD *biom,
wolfSSL_BIO_meth_get_ctrl_cb biom_ctrl)
wolfSSL_BIO_meth_ctrl_get_cb biom_ctrl)
{
WOLFSSL_ENTER("wolfSSL_BIO_meth_set_ctrl");
if (biom) {

View File

@ -27586,7 +27586,15 @@ static void test_wolfSSL_X509_print()
/* print to memory */
AssertNotNull(bio = BIO_new(BIO_s_mem()));
AssertIntEQ(X509_print(bio, x509), SSL_SUCCESS);
#ifdef WOLFSSL_WPAS
/* WPAS adds extra "="" */
/* WPAS Issuer: /C==US/ST==Montana/L==Bozeman/O==Sawtooth/... */
/* NORM Issuer: /C=US/ST=Montana/L=Bozeman/O=Sawtooth/... */
AssertIntEQ(BIO_get_mem_data(bio, NULL), 3230);
#else
AssertIntEQ(BIO_get_mem_data(bio, NULL), 3212);
#endif
BIO_free(bio);
/* print to stdout */

View File

@ -32,12 +32,37 @@
extern "C" {
#endif
#define BIO_FLAG_BASE64_NO_NL WOLFSSL_BIO_FLAG_BASE64_NO_NL
#define BIO_FLAG_READ WOLFSSL_BIO_FLAG_READ
#define BIO_FLAG_WRITE WOLFSSL_BIO_FLAG_WRITE
#define BIO_FLAG_IO_SPECIAL WOLFSSL_BIO_FLAG_IO_SPECIAL
#define BIO_FLAG_RETRY WOLFSSL_BIO_FLAG_RETRY
#define BIO_new_fp wolfSSL_BIO_new_fp
#define BIO_new_file wolfSSL_BIO_new_file
#define BIO_new_fp wolfSSL_BIO_new_fp
#define BIO_ctrl wolfSSL_BIO_ctrl
#define BIO_ctrl_pending wolfSSL_BIO_ctrl_pending
#define BIO_wpending wolfSSL_BIO_wpending
#define BIO_get_mem_ptr wolfSSL_BIO_get_mem_ptr
#define BIO_int_ctrl wolfSSL_BIO_int_ctrl
#define BIO_reset wolfSSL_BIO_reset
#define BIO_s_file wolfSSL_BIO_s_file
#define BIO_s_bio wolfSSL_BIO_s_bio
#define BIO_s_socket wolfSSL_BIO_s_socket
#define BIO_set_fd wolfSSL_BIO_set_fd
#define BIO_ctrl_reset_read_request wolfSSL_BIO_ctrl_reset_read_request
#define BIO_set_write_buf_size wolfSSL_BIO_set_write_buf_size
#define BIO_make_bio_pair wolfSSL_BIO_make_bio_pair
#define BIO_set_fp wolfSSL_BIO_set_fp
#define BIO_get_fp wolfSSL_BIO_get_fp
#define BIO_seek wolfSSL_BIO_seek
#define BIO_write_filename wolfSSL_BIO_write_filename
#define BIO_set_mem_eof_return wolfSSL_BIO_set_mem_eof_return
#define BIO_find_type wolfSSL_BIO_find_type
#define BIO_next wolfSSL_BIO_next
#define BIO_gets wolfSSL_BIO_gets
@ -51,7 +76,7 @@
#define BIO_printf wolfSSL_BIO_printf
#define BIO_dump wolfSSL_BIO_dump
/* BIO callback */
/* BIO info callback */
#define BIO_CB_FREE WOLFSSL_BIO_CB_FREE
#define BIO_CB_READ WOLFSSL_BIO_CB_READ
#define BIO_CB_WRITE WOLFSSL_BIO_CB_WRITE
@ -77,7 +102,7 @@
wolfSSL_BIO_set_flags((bio), WOLFSSL_BIO_FLAG_RETRY | WOLFSSL_BIO_FLAG_READ)
#define BIO_set_retry_write(bio)\
wolfSSL_BIO_set_flags((bio), WOLFSSL_BIO_FLAG_RETRY | WOLFSSL_BIO_FLAG_WRITE)
#define BIO_clear_retry_flags wolfSSL_BIO_clear_retry_flags
#define BIO_meth_new wolfSSL_BIO_meth_new
@ -93,16 +118,34 @@
/* BIO CTRL */
#define BIO_CTRL_RESET 1
#define BIO_CTRL_EOF 2
#define BIO_CTRL_INFO 3
#define BIO_CTRL_PUSH 6
#define BIO_CTRL_POP 7
#define BIO_CTRL_GET_CLOSE 8
#define BIO_CTRL_SET_CLOSE 9
#define BIO_CTRL_PENDING 10
#define BIO_CTRL_FLUSH 11
#define BIO_CTRL_DUP 12
#define BIO_CTRL_WPENDING 13
#define BIO_C_SET_BUF_MEM 114
#define BIO_C_GET_BUF_MEM_PTR 115
#define BIO_C_SET_FILE_PTR 106
#define BIO_C_GET_FILE_PTR 107
#define BIO_C_SET_FILENAME 108
#define BIO_C_SET_BUF_MEM 114
#define BIO_C_GET_BUF_MEM_PTR 115
#define BIO_C_FILE_SEEK 128
#define BIO_C_SET_BUF_MEM_EOF_RETURN 130
#define BIO_C_SET_WRITE_BUF_SIZE 136
#define BIO_C_MAKE_BIO_PAIR 138
#define BIO_CTRL_DGRAM_QUERY_MTU 40
#define BIO_NOCLOSE 0x00
#define BIO_CLOSE 0x01
#define BIO_FP_WRITE 0x04
#ifdef __cplusplus

View File

@ -849,30 +849,6 @@ enum {
#define SSL_CTX_set_tmp_dh wolfSSL_CTX_set_tmp_dh
#define BIO_new_fp wolfSSL_BIO_new_fp
#define BIO_new_file wolfSSL_BIO_new_file
#define BIO_new_fp wolfSSL_BIO_new_fp
#define BIO_ctrl wolfSSL_BIO_ctrl
#define BIO_ctrl_pending wolfSSL_BIO_ctrl_pending
#define BIO_wpending wolfSSL_BIO_wpending
#define BIO_get_mem_ptr wolfSSL_BIO_get_mem_ptr
#define BIO_int_ctrl wolfSSL_BIO_int_ctrl
#define BIO_reset wolfSSL_BIO_reset
#define BIO_s_file wolfSSL_BIO_s_file
#define BIO_s_bio wolfSSL_BIO_s_bio
#define BIO_s_socket wolfSSL_BIO_s_socket
#define BIO_set_fd wolfSSL_BIO_set_fd
#define BIO_ctrl_reset_read_request wolfSSL_BIO_ctrl_reset_read_request
#define BIO_set_write_buf_size wolfSSL_BIO_set_write_buf_size
#define BIO_make_bio_pair wolfSSL_BIO_make_bio_pair
#define BIO_set_fp wolfSSL_BIO_set_fp
#define BIO_get_fp wolfSSL_BIO_get_fp
#define BIO_seek wolfSSL_BIO_seek
#define BIO_write_filename wolfSSL_BIO_write_filename
#define BIO_set_mem_eof_return wolfSSL_BIO_set_mem_eof_return
#define TLSEXT_STATUSTYPE_ocsp 1
#define SSL_set_options wolfSSL_set_options
@ -908,22 +884,6 @@ enum {
#define SSL_get_tlsext_status_exts wolfSSL_get_tlsext_status_exts
#define BIO_C_SET_FILE_PTR 106
#define BIO_C_GET_FILE_PTR 107
#define BIO_C_SET_FILENAME 108
#define BIO_C_FILE_SEEK 128
#define BIO_C_SET_BUF_MEM_EOF_RETURN 130
#define BIO_C_SET_WRITE_BUF_SIZE 136
#define BIO_C_MAKE_BIO_PAIR 138
#define BIO_CTRL_RESET 1
#define BIO_CTRL_INFO 3
#define BIO_CTRL_FLUSH 11
#define BIO_CTRL_WPENDING 13
#define BIO_CLOSE 0x01
#define BIO_FP_WRITE 0x04
#define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS 11
#define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS 12
#define SSL_CTRL_SET_TMP_DH 3

View File

@ -422,13 +422,16 @@ typedef struct WOLFSSL_BUF_MEM {
} WOLFSSL_BUF_MEM;
/* custom method with user set callbacks */
typedef int (*wolfSSL_BIO_meth_write_cb)(WOLFSSL_BIO*, const char*, int);
typedef int (*wolfSSL_BIO_meth_read_cb)(WOLFSSL_BIO *, char *, int);
typedef int (*wolfSSL_BIO_meth_puts_cb)(WOLFSSL_BIO*, const char*);
typedef int (*wolfSSL_BIO_meth_gets_cb)(WOLFSSL_BIO*, char*, int);
typedef long (*wolfSSL_BIO_meth_get_ctrl_cb)(WOLFSSL_BIO*, int, long, void*);
typedef int (*wolfSSL_BIO_meth_create_cb)(WOLFSSL_BIO*);
typedef int (*wolfSSL_BIO_meth_destroy_cb)(WOLFSSL_BIO*);
typedef int (*wolfSSL_BIO_meth_write_cb)(WOLFSSL_BIO*, const char*, int);
typedef int (*wolfSSL_BIO_meth_read_cb)(WOLFSSL_BIO *, char *, int);
typedef int (*wolfSSL_BIO_meth_puts_cb)(WOLFSSL_BIO*, const char*);
typedef int (*wolfSSL_BIO_meth_gets_cb)(WOLFSSL_BIO*, char*, int);
typedef long (*wolfSSL_BIO_meth_ctrl_get_cb)(WOLFSSL_BIO*, int, long, void*);
typedef int (*wolfSSL_BIO_meth_create_cb)(WOLFSSL_BIO*);
typedef int (*wolfSSL_BIO_meth_destroy_cb)(WOLFSSL_BIO*);
typedef int wolfSSL_BIO_info_cb(WOLFSSL_BIO *, int, int);
typedef long (*wolfssl_BIO_meth_ctrl_info_cb)(WOLFSSL_BIO*, int, wolfSSL_BIO_info_cb*);
/* wolfSSL BIO_METHOD type */
#ifndef MAX_BIO_METHOD_NAME
@ -437,17 +440,14 @@ typedef int (*wolfSSL_BIO_meth_destroy_cb)(WOLFSSL_BIO*);
struct WOLFSSL_BIO_METHOD {
byte type; /* method type */
char name[MAX_BIO_METHOD_NAME];
wolfSSL_BIO_meth_write_cb writeCb;
wolfSSL_BIO_meth_read_cb readCb;
wolfSSL_BIO_meth_puts_cb putsCb;
wolfSSL_BIO_meth_gets_cb getsCb;
wolfSSL_BIO_meth_read_cb readCb;
wolfSSL_BIO_meth_write_cb writeCb;
wolfSSL_BIO_meth_ctrl_get_cb ctrlCb;
wolfSSL_BIO_meth_create_cb createCb;
wolfSSL_BIO_meth_destroy_cb freeCb;
wolfSSL_BIO_meth_create_cb createCb;
wolfSSL_BIO_meth_get_ctrl_cb ctrlCb;
wolfssl_BIO_meth_ctrl_info_cb ctrlInfoCb;
};
/* wolfSSL BIO type */
@ -1165,7 +1165,7 @@ WOLFSSL_API int wolfSSL_BIO_meth_set_write(WOLFSSL_BIO_METHOD*, wolfSSL_BIO_meth
WOLFSSL_API int wolfSSL_BIO_meth_set_read(WOLFSSL_BIO_METHOD*, wolfSSL_BIO_meth_read_cb);
WOLFSSL_API int wolfSSL_BIO_meth_set_puts(WOLFSSL_BIO_METHOD*, wolfSSL_BIO_meth_puts_cb);
WOLFSSL_API int wolfSSL_BIO_meth_set_gets(WOLFSSL_BIO_METHOD*, wolfSSL_BIO_meth_gets_cb);
WOLFSSL_API int wolfSSL_BIO_meth_set_ctrl(WOLFSSL_BIO_METHOD*, wolfSSL_BIO_meth_get_ctrl_cb);
WOLFSSL_API int wolfSSL_BIO_meth_set_ctrl(WOLFSSL_BIO_METHOD*, wolfSSL_BIO_meth_ctrl_get_cb);
WOLFSSL_API int wolfSSL_BIO_meth_set_create(WOLFSSL_BIO_METHOD*, wolfSSL_BIO_meth_create_cb);
WOLFSSL_API int wolfSSL_BIO_meth_set_destroy(WOLFSSL_BIO_METHOD*, wolfSSL_BIO_meth_destroy_cb);
WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_new_mem_buf(void* buf, int len);