/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ /* This program and the accompanying materials are made available under */ /* the terms of the MIT License which is available at */ /* https://opensource.org/licenses/MIT. */ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ #include "tx_api.h" #include "nx_api.h" #include "nx_tcp.h" #include "nx_secure_tls_api.h" #include "tls_test_utility.h" extern void test_control_return(UINT status); #if !defined(NX_SECURE_TLS_CLIENT_DISABLED) && !defined(NX_SECURE_TLS_SERVER_DISABLED) && !defined(NX_SECURE_DISABLE_X509) #define __LINUX__ #define LOOP 1000 /* Define the ThreadX and NetX object control blocks... */ static TX_THREAD ntest_0; static TX_THREAD ntest_1; static TX_THREAD ntest_2; static NX_PACKET_POOL pool_0; static NX_PACKET_POOL pool_1; static NX_IP ip_0; static NX_IP ip_1; static NX_TCP_SOCKET client_socket; static NX_TCP_SOCKET server_socket; static NX_SECURE_TLS_SESSION client_tls_session; static NX_SECURE_TLS_SESSION server_tls_session; static NX_SECURE_X509_CERT certificate; static NX_SECURE_X509_CERT server_certificate; static NX_SECURE_X509_CERT ica_certificate; static NX_SECURE_X509_CERT remote_certificate, remote_issuer; static NX_SECURE_X509_CERT trusted_certificate; UCHAR remote_cert_buffer[2000]; UCHAR remote_issuer_buffer[2000]; UCHAR server_packet_buffer[4000]; UCHAR client_packet_buffer[4000]; CHAR server_crypto_metadata[16000]; CHAR client_crypto_metadata[16000]; /* Test PKI (3-level). */ #include "test_ca_cert.c" #define ca_cert_der test_ca_cert_der #define ca_cert_der_len test_ca_cert_der_len /* Cryptographic routines. */ extern const NX_SECURE_TLS_CRYPTO nx_crypto_tls_ciphers; static unsigned char ica_cert_der[] = { 0x30, 0x82, 0x03, 0xdf, 0x30, 0x82, 0x02, 0xc7, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x7a, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x43, 0x41, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x09, 0x53, 0x61, 0x6e, 0x20, 0x44, 0x69, 0x65, 0x67, 0x6f, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0d, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x20, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x0b, 0x4e, 0x65, 0x74, 0x58, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x13, 0x4e, 0x65, 0x74, 0x58, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x37, 0x30, 0x33, 0x33, 0x31, 0x32, 0x31, 0x30, 0x30, 0x30, 0x32, 0x5a, 0x17, 0x0d, 0x32, 0x37, 0x30, 0x33, 0x32, 0x39, 0x32, 0x31, 0x30, 0x30, 0x30, 0x32, 0x5a, 0x30, 0x6f, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x43, 0x41, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0d, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x20, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x09, 0x4e, 0x58, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x31, 0x27, 0x30, 0x25, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4e, 0x58, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x20, 0x43, 0x41, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xa7, 0xa4, 0xd9, 0xd0, 0x19, 0x84, 0x4e, 0xab, 0x8e, 0x08, 0xad, 0x30, 0xe6, 0x79, 0x46, 0x46, 0xe2, 0xd3, 0x13, 0xc1, 0x69, 0xa9, 0x4a, 0xc9, 0xc8, 0x95, 0x54, 0xa8, 0x76, 0x41, 0x63, 0x10, 0xc4, 0xe4, 0xfd, 0x08, 0x69, 0x7f, 0x89, 0x79, 0x82, 0x62, 0xd7, 0x90, 0x73, 0x55, 0x06, 0x0d, 0x62, 0xec, 0x1b, 0x2d, 0xaf, 0xf2, 0x39, 0x14, 0x47, 0x5b, 0x9d, 0x7a, 0xd2, 0xe3, 0xf9, 0xae, 0x37, 0x49, 0xd0, 0xb8, 0x01, 0xf2, 0x1a, 0x84, 0x9a, 0x50, 0x37, 0x4d, 0xd6, 0xed, 0x7c, 0x44, 0xef, 0xd1, 0xb8, 0x05,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x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x2c, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42, 0x01, 0x0d, 0x04, 0x1f, 0x16, 0x1d, 0x4f, 0x70, 0x65, 0x6e, 0x53, 0x53, 0x4c, 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x8e, 0x6a, 0xb0, 0xfe, 0x49, 0xc5, 0x6a, 0x96, 0x9e, 0xba, 0xb8, 0xb6, 0x58, 0xfc, 0x52, 0x7f, 0xab, 0x51, 0xf2, 0x3a, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x1b, 0x8d, 0x06, 0xd9, 0x6b, 0xad, 0xee, 0x82, 0x24, 0x26, 0x55, 0x9a, 0x1b, 0x03, 0x44, 0x92, 0x0a, 0x06, 0x92, 0x48, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x18, 0x5a, 0x50, 0xb6, 0x44, 0xba, 0x68, 0xac, 0x7f, 0x06, 0x0f, 0xbc, 0x1a, 0x58, 0x59, 0xf1, 0xf1, 0xe3, 0xb8, 0x0d, 0x74, 0xdd, 0x74, 0x26, 0x6a, 0xea, 0xfc, 0xfe, 0x06, 0x53, 0xe9, 0x80, 0xe3, 0x07, 0x83, 0x8a, 0xc9, 0xc9, 0xc0, 0x93, 0xb4, 0xc2, 0x59, 0x71, 0xa7, 0x58, 0xac, 0x32, 0x0f, 0x32, 0x9c, 0x5b, 0x4d, 0x53, 0x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x4f, 0x2e, 0x4c, 0x5c, 0xed, 0x99, 0x26, 0xe8, 0xf1, 0x72, 0x5e, 0x9b, 0x86, 0x73, 0xda, 0xfb }; static unsigned int ica_cert_der_len = 995; /* Basic server certificate, no policies. Common Name: "NX Secure Device Certificate" */ static unsigned char test_server_cert_der[] = { 0x30, 0x82, 0x03, 0xdb, 0x30, 0x82, 0x02, 0xc3, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x10, 0x00, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x6f, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x43, 0x41, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0d, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x20, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x09, 0x4e, 0x58, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x31, 0x27, 0x30, 0x25, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4e, 0x58, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x37, 0x30, 0x33, 0x33, 0x31, 0x32, 0x31, 0x30, 0x39, 0x30, 0x39, 0x5a, 0x17, 0x0d, 0x32, 0x37, 0x30, 0x33, 0x32, 0x39, 0x32, 0x31, 0x30, 0x39, 0x30, 0x39, 0x5a, 0x30, 0x75, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x43, 0x61, 0x6c, 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0d, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x20, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x09, 0x4e, 0x58, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x31, 0x25, 0x30, 0x23, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1c, 0x4e, 0x58, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xc4, 0x7e, 0xd4, 0xe3, 0xa2, 0x0c, 0x78, 0xe6, 0x0f, 0xa5, 0x3c, 0x01, 0x9b, 0x01, 0xdf, 0x96, 0xf6, 0x8e, 0xa0, 0x80, 0x4b, 0xb1, 0xc7, 0x20, 0x3c, 0xca, 0x81, 0x9a, 0xce, 0x08, 0x5f, 0x70, 0x99, 0x8d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0x4b, 0x95, 0xf3, 0x0e, 0x0f, 0x10, 0x60, 0x74, 0x54, 0xda, 0xb0, 0x91, 0x0a, 0x10, 0x07, 0x19, 0x30, 0x71, 0x34, 0x5f, 0xe2, 0x1c, 0x08, 0x77, 0x2e, 0xbc, 0xa3, 0x13, 0x18, 0x22, 0x5e, 0xf9, 0xe0, 0x67, 0x8e, 0xbc, 0xc0, 0x7d, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x7b, 0x30, 0x79, 0x30, 0x09, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x2c, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42, 0x01, 0x0d, 0x04, 0x1f, 0x16, 0x1d, 0x4f, 0x70, 0x65, 0x6e, 0x53, 0x53, 0x4c, 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x5c, 0xac, 0x85, 0x36, 0xd2, 0x6c, 0x5b, 0x71, 0xd0, 0x7e, 0x78, 0xe6, 0x4b, 0xc7, 0x9e, 0x0b, 0x06, 0xaa, 0x70, 0x8b, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x8e, 0x6a, 0xb0, 0xfe, 0x49, 0xc5, 0x6a, 0x96, 0x9e, 0xba, 0xb8, 0xb6, 0x58, 0xfc, 0x52, 0x7f, 0xab, 0x51, 0xf2, 0x3a, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x58, 0x39, 0x3d, 0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 0xf6, 0x8f, 0xba, 0x08, 0x1a, 0x8a, 0x13, 0x2c, 0x2d, 0x38, 0xce, 0xfe, 0xa5, 0x59, 0xc5, 0xea, 0x3a, 0x07, 0x8b, 0xf9, 0x8d, 0x33, 0x25, 0xc0, 0x4e, 0x75, 0x51, 0xfc, 0xd1, 0x12, 0xec, 0x85, 0xb1, 0xb5, 0xf4, 0xc2, 0xb8, 0x05, 0x3c, 0x00, 0x4a, 0x1b, 0xab, 0xb2, 0xab, 0x69, 0x58, 0x33, 0x93, 0xf8, 0x47, 0x12, 0x75, 0xc2, 0x3a, 0x82, 0xe1, 0x2d, 0x95, 0xa9, 0x9c, 0xb9, 0xe3, 0x3d, 0x29, 0x93, 0x65, 0xa1, 0x79, 0xee }; static unsigned int test_server_cert_der_len = 991; static unsigned char test_server_cert_key_der[] = { 0x30, 0x82, 0x04, 0xa3, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xc4, 0x7e, 0xd4, 0xe3, 0xa2, 0x0c, 0x78, 0xe6, 0x0f, 0xa5, 0x3c, 0x01, 0x9b, 0x01, 0xdf, 0x96, 0xf6, 0x8e, 0xa0, 0x80, 0x4b, 0xb1, 0xc7, 0x20, 0x3c, 0xca, 0x81, 0x9a, 0xce, 0x08, 0x5f, 0x70, 0x99, 0x8d, 0x44, 0x46, 0xbc, 0xf5, 0xb1, 0x80, 0x3c, 0xe0, 0xc9, 0x09, 0x11, 0xb4, 0x07, 0x89, 0x5f, 0x06, 0x89, 0xec, 0xbe, 0xf8, 0x29, 0x48, 0x40, 0x55, 0x60, 0x1d, 0x59, 0xb3, 0x7b, 0x84, 0x77, 0xc3, 0x34, 0xf4, 0xd3, 0x51, 0x3e, 0x2f, 0x9d, 0x10, 0xbb, 0xaf, 0x47, 0xb2, 0xc5, 0x78, 0x8a, 0x85, 0xea, 0xbb, 0xe5, 0xb3, 0x8a, 0x25, 0xaf, 0xd6, 0xb9, 0xb3, 0x47, 0xf3, 0x5f, 0x7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e1, 0x8f, 0x86, 0x34, 0x8a, 0xb4, 0x85, 0x08, 0x7a, 0x27, 0x43, 0x76, 0xf2, 0x3f, 0x39, 0x03, 0x1c, 0xdf, 0x4e, 0x4d, 0xf1, 0xef, 0xa9, 0x02, 0x81, 0x80, 0x5c, 0x2d, 0x0a, 0x0d, 0x51, 0x48, 0xcd, 0x38, 0x64, 0xf3, 0x7a, 0xfd, 0x1a, 0x19, 0x42, 0x28, 0x68, 0xca, 0xda, 0x98, 0x2b, 0x46, 0xbb, 0x85, 0xdd, 0x55, 0x3d, 0xd8, 0x61, 0x7d, 0xc4, 0x90, 0x9d, 0xee, 0xe8, 0xb2, 0xc8, 0x85, 0xc9, 0x43, 0x14, 0xf7, 0x74, 0x01, 0xeb, 0x03, 0x0b, 0x7f, 0x24, 0x13, 0x99, 0x04, 0xff, 0x95, 0xf0, 0x08, 0x45, 0x76, 0xce, 0x00, 0xe8, 0xc5, 0x76, 0x34, 0xf9, 0x91, 0xa0, 0xc8, 0x83, 0xa9, 0x78, 0x87, 0x1d, 0xac, 0xc9, 0x66, 0x4d, 0x90, 0x46, 0x4e, 0x99, 0xef, 0xdd, 0x16, 0xa9, 0xc9, 0x43, 0xd6, 0xbf, 0xa1, 0x6b, 0x33, 0x8b, 0x68, 0x1d, 0x25, 0xd2, 0x95, 0x0d, 0xd0, 0x4d, 0xe2, 0xd9, 0x1e, 0x9c, 0xe0, 0x4a, 0xad, 0x1e, 0xda, 0xfd, 0x0d, 0xc1, 0xf7, 0x9c, 0xa7, 0x55, 0xb1, 0x70, 0xad, 0x33, 0x15, 0x1e, 0xe5, 0xc0, 0x44, 0x78, 0xd1 }; static unsigned int test_server_cert_key_der_len = 1191; /* Policy certificate with key usage extensions. Common Name: "certificate_with_policies" */ static unsigned char test_device_cert_der[] = { 0x30, 0x82, 0x04, 0x14, 0x30, 0x82, 0x02, 0xfc, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x10, 0x02, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x6f, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x43, 0x41, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0d, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x20, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x09, 0x4e, 0x58, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x31, 0x27, 0x30, 0x25, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4e, 0x58, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x37, 0x31, 0x31, 0x33, 0x30, 0x30, 0x30, 0x31, 0x36, 0x34, 0x30, 0x5a, 0x17, 0x0d, 0x32, 0x37, 0x31, 0x31, 0x32, 0x38, 0x30, 0x30, 0x31, 0x36, 0x34, 0x30, 0x5a, 0x30, 0x74, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x43, 0x61, 0x6c, 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0d, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x20, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x0b, 0x4e, 0x65, 0x74, 0x58, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x31, 0x22, 0x30, 0x20, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x19, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xda, 0x31, 0xa1, 0xae, 0x67, 0xaf, 0x9c, 0x50, 0x5f, 0x1b, 0xd4, 0xce, 0x6d, 0x3c, 0x3c, 0xa6, 0xd2, 0x41, 0x86, 0x7a, 0xed, 0x81, 0x65, 0x82, 0x3f, 0xa1, 0x54, 0x89, 0xba, 0x4d, 0x7a, 0x9e, 0xab, 0x99, 0x24, 0x23, 0x19, 0xf8, 0xb4, 0x83, 0xe1, 0xb0, 0x08, 0x7b, 0x6f, 0x02, 0x7d, 0x80, 0x2e, 0xd9, 0xb5, 0xe1, 0xb2, 0x13, 0x3b, 0x23, 0x32, 0xc8, 0x0b, 0xad, 0xc4, 0xac, 0x95, 0xa6, 0x82, 0x0e, 0xec, 0x62, 0xfa, 0x7f, 0xf5, 0x2c, 0xc7, 0xe6, 0x4e, 0x28, 0x30, 0xb6, 0x66, 0x5d, 0xa8, 0x28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 0xb1, 0x30, 0x09, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x11, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42, 0x01, 0x01, 0x04, 0x04, 0x03, 0x02, 0x06, 0x40, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x04, 0x04, 0x03, 0x02, 0x05, 0xe0, 0x30, 0x2c, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42, 0x01, 0x0d, 0x04, 0x1f, 0x16, 0x1d, 0x4f, 0x70, 0x65, 0x6e, 0x53, 0x53, 0x4c, 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x98, 0x0c, 0xd6, 0x1c, 0x08, 0x75, 0x6d, 0x49, 0x3f, 0xa4, 0xe9, 0x2d, 0xf9, 0xd1, 0x70, 0x1a, 0xd7, 0xef, 0xc6, 0x05, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x8e, 0x6a, 0xb0, 0xfe, 0x49, 0xc5, 0x6a, 0x96, 0x9e, 0xba, 0xb8, 0xb6, 0x58, 0xfc, 0x52, 0x7f, 0xab, 0x51, 0xf2, 0x3a, 0x30, 0x16, 0x06, 0x03, 0x55, 0x1d, 0x25, 0x01, 0x01, 0xff, 0x04, 0x0c, 0x30, 0x0a, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x08, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x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0xf6, 0x2e, 0xb1, 0x68, 0x5f, 0xb4, 0x73, 0x85, 0x92, 0x3d, 0x97, 0xd3, 0xd1, 0x1a, 0x5d, 0x56, 0xb4, 0x0e, 0x92, 0x99, 0x61, 0x5f, 0x56, 0xf3, 0xf4, 0xc4, 0xec, 0xfa, 0xde, 0x71, 0xee, 0x47, 0xaf, 0xb5, 0x36, 0x6d, 0x01, 0xcf, 0xc8, 0xc6, 0x93, 0x65, 0x7a, 0x1e, 0x1f, 0x1b, 0x1f, 0xf2, 0xf7, 0x0e, 0xd9, 0x21, 0x61, 0xf3, 0x39, 0xf3, 0xa9, 0x1c, 0x8a, 0x3d, 0x90, 0x0c, 0x49, 0x85, 0x69, 0x08, 0xc1, 0x3e, 0x1d, 0xbb, 0x63, 0xa6, 0xd8, 0x57, 0xe6, 0x00 }; static unsigned int test_device_cert_der_len = 1048; static unsigned char test_device_cert_key_der[] = { 0x30, 0x82, 0x04, 0xa4, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xda, 0x31, 0xa1, 0xae, 0x67, 0xaf, 0x9c, 0x50, 0x5f, 0x1b, 0xd4, 0xce, 0x6d, 0x3c, 0x3c, 0xa6, 0xd2, 0x41, 0x86, 0x7a, 0xed, 0x81, 0x65, 0x82, 0x3f, 0xa1, 0x54, 0x89, 0xba, 0x4d, 0x7a, 0x9e, 0xab, 0x99, 0x24, 0x23, 0x19, 0xf8, 0xb4, 0x83, 0xe1, 0xb0, 0x08, 0x7b, 0x6f, 0x02, 0x7d, 0x80, 0x2e, 0xd9, 0xb5, 0xe1, 0xb2, 0x13, 0x3b, 0x23, 0x32, 0xc8, 0x0b, 0xad, 0xc4, 0xac, 0x95, 0xa6, 0x82, 0x0e, 0xec, 0x62, 0xfa, 0x7f, 0xf5, 0x2c, 0xc7, 0xe6, 0x4e, 0x28, 0x30, 0xb6, 0x66, 0x5d, 0xa8, 0x28, 0xeb, 0xbe, 0xfd, 0xd3, 0xa7, 0xc5, 0xc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0x59, 0x15, 0xc5, 0x46, 0xb2, 0xb1, 0xd5, 0x9b, 0xa3, 0x55, 0x4b, 0x3e, 0x9a, 0x90, 0x2b, 0xb8, 0x8f, 0x5d, 0x74, 0x03, 0x9f, 0x9d, 0x1e, 0x8b, 0xe9, 0x80, 0x5f, 0xf6, 0xa7, 0xa1, 0x14, 0xad, 0x15, 0x4d, 0x93, 0xfb, 0x97, 0xc9, 0x02, 0x81, 0x80, 0x20, 0xab, 0x75, 0xb3, 0xf1, 0x7c, 0x47, 0x3e, 0x4b, 0x81, 0xb4, 0xf6, 0x3d, 0xb2, 0x5d, 0x7c, 0x09, 0x3f, 0x33, 0x62, 0xa3, 0x14, 0xf1, 0xa8, 0x29, 0x64, 0x94, 0x6f, 0xab, 0x98, 0xec, 0xeb, 0x65, 0x84, 0xa2, 0x34, 0xd0, 0xce, 0x14, 0x22, 0xdd, 0xf5, 0x1c, 0x12, 0xd7, 0xb2, 0xb3, 0xb6, 0xa6, 0x84, 0xbc, 0x9d, 0x1e, 0x32, 0x8e, 0x82, 0xb6, 0xe0, 0xfd, 0xe2, 0xa2, 0x01, 0xe1, 0x31, 0x90, 0xac, 0xcf, 0xce, 0xcd, 0xf7, 0x55, 0x01, 0x38, 0x33, 0xa5, 0x1b, 0x8f, 0x15, 0x44, 0x26, 0x26, 0xc2, 0x03, 0xae, 0xe8, 0xda, 0x57, 0x9d, 0x3d, 0xfb, 0x7d, 0xb1, 0xe0, 0xa5, 0x0f, 0x74, 0xfd, 0x35, 0xd1, 0xa1, 0xa4, 0xab, 0x0b, 0xf3, 0xa8, 0x6a, 0xeb, 0x66, 0x2f, 0x99, 0xab, 0xc1, 0x43, 0x4f, 0x78, 0x69, 0x82, 0x99, 0xf4, 0xac, 0xb9, 0x28, 0x2d, 0xa3, 0x1a, 0x56, 0x71, 0x65 }; static unsigned int test_device_cert_key_der_len = 1192; #define DEMO_STACK_SIZE 4096 // (3 * 1024 / sizeof(ULONG)) /* Define the IP thread's stack area. */ #define IP_STACK_SIZE 4096 //(2 * 1024 / sizeof(ULONG)) /* Define packet pool for the demonstration. */ #define NX_PACKET_POOL_BYTES ((1536 + sizeof(NX_PACKET)) * 200) #define NX_PACKET_POOL_SIZE (NX_PACKET_POOL_BYTES/sizeof(ULONG) + 64 / sizeof(ULONG)) /* Define the ARP cache area. */ #define ARP_AREA_SIZE 1024 // (512 / sizeof(ULONG)) #define TOTAL_STACK_SPACE (2 * (DEMO_STACK_SIZE + IP_STACK_SIZE + NX_PACKET_POOL_SIZE + ARP_AREA_SIZE) + DEMO_STACK_SIZE) #ifndef __LINUX__ ULONG test_stack_area[TOTAL_STACK_SPACE + 2000]; #endif static ULONG pool_area[2][NX_PACKET_POOL_SIZE]; /* Define the counters used in the demo application... */ ULONG error_counter; /* Define thread prototypes. */ static void ntest_0_entry(ULONG thread_input); static void ntest_1_entry(ULONG thread_input); static void ntest_2_entry(ULONG thread_input); extern void _nx_ram_network_driver_1500(struct NX_IP_DRIVER_STRUCT *driver_req); /* Define what the initial system looks like. */ #ifndef __LINUX__ void tx_application_define(void *first_unused_memory) #else #ifdef CTEST void test_application_define(void *first_unused_memory); void test_application_define(void *first_unused_memory) #else void nx_secure_tls_multithread_test_application_define(void *first_unused_memory) #endif #endif { CHAR *pointer; UINT status; /* Setup the working pointer. */ #ifndef __LINUX__ pointer = (CHAR*)test_stack_area; #else pointer = (CHAR *) first_unused_memory; #endif error_counter = 0; /* Create the main thread. */ tx_thread_create(&ntest_0, "thread 0", ntest_0_entry, 0, pointer, DEMO_STACK_SIZE, 3, 3, TX_NO_TIME_SLICE, TX_AUTO_START); pointer = pointer + DEMO_STACK_SIZE; /* Create the main thread. */ tx_thread_create(&ntest_1, "thread 1", ntest_1_entry, 0, pointer, DEMO_STACK_SIZE, 4, 4, 1, TX_AUTO_START); pointer = pointer + DEMO_STACK_SIZE; /* Create the main thread. */ tx_thread_create(&ntest_2, "thread 2", ntest_2_entry, 0, pointer, DEMO_STACK_SIZE, 4, 4, 1, TX_DONT_START); pointer = pointer + DEMO_STACK_SIZE; /* Initialize the NetX system. */ nx_system_initialize(); /* Create a packet pool. */ status = nx_packet_pool_create(&pool_0, "NetX Main Packet Pool", 1536, pool_area[0], sizeof(pool_area[0])); if(status) { printf("Error in function nx_packet_pool_create: 0x%x\n", status); error_counter++; } /* Create a packet pool. */ status = nx_packet_pool_create(&pool_1, "NetX Main Packet Pool", 1536, pool_area[1], sizeof(pool_area[1])); if(status) { printf("Error in function nx_packet_pool_create: 0x%x\n", status); error_counter++; } /* Create an IP instance. */ status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 4), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_1500, pointer, IP_STACK_SIZE, 1); pointer = pointer + IP_STACK_SIZE; /* Create another IP instance. */ status += nx_ip_create(&ip_1, "NetX IP Instance 1", IP_ADDRESS(1, 2, 3, 5), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_1500, pointer, IP_STACK_SIZE, 1); pointer = pointer + IP_STACK_SIZE; if(status) { printf("Error in function nx_ip_create: 0x%x\n", status); error_counter++; } /* Enable ARP and supply ARP cache memory for IP Instance 0. */ status = nx_arp_enable(&ip_0, (void *) pointer, ARP_AREA_SIZE); pointer = pointer + ARP_AREA_SIZE; /* Enable ARP and supply ARP cache memory for IP Instance 1. */ status += nx_arp_enable(&ip_1, (void *) pointer, ARP_AREA_SIZE); pointer = pointer + ARP_AREA_SIZE; /* Check ARP enable status. */ if(status) { printf("Error in function nx_arp_enable: 0x%x\n", status); error_counter++; } /* Enable TCP processing for both IP instances. */ status = nx_tcp_enable(&ip_0); status += nx_tcp_enable(&ip_1); /* Check TCP enable status. */ if(status) { printf("Error in function tcp_enable: 0x%x\n", status); error_counter++; } nx_secure_tls_initialize(); } static void ntest_0_entry(ULONG thread_input) { UINT status; ULONG actual_status; NX_PACKET *receive_packet; UINT i; /* Print out test information banner. */ printf("NetX Secure Test: TLS Multithread Test..............................."); /* Check for earlier error. */ if(error_counter) { printf("ERROR!\n"); test_control_return(1); } /* Ensure the IP instance has been initialized. */ status = nx_ip_status_check(&ip_0, NX_IP_INITIALIZE_DONE, &actual_status, NX_IP_PERIODIC_RATE); /* Check for error. */ if(status) { printf("Error in function nx_ip_status_check: 0x%x\n", status); error_counter++; } /* Create a socket. */ status = nx_tcp_socket_create(&ip_0, &server_socket, "Server Socket", NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE * 100, 8*1024, NX_NULL, NX_NULL); /* Check for error. */ if(status) { printf("Error in function nx_tcp_socket_create: 0x%x\n", status); error_counter++; } /* Create a TLS session for our socket. */ status = nx_secure_tls_session_create(&server_tls_session, &nx_crypto_tls_ciphers, server_crypto_metadata, sizeof(server_crypto_metadata)); /* Check for error. */ if(status) { printf("Error in function nx_secure_tls_session_create: 0x%x\n", status); error_counter++; } /* Setup our packet reassembly buffer. */ nx_secure_tls_session_packet_buffer_set(&server_tls_session, server_packet_buffer, sizeof(server_packet_buffer)); ///////////////////////////////////////////////////////////////////////////////////////////////////////// // Initialize our certificate nx_secure_x509_certificate_initialize(&certificate, test_device_cert_der, test_device_cert_der_len, NX_NULL, 0, test_device_cert_key_der, test_device_cert_key_der_len, NX_SECURE_X509_KEY_TYPE_RSA_PKCS1_DER); nx_secure_tls_server_certificate_add(&server_tls_session, &certificate, 1); nx_secure_x509_certificate_initialize(&server_certificate, test_server_cert_der, test_server_cert_der_len, NX_NULL, 0, test_server_cert_key_der, test_server_cert_key_der_len, NX_SECURE_X509_KEY_TYPE_RSA_PKCS1_DER); nx_secure_tls_server_certificate_add(&server_tls_session, &server_certificate, 2); nx_secure_x509_certificate_initialize(&ica_certificate, ica_cert_der, ica_cert_der_len, NX_NULL, 0, NULL, 0, NX_SECURE_X509_KEY_TYPE_NONE); nx_secure_tls_local_certificate_add(&server_tls_session, &ica_certificate); ///////////////////////////////////////////////////////////////////////////////////////////////////////// /* Setup this thread to listen. */ status = nx_tcp_server_socket_listen(&ip_0, 12, &server_socket, 5, NX_NULL); /* Check for error. */ if(status) { printf("Error in function nx_tcp_server_socket_listen: 0x%x\n", status); error_counter++; } /* Accept a client socket connection. */ status = nx_tcp_server_socket_accept(&server_socket, NX_IP_PERIODIC_RATE); /* Check for error. */ if(status) { printf("Error in function nx_tcp_server_socket_accept: 0x%x\n", status); error_counter++; } /* Start the TLS Session now that we have a connected socket. */ status = nx_secure_tls_session_start(&server_tls_session, &server_socket, NX_WAIT_FOREVER); /* Check for error. */ if (status) { printf("TLS Server Session start failed, error: %x\n", status); error_counter++; } /* Loop to receive packets. */ for (i = 0; i < (LOOP << 1); i++) { status = nx_secure_tls_session_receive(&server_tls_session, &receive_packet, NX_IP_PERIODIC_RATE * 5); EXPECT_EQ(NX_SUCCESS, status); nx_packet_release(receive_packet); } /* End the TLS session. This is required to properly shut down the TLS connection. */ status = nx_secure_tls_session_end(&server_tls_session, NX_WAIT_FOREVER); /* If the session did not shut down cleanly, this is a possible security issue. */ if (status) { printf("Error in TLS Server session end: %x\n", status); error_counter++; } /* Disconnect the server socket. */ status = nx_tcp_socket_disconnect(&server_socket, NX_WAIT_FOREVER); // NX_IP_PERIODIC_RATE * 10); /* Check for error. */ if(status) { printf("Error in function nx_tcp_socket_disconnect: 0x%x\n", status); error_counter++; } /* Unaccept the server socket. */ status = nx_tcp_server_socket_unaccept(&server_socket); /* Check for error. */ if(status) { printf("Error in function nx_tcp_server_socket_unaccept: 0x%x\n", status); error_counter++; } /* Unlisten on the server port. */ status = nx_tcp_server_socket_unlisten(&ip_0, 12); /* Check for error. */ if (status) { printf("Error in function nx_tcp_server_socket_unlisten: 0x%x\n", status); error_counter++; } /* Delete TLS session. */ status = nx_secure_tls_session_delete(&server_tls_session); /* Check for error. */ if(status) { printf("Error in function nx_secure_tls_session_delete: 0x%x\n", status); error_counter++; } /* Delete the socket. */ status = nx_tcp_socket_delete(&server_socket); /* Check for error. */ if(status) { printf("Error in function nx_tcp_socket_delete: 0x%x\n", status); error_counter++; } /* Determine if the test was successful. */ if(error_counter) { printf("ERROR!\n"); test_control_return(1); } else { printf("SUCCESS!\n"); test_control_return(0); } } /* -----===== CLIENT =====----- */ static void ntest_1_entry(ULONG thread_input) { UINT status; UINT state; /* Create a socket. */ status = nx_tcp_socket_create(&ip_1, &client_socket, "Client Socket", NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE * 100, 1024*16, NX_NULL, NX_NULL); /* Check for error. */ if(status) { printf("Error in function nx_tcp_socket_create: 0x%x\n", status); error_counter++; } /* Create a TLS session for our socket. */ status = nx_secure_tls_session_create(&client_tls_session, &nx_crypto_tls_ciphers, client_crypto_metadata, sizeof(client_crypto_metadata)); /* Check for error. */ if(status) { printf("Error in function nx_secure_tls_session_create: 0x%x\n", status); error_counter++; } /* Setup our packet reassembly buffer. */ nx_secure_tls_session_packet_buffer_set(&client_tls_session, client_packet_buffer, sizeof(client_packet_buffer)); /* Need to allocate space for the certificate coming in from the remote host. */ nx_secure_tls_remote_certificate_allocate(&client_tls_session, &remote_certificate, remote_cert_buffer, sizeof(remote_cert_buffer)); nx_secure_tls_remote_certificate_allocate(&client_tls_session, &remote_issuer, remote_issuer_buffer, sizeof(remote_issuer_buffer)); /* Add a CA Certificate to our trusted store for verifying incoming server certificates. */ nx_secure_x509_certificate_initialize(&trusted_certificate, ca_cert_der, ca_cert_der_len, NX_NULL, 0, NULL, 0, NX_SECURE_X509_KEY_TYPE_NONE); nx_secure_tls_trusted_certificate_add(&client_tls_session, &trusted_certificate); /* Bind the socket. */ status = nx_tcp_client_socket_bind(&client_socket, 12, NX_IP_PERIODIC_RATE); /* Check for error. */ if(status) { printf("Error in function nx_tcp_client_socket_bind: 0x%x\n", status); error_counter++; } status = nx_tcp_client_socket_connect(&client_socket, IP_ADDRESS(1, 2, 3, 4), 12, 5 * NX_IP_PERIODIC_RATE); if(status) { printf("Error in function nx_tcp_client_socket_connect: 0x%x\n", status); error_counter++; } status = nx_secure_tls_session_start(&client_tls_session, &client_socket, NX_WAIT_FOREVER); /* Check for error. */ if (status) { printf("Error in Client TLS handshake: 0x%02X\n", status); printf("ERROR!\n"); test_control_return(1); } tx_thread_resume(&ntest_2); ntest_2_entry(thread_input); for (;;) { tx_thread_info_get(&ntest_2, NX_NULL, &state, NX_NULL, NX_NULL, NX_NULL, NX_NULL, NX_NULL, NX_NULL); if (state == TX_COMPLETED) { break; } tx_thread_sleep(NX_IP_PERIODIC_RATE); } /* End the TLS session. This is required to properly shut down the TLS connection. */ status = nx_secure_tls_session_end(&client_tls_session, NX_WAIT_FOREVER); /* If the session did not shut down cleanly, this is a possible security issue. */ if (status) { printf("Error in TLS Client session end: %x\n", status); error_counter++; } /* Disconnect this socket. */ status = nx_tcp_socket_disconnect(&client_socket, NX_WAIT_FOREVER); /* Check for error. */ if(status) { printf("Error in function nx_tcp_socket_disconnect: 0x%x\n", status); error_counter++; } /* Bind the socket. */ status = nx_tcp_client_socket_unbind(&client_socket); /* Check for error. */ if(status) { printf("Error in function nx_tcp_client_socket_unbind: 0x%x\n", status); error_counter++; } /* Delete TLS session. */ status = nx_secure_tls_session_delete(&client_tls_session); /* Check for error. */ if(status) { printf("Error in function nx_secure_tls_session_delete: %x\n", status); error_counter++; } /* Delete the socket. */ status = nx_tcp_socket_delete(&client_socket); /* Check for error. */ if(status) { printf("Error in function nx_tcp_socket_delete: %x\n", status); error_counter++; } } static void ntest_2_entry(ULONG thread_input) { UINT i; UINT status; NX_PACKET *send_packet; for (i = 0; i < LOOP; i++) { /* Send random data. */ nx_secure_tls_packet_allocate(&client_tls_session, &pool_1, &send_packet, NX_WAIT_FOREVER); send_packet -> nx_packet_append_ptr = send_packet -> nx_packet_data_end; send_packet -> nx_packet_length = send_packet -> nx_packet_append_ptr - send_packet -> nx_packet_prepend_ptr; status = nx_secure_tls_session_send(&client_tls_session, send_packet, NX_WAIT_FOREVER); EXPECT_EQ(NX_SUCCESS, status); } } #else #ifdef CTEST void test_application_define(void *first_unused_memory); void test_application_define(void *first_unused_memory) #else void nx_secure_tls_multithread_test_application_define(void *first_unused_memory) #endif { /* Print out test information banner. */ printf("NetX Secure Test: TLS Multithread Test...............................N/A\n"); test_control_return(3); } #endif