*/
static int SSLParserTest01(void)
{
- int result = 1;
Flow f;
uint8_t tlsbuf[] = { 0x16, 0x03, 0x01 };
uint32_t tlslen = sizeof(tlsbuf);
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER | STREAM_EOF, tlsbuf, tlslen);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
- if (ssl_state->client_connp.content_type != 0x16) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ", 0x16,
- ssl_state->client_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.content_type != 0x16);
- if (ssl_state->client_connp.version != TLS_VERSION_10) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- TLS_VERSION_10, ssl_state->client_connp.version);
- result = 0;
- goto end;
- }
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ FAIL_IF(ssl_state->client_connp.version != TLS_VERSION_10);
+
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/** \test Send a get request in two chunks. */
static int SSLParserTest02(void)
{
- int result = 1;
Flow f;
uint8_t tlsbuf1[] = { 0x16 };
uint32_t tlslen1 = sizeof(tlsbuf1);
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, tlsbuf1, tlslen1);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, tlsbuf2, tlslen2);
- if (r != 0) {
- printf("toserver chunk 2 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
- if (ssl_state->client_connp.content_type != 0x16) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ", 0x16,
- ssl_state->client_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.content_type != 0x16);
- if (ssl_state->client_connp.version != TLS_VERSION_10) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- TLS_VERSION_10, ssl_state->client_connp.version);
- result = 0;
- goto end;
- }
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ FAIL_IF(ssl_state->client_connp.version != TLS_VERSION_10);
+
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/** \test Send a get request in three chunks. */
static int SSLParserTest03(void)
{
- int result = 1;
Flow f;
uint8_t tlsbuf1[] = { 0x16 };
uint32_t tlslen1 = sizeof(tlsbuf1);
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, tlsbuf1, tlslen1);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, tlsbuf2, tlslen2);
- if (r != 0) {
- printf("toserver chunk 2 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, tlsbuf3, tlslen3);
- if (r != 0) {
- printf("toserver chunk 3 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
- if (ssl_state->client_connp.content_type != 0x16) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ", 0x16,
- ssl_state->client_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.content_type != 0x16);
- if (ssl_state->client_connp.version != TLS_VERSION_10) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- TLS_VERSION_10, ssl_state->client_connp.version);
- result = 0;
- goto end;
- }
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ FAIL_IF(ssl_state->client_connp.version != TLS_VERSION_10);
+
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/** \test Send a get request in three chunks + more data. */
static int SSLParserTest04(void)
{
- int result = 1;
Flow f;
uint8_t tlsbuf1[] = { 0x16 };
uint32_t tlslen1 = sizeof(tlsbuf1);
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, tlsbuf1, tlslen1);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, tlsbuf2, tlslen2);
- if (r != 0) {
- printf("toserver chunk 2 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, tlsbuf3, tlslen3);
- if (r != 0) {
- printf("toserver chunk 3 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, tlsbuf4, tlslen4);
- if (r != 0) {
- printf("toserver chunk 4 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
- if (ssl_state->client_connp.content_type != 0x16) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ", 0x16,
- ssl_state->client_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.content_type != 0x16);
- if (ssl_state->client_connp.version != TLS_VERSION_10) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- TLS_VERSION_10, ssl_state->client_connp.version);
- result = 0;
- goto end;
- }
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ FAIL_IF(ssl_state->client_connp.version != TLS_VERSION_10);
+
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
#if 0
/** \test multimsg test */
static int SSLParserMultimsgTest01(void)
{
- int result = 1;
Flow f;
/* 3 msgs */
uint8_t tlsbuf1[] = {
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, tlsbuf1, tlslen1);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
- if (ssl_state->client_connp.content_type != 0x16) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ", 0x16,
- ssl_state->client_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.content_type != 0x16);
- if (ssl_state->client_connp.version != TLS_VERSION_10) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- TLS_VERSION_10, ssl_state->client_connp.version);
- result = 0;
- goto end;
- }
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ FAIL_IF(ssl_state->client_connp.version != TLS_VERSION_10);
+
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/** \test multimsg test server */
static int SSLParserMultimsgTest02(void)
{
- int result = 1;
Flow f;
/* 3 msgs */
uint8_t tlsbuf1[] = {
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOCLIENT, tlsbuf1, tlslen1);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
- if (ssl_state->server_connp.content_type != 0x16) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ", 0x16,
- ssl_state->server_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->server_connp.content_type != 0x16);
- if (ssl_state->server_connp.version != 0x0301) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ", 0x0301,
- ssl_state->server_connp.version);
- result = 0;
- goto end;
- }
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ FAIL_IF(ssl_state->server_connp.version != 0x0301);
+
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest07(void)
{
- int result = 1;
Flow f;
uint8_t tlsbuf[] = { 0x16, 0x03, 0x00, 0x00, 0x4c, 0x01,
0x00, 0x00, 0x48, 0x03, 0x00, 0x57, 0x04, 0x9f,
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, tlsbuf, tlslen);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
- if (ssl_state->client_connp.content_type != 0x16) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ", 0x17,
- ssl_state->client_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.content_type != 0x16);
- if (ssl_state->client_connp.version != SSL_VERSION_3) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- SSL_VERSION_3, ssl_state->client_connp.version);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.version != SSL_VERSION_3);
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
#if 0
*/
static int SSLParserTest09(void)
{
- int result = 1;
Flow f;
uint8_t buf1[] = {
0x16,
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf1, buf1_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf2, buf2_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
- if (ssl_state->client_connp.content_type != 0x16) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ", 0x17,
- ssl_state->client_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.content_type != 0x16);
- if (ssl_state->client_connp.version != SSL_VERSION_3) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- SSL_VERSION_3, ssl_state->client_connp.version);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.version != SSL_VERSION_3);
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest10(void)
{
- int result = 1;
Flow f;
uint8_t buf1[] = {
0x16, 0x03,
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf1, buf1_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf2, buf2_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
- if (ssl_state->client_connp.content_type != 0x16) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ", 0x17,
- ssl_state->client_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.content_type != 0x16);
- if (ssl_state->client_connp.version != SSL_VERSION_3) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- SSL_VERSION_3, ssl_state->client_connp.version);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.version != SSL_VERSION_3);
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest11(void)
{
- int result = 1;
Flow f;
uint8_t buf1[] = {
0x16, 0x03, 0x00, 0x00, 0x4c, 0x01,
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf1, buf1_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf2, buf2_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
- if (ssl_state->client_connp.content_type != 0x16) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ", 0x17,
- ssl_state->client_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.content_type != 0x16);
- if (ssl_state->client_connp.version != SSL_VERSION_3) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- SSL_VERSION_3, ssl_state->client_connp.version);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.version != SSL_VERSION_3);
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest12(void)
{
- int result = 1;
Flow f;
uint8_t buf1[] = {
0x16, 0x03, 0x00, 0x00, 0x4c, 0x01,
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf1, buf1_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf2, buf2_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf3, buf3_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
- if (ssl_state->client_connp.content_type != 0x16) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ", 0x17,
- ssl_state->client_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.content_type != 0x16);
- if (ssl_state->client_connp.version != SSL_VERSION_3) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- SSL_VERSION_3, ssl_state->client_connp.version);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.version != SSL_VERSION_3);
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest13(void)
{
- int result = 1;
Flow f;
uint8_t buf1[] = {
0x16, 0x03, 0x00, 0x00, 0x4c, 0x01,
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf1, buf1_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf2, buf2_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf3, buf3_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf4, buf4_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
- if (ssl_state->client_connp.content_type != 0x16) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ", 0x17,
- ssl_state->client_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.content_type != 0x16);
- if (ssl_state->client_connp.version != SSL_VERSION_3) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- SSL_VERSION_3, ssl_state->client_connp.version);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.version != SSL_VERSION_3);
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest14(void)
{
- int result = 1;
Flow f;
uint8_t buf1[] = {
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf1, buf1_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf2, buf2_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest15(void)
{
- int result = 1;
Flow f;
uint8_t buf1[] = {
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf1, buf1_len);
- if (r == 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
- FLOWLOCK_UNLOCK(&f);
-
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r == 0);
+
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest16(void)
{
- int result = 1;
Flow f;
uint8_t buf1[] = {
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf1, buf1_len);
- if (r == 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r == 0);
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest17(void)
{
- int result = 1;
Flow f;
uint8_t buf1[] = {
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf1, buf1_len);
- if (r == 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r == 0);
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest18(void)
{
- int result = 1;
Flow f;
uint8_t buf1[] = {
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf1, buf1_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf2, buf2_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest19(void)
{
- int result = 1;
Flow f;
uint8_t buf1[] = {
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf1, buf1_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest20(void)
{
- int result = 1;
Flow f;
uint8_t buf1[] = {
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf1, buf1_len);
- if (r == 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r == 0);
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest21(void)
{
- int result = 0;
Flow f;
uint8_t buf[] = {
0x80, 0x31, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00,
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER | STREAM_EOF, buf,
buf_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *app_state = f.alstate;
- if (app_state == NULL) {
- printf("no ssl state: ");
- goto end;
- }
+ FAIL_IF_NULL(app_state);
- if (app_state->client_connp.content_type != SSLV2_MT_CLIENT_HELLO) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ",
- SSLV2_MT_SERVER_HELLO, app_state->client_connp.content_type);
- goto end;
- }
+ FAIL_IF(app_state->client_connp.content_type != SSLV2_MT_CLIENT_HELLO);
- if (app_state->client_connp.version != SSL_VERSION_2) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- SSL_VERSION_2, app_state->client_connp.version);
- goto end;
- }
+ FAIL_IF(app_state->client_connp.version != SSL_VERSION_2);
- result = 1;
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest22(void)
{
- int result = 1;
Flow f;
uint8_t buf[] = {
0x80, 0x31, 0x04, 0x00, 0x01, 0x00,
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOCLIENT | STREAM_EOF, buf,
buf_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *app_state = f.alstate;
- if (app_state == NULL) {
- printf("no ssl state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(app_state);
- if (app_state->server_connp.content_type != SSLV2_MT_SERVER_HELLO) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ",
- SSLV2_MT_SERVER_HELLO, app_state->server_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(app_state->server_connp.content_type != SSLV2_MT_SERVER_HELLO);
- if (app_state->server_connp.version != SSL_VERSION_2) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- SSL_VERSION_2, app_state->server_connp.version);
- result = 0;
- goto end;
- }
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ FAIL_IF(app_state->server_connp.version != SSL_VERSION_2);
+
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest23(void)
{
- int result = 1;
Flow f;
uint8_t chello_buf[] = {
0x80, 0x67, 0x01, 0x03, 0x00, 0x00, 0x4e, 0x00,
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER | STREAM_START, chello_buf,
chello_buf_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *app_state = f.alstate;
- if (app_state == NULL) {
- printf("no ssl state: ");
- result = 0;
- goto end;
- }
-
- if (app_state->client_connp.content_type != SSLV2_MT_CLIENT_HELLO) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ",
- SSLV2_MT_CLIENT_HELLO, app_state->client_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(app_state);
- if (app_state->client_connp.version != SSL_VERSION_2) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- SSL_VERSION_2, app_state->client_connp.version);
- result = 0;
- goto end;
- }
+ FAIL_IF(app_state->client_connp.content_type != SSLV2_MT_CLIENT_HELLO);
- if ((app_state->flags & SSL_AL_FLAG_STATE_CLIENT_HELLO) == 0 ||
- (app_state->flags & SSL_AL_FLAG_SSL_CLIENT_HS) == 0 ||
- (app_state->flags & SSL_AL_FLAG_SSL_NO_SESSION_ID) == 0) {
- printf("flags not set\n");
- result = 0;
- goto end;
- }
+ FAIL_IF(app_state->client_connp.version != SSL_VERSION_2);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_STATE_CLIENT_HELLO) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_SSL_CLIENT_HS) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_SSL_NO_SESSION_ID) == 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOCLIENT, shello_buf,
shello_buf_len);
- if (r != 0) {
- printf("toclient chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
- if (app_state->server_connp.content_type != SSLV3_HANDSHAKE_PROTOCOL) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ",
- SSLV3_HANDSHAKE_PROTOCOL, app_state->server_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(app_state->server_connp.content_type != SSLV3_HANDSHAKE_PROTOCOL);
- if (app_state->server_connp.version != SSL_VERSION_3) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- SSL_VERSION_3, app_state->server_connp.version);
- result = 0;
- goto end;
- }
+ FAIL_IF(app_state->server_connp.version != SSL_VERSION_3);
- if ((app_state->flags & SSL_AL_FLAG_STATE_CLIENT_HELLO) == 0 ||
- (app_state->flags & SSL_AL_FLAG_SSL_CLIENT_HS) == 0 ||
- (app_state->flags & SSL_AL_FLAG_SSL_NO_SESSION_ID) == 0 ||
- (app_state->flags & SSL_AL_FLAG_STATE_SERVER_HELLO) == 0) {
- printf("flags not set\n");
- result = 0;
- goto end;
- }
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_STATE_CLIENT_HELLO) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_SSL_CLIENT_HS) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_SSL_NO_SESSION_ID) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_STATE_SERVER_HELLO) == 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, client_change_cipher_spec_buf,
client_change_cipher_spec_buf_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
/* with multiple records the client content type hold the type from the last
* record */
- if (app_state->client_connp.content_type != SSLV3_HANDSHAKE_PROTOCOL) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ",
- SSLV3_HANDSHAKE_PROTOCOL, app_state->client_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(app_state->client_connp.content_type != SSLV3_HANDSHAKE_PROTOCOL);
- if (app_state->client_connp.version != SSL_VERSION_3) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- SSL_VERSION_3, app_state->client_connp.version);
- result = 0;
- goto end;
- }
+ FAIL_IF(app_state->client_connp.version != SSL_VERSION_3);
- if ((app_state->flags & SSL_AL_FLAG_STATE_CLIENT_HELLO) == 0 ||
- (app_state->flags & SSL_AL_FLAG_SSL_CLIENT_HS) == 0 ||
- (app_state->flags & SSL_AL_FLAG_SSL_NO_SESSION_ID) == 0 ||
- (app_state->flags & SSL_AL_FLAG_STATE_SERVER_HELLO) == 0 ||
- (app_state->flags & SSL_AL_FLAG_STATE_CLIENT_KEYX) == 0 ||
- (app_state->flags & SSL_AL_FLAG_CLIENT_CHANGE_CIPHER_SPEC) == 0 ||
- (app_state->flags & SSL_AL_FLAG_CHANGE_CIPHER_SPEC) == 0) {
- printf("flags not set\n");
- result = 0;
- goto end;
- }
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_STATE_CLIENT_HELLO) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_SSL_CLIENT_HS) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_SSL_NO_SESSION_ID) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_STATE_SERVER_HELLO) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_STATE_CLIENT_KEYX) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_CLIENT_CHANGE_CIPHER_SPEC) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_CHANGE_CIPHER_SPEC) == 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOCLIENT, server_change_cipher_spec_buf,
server_change_cipher_spec_buf_len);
- if (r != 0) {
- printf("toclient chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
/* with multiple records the serve content type hold the type from the last
* record */
- if (app_state->server_connp.content_type != SSLV3_HANDSHAKE_PROTOCOL) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ",
- SSLV3_HANDSHAKE_PROTOCOL, app_state->server_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(app_state->server_connp.content_type != SSLV3_HANDSHAKE_PROTOCOL);
- if (app_state->server_connp.version != SSL_VERSION_3) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- SSL_VERSION_3, app_state->server_connp.version);
- result = 0;
- goto end;
- }
+ FAIL_IF(app_state->server_connp.version != SSL_VERSION_3);
- if ((app_state->flags & SSL_AL_FLAG_STATE_CLIENT_HELLO) == 0 ||
- (app_state->flags & SSL_AL_FLAG_SSL_CLIENT_HS) == 0 ||
- (app_state->flags & SSL_AL_FLAG_SSL_NO_SESSION_ID) == 0 ||
- (app_state->flags & SSL_AL_FLAG_STATE_SERVER_HELLO) == 0 ||
- (app_state->flags & SSL_AL_FLAG_STATE_CLIENT_KEYX) == 0 ||
- (app_state->flags & SSL_AL_FLAG_CLIENT_CHANGE_CIPHER_SPEC) == 0 ||
- (app_state->flags & SSL_AL_FLAG_CHANGE_CIPHER_SPEC) == 0 ||
- (app_state->flags & SSL_AL_FLAG_SERVER_CHANGE_CIPHER_SPEC) == 0 ||
- (app_state->flags & SSL_AL_FLAG_CHANGE_CIPHER_SPEC) == 0) {
- printf("flags not set\n");
- result = 0;
- goto end;
- }
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_STATE_CLIENT_HELLO) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_SSL_CLIENT_HS) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_SSL_NO_SESSION_ID) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_STATE_SERVER_HELLO) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_STATE_CLIENT_KEYX) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_CLIENT_CHANGE_CIPHER_SPEC) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_SERVER_CHANGE_CIPHER_SPEC) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_CHANGE_CIPHER_SPEC) == 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, toserver_app_data_buf,
toserver_app_data_buf_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
- if (app_state->client_connp.content_type != SSLV3_APPLICATION_PROTOCOL) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ",
- SSLV3_APPLICATION_PROTOCOL, app_state->client_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(app_state->client_connp.content_type != SSLV3_APPLICATION_PROTOCOL);
- if (app_state->client_connp.version != SSL_VERSION_3) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- SSL_VERSION_3, app_state->client_connp.version);
- result = 0;
- goto end;
- }
+ FAIL_IF(app_state->client_connp.version != SSL_VERSION_3);
- if ((app_state->flags & SSL_AL_FLAG_STATE_CLIENT_HELLO) == 0 ||
- (app_state->flags & SSL_AL_FLAG_SSL_CLIENT_HS) == 0 ||
- (app_state->flags & SSL_AL_FLAG_SSL_NO_SESSION_ID) == 0 ||
- (app_state->flags & SSL_AL_FLAG_STATE_SERVER_HELLO) == 0 ||
- (app_state->flags & SSL_AL_FLAG_STATE_CLIENT_KEYX) == 0 ||
- (app_state->flags & SSL_AL_FLAG_CLIENT_CHANGE_CIPHER_SPEC) == 0 ||
- (app_state->flags & SSL_AL_FLAG_CHANGE_CIPHER_SPEC) == 0 ||
- (app_state->flags & SSL_AL_FLAG_SERVER_CHANGE_CIPHER_SPEC) == 0 ||
- (app_state->flags & SSL_AL_FLAG_CHANGE_CIPHER_SPEC) == 0) {
- printf("flags not set\n");
- result = 0;
- goto end;
- }
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_STATE_CLIENT_HELLO) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_SSL_CLIENT_HS) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_SSL_NO_SESSION_ID) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_STATE_SERVER_HELLO) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_STATE_CLIENT_KEYX) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_CLIENT_CHANGE_CIPHER_SPEC) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_SERVER_CHANGE_CIPHER_SPEC) == 0);
+ FAIL_IF((app_state->flags & SSL_AL_FLAG_CHANGE_CIPHER_SPEC) == 0);
- if (!(f.flags & FLOW_NOPAYLOAD_INSPECTION)) {
- printf("The flags should be set\n");
- result = 0;
- goto end;
- }
+ FAIL_IF_NOT(f.flags & FLOW_NOPAYLOAD_INSPECTION);
-end:
if (alp_tctx != NULL)
AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest24(void)
{
- int result = 1;
Flow f;
uint8_t buf1[] = {
0x16, 0x03, 0x00, 0x00, 0x6f, 0x01, 0x00, 0x00,
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf1, buf1_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, buf2, buf2_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- result = 0;
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
- if (ssl_state->client_connp.content_type != 0x16) {
- printf("expected content_type %" PRIu8 ", got %" PRIu8 ": ", 0x16,
- ssl_state->client_connp.content_type);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.content_type != 0x16);
- if (ssl_state->client_connp.version != SSL_VERSION_3) {
- printf("expected version %04" PRIu16 ", got %04" PRIu16 ": ",
- SSL_VERSION_3, ssl_state->client_connp.version);
- result = 0;
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.version != SSL_VERSION_3);
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
/**
*/
static int SSLParserTest25(void)
{
- int result = 0;
Flow f;
uint8_t client_hello[] = {
0x16, 0x03, 0x01, 0x00, 0xd3, 0x01, 0x00, 0x00,
FLOWLOCK_WRLOCK(&f);
int r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER, client_hello, client_hello_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
SSLState *ssl_state = f.alstate;
- if (ssl_state == NULL) {
- printf("no tls state: ");
- goto end;
- }
+ FAIL_IF_NULL(ssl_state);
- if (ssl_state->client_connp.bytes_processed != 0 ||
- ssl_state->client_connp.hs_bytes_processed != 0)
- {
- printf("client_hello error\n");
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.bytes_processed != 0);
+ FAIL_IF(ssl_state->client_connp.hs_bytes_processed != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOCLIENT,
server_hello_certificate_done,
server_hello_certificate_done_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
- if (ssl_state->client_connp.bytes_processed != 0 ||
- ssl_state->client_connp.hs_bytes_processed != 0)
- {
- printf("server_hello_certificate_done error\n");
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.bytes_processed != 0);
+ FAIL_IF(ssl_state->client_connp.hs_bytes_processed != 0);
FLOWLOCK_WRLOCK(&f);
r = AppLayerParserParse(alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER,
client_key_exchange_cipher_enc_hs,
client_key_exchange_cipher_enc_hs_len);
- if (r != 0) {
- printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- FLOWLOCK_UNLOCK(&f);
- goto end;
- }
FLOWLOCK_UNLOCK(&f);
+ FAIL_IF(r != 0);
/* The reason hs_bytes_processed is 2 is because, the record
* immediately after the client key exchange is 2 bytes long,
* handshake, we immediately break and don't parse the pdu from
* where we left off, and leave the hs_bytes_processed var
* isn't reset. */
- if (ssl_state->client_connp.bytes_processed != 0 ||
- ssl_state->client_connp.hs_bytes_processed != 2)
- {
- printf("client_key_exchange_cipher_enc_hs error\n");
- goto end;
- }
+ FAIL_IF(ssl_state->client_connp.bytes_processed != 0);
+ FAIL_IF(ssl_state->client_connp.hs_bytes_processed != 2);
- result = 1;
-end:
- if (alp_tctx != NULL)
- AppLayerParserThreadCtxFree(alp_tctx);
+ AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
- return result;
+
+ PASS;
}
#endif /* UNITTESTS */