mirror of https://github.com/wolfSSL/wolfssl.git
Merge branch 'master' into ti
commit
00abb2d90e
112
tests/api.c
112
tests/api.c
|
@ -24,6 +24,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cyassl/ctaocrypt/settings.h>
|
#include <cyassl/ctaocrypt/settings.h>
|
||||||
|
#include <cyassl/error-ssl.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <cyassl/ssl.h>
|
#include <cyassl/ssl.h>
|
||||||
|
@ -252,7 +253,8 @@ static void use_SNI_at_ctx(CYASSL_CTX* ctx)
|
||||||
byte type = CYASSL_SNI_HOST_NAME;
|
byte type = CYASSL_SNI_HOST_NAME;
|
||||||
char name[] = "www.yassl.com";
|
char name[] = "www.yassl.com";
|
||||||
|
|
||||||
AssertIntEQ(1, CyaSSL_CTX_UseSNI(ctx, type, (void *) name, XSTRLEN(name)));
|
AssertIntEQ(SSL_SUCCESS,
|
||||||
|
CyaSSL_CTX_UseSNI(ctx, type, (void *) name, XSTRLEN(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void use_SNI_at_ssl(CYASSL* ssl)
|
static void use_SNI_at_ssl(CYASSL* ssl)
|
||||||
|
@ -260,7 +262,8 @@ static void use_SNI_at_ssl(CYASSL* ssl)
|
||||||
byte type = CYASSL_SNI_HOST_NAME;
|
byte type = CYASSL_SNI_HOST_NAME;
|
||||||
char name[] = "www.yassl.com";
|
char name[] = "www.yassl.com";
|
||||||
|
|
||||||
AssertIntEQ(1, CyaSSL_UseSNI(ssl, type, (void *) name, XSTRLEN(name)));
|
AssertIntEQ(SSL_SUCCESS,
|
||||||
|
CyaSSL_UseSNI(ssl, type, (void *) name, XSTRLEN(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void different_SNI_at_ssl(CYASSL* ssl)
|
static void different_SNI_at_ssl(CYASSL* ssl)
|
||||||
|
@ -268,7 +271,8 @@ static void different_SNI_at_ssl(CYASSL* ssl)
|
||||||
byte type = CYASSL_SNI_HOST_NAME;
|
byte type = CYASSL_SNI_HOST_NAME;
|
||||||
char name[] = "ww2.yassl.com";
|
char name[] = "ww2.yassl.com";
|
||||||
|
|
||||||
AssertIntEQ(1, CyaSSL_UseSNI(ssl, type, (void *) name, XSTRLEN(name)));
|
AssertIntEQ(SSL_SUCCESS,
|
||||||
|
CyaSSL_UseSNI(ssl, type, (void *) name, XSTRLEN(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void use_SNI_WITH_CONTINUE_at_ssl(CYASSL* ssl)
|
static void use_SNI_WITH_CONTINUE_at_ssl(CYASSL* ssl)
|
||||||
|
@ -291,14 +295,12 @@ static void use_SNI_WITH_FAKE_ANSWER_at_ssl(CYASSL* ssl)
|
||||||
|
|
||||||
static void verify_SNI_abort_on_client(CYASSL* ssl)
|
static void verify_SNI_abort_on_client(CYASSL* ssl)
|
||||||
{
|
{
|
||||||
/* FATAL_ERROR */
|
AssertIntEQ(FATAL_ERROR, CyaSSL_get_error(ssl, 0));
|
||||||
AssertIntEQ(-313, CyaSSL_get_error(ssl, 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify_SNI_abort_on_server(CYASSL* ssl)
|
static void verify_SNI_abort_on_server(CYASSL* ssl)
|
||||||
{
|
{
|
||||||
/* UNKNOWN_SNI_HOST_NAME_E */
|
AssertIntEQ(UNKNOWN_SNI_HOST_NAME_E, CyaSSL_get_error(ssl, 0));
|
||||||
AssertIntEQ(-381, CyaSSL_get_error(ssl, 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify_SNI_no_matching(CYASSL* ssl)
|
static void verify_SNI_no_matching(CYASSL* ssl)
|
||||||
|
@ -417,20 +419,20 @@ static void test_CyaSSL_SNI_GetFromBuffer(void)
|
||||||
AssertIntEQ(0, CyaSSL_SNI_GetFromBuffer(buffer2, sizeof(buffer2),
|
AssertIntEQ(0, CyaSSL_SNI_GetFromBuffer(buffer2, sizeof(buffer2),
|
||||||
1, result, &length));
|
1, result, &length));
|
||||||
|
|
||||||
AssertIntEQ(-328, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer), 0,
|
AssertIntEQ(BUFFER_ERROR, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer),
|
||||||
result, &length));
|
0, result, &length));
|
||||||
buffer[0] = 0x16;
|
buffer[0] = 0x16;
|
||||||
|
|
||||||
AssertIntEQ(-328, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer), 0,
|
AssertIntEQ(BUFFER_ERROR, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer),
|
||||||
result, &length));
|
0, result, &length));
|
||||||
buffer[1] = 0x03;
|
buffer[1] = 0x03;
|
||||||
|
|
||||||
AssertIntEQ(-328, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer), 0,
|
AssertIntEQ(BUFFER_ERROR, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer),
|
||||||
result, &length));
|
0, result, &length));
|
||||||
buffer[2] = 0x03;
|
buffer[2] = 0x03;
|
||||||
|
|
||||||
AssertIntEQ(-310, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer), 0,
|
AssertIntEQ(INCOMPLETE_DATA, CyaSSL_SNI_GetFromBuffer(buffer,
|
||||||
result, &length));
|
sizeof(buffer), 0, result, &length));
|
||||||
buffer[4] = 0x64;
|
buffer[4] = 0x64;
|
||||||
|
|
||||||
AssertIntEQ(SSL_SUCCESS, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer),
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer),
|
||||||
|
@ -458,16 +460,24 @@ void test_CyaSSL_UseSNI(void)
|
||||||
AssertNotNull(ssl);
|
AssertNotNull(ssl);
|
||||||
|
|
||||||
/* error cases */
|
/* error cases */
|
||||||
AssertIntNE(1, CyaSSL_CTX_UseSNI(NULL, 0, (void *) "ctx", XSTRLEN("ctx")));
|
AssertIntNE(SSL_SUCCESS,
|
||||||
AssertIntNE(1, CyaSSL_UseSNI( NULL, 0, (void *) "ssl", XSTRLEN("ssl")));
|
CyaSSL_CTX_UseSNI(NULL, 0, (void *) "ctx", XSTRLEN("ctx")));
|
||||||
AssertIntNE(1, CyaSSL_CTX_UseSNI(ctx, -1, (void *) "ctx", XSTRLEN("ctx")));
|
AssertIntNE(SSL_SUCCESS,
|
||||||
AssertIntNE(1, CyaSSL_UseSNI( ssl, -1, (void *) "ssl", XSTRLEN("ssl")));
|
CyaSSL_UseSNI( NULL, 0, (void *) "ssl", XSTRLEN("ssl")));
|
||||||
AssertIntNE(1, CyaSSL_CTX_UseSNI(ctx, 0, (void *) NULL, XSTRLEN("ctx")));
|
AssertIntNE(SSL_SUCCESS,
|
||||||
AssertIntNE(1, CyaSSL_UseSNI( ssl, 0, (void *) NULL, XSTRLEN("ssl")));
|
CyaSSL_CTX_UseSNI(ctx, -1, (void *) "ctx", XSTRLEN("ctx")));
|
||||||
|
AssertIntNE(SSL_SUCCESS,
|
||||||
|
CyaSSL_UseSNI( ssl, -1, (void *) "ssl", XSTRLEN("ssl")));
|
||||||
|
AssertIntNE(SSL_SUCCESS,
|
||||||
|
CyaSSL_CTX_UseSNI(ctx, 0, (void *) NULL, XSTRLEN("ctx")));
|
||||||
|
AssertIntNE(SSL_SUCCESS,
|
||||||
|
CyaSSL_UseSNI( ssl, 0, (void *) NULL, XSTRLEN("ssl")));
|
||||||
|
|
||||||
/* success case */
|
/* success case */
|
||||||
AssertIntEQ(1, CyaSSL_CTX_UseSNI(ctx, 0, (void *) "ctx", XSTRLEN("ctx")));
|
AssertIntEQ(SSL_SUCCESS,
|
||||||
AssertIntEQ(1, CyaSSL_UseSNI( ssl, 0, (void *) "ssl", XSTRLEN("ssl")));
|
CyaSSL_CTX_UseSNI(ctx, 0, (void *) "ctx", XSTRLEN("ctx")));
|
||||||
|
AssertIntEQ(SSL_SUCCESS,
|
||||||
|
CyaSSL_UseSNI( ssl, 0, (void *) "ssl", XSTRLEN("ssl")));
|
||||||
|
|
||||||
CyaSSL_free(ssl);
|
CyaSSL_free(ssl);
|
||||||
CyaSSL_CTX_free(ctx);
|
CyaSSL_CTX_free(ctx);
|
||||||
|
@ -523,24 +533,24 @@ static void test_CyaSSL_UseMaxFragment(void)
|
||||||
AssertNotNull(ssl);
|
AssertNotNull(ssl);
|
||||||
|
|
||||||
/* error cases */
|
/* error cases */
|
||||||
AssertIntNE(1, CyaSSL_CTX_UseMaxFragment(NULL, CYASSL_MFL_2_9));
|
AssertIntNE(SSL_SUCCESS, CyaSSL_CTX_UseMaxFragment(NULL, CYASSL_MFL_2_9));
|
||||||
AssertIntNE(1, CyaSSL_UseMaxFragment( NULL, CYASSL_MFL_2_9));
|
AssertIntNE(SSL_SUCCESS, CyaSSL_UseMaxFragment( NULL, CYASSL_MFL_2_9));
|
||||||
AssertIntNE(1, CyaSSL_CTX_UseMaxFragment(ctx, 0));
|
AssertIntNE(SSL_SUCCESS, CyaSSL_CTX_UseMaxFragment(ctx, 0));
|
||||||
AssertIntNE(1, CyaSSL_CTX_UseMaxFragment(ctx, 6));
|
AssertIntNE(SSL_SUCCESS, CyaSSL_CTX_UseMaxFragment(ctx, 6));
|
||||||
AssertIntNE(1, CyaSSL_UseMaxFragment(ssl, 0));
|
AssertIntNE(SSL_SUCCESS, CyaSSL_UseMaxFragment(ssl, 0));
|
||||||
AssertIntNE(1, CyaSSL_UseMaxFragment(ssl, 6));
|
AssertIntNE(SSL_SUCCESS, CyaSSL_UseMaxFragment(ssl, 6));
|
||||||
|
|
||||||
/* success case */
|
/* success case */
|
||||||
AssertIntEQ(1, CyaSSL_CTX_UseMaxFragment(ctx, CYASSL_MFL_2_9));
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_CTX_UseMaxFragment(ctx, CYASSL_MFL_2_9));
|
||||||
AssertIntEQ(1, CyaSSL_CTX_UseMaxFragment(ctx, CYASSL_MFL_2_10));
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_CTX_UseMaxFragment(ctx, CYASSL_MFL_2_10));
|
||||||
AssertIntEQ(1, CyaSSL_CTX_UseMaxFragment(ctx, CYASSL_MFL_2_11));
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_CTX_UseMaxFragment(ctx, CYASSL_MFL_2_11));
|
||||||
AssertIntEQ(1, CyaSSL_CTX_UseMaxFragment(ctx, CYASSL_MFL_2_12));
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_CTX_UseMaxFragment(ctx, CYASSL_MFL_2_12));
|
||||||
AssertIntEQ(1, CyaSSL_CTX_UseMaxFragment(ctx, CYASSL_MFL_2_13));
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_CTX_UseMaxFragment(ctx, CYASSL_MFL_2_13));
|
||||||
AssertIntEQ(1, CyaSSL_UseMaxFragment( ssl, CYASSL_MFL_2_9));
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_UseMaxFragment( ssl, CYASSL_MFL_2_9));
|
||||||
AssertIntEQ(1, CyaSSL_UseMaxFragment( ssl, CYASSL_MFL_2_10));
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_UseMaxFragment( ssl, CYASSL_MFL_2_10));
|
||||||
AssertIntEQ(1, CyaSSL_UseMaxFragment( ssl, CYASSL_MFL_2_11));
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_UseMaxFragment( ssl, CYASSL_MFL_2_11));
|
||||||
AssertIntEQ(1, CyaSSL_UseMaxFragment( ssl, CYASSL_MFL_2_12));
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_UseMaxFragment( ssl, CYASSL_MFL_2_12));
|
||||||
AssertIntEQ(1, CyaSSL_UseMaxFragment( ssl, CYASSL_MFL_2_13));
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_UseMaxFragment( ssl, CYASSL_MFL_2_13));
|
||||||
|
|
||||||
CyaSSL_free(ssl);
|
CyaSSL_free(ssl);
|
||||||
CyaSSL_CTX_free(ctx);
|
CyaSSL_CTX_free(ctx);
|
||||||
|
@ -557,12 +567,12 @@ static void test_CyaSSL_UseTruncatedHMAC(void)
|
||||||
AssertNotNull(ssl);
|
AssertNotNull(ssl);
|
||||||
|
|
||||||
/* error cases */
|
/* error cases */
|
||||||
AssertIntNE(1, CyaSSL_CTX_UseTruncatedHMAC(NULL));
|
AssertIntNE(SSL_SUCCESS, CyaSSL_CTX_UseTruncatedHMAC(NULL));
|
||||||
AssertIntNE(1, CyaSSL_UseTruncatedHMAC(NULL));
|
AssertIntNE(SSL_SUCCESS, CyaSSL_UseTruncatedHMAC(NULL));
|
||||||
|
|
||||||
/* success case */
|
/* success case */
|
||||||
AssertIntEQ(1, CyaSSL_CTX_UseTruncatedHMAC(ctx));
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_CTX_UseTruncatedHMAC(ctx));
|
||||||
AssertIntEQ(1, CyaSSL_UseTruncatedHMAC(ssl));
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_UseTruncatedHMAC(ssl));
|
||||||
|
|
||||||
CyaSSL_free(ssl);
|
CyaSSL_free(ssl);
|
||||||
CyaSSL_CTX_free(ctx);
|
CyaSSL_CTX_free(ctx);
|
||||||
|
@ -580,15 +590,19 @@ static void test_CyaSSL_UseSupportedCurve(void)
|
||||||
|
|
||||||
#ifndef NO_CYASSL_CLIENT
|
#ifndef NO_CYASSL_CLIENT
|
||||||
/* error cases */
|
/* error cases */
|
||||||
AssertIntNE(1, CyaSSL_CTX_UseSupportedCurve(NULL, CYASSL_ECC_SECP160R1));
|
AssertIntNE(SSL_SUCCESS,
|
||||||
AssertIntNE(1, CyaSSL_CTX_UseSupportedCurve(ctx, 0));
|
CyaSSL_CTX_UseSupportedCurve(NULL, CYASSL_ECC_SECP160R1));
|
||||||
|
AssertIntNE(SSL_SUCCESS, CyaSSL_CTX_UseSupportedCurve(ctx, 0));
|
||||||
|
|
||||||
AssertIntNE(1, CyaSSL_UseSupportedCurve(NULL, CYASSL_ECC_SECP160R1));
|
AssertIntNE(SSL_SUCCESS,
|
||||||
AssertIntNE(1, CyaSSL_UseSupportedCurve(ssl, 0));
|
CyaSSL_UseSupportedCurve(NULL, CYASSL_ECC_SECP160R1));
|
||||||
|
AssertIntNE(SSL_SUCCESS, CyaSSL_UseSupportedCurve(ssl, 0));
|
||||||
|
|
||||||
/* success case */
|
/* success case */
|
||||||
AssertIntEQ(1, CyaSSL_CTX_UseSupportedCurve(ctx, CYASSL_ECC_SECP160R1));
|
AssertIntEQ(SSL_SUCCESS,
|
||||||
AssertIntEQ(1, CyaSSL_UseSupportedCurve(ssl, CYASSL_ECC_SECP160R1));
|
CyaSSL_CTX_UseSupportedCurve(ctx, CYASSL_ECC_SECP160R1));
|
||||||
|
AssertIntEQ(SSL_SUCCESS,
|
||||||
|
CyaSSL_UseSupportedCurve(ssl, CYASSL_ECC_SECP160R1));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CyaSSL_free(ssl);
|
CyaSSL_free(ssl);
|
||||||
|
|
Loading…
Reference in New Issue