void B2W2InitialSeedSearcher::Search (const Criteria &criteria, const ResultCallback &resultHandler, const SearchRunner::ProgressCallback &progressHandler) { HashedSeedGenerator seedGenerator(criteria.seedParameters); B2W2InitialSeedChecker seedChecker(criteria.spins, criteria.memoryLinkUsed); SearchRunner searcher; searcher.SearchThreaded(seedGenerator, seedChecker, seedChecker, resultHandler, progressHandler); }
void Gen4TIDSearcher::Search (const Criteria &criteria, const ResultCallback &resultHandler, const SearchRunner::ProgressCallback &progressHandler) { TimeSeedGenerator seedGenerator(criteria.minDelay, criteria.maxDelay); SeedSearcher seedSearcher; FrameChecker frameChecker(criteria); SearchRunner searcher; searcher.Search(seedGenerator, seedSearcher, frameChecker, resultHandler, progressHandler); }
void Gen4QuickSeedSearcher::Search (const Criteria &criteria, const ResultCallback &resultHandler, SearchRunner::StatusHandler &statusHandler) { Gen34IVSeedGenerator seedGenerator(criteria.ivs.min, criteria.ivs.max); SeedSearcher seedSearcher; FrameChecker frameChecker(criteria); SeedChecker seedChecker(criteria, resultHandler); SearchRunner searcher; searcher.Search(seedGenerator, seedSearcher, frameChecker, seedChecker, statusHandler); }
void Gen4EggIVSeedSearcher::Search (const Criteria &criteria, const ResultCallback &resultHandler, const SearchRunner::ProgressCallback &progressHandler) { TimeSeedGenerator seedGenerator(criteria.delay.min, criteria.delay.max); FrameGeneratorFactory frameGeneratorFactory(criteria.version); SeedFrameSearcher<FrameGeneratorFactory> seedSearcher(frameGeneratorFactory, criteria.frame); FrameChecker frameChecker; FrameResultHandler frameResultHandler(criteria, resultHandler); SearchRunner searcher; searcher.Search(seedGenerator, seedSearcher, frameChecker, frameResultHandler, progressHandler); }
void TrainerIDSearcher::Search (const Criteria &criteria, const ResultCallback &resultHandler, SearchRunner::StatusHandler &statusHandler, const std::vector<uint64_t> &startingSeeds) { HashedSeedGenerator seedGenerator(criteria.seedParameters); FrameGeneratorFactory frameGeneratorFactory(criteria.hasSaveFile); SeedFrameSearcher<FrameGeneratorFactory> seedSearcher(frameGeneratorFactory, criteria.frame); FrameChecker frameChecker(criteria); SearchRunner searcher; if (startingSeeds.size() > 0) searcher.ContinueSearchThreaded(seedGenerator, seedSearcher, frameChecker, resultHandler, statusHandler, startingSeeds); else searcher.SearchThreaded(seedGenerator, seedSearcher, frameChecker, resultHandler, statusHandler); }
void OBAClassifier::segmentRegionBySeeds(const double &maxObjSize, const double &segHeightTh, const double &segSlopeTh) { int ii = 0, count = 0, iy = 0, ix = 0, pos = 0, id = 0, entityID = 0; double ptZ = 0.0; bool *enter_queue = NULL, *localEdge = NULL; vector<PT> seeds; vector<PT>::iterator ptIter; PT pt; PointType type; Entity* entity = NULL; PT3D *pt3d; // First dispose garbage this->dispose(); count = this->_gridH * this->_gridW; this->_entityIDs = new int[count]; for(ii = 0; ii < count; ++ii) { this->_entityIDs[ii] = NAN; } enter_queue = new bool[count]; memset(enter_queue, 0, count * sizeof(bool)); localEdge = new bool[count]; memset(localEdge, 0, count*sizeof(bool)); getLocalEdge(this->_workSpace, 1.0, localEdge); // Find ground seeds, and segment from ground seeds SeedGenerator seedGenerator(this->_workSpace, maxObjSize, 20.0); seedGenerator.findMaxSeeds(seeds); for (ptIter = seeds.begin(); ptIter != seeds.end(); ++ptIter) { pt = *ptIter; pos = pt.y * this->_gridW + pt.x; if(this->_entityIDs[pos] != NAN) { continue; } type = PointType::p_unclassified; entityID++; entity = new Entity(entityID, type); this->_queue.push_back(pt); enter_queue[pos] = true; while(!this->isQueueEmpty()) { pt = this->popQueue(); pos = pt.y * this->_gridW + pt.x; enter_queue[pos] = false; this->_entityIDs[pos] = entityID; pt3d = this->_gridIndex->getMaxPT3D(pt.x, pt.y); entity->addPoint(pt, pt3d->z); if(localEdge[pos]) { continue; } this->enterQueue(pt, type, enter_queue, segHeightTh, segSlopeTh); } this->_entitys[entityID] = entity; } // Segment for the left points for(iy = 0; iy < this->_gridH; ++iy) { for(ix = 0; ix < this->_gridW; ++ix) { pos = iy * this->_gridW + ix; if(this->_entityIDs[pos] != NAN) { continue; } // Set an object as an unclassified object if it is not a hole type = PointType::p_unclassified; pt3d = this->_gridIndex->getMaxPT3D(ix, iy); if(pt3d == NULL) { // Set an object as an created object if it is a hole type = PointType::p_created; } entityID++; entity = new Entity(entityID, type); pt.x = ix; pt.y = iy; this->_queue.push_back(pt); enter_queue[pos] = true; // When the queue is empty, a new object is derived while(!this->isQueueEmpty()) { pt = this->popQueue(); pos = pt.y * this->_gridW + pt.x; enter_queue[pos] = false; pt3d = this->_gridIndex->getMaxPT3D(pt.x, pt.y); if(pt3d == NULL) { ptZ = 0.0; } else { ptZ = pt3d->z; } this->_entityIDs[pos] = entityID; entity->addPoint(pt, ptZ); if(localEdge[pos]) { continue; } this->enterQueue(pt, type, enter_queue, segHeightTh, segSlopeTh); } this->_entitys[entityID] = entity; } } if(enter_queue != NULL) { delete []enter_queue; enter_queue = NULL; } if(localEdge != NULL) { delete []localEdge; localEdge = NULL; } }
void Security::generateSessionKey() throw (SecurityException) { int seedSize; unsigned char seed[SEED_SIZE]; #ifndef _WINDOWS // Reads 256 bytes from file /dev/urandom and adds them to // PRNG to use as seed of the random number generator int fd = open("/dev/urandom", O_RDONLY); if (fd < 0) #ifdef MXHPUXPA // HP-UX PA-RISC // /dev/urandom file does not exist on HP-UX PA-RISK. If customers // do not choose to install the HP-UX Strong Random Number Generator // package which can be obtained from this link, provide the following // weak Random Number Generator { seedSize = WEAK_SEED_SIZE; if (seedGenerator((char*)seed) != seedSize) throw SecurityException(UNABLE_TO_SEED_RNG, NULL); } #else // other UNIX platforms throw SecurityException(UNABLE_TO_SEED_RNG, NULL); seedSize = SEED_SIZE; int num = 0; // This can infinitely loops if /dev/urandom does not return 256 bytes // However, it's very very unlikely to happen. while (num != seedSize) { int count = 0; count = read(fd, &seed[num], seedSize - num); if (count > 0) num += count; else if (count == 0) { close(fd); throw SecurityException(FAILED_GENERATE_RANDOM_NUM, NULL); } else //count < 0 { switch (errno) { #ifdef EINTR case EINTR: // Interrupted system call #endif #ifdef EAGAIN case EAGAIN: // Resource temporarily unavailable #endif /* No error, try again */ break; default: close(fd); throw SecurityException(FAILED_GENERATE_RANDOM_NUM, NULL); } } } close(fd); #endif //MXHPUXPA #else // _WINDOWS seedSize=SEED_SIZE; // Get a handle to the DLL module. HINSTANCE hLib = LoadLibrary(TEXT("advapi32.dll")); // Do the following to avoid the overhead of loading the entire CryptoAPI if (hLib) { BOOLEAN (APIENTRY *pfn)(void*, ULONG) = (BOOLEAN (APIENTRY *)(void*,ULONG))GetProcAddress(hLib, "SystemFunction036"); if (pfn) { if(!pfn(seed, seedSize)) { throw SecurityException(UNABLE_TO_SEED_RNG, NULL); } } } else { throw SecurityException(FAILED_LOADING_LIB, NULL); } #endif // _WINDOWS getMutex(); RAND_seed((const void *)seed, seedSize); // Check if the PRNG has been seeded with enough randomness if (!RAND_status ()) { releaseMutex(); throw SecurityException(UNABLE_TO_SEED_RNG, NULL); } // Generate 64 bytes of random number using the seed generated above int errcode = RAND_bytes((unsigned char*) &m_pwdKey.data.session_key[0], SESSION_KEYLEN + NONCE_SIZE); releaseMutex(); if (errcode != 1) throw SecurityException(SESSION_KEY_GENERATION_FAILED, NULL); // Get nonce sequence memcpy((char*) &m_nonceSeq, &m_pwdKey.data.nonce[NONCE_RANDOM], NONCE_SEQNUM); if (!m_littleEndian) { m_nonceSeq = swapByteOrderOfLL(m_nonceSeq); // Store the swap bytes back in nonce //intLLong.llVal = m_nonceSeq; memcpy(&m_pwdKey.data.nonce[NONCE_RANDOM], (char*) &m_nonceSeq, NONCE_SEQNUM); } // Set time when session key is generated m_keyTime = get_msts(); }