Exemplo n.º 1
0
static void ServerToClientTimeoutConnectClient () {
	const TCHAR *pszPipeName = CNamedPipe::GetTestPipePrefix ();
	CPipeServerThread *poServer = new CPipeServerThread (pszPipeName, false, false, 0);
	CPipeClientThread *poClient = new CPipeClientThread (pszPipeName, true, 1);
	ASSERT (poServer->Wait (TIMEOUT_JOIN));
	ASSERT (poClient->Wait (TIMEOUT_JOIN));
#ifdef _WIN32
	ASSERT_FAILURE (FAIL_NONE, FAIL_NO_READWRITE);
#else
	ASSERT_FAILURE (FAIL_NONE, FAIL_NO_CREATE);
#endif
	CThread::Release (poServer);
	CThread::Release (poClient);
}
Exemplo n.º 2
0
static void ServerToClientTimeoutWriteServer () {
	const TCHAR *pszPipeName = CNamedPipe::GetTestPipePrefix ();
	CPipeServerThread *poServer = new CPipeServerThread (pszPipeName, false, true, 1);
	CPipeClientThread *poClient = new CPipeClientThread (pszPipeName, true, 0);
	ASSERT (poServer->Wait (TIMEOUT_JOIN));
	ASSERT (poClient->Wait (TIMEOUT_JOIN));
	ASSERT_FAILURE (FAIL_NO_READWRITE, FAIL_NONE);
	CThread::Release (poServer);
	CThread::Release (poClient);
}
Exemplo n.º 3
0
static void ClientToServerComplete () {
	const TCHAR *pszPipeName = CNamedPipe::GetTestPipePrefix ();
	CPipeServerThread *poServer = new CPipeServerThread (pszPipeName, true, true, 2);
	CPipeClientThread *poClient = new CPipeClientThread (pszPipeName, false, 2);
	ASSERT (poServer->Wait (TIMEOUT_JOIN));
	ASSERT (poClient->Wait (TIMEOUT_JOIN));
	ASSERT_FAILURE (FAIL_NONE, FAIL_NONE);
	CThread::Release (poServer);
	CThread::Release (poClient);
}
Exemplo n.º 4
0
static void TestCancelLazyClose (bool bClientToServer, bool bCloseServer) {
	const TCHAR *pszPipeName = CNamedPipe::GetTestPipePrefix ();
	CPipeServerThread *poServer = new CPipeServerThread (pszPipeName, bClientToServer, true, READWRITE_OPERATIONS);
	CPipeClientThread *poClient = new CPipeClientThread (pszPipeName, !bClientToServer, READWRITE_OPERATIONS);
	CPipeClosingThread *poCloser = new CPipeClosingThread (bCloseServer ? &poServer->m_poPipe : &poClient->m_poPipe, TIMEOUT_READWRITE * 2, true);
	ASSERT (poServer->Wait (TIMEOUT_JOIN));
	ASSERT (poClient->Wait (TIMEOUT_JOIN));
	ASSERT (poCloser->Wait (TIMEOUT_JOIN));
	ASSERT_FAILURE (FAIL_NONE, FAIL_NONE);
	CThread::Release (poServer);
	CThread::Release (poClient);
	CThread::Release (poCloser);
}
Exemplo n.º 5
0
int test_hkdf_precond(void)
{
    unsigned char key[4] = {0};
    unsigned char salt[4] = {0};
    unsigned char info[4] = {0};
    unsigned char out[4];

    /* Invalid hash function (failure) */

    ASSERT_FAILURE(kdf_hkdf(0, 0,
                            key, sizeof(key),
                            salt, sizeof(salt),
                            info, sizeof(info),
                            out, sizeof(out)));

    ASSERT_FAILURE(kdf_hkdf(BLOCK_AES, 0,
                            key, sizeof(key),
                            salt, sizeof(salt),
                            info, sizeof(info),
                            out, sizeof(out)));

    /* Zero length key (failure) */

    ASSERT_FAILURE(kdf_hkdf(HASH_SHA256, 0,
                            key, 0,
                            salt, sizeof(salt),
                            info, sizeof(info),
                            out, sizeof(out)));

    /* Zero length output (failure) */

    ASSERT_FAILURE(kdf_hkdf(HASH_SHA256, 0,
                            key, sizeof(key),
                            salt, sizeof(salt),
                            info, sizeof(info),
                            out, 0));

    /* Zero length salt (success) */

    ASSERT_SUCCESS(kdf_hkdf(HASH_SHA256, 0,
                            key, sizeof(key),
                            salt, 0,
                            info, sizeof(info),
                            out, sizeof(out)));

    /* Zero length info (success) */

    ASSERT_SUCCESS(kdf_hkdf(HASH_SHA256, 0,
                            key, sizeof(key),
                            salt, sizeof(salt),
                            info, 0,
                            out, sizeof(out)));

    {
        static unsigned char out_large[HASH_DIGEST_LEN * 255 + 1];
        prim_t hash = prim_default(PRIM_TYPE_HASH);
        size_t digest_len = digest_length(hash);

        /* Largest output length (success) */

        ASSERT_SUCCESS(kdf_hkdf(hash, 0,
                                key, sizeof(key),
                                salt, sizeof(salt),
                                info, sizeof(info),
                                out_large, digest_len * 255));

        /* Too long output length (failure) */

        ASSERT_FAILURE(kdf_hkdf(HASH_SHA256, 0,
                                key, sizeof(key),
                                salt, sizeof(salt),
                                info, sizeof(info),
                                out_large, digest_len * 255 + 1));
    }

    return 1;
}