Beispiel #1
0
  // Attempt to load private key.
  bool AdbEndpoint::load_key()
  {
    BIO* bp_public;
    BIO* bp_private;

    wxFileName key_file_name(globalSettings()->settings_folder());

    key_file_name.SetName("adb_public.pem");
    bp_public = BIO_new_file(key_file_name.GetFullPath(), "r");
    if (!bp_public) {
      wxLogError("Unable to open public key file %s", key_file_name.GetFullPath());
      return false;
    }
    

    key_file_name.SetName("adb_private.pem");
    bp_private = BIO_new_file(key_file_name.GetFullPath(), "r");
    if (!bp_private) {
      wxLogError("Unable to open private key file %s", key_file_name.GetFullPath());
      BIO_free_all(bp_public);
      return false;
    }

    _key = RSA_new();
    PEM_read_bio_RSAPublicKey(bp_public, &_key, NULL, NULL);
    //PEM_read_bio_RSAPrivateKey(bp_private, &_key, NULL, NULL);
    
    BIO_free_all(bp_private);
    BIO_free_all(bp_public);

    return true;
  }
Beispiel #2
0
  bool AdbEndpoint::generate_key()
  {
    bool success = false;
    BIGNUM* bne = NULL;
    //BIO* bp_public = NULL;
    //BIO* bp_private = NULL;
    int bits = 2048;
    unsigned long e = RSA_F4;

    // Generate RSA key
    bne = BN_new();
    if (1 == BN_set_word(bne, e))
    {
      _key = RSA_new();
      if (1 == RSA_generate_key_ex(_key, bits, bne, NULL))
      {
        success = true;
        int ret;
        BIO* bp;

        wxLogDebug("generated RSA key");

        // save it.
        wxFileName key_file_name(globalSettings()->settings_folder());

        key_file_name.SetName("adb_public.pem");
        bp = BIO_new_file(key_file_name.GetFullPath(), "w+");
        ret = PEM_write_bio_RSAPublicKey(bp, _key);
        BIO_free_all(bp);

        key_file_name.SetName("adb_private.pem");
        bp = BIO_new_file(key_file_name.GetFullPath(), "w+");
        ret = PEM_write_bio_RSAPrivateKey(bp, _key, NULL, NULL, 0, NULL, NULL);
        BIO_free_all(bp);
      }
      BN_free(bne);
    }

    return success;
  }
void KstSettings::setGlobalSettings(const KstSettings *settings) {
  globalSettings(); // force instantiation
  *_self = *settings;
}
Beispiel #4
0
void WorkerThread::runConfig() {
	emit(stageEvent("Configuring WHDLoad slave"));
	bool ok;
	UserStartup userStartup(m_startupFileName, &ok);
	if(!ok) {
		emit(errorEvent("Could not read user-startup (" + m_startupFileName + ")"));
		m_die = true;
		return;
	}
	
	//QString baseKey = Names::baseName(m_gameFileName).toLower(); // base names aren't unique
	QString baseKey = userStartup.slaveName().toLower();
	
	QString appPath = QCoreApplication::applicationDirPath();
	QString dataPath = appPath + "/whdrun-data"; // default
	QSettings globalSettings(appPath + "/WHDRun.ini", QSettings::IniFormat);
	if(globalSettings.value("WHDRun/dataPath.useCustom", false).toBool()) {
		dataPath = globalSettings.value("WHDRun/dataPath", m_dataPath).toString();
	}
	
	QString iniPath = m_dataPath + "/__WHDRun__Games.ini";
	
	QSettings ini(iniPath, QSettings::IniFormat);

	if(ini.value(baseKey + "/quitKey.useCustom", 0).toInt() == 1) {
		QString quitKey = ini.value(baseKey + "/quitKey", "$4B").toString();
		quitKey = quitKey.right(quitKey.size() - 1);
		bool ok;
		quitKey = QString("%1").arg(quitKey.toInt(&ok, 16));
		userStartup.set("QUITKEY", ok ? quitKey : "75"); // 0x5D == 93; 0x4B == 75
	}
	
	if(ini.value(baseKey + "/CUSTOM.useCustom", 0).toInt() == 1) {
		userStartup.set("CUSTOM", "\"" + ini.value(baseKey + "/CUSTOM", "").toString() + "\"");
	}
	
	if(ini.value(baseKey + "/CUSTOM1.useCustom", 0).toInt() == 1) {
		userStartup.set("CUSTOM1", ini.value(baseKey + "/CUSTOM1", 0).toString());
	}
	
	if(ini.value(baseKey + "/CUSTOM2.useCustom", 0).toInt() == 1) {
		userStartup.set("CUSTOM2", ini.value(baseKey + "/CUSTOM2", 0).toString());
	}
	
	if(ini.value(baseKey + "/CUSTOM3.useCustom", 0).toInt() == 1) {
		userStartup.set("CUSTOM3", ini.value(baseKey + "/CUSTOM3", 0).toString());
	}
	
	if(ini.value(baseKey + "/CUSTOM4.useCustom", 0).toInt() == 1) {
		userStartup.set("CUSTOM4", ini.value(baseKey + "/CUSTOM4", 0).toString());
	}
	
	if(ini.value(baseKey + "/CUSTOM5.useCustom", 0).toInt() == 1) {
		userStartup.set("CUSTOM5", ini.value(baseKey + "/CUSTOM5", 0).toString());
	}
	
	if(!userStartup.save(m_startupFileName)) {
		emit(errorEvent("Could not write to user-startup (" + m_startupFileName + ")"));
		m_die = true;
		return;
	}
}