Exemplo n.º 1
0
static void test_CyaSSL_UseMaxFragment(void)
{
#ifdef HAVE_MAX_FRAGMENT
    CYASSL_CTX *ctx = CyaSSL_CTX_new(CyaSSLv23_client_method());
    CYASSL     *ssl = CyaSSL_new(ctx);

    AssertNotNull(ctx);
    AssertNotNull(ssl);

    /* error cases */
    AssertIntNE(SSL_SUCCESS, CyaSSL_CTX_UseMaxFragment(NULL, CYASSL_MFL_2_9));
    AssertIntNE(SSL_SUCCESS, CyaSSL_UseMaxFragment(    NULL, CYASSL_MFL_2_9));
    AssertIntNE(SSL_SUCCESS, CyaSSL_CTX_UseMaxFragment(ctx, 0));
    AssertIntNE(SSL_SUCCESS, CyaSSL_CTX_UseMaxFragment(ctx, 6));
    AssertIntNE(SSL_SUCCESS, CyaSSL_UseMaxFragment(ssl, 0));
    AssertIntNE(SSL_SUCCESS, CyaSSL_UseMaxFragment(ssl, 6));

    /* success case */
    AssertIntEQ(SSL_SUCCESS, CyaSSL_CTX_UseMaxFragment(ctx,  CYASSL_MFL_2_9));
    AssertIntEQ(SSL_SUCCESS, CyaSSL_CTX_UseMaxFragment(ctx,  CYASSL_MFL_2_10));
    AssertIntEQ(SSL_SUCCESS, CyaSSL_CTX_UseMaxFragment(ctx,  CYASSL_MFL_2_11));
    AssertIntEQ(SSL_SUCCESS, CyaSSL_CTX_UseMaxFragment(ctx,  CYASSL_MFL_2_12));
    AssertIntEQ(SSL_SUCCESS, CyaSSL_CTX_UseMaxFragment(ctx,  CYASSL_MFL_2_13));
    AssertIntEQ(SSL_SUCCESS, CyaSSL_UseMaxFragment(    ssl,  CYASSL_MFL_2_9));
    AssertIntEQ(SSL_SUCCESS, CyaSSL_UseMaxFragment(    ssl,  CYASSL_MFL_2_10));
    AssertIntEQ(SSL_SUCCESS, CyaSSL_UseMaxFragment(    ssl,  CYASSL_MFL_2_11));
    AssertIntEQ(SSL_SUCCESS, CyaSSL_UseMaxFragment(    ssl,  CYASSL_MFL_2_12));
    AssertIntEQ(SSL_SUCCESS, CyaSSL_UseMaxFragment(    ssl,  CYASSL_MFL_2_13));

    CyaSSL_free(ssl);
    CyaSSL_CTX_free(ctx);
#endif
}
Exemplo n.º 2
0
static void test_client_CyaSSL_new(void)
{
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA)
    CYASSL_CTX *ctx;
    CYASSL_CTX *ctx_nocert;
    CYASSL *ssl;

    AssertNotNull(ctx_nocert = CyaSSL_CTX_new(CyaSSLv23_client_method()));
    AssertNotNull(ctx        = CyaSSL_CTX_new(CyaSSLv23_client_method()));

    AssertTrue(CyaSSL_CTX_load_verify_locations(ctx, caCert, 0));
    
    /* invalid context */
    AssertNull(ssl = CyaSSL_new(NULL));

    /* success */
    AssertNotNull(ssl = CyaSSL_new(ctx_nocert));
    CyaSSL_free(ssl);
    
    /* success */
    AssertNotNull(ssl = CyaSSL_new(ctx));
    CyaSSL_free(ssl);
    
    CyaSSL_CTX_free(ctx);
    CyaSSL_CTX_free(ctx_nocert);
#endif
}
Exemplo n.º 3
0
void TestObjectsFlushClearGetByName(void)
{
	CFileUtil						cFileUtil;
	CPointer						pObject;
	Ptr<CTestDoubleNamedString>		pDouble;
	Ptr<CRoot>						pRoot;

	cFileUtil.RemoveDir("Output");
	cFileUtil.MakeDir("Output/Dehollowfication");

	ObjectsInit("Output/Dehollowfication");
	SetupObjectsConstructors();

	pRoot = ORoot();
	pDouble = ONMalloc(CTestDoubleNamedString, "Double")->Init();
	pRoot->Add(pDouble);
	AssertLongLongInt(0, gcObjects.NumDatabaseObjects());
	AssertLongLongInt(0, gcObjects.NumDatabaseNames());
	pObject = gcObjects.Get(3);
	AssertNotNull(pObject.Object());
	AssertString("CTestDoubleNamedString", pObject.ClassName());

	gcObjects.Flush(TRUE, TRUE);
	AssertLongLongInt(3, gcObjects.NumDatabaseObjects());
	AssertLongLongInt(2, gcObjects.NumDatabaseNames());

	pObject = gcObjects.Get("Double");
	AssertNotNull(pObject.Object());
	AssertString("CTestDoubleNamedString", pObject.ClassName());

	ObjectsKill();
}
Exemplo n.º 4
0
static void test_wolfSSL_UseSupportedCurve(void)
{
#ifdef HAVE_SUPPORTED_CURVES
    WOLFSSL_CTX *ctx = wolfSSL_CTX_new(wolfSSLv23_client_method());
    WOLFSSL     *ssl = wolfSSL_new(ctx);

    AssertNotNull(ctx);
    AssertNotNull(ssl);

#ifndef NO_WOLFSSL_CLIENT
    /* error cases */
    AssertIntNE(SSL_SUCCESS,
                      wolfSSL_CTX_UseSupportedCurve(NULL, WOLFSSL_ECC_SECP256R1));
    AssertIntNE(SSL_SUCCESS, wolfSSL_CTX_UseSupportedCurve(ctx,  0));

    AssertIntNE(SSL_SUCCESS,
                          wolfSSL_UseSupportedCurve(NULL, WOLFSSL_ECC_SECP256R1));
    AssertIntNE(SSL_SUCCESS, wolfSSL_UseSupportedCurve(ssl,  0));

    /* success case */
    AssertIntEQ(SSL_SUCCESS,
                       wolfSSL_CTX_UseSupportedCurve(ctx, WOLFSSL_ECC_SECP256R1));
    AssertIntEQ(SSL_SUCCESS,
                           wolfSSL_UseSupportedCurve(ssl, WOLFSSL_ECC_SECP256R1));
#endif

    wolfSSL_free(ssl);
    wolfSSL_CTX_free(ctx);
#endif
}
Exemplo n.º 5
0
void TestFileSystemNearest(void)
{
	CFileSystem				cSystem;
	CFileUtil				cFileUtil;
	CChars					szWorkingDirectory;
	CFileNodeSystemFile*	pcNode;
	CChars					szRemaining;

	szWorkingDirectory.Init("Finder");
	cFileUtil.FullPath(&szWorkingDirectory);

	cSystem.Init("Finder");

	szRemaining.Init();
	pcNode = cSystem.GetFileNode("Lord/1.rar/Happy/Quan", &szRemaining);
	AssertNotNull(pcNode);
	AssertString("Happy/Quan", szRemaining.Text());
	szRemaining.Kill();

	szRemaining.Init();
	pcNode = cSystem.GetFileNode("File.txt/Sad/Quan", &szRemaining);
	AssertNotNull(pcNode);
	AssertString("Sad/Quan", szRemaining.Text());
	szRemaining.Kill();

	cSystem.Kill();
}
void TestMemoryStackOutOfMemory(void)
{
	CMemoryStack	cStack;
	void*			pvData;

	cStack.Init(3);
	pvData = cStack.Add(2);
	AssertNotNull(pvData);

	pvData = cStack.Add(2);
	AssertNull(pvData);

	pvData = cStack.Add(1);
	AssertNotNull(pvData);

	pvData = cStack.Add(1);
	AssertNull(pvData);

	cStack.Clear();

	pvData = cStack.Add(3);
	AssertNotNull(pvData);

	pvData = cStack.Add(1);
	AssertNull(pvData);

	cStack.Kill();
}
Exemplo n.º 7
0
static void test_CyaSSL_UseSupportedCurve(void)
{
#ifdef HAVE_SUPPORTED_CURVES
    CYASSL_CTX *ctx = CyaSSL_CTX_new(CyaSSLv23_client_method());
    CYASSL     *ssl = CyaSSL_new(ctx);

    AssertNotNull(ctx);
    AssertNotNull(ssl);

#ifndef NO_CYASSL_CLIENT
    /* error cases */
    AssertIntNE(SSL_SUCCESS,
                      CyaSSL_CTX_UseSupportedCurve(NULL, CYASSL_ECC_SECP160R1));
    AssertIntNE(SSL_SUCCESS, CyaSSL_CTX_UseSupportedCurve(ctx,  0));

    AssertIntNE(SSL_SUCCESS,
                          CyaSSL_UseSupportedCurve(NULL, CYASSL_ECC_SECP160R1));
    AssertIntNE(SSL_SUCCESS, CyaSSL_UseSupportedCurve(ssl,  0));

    /* success case */
    AssertIntEQ(SSL_SUCCESS,
                       CyaSSL_CTX_UseSupportedCurve(ctx, CYASSL_ECC_SECP160R1));
    AssertIntEQ(SSL_SUCCESS,
                           CyaSSL_UseSupportedCurve(ssl, CYASSL_ECC_SECP160R1));
#endif

    CyaSSL_free(ssl);
    CyaSSL_CTX_free(ctx);
#endif
}
Exemplo n.º 8
0
static void test_server_CyaSSL_new(void)
{
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA)
    CYASSL_CTX *ctx;
    CYASSL_CTX *ctx_nocert;
    CYASSL *ssl;

    AssertNotNull(ctx_nocert = CyaSSL_CTX_new(CyaSSLv23_server_method()));
    AssertNotNull(ctx        = CyaSSL_CTX_new(CyaSSLv23_server_method()));

    AssertTrue(CyaSSL_CTX_use_certificate_file(ctx, svrCert, SSL_FILETYPE_PEM));
    AssertTrue(CyaSSL_CTX_use_PrivateKey_file(ctx, svrKey, SSL_FILETYPE_PEM));

    /* invalid context */
    AssertNull(ssl = CyaSSL_new(NULL));
    AssertNull(ssl = CyaSSL_new(ctx_nocert));

    /* success */
    AssertNotNull(ssl = CyaSSL_new(ctx));

    CyaSSL_free(ssl);
    CyaSSL_CTX_free(ctx);
    CyaSSL_CTX_free(ctx_nocert);
#endif
}
Exemplo n.º 9
0
void TestMapBlockInternals(void)
{
	CMapBlock			cMapBlock;
	int					i;
	int					j;
	int					iKey;
	int*				piData;
	CArrayBlockSorted*	paBlock;
	SMNode**			psNode1;
	SMNode**			psNode2;
	int*				piKey;

	cMapBlock.Init(1024, &CompareInt, TRUE);
	i = 7; j = 43;
	cMapBlock.Put(&i, sizeof(int), &j, sizeof(int));

	i = 9; j = 21;
	cMapBlock.Put(&i, sizeof(int), &j, sizeof(int));
	AssertInt(2, cMapBlock.NumElements());

	paBlock = cMapBlock.GetArray();
	paBlock->InsertHoldingIntoSorted();
	psNode1 = (SMNode**)paBlock->GetInSorted(0);
	psNode2 = (SMNode**)paBlock->GetInSorted(1);
	AssertInt(sizeof(int), (*psNode1)->iDataSize);
	AssertInt(sizeof(int), (*psNode1)->iKeySize);
	AssertPointer(&cMapBlock, (*psNode1)->pcMapBlock);
	AssertInt(sizeof(int), (*psNode2)->iDataSize);
	AssertInt(sizeof(int), (*psNode2)->iKeySize);
	AssertPointer(&cMapBlock, (*psNode2)->pcMapBlock);
	piKey = (int*)RemapSinglePointer(*psNode1, sizeof(SMNode));
	AssertInt(7, *piKey);
	piData = (int*)RemapSinglePointer(piKey, (int)sizeof(int));
	AssertInt(43, *piData);
	piKey = (int*)RemapSinglePointer(*psNode2, sizeof(SMNode));
	AssertInt(9, *piKey);
	piData = (int*)RemapSinglePointer(piKey, (int)sizeof(int));
	AssertInt(21, *piData);

	iKey = 7; piData = NULL;
	cMapBlock.Get(&iKey, (void**)&piData, NULL);
	AssertNotNull(piData);
	AssertInt(43, *piData);

	iKey = 9; piData = NULL;
	cMapBlock.Get(&iKey, (void**)&piData, NULL);
	AssertNotNull(piData);
	AssertInt(21, *piData);

	iKey = 3; piData = NULL;
	cMapBlock.Get(&iKey, (void**)&piData, NULL);
	AssertNull(piData);

	cMapBlock.Kill();
}
Exemplo n.º 10
0
static void test_wolfSSL_CTX_new(WOLFSSL_METHOD *method)
{
    WOLFSSL_CTX *ctx;

    AssertNull(ctx = wolfSSL_CTX_new(NULL));

    AssertNotNull(method);
    AssertNotNull(ctx = wolfSSL_CTX_new(method));

    wolfSSL_CTX_free(ctx);
}
Exemplo n.º 11
0
static void test_CyaSSL_CTX_new(CYASSL_METHOD *method)
{
    CYASSL_CTX *ctx;
    
    AssertNull(ctx = CyaSSL_CTX_new(NULL));
    
    AssertNotNull(method);
    AssertNotNull(ctx = CyaSSL_CTX_new(method));

    CyaSSL_CTX_free(ctx);
}
Exemplo n.º 12
0
void TestReadExternalReference(void)
{
	CXMLFile	cXMLFile;
	CChars		szDoc;
	int			iLine;
	char		szExpected[] = "<InputDevices>\n\
  This is text &lt; and doom stuff\n\
  <RootInSecond>\n\
    Hello\n\
  </RootInSecond>\n\
  Sweet &gt; other stuff\n\
  <ThirdsRoot>\n\
    World\n\
  </ThirdsRoot>\n\
</InputDevices>\n";
	CMarkupTag*	pcTag;
	CMarkupTag*	pcSecondTag;
	CMarkupTag*	pcThirdTag;
	CChars		szText;

	cXMLFile.Init();
	cXMLFile.Read("First.xml", ".");

	szDoc.Init(16);
	iLine = cXMLFile.mcMarkup.mpcDoc->ToString(&szDoc);
	AssertInt(10, iLine);
	AssertString(szExpected, szDoc.Text());
	szDoc.Kill();

	pcTag = cXMLFile.mcMarkup.mpcDoc->GetRootTag();
	pcSecondTag = pcTag->GetTag("RootInSecond");
	AssertNotNull(pcSecondTag);
	szText.Init();
	pcSecondTag->GetText(&szText);
	szText.StripWhiteSpace(TRUE);
	AssertString("Hello", szText.Text());
	szText.Kill();

	pcTag = cXMLFile.mcMarkup.mpcDoc->GetRootTag();
	pcThirdTag = pcTag->GetTag("ThirdsRoot");
	AssertNotNull(pcThirdTag);
	szText.Init();
	pcThirdTag->GetText(&szText);
	szText.StripWhiteSpace(TRUE);
	AssertString("World", szText.Text());
	szText.Kill();

	cXMLFile.Kill();
}
Exemplo n.º 13
0
void TestMemoryCacheBrokenExample(void)
{
	CMemoryCache	cCache;
	void*			pvData;

	cCache.Init(64+12);

	pvData = cCache.QuickAllocate(20);
	FillCachedElement(pvData, 20, 'A');
	AssertCache(&cCache, 20, 'A');

	pvData = cCache.QuickAllocate(20);
	FillCachedElement(pvData, 20, 'B');
	AssertCache(&cCache, 20, 'A', 20, 'B');

	pvData = cCache.QuickAllocate(20);
	FillCachedElement(pvData, 20, 'C');
	AssertCache(&cCache, 20, 'B', 20, 'C');

	pvData = cCache.QuickAllocate(20);
	AssertNotNull(pvData);
	FillCachedElement(pvData, 20, 'D');
	AssertCache(&cCache, 20, 'C', 20, 'D');

	cCache.Kill();
}
void TestMapStringUnknownNoOverwrite(void)
{
    MemoryInit();
    UnknownsInit();

    CMapStringUnknown	cMap;
    CTestUnknownJobbie*	pcTest;

    cMap.Init(TRUE, FALSE);

    AssertInt(0, gcUnknowns.NumElements());

    pcTest = cMap.Put<CTestUnknownJobbie>("One");
    pcTest->Init(2, "");
    AssertNotNull(pcTest);
    AssertInt(1, gcUnknowns.NumElements());

    pcTest = cMap.Put<CTestUnknownJobbie>("One");
    AssertNull(pcTest);
    AssertInt(1, gcUnknowns.NumElements());

    cMap.Kill();

    AssertInt(0, gcUnknowns.NumElements());

    UnknownsKill();
    MemoryKill();
}
Exemplo n.º 15
0
static void test_wolfSSL_CTX_use_certificate_file(void)
{
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
    WOLFSSL_CTX *ctx;

    AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method()));

    /* invalid context */
    AssertFalse(wolfSSL_CTX_use_certificate_file(NULL, svrCert,
                                                             SSL_FILETYPE_PEM));
    /* invalid cert file */
    AssertFalse(wolfSSL_CTX_use_certificate_file(ctx, bogusFile,
                                                             SSL_FILETYPE_PEM));
    /* invalid cert type */
    AssertFalse(wolfSSL_CTX_use_certificate_file(ctx, svrCert, 9999));

#ifdef NO_RSA
    /* rsa needed */
    AssertFalse(wolfSSL_CTX_use_certificate_file(ctx, svrCert,SSL_FILETYPE_PEM));
#else
    /* success */
    AssertTrue(wolfSSL_CTX_use_certificate_file(ctx, svrCert, SSL_FILETYPE_PEM));
#endif

    wolfSSL_CTX_free(ctx);
#endif
}
Exemplo n.º 16
0
static void test_CyaSSL_CTX_use_PrivateKey_file(void)
{
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
    CYASSL_CTX *ctx;

    AssertNotNull(ctx = CyaSSL_CTX_new(CyaSSLv23_server_method()));

    /* invalid context */
    AssertFalse(CyaSSL_CTX_use_PrivateKey_file(NULL, svrKey, 
                                                             SSL_FILETYPE_PEM));
    /* invalid key file */
    AssertFalse(CyaSSL_CTX_use_PrivateKey_file(ctx, bogusFile, 
                                                             SSL_FILETYPE_PEM));
    /* invalid key type */
    AssertFalse(CyaSSL_CTX_use_PrivateKey_file(ctx, svrKey, 9999));

    /* success */
#ifdef NO_RSA
    /* rsa needed */
    AssertFalse(CyaSSL_CTX_use_PrivateKey_file(ctx, svrKey, SSL_FILETYPE_PEM));
#else
    /* success */
    AssertTrue(CyaSSL_CTX_use_PrivateKey_file(ctx, svrKey, SSL_FILETYPE_PEM));
#endif

    CyaSSL_CTX_free(ctx);
#endif
}
Exemplo n.º 17
0
static void test_CyaSSL_CTX_load_verify_locations(void)
{
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
    CYASSL_CTX *ctx;

    AssertNotNull(ctx = CyaSSL_CTX_new(CyaSSLv23_client_method()));
    
    /* invalid context */
    AssertFalse(CyaSSL_CTX_load_verify_locations(NULL, caCert, 0));

    /* invalid ca file */
    AssertFalse(CyaSSL_CTX_load_verify_locations(ctx, NULL,      0));
    AssertFalse(CyaSSL_CTX_load_verify_locations(ctx, bogusFile, 0));

#ifndef CYASSL_TIRTOS
    /* invalid path */
    /* not working... investigate! */
    /* AssertFalse(CyaSSL_CTX_load_verify_locations(ctx, caCert, bogusFile)); */
#endif

    /* success */
    AssertTrue(CyaSSL_CTX_load_verify_locations(ctx, caCert, 0));

    CyaSSL_CTX_free(ctx);
#endif
}
Exemplo n.º 18
0
void AssertFileName(CMapStringInt* pcMap, int iCount, int iRank, char* szFileName)
{
	int*			piValue;

	piValue = pcMap->Get(szFileName);
	AssertNotNull(piValue);

	AssertInt(iCount, *piValue & 0xFFFF);
	AssertInt(iRank, *piValue >> 16);
}
Exemplo n.º 19
0
static void verify_SNI_fake_matching(WOLFSSL* ssl)
{
    byte type = WOLFSSL_SNI_HOST_NAME;
    char* request = NULL;

    AssertIntEQ(WOLFSSL_SNI_FAKE_MATCH, wolfSSL_SNI_Status(ssl, type));
    AssertIntEQ(15, wolfSSL_SNI_GetRequest(ssl, type, (void**) &request));
    AssertNotNull(request);
    AssertStrEQ("ww2.wolfssl.com", request);
}
Exemplo n.º 20
0
static void verify_SNI_no_matching(WOLFSSL* ssl)
{
    byte type = WOLFSSL_SNI_HOST_NAME;
    char* request = (char*) &type; /* to be overwriten */

    AssertIntEQ(WOLFSSL_SNI_NO_MATCH, wolfSSL_SNI_Status(ssl, type));
    AssertNotNull(request);
    AssertIntEQ(0, wolfSSL_SNI_GetRequest(ssl, type, (void**) &request));
    AssertNull(request);
}
Exemplo n.º 21
0
void TestObjectDehollowfication(void)
{
	CFileUtil						cFileUtil;
	CPointer						pPointer;
	CTestDoubleNamedString*			pcInternal;
	Ptr<CTestDoubleNamedString>		pDouble;
	Ptr<CTestNamedString>			pSingle;
	int								iClassSize;
	OIndex							oiOld;
	OIndex							oiNew;

	cFileUtil.RemoveDir("Output");
	cFileUtil.MakeDir("Output/Dehollowfication");
	ObjectsInit("Output/Dehollowfication");
	SetupObjectsForDehollowfication();
	gcObjects.Flush(TRUE, TRUE);
	AssertLongLongInt(9, gcObjects.NumDatabaseObjects());
	ObjectsKill();

	ObjectsInit("Output/Dehollowfication");
	SetupObjectsConstructors();
	AssertLongLongInt(9, gcObjects.NumDatabaseObjects());

	AssertTrue(gcObjects.Contains("Double"));

	pPointer = gcObjects.Get("Double");
	AssertNotNull(pPointer.Object());
	AssertString("CTestDoubleNamedString", pPointer.ClassName());

	pcInternal = (CTestDoubleNamedString*)pPointer.Object();
	AssertTrue(pcInternal->mpSplit1.IsNotNull());
	AssertTrue(pcInternal->mpSplit1.IsHollow());
	AssertTrue(pcInternal->mpSplit2.IsNotNull());
	AssertTrue(pcInternal->mpSplit2.IsHollow());

	pDouble = pPointer;

	oiOld = pDouble->mpSplit1.GetIndex();
	AssertTrue(pcInternal->mpSplit1.IsHollow());  //Making sure we haven't de-hollowed the object by calling GetIndex.

	//Problem - An oi of 1 is briefly assigned to the de-hollowed object and then it is reassigned back to its original value.
	iClassSize = pDouble->mpSplit1->ClassSize();  //The method call - ClassSize() - is irrelevant as long as the -> operator on mpSplit1 is invoked.
	AssertTrue(pcInternal->mpSplit1.IsNotNull());
	AssertFalse(pcInternal->mpSplit1.IsHollow());
	AssertInt(sizeof(CTestNamedString), iClassSize);
	AssertString("CTestNamedString", pcInternal->mpSplit1.ClassName());
	oiNew = pDouble->mpSplit1.GetIndex();
	AssertLongLongInt(oiOld, oiNew);

	pSingle = pDouble->mpSplit2;
	AssertTrue(pcInternal->mpSplit2.IsNotNull());
	AssertTrue(pcInternal->mpSplit2.IsHollow());

	ObjectsKill();
}
Exemplo n.º 22
0
/////////////////////////////////////////////////////////////////////////////
// Application message loop
/////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK MainWindow::WndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam)
{
    MainWindow * pMainWindow = nullptr;

    // Grab a pointer to the Window* instance that is sending this message. Either a window was created, in which case
    // we need to save the pointer, or we need to look up the saved value.
    if (message == WM_NCCREATE)
    {
        // We need to intercept the WM_NCCREATE message, since it is the first message that a newly created window will
        // send.  Once we get it, grab the encoded Window* pointer and use SetWindowLong to save it for future use.
        CREATESTRUCT * pCreateStruct = reinterpret_cast<CREATESTRUCT *>(lParam);
        AssertNotNull(pCreateStruct);

        pMainWindow = static_cast<MainWindow*>(pCreateStruct->lpCreateParams);
        AssertNotNull(pMainWindow);

        // Store the window pointer.
        ::SetWindowLongPtr(
            window,
            GWLP_USERDATA,
            reinterpret_cast<LONG_PTR>(pMainWindow));

        // Also store the assigned HWND value.
        pMainWindow->SetWindowHandle(window);
    }
    else
    {
        // Try to look up the pointer that is stored in the window's userdata field.
        pMainWindow = reinterpret_cast<MainWindow*>(::GetWindowLongPtr(window, GWLP_USERDATA));
    }

    // Route the message to the correct window instance. If we could not decipher the instance, then just let windows
    // perform a default action.
    if (pMainWindow != nullptr)
    {
        return pMainWindow->HandleMessage(message, wParam, lParam);
    }
    else
    {
        return DefWindowProc(window, message, wParam, lParam);
    }
}
Exemplo n.º 23
0
static void test_CyaSSL_UseTruncatedHMAC(void)
{
#ifdef HAVE_TRUNCATED_HMAC
    CYASSL_CTX *ctx = CyaSSL_CTX_new(CyaSSLv23_client_method());
    CYASSL     *ssl = CyaSSL_new(ctx);

    AssertNotNull(ctx);
    AssertNotNull(ssl);

    /* error cases */
    AssertIntNE(SSL_SUCCESS, CyaSSL_CTX_UseTruncatedHMAC(NULL));
    AssertIntNE(SSL_SUCCESS, CyaSSL_UseTruncatedHMAC(NULL));

    /* success case */
    AssertIntEQ(SSL_SUCCESS, CyaSSL_CTX_UseTruncatedHMAC(ctx));
    AssertIntEQ(SSL_SUCCESS, CyaSSL_UseTruncatedHMAC(ssl));

    CyaSSL_free(ssl);
    CyaSSL_CTX_free(ctx);
#endif
}
Exemplo n.º 24
0
Arquivo: api.c Projeto: HclX/freertos
static void verify_SNI_real_matching(WOLFSSL* ssl)
{
    byte   type    = WOLFSSL_SNI_HOST_NAME;
    char*  request = NULL;
    char   name[]  = "www.yassl.com";
    word16 length  = XSTRLEN(name);

    AssertIntEQ(WOLFSSL_SNI_REAL_MATCH, wolfSSL_SNI_Status(ssl, type));

    AssertIntEQ(length, wolfSSL_SNI_GetRequest(ssl, type, (void**) &request));
    AssertNotNull(request);
    AssertStrEQ(name, request);
}
Exemplo n.º 25
0
static void verify_SNI_fake_matching(CYASSL* ssl)
{
    byte   type    = CYASSL_SNI_HOST_NAME;
    char*  request = NULL;
    char   name[]  = "ww2.yassl.com";
    word16 length  = XSTRLEN(name);

    AssertIntEQ(CYASSL_SNI_FAKE_MATCH, CyaSSL_SNI_Status(ssl, type));

    AssertIntEQ(length, CyaSSL_SNI_GetRequest(ssl, type, (void**) &request));
    AssertNotNull(request);
    AssertStrEQ(name, request);
}
Exemplo n.º 26
0
void AssertPakFile(char* szFileName, char* szContents, CFiles* pcFiles)
{
	CAbstractFile*	pcFile;
	CTextFile		cTextFile;

	pcFile = pcFiles->GetFile(szFileName);
	AssertNotNull(pcFile);

	cTextFile.Init();
	cTextFile.Read(pcFile);
	AssertString(szContents, cTextFile.Text());
	cTextFile.Kill();
}
Exemplo n.º 27
0
void TestFilesSimple(void)
{
	CFiles			cFiles;
	CAbstractFile*	pcFile;
	CTextFile		cTextFile;

	//If this test fails you probably need to re-generate the source PAK files.
	//Use TestPackFilesPackerSimple to do this.

	cFiles.Init("Game", "PAK");
	AssertInt(6, cFiles.GetNumPackFiles());

	pcFile = cFiles.GetFile("Sounds/Santa/Seattle.txt");
	AssertNotNull(pcFile);

	cTextFile.Init();
	cTextFile.Read(pcFile);
	AssertString("All night long\r\n", cTextFile.Text());
	cTextFile.Kill();

	pcFile = cFiles.GetFile("Sounds/General.txt");
	AssertNotNull(pcFile);

	cTextFile.Init();
	cTextFile.Read(pcFile);
	AssertString("General", cTextFile.Text());
	cTextFile.Kill();

	pcFile = cFiles.GetFile("Sounds/Santa/Slay/Spelling.txt");
	AssertNotNull(pcFile);

	cTextFile.Init();
	cTextFile.Read(pcFile);
	AssertString("Spelling", cTextFile.Text());
	cTextFile.Kill();

	cFiles.Kill();
}
Exemplo n.º 28
0
void TestMemoryCacheEvictAll(void)
{
	CMemoryCache	cCache;
	void*			pvData;

	cCache.Init(64+12);

	pvData = cCache.QuickAllocate(17);
	AssertNotNull(pvData);
	FillCachedElement(pvData, 17, 'A');
	AssertCache(&cCache, 17, 'A');

	pvData = cCache.QuickAllocate(6);
	AssertNotNull(pvData);
	FillCachedElement(pvData, 6, 'B');
	AssertCache(&cCache, 17, 'A', 6, 'B');

	pvData = cCache.QuickAllocate(47);
	AssertNotNull(pvData);
	FillCachedElement(pvData, 47, 'C');
	AssertCache(&cCache, 47, 'C');

	cCache.Kill();
}
void TestDehollowficationFromChunkFileSource(void)
{
	CFileUtil		cFileUtil;

	cFileUtil.RemoveDir("Output\\Dehollowfication\\ChunkFile");

	MemoryInit();
	ObjectsInit("Output\\Dehollowfication\\Temp");
	WriteDehollowficationChunkedFile();
	ObjectsKill();
	MemoryKill();
	cFileUtil.RemoveDir("Output\\Dehollowfication\\Temp");

	CObjectSourceChunked* pcObjectSourceChunked;


	CDiskFile*	pcDiskFile = DiskFile("Output\\Dehollowfication\\ChunkFile\\Double.DRG");

	MemoryInit();
	ObjectsInit("Output\\Dehollowfication\\Temp");
	SetupDehollowficationConstructors();

	pcObjectSourceChunked = (CObjectSourceChunked*)gcObjects.AddSource<CObjectConverterNative>(pcDiskFile, "Double");  //Note the .DRG is intentionally dropped.
	AssertNotNull(pcObjectSourceChunked);

	AssertInt(4, pcObjectSourceChunked->NumNames());
	AssertString("Diamond End", pcObjectSourceChunked->GetName(0));
	AssertString("Double Start", pcObjectSourceChunked->GetName(1));
	AssertString("NamedString 1", pcObjectSourceChunked->GetName(2));
	AssertString("NamedString 2", pcObjectSourceChunked->GetName(3));

	Ptr<CTestDoubleNamedString> pStart;

	pStart = gcObjects.Get("Double Start");
	AssertTrue(pStart.IsNotNull());
	AssertString("CTestDoubleNamedString", pStart.ClassName());

	AssertTrue(pStart->mpSplit1.IsHollow());
	AssertTrue(pStart->mpSplit2.IsHollow());
	AssertFalse(pStart->mszString.IsHollow());

	pStart->mpSplit1->ClassName();
	AssertFalse(pStart->mpSplit1.IsHollow());
	AssertString("CTestNamedString", pStart->mpSplit1.ClassName());

	ObjectsKill();
	MemoryKill();
}
Exemplo n.º 30
-1
static void test_wolfSSL_UseSNI_params(void)
{
    WOLFSSL_CTX *ctx = wolfSSL_CTX_new(wolfSSLv23_client_method());
    WOLFSSL     *ssl = wolfSSL_new(ctx);

    AssertNotNull(ctx);
    AssertNotNull(ssl);

    /* invalid [ctx|ssl] */
    AssertIntNE(SSL_SUCCESS, wolfSSL_CTX_UseSNI(NULL, 0, "ctx", 3));
    AssertIntNE(SSL_SUCCESS, wolfSSL_UseSNI(    NULL, 0, "ssl", 3));
    /* invalid type */
    AssertIntNE(SSL_SUCCESS, wolfSSL_CTX_UseSNI(ctx, -1, "ctx", 3));
    AssertIntNE(SSL_SUCCESS, wolfSSL_UseSNI(    ssl, -1, "ssl", 3));
    /* invalid data */
    AssertIntNE(SSL_SUCCESS, wolfSSL_CTX_UseSNI(ctx,  0, NULL,  3));
    AssertIntNE(SSL_SUCCESS, wolfSSL_UseSNI(    ssl,  0, NULL,  3));
    /* success case */
    AssertIntEQ(SSL_SUCCESS, wolfSSL_CTX_UseSNI(ctx,  0, "ctx", 3));
    AssertIntEQ(SSL_SUCCESS, wolfSSL_UseSNI(    ssl,  0, "ssl", 3));

    wolfSSL_free(ssl);
    wolfSSL_CTX_free(ctx);
}