Ejemplo n.º 1
0
TripleDESCryptor::TripleDESCryptor(const std::string& key)
{
	if (key.size() == KEY_LEN*3) {
		InitKeys(key);
	} else {
		std::string key24(key);
		if (key24.size() < KEY_LEN*3) {
			key24.append(KEY_LEN*3 - key24.size(), '\0');
		} else {
			key24.erase(KEY_LEN*3, std::string::npos);
		}
		InitKeys(key24);
	}
}
Ejemplo n.º 2
0
    /* 生成子密钥*/
    void GenKeys(char In[], TKeys *Out)
    {
        int i, j;
        A64 Temp64;
        A56 Temp56;
        int SaveC00, SaveC01, SaveD00, SaveD01;

        InitKeys(In, &Temp64);
        DoPC_1(Temp64, &Temp56);
        for (i = 0; i < 16; i++)
        {
            SaveC00 = Temp56[0];
            SaveC01 = Temp56[1];
            SaveD00 = Temp56[28];
            SaveD01 = Temp56[29];
            for (j = 0; j < 28 - LS[i]; j ++)
            {
                Temp56[j] = Temp56[j + LS[i]];
                Temp56[j + 28] = Temp56[j + 28 + LS[i]];
            }
            if (LS[i] == 1)
            {
                Temp56[27] = SaveC00;
                Temp56[55] = SaveD00;
            }
            else
            {
                Temp56[26] = SaveC00;
                Temp56[27] = SaveC01;
                Temp56[54] = SaveD00;
                Temp56[55] = SaveD01;
            }
            DoPC_2(Temp56, Out, i);
        }
    }
Ejemplo n.º 3
0
void scripts::SG002::setup_game()
{
	Game *game = CurrentGame();
	if (game == nullptr) return;

	Keyboard *keyboard = game->getKeyboard();
	EventManager *event_manager = game->getEventManager();
	World *world = game->getWorld();
	ViewController *view_controller = game->getViewController();
	if (view_controller == nullptr ||
		world == nullptr ||
		keyboard == nullptr ||
		event_manager == nullptr) {
		return;
	}

	auto level_script = MakeLevelScript();
	level_script->setup();
#ifdef MAP_TUNNEL
	world->readFromFile("stage/tunnel.txt");
	world->m_game_play_range.m_min = Vec3i{-30, 1, -30};
	world->m_game_play_range.m_max = Vec3i{30, 1, 30};
#else
	//world->readFromFile("stage/last_save.txt");
	world->randomGenerate(0, k_map_size, k_map_size/6, 100.0f);
	world->m_game_play_range.m_min = Vec3i{-k_map_size, 1, -k_map_size/6};
	world->m_game_play_range.m_max = Vec3i{k_map_size, 1, k_map_size/6};
#endif
	world->setup(level_script);

	InitKeys();

	view_controller->setup(0.005f, -0.001f);
}
Ejemplo n.º 4
0
Player::Player()
{
	InitKeys();
	InitActions();

	for (auto & pair : actionBinding_)
	{
		pair.second.category = Category::Player;
	}
}
Ejemplo n.º 5
0
 int main( void )
  {
   InitVFD();
   InitISD();
   InitI2C();
   InitADC();
   InitRTC();
   InitDS75();
   InitKeys();
   InitUART();
   InitRFM();
   InitAlarm();

   sei();
   wdt_enable(WDT_DEFAULT);

   UI();   

   return 0;
 }
Ejemplo n.º 6
0
int ParseArgs(int argc, char *argv[], user_settings *set)
{
	if (argv == NULL || set == NULL)
		return USR_PTR_PASS_FAIL;

	if (argc < 2) {
		DisplayHelp(argv[0]);
		return USR_HELP;
	}

	// Detecting Help Requried
	for (int i = 1; i < argc; i++) {
		if (strcmp(argv[i], "-help") == 0) {
			DisplayHelp(argv[0]);
			return USR_HELP;
		}
		else if (strcmp(argv[i], "-exthelp") == 0) {
			DisplayExtendedHelp(argv[0]);
			return USR_HELP;
		}
	}

	// Allocating Memory for Content Path Ptrs
	set->common.contentPath = calloc(CIA_MAX_CONTENT, sizeof(char*));
	if (set->common.contentPath == NULL) {
		fprintf(stderr, "[SETTING ERROR] Not Enough Memory\n");
		return USR_MEM_ERROR;
	}

	// Initialise Keys
	InitKeys(&set->common.keys);

	// Setting Defaults
	SetDefaults(set);

	// Parsing Arguments
	int set_result;
	for (int i = 1; i < argc; i += set_result) {
		set_result = SetArgument(argc, i, argv, set);
		if (set_result < 1) {
			fprintf(stderr, "[RESULT] Invalid arguments, see '%s -help'\n", argv[0]);
			return set_result;
		}
	}

	// Checking arguments
	if ((set_result = CheckArgumentCombination(set)) != 0)
		return set_result;

	// Setting Keys
	if ((set_result = SetKeys(&set->common.keys)) != 0)
		return set_result;

	// Generating outpath if required
	if (!set->common.outFileName) {
		char *source_path = NULL;
		if (set->ncch.buildNcch0)
			source_path = set->common.rsfPath;
		else if (set->common.workingFileType == infile_ncsd || set->common.workingFileType == infile_cia || set->common.workingFileType == infile_srl)
			source_path = set->common.workingFilePath;
		else
			source_path = set->common.contentPath[0];
		set->common.outFileName_mallocd = true;
		set->common.outFileName = replace_filextention(source_path, GetOutputExtention(set->common.outFormat));
	}
	return 0;
}
Ejemplo n.º 7
0
void IS::RunBenchMark()
{
	cout << " Size: " << TOTAL_KEYS << " Iterations: " << MAX_ITERATIONS << endl;

	//Initialize timer
	timer = new Timer();
	timer->ResetTimer(0);

	//Generate random number sequence and subsequent keys on all procs
	InitKeys(amult); 	// Random number gen seed
						// Random number gen mult

	/* Do one iteration for free (i.e., "untimed") to guarantee initialization of
		all data and code pages and respective tables */
	if(isSerial)
	{
		Rank(1);
	}
	else
	{
		SetupThreads(this);

		RankThread::iteration = 1;

		doSort();

		for(int i=0; i<MAX_KEY; i++ )
			master_hist[i] = 0;

		doSort();

		Partial_Verify(1);
	}

	/*Start verification counter */
	passed_verification = 0;

	if( execClass != 'S' )
		cout << "\n     iteration#" << endl;

	timer->Start(0);

	/*This is the main iteration */
	for(int it=1; it<=MAX_ITERATIONS; it++ )
	{
		if( execClass != 'S' ) cout << "	  " << it << endl;

		if(isSerial)
		{
			Rank(it);
		}
		else
		{
			RankThread::iteration = it;

			doSort();

			for(int i=0; i<MAX_KEY; i++ )
				master_hist[i] = 0;

			doSort();
			Partial_Verify(it);
		}
	}

	timer->Stop(0);

	/*This tests that keys are in sequence: sorting of last ranked key seq
	  occurs here, but is an untimed operation			       */
	Full_Verify();

	int verified = 0;

	if( passed_verification == 5*MAX_ITERATIONS + 1 )
		verified = 1;

	std::chrono::duration<double> tm = timer->ReadTimer(0);

	BMResults * results = new BMResults(BMName,
						execClass,
						TOTAL_KEYS,
						0,
						0,
						MAX_ITERATIONS,
						tm,
						GetMOPS(tm, MAX_ITERATIONS, TOTAL_KEYS),
						"keys ranked",
						verified,
						isSerial,
						numThreads,
						bid);

	results->PrintVerificationStatus(execClass, verified, BMName);

	results->Print();
}
Ejemplo n.º 8
0
/****************Function to initialize key structure****************/
static void Init(void) {

    GLint i = 1;

    float xGap = 0.5;
    float yGap = 1;
    float startX = xOrigin;
    float startY = yOrigin;

    text = (char*) malloc(100 * sizeof(char));
    strcpy(text, "");

    InitKeys(0, xOrigin, yOrigin + 50, keyWidth * 15.3, keyHeight+30, text, "");

    //Row 1
    row=1;
    InitKeys(i++, startX, startY, keyWidth, keyHeight, "`", "~");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "1", "!");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "2", "@");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "3", "#");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "4", "$");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "5", "%");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "6", "^");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "7", "&");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "8", "*");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "9", "(");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "0", ")");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "[", "{");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "]", "}");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth * 2, keyHeight, "Backspace", NULL);

    //Row2
    row=2;
    InitKeys(i++, startX = xOrigin, startY -= keyHeight + yGap, keyWidth * 1.5, keyHeight, "Tab", NULL);
    InitKeys(i++, startX += keyWidth * 1.5 + xGap, startY, keyWidth, keyHeight, "'", "\"");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, ",", "<");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, ".", ">");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "P", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "Y", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "F", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "G", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "C", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "R", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "L", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "/", "?");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "=", "+");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth * 1.5, keyHeight, "\\", "|");

    //Row3
    row=3;
    InitKeys(i++, startX = xOrigin, startY -= keyHeight + yGap, keyWidth * 2, keyHeight, "Caps Lock", NULL);
    InitKeys(i++, startX += keyWidth * 2 + xGap, startY, keyWidth, keyHeight, "A", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "O", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "E", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "U", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "I", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "D", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "H", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "T", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "N", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "S", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "-", "_");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth * 2.03, keyHeight, "Enter", NULL);

    //Row4
    row=4;
    InitKeys(i++, startX = xOrigin, startY -= keyHeight + yGap, keyWidth * 2.5, keyHeight, "Shift", NULL);
    InitKeys(i++, startX += keyWidth * 2.5 + xGap, startY, keyWidth, keyHeight, ";", ":");
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "Q", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "J", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "K", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "X", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "B", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "M", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "W", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "V", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "Z", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth * 2.55, keyHeight, "Shift", NULL);

    //Row5
    row=5;
    InitKeys(i++, startX = xOrigin, startY -= keyHeight + yGap, keyWidth * 1.5, keyHeight, "Ctrl", NULL);
    InitKeys(i++, startX += keyWidth * 1.5 + xGap, startY, keyWidth, keyHeight, "Win", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth * 1.5, keyHeight, "Alt", NULL);
    InitKeys(i++, startX += keyWidth * 1.5 + xGap, startY, keyWidth * 6, keyHeight, "Space", NULL);
    InitKeys(i++, startX += keyWidth * 6 + xGap, startY, keyWidth * 1.5, keyHeight, "Alt Gr", NULL);
    InitKeys(i++, startX += keyWidth * 1.5 + xGap, startY, keyWidth, keyHeight, "Win", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth, keyHeight, "Menu", NULL);
    InitKeys(i++, startX += keyWidth + xGap, startY, keyWidth * 1.65, keyHeight, "Ctrl", NULL);

}
Ejemplo n.º 9
0
int main(int argc, char** argv)
{

	int dw = GetScreenWidth();
	int dh = GetScreenHeight();

	vec3 icp = {0.0F, 4.0F, 8.0F};
	vec3 icl = {0.0F, 0.0F, 0.0F};
	vec3 icu = {0.0F, 1.0F, 0.0F};
	g_globalCam.SetCamera(icp, icl, icu);
	g_globalCam.SetPerspective(65.0F, dw / (float)dh, 0.1F, 1000.0F);



	// Query extension base //
	CreateAppWindow("Mooball", dw, dh, 32, false);
	initExtensions();
	InitKeys();

	srand(time(NULL));

	// Query Device capabilities //
	if(!ValidateDevice())
	{
		DestroyAppWindow();
		return 0;
	}
	g_pTexInterface = new CTextureInterface;
	g_pShaderInterface = new CShaderInterface;
	g_lightManager = new CLightManager;
	g_bMSAA = (quickINI::Instance()->getValueAsInt("msaa") > 0) && (g_pTexInterface->GetMaxMSAA() > 0);
	g_bVSYNC = quickINI::Instance()->getValueAsInt("vsync") > 0;

//	g_model.Load( "Media/Models/Pokeball.3ds" );
	CModelObject* pMdl = new COBJModel;
	std::string err = pMdl->LoadModel("sponza.obj", "Media/Models/");

	// Initialize CG Runtime and shaders //
	init_cg();

	// Turn vsync on //
	if( EXT_VSYNC && g_bVSYNC )
	{
        #ifdef WIN32
            wglSwapIntervalEXT(1);
        #else
            glXSwapIntervalSGI(1);
        #endif
	}

	// Create offscreen targets and depth configurations //
	init_render_targets();

	// Added 8/4/10 - Keeps Mooball from hogging
	// the input focus while it's minimized.
//	HWND windowHandle = GetFocus();

	while(running)
	{
		if(QueryQuitMsg())
			running = false;

		else
		{
			if(!g_bDebugMode)
			{
				UpdateScene();
				PollKeys();
				PollMouse();
			}
			RenderScene();
			FlipBuffers();
		}

	}

	// Fall through to destruction //
	DestroyAppWindow();

	delete g_lightManager;
	delete g_pTexInterface;
	delete g_pShaderInterface;

	return 0;
}