void
MaterialAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("MaterialAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("smoothing")) != 0)
        SetSmoothing(node->AsBool());
    if((node = searchNode->GetNode("forceMIR")) != 0)
        SetForceMIR(node->AsBool());
    if((node = searchNode->GetNode("cleanZonesOnly")) != 0)
        SetCleanZonesOnly(node->AsBool());
    if((node = searchNode->GetNode("needValidConnectivity")) != 0)
        SetNeedValidConnectivity(node->AsBool());
    if((node = searchNode->GetNode("algorithm")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 5)
                SetAlgorithm(Algorithm(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Algorithm value;
            if(Algorithm_FromString(node->AsString(), value))
                SetAlgorithm(value);
        }
    }
    if((node = searchNode->GetNode("iterationEnabled")) != 0)
        SetIterationEnabled(node->AsBool());
    if((node = searchNode->GetNode("numIterations")) != 0)
        SetNumIterations(node->AsInt());
    if((node = searchNode->GetNode("iterationDamping")) != 0)
        SetIterationDamping(node->AsFloat());
    if((node = searchNode->GetNode("simplifyHeavilyMixedZones")) != 0)
        SetSimplifyHeavilyMixedZones(node->AsBool());
    if((node = searchNode->GetNode("maxMaterialsPerZone")) != 0)
        SetMaxMaterialsPerZone(node->AsInt());
    if((node = searchNode->GetNode("isoVolumeFraction")) != 0)
        SetIsoVolumeFraction(node->AsFloat());
    if((node = searchNode->GetNode("annealingTime")) != 0)
        SetAnnealingTime(node->AsInt());
}
Beispiel #2
0
CTrustedKey::CTrustedKey(byte* pKey, size_t uSize, bool bAuthenticated, UINT eAlgorithm)
 : CAbstractKey(pKey, uSize)
{
	if(eAlgorithm == CAbstractKey::eUndefined)
		eAlgorithm = CHashFunction::eSHA256;
	SetAlgorithm(eAlgorithm);

	m_bAuthenticated = bAuthenticated;

	CHashFunction Hash(eAlgorithm);
	Hash.Add(pKey, uSize);
	Hash.Finish();
	Hash.Fold((byte*)&m_FingerPrint, sizeof(uint64));
}
//---------------------------------------------------------------------------
sgStagingAlgorithm::sgStagingAlgorithm(std::string algorithm) {
        SetAlgorithm(algorithm);
    }
void ToolsOptionsWindow::OnCommand (HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	switch (LOWORD (wParam)) {
		case ID_LSTOPTIONCATEGORY:
		{
			switch (HIWORD (wParam))
			{
				case LBN_SELCHANGE:
				{					
					int iIndex = SendMessage (m_lstcategory, LB_GETCURSEL, 0, 0);
					char selItem[SIZE_STRING];
					ZeroMemory (selItem, SIZE_STRING);

					if (iIndex != LB_ERR) {
						SendMessage (m_lstcategory,LB_GETTEXT, iIndex, (LPARAM) selItem);

						ActivatePanel (selItem);
					}
				}
				break;
			}
			break;
		}
		break;
		case ID_OPTWINDOWCLOSE:
		{
			if (SaveHotKeySettings () == true) {
				Hide ();
			}
		}
		break;

		case ID_CHKPFOLDERPROMPTPUP:
		{
			if (m_bpfolderspromptpowerup == false) {
				SetCheck (m_pfolderspromptpowerup, true);
				m_bpfolderspromptpowerup = true;
				m_registry.WriteStringSetting (PROTECTEDFOLDERSPROMPTPUP, "yes");
			} else {
				m_registry.WriteStringSetting (PROTECTEDFOLDERSPROMPTPUP, "no");
				SetCheck (m_pfolderspromptpowerup, false);
				m_bpfolderspromptpowerup = false;
			}
		}
		break;

		case ID_CHKPFOLDERPROMPTPDN:
		{
			if (m_bpfolderspromptpowerdown == false) {
				SetCheck (m_pfolderspromptpowerdown, true);
				m_bpfolderspromptpowerdown = true;
				m_registry.WriteStringSetting (PROTECTEDFOLDERSPROMPTPDN, "yes");
			} else {
				m_registry.WriteStringSetting (PROTECTEDFOLDERSPROMPTPDN, "no");
				SetCheck (m_pfolderspromptpowerdown, false);
				m_bpfolderspromptpowerdown = false;
			}
		}
		break;

		// Encryption CTRL key
		case ID_UTEBTNHOTENCCTRL:
		{
			if (m_buseencctrl == false) {
				SetCheck (m_chkencctrl, true);
				m_buseencctrl = true;
				m_registry.WriteStringSetting (UTEENCRYPTUSECTRL, "yes");

			} else {
				SetCheck (m_chkencctrl, false);
				m_buseencctrl = false;
				m_registry.WriteStringSetting (UTEENCRYPTUSECTRL, "no");
			}
		}
		break;

		// Encryption ALT key
		case ID_UTEBTNHOTENCALT:
		{
			if (m_buseencalt == false) {
				SetCheck (m_chkencalt, true);
				m_buseencalt = true;
				m_registry.WriteStringSetting (UTEENCRYPTUSEALT, "yes");

			} else {				
				SetCheck (m_chkencalt, false);
				m_buseencalt = false;
				m_registry.WriteStringSetting (UTEENCRYPTUSEALT, "no");
			}
		}
		break;

		// Decryption CTRL key
		case ID_UTEBTNHOTDECCTRL:
		{
			if (m_busedecctrl == false) {
				SetCheck (m_chkdecctrl, true);
				m_busedecctrl = true;
				m_registry.WriteStringSetting (UTEDECRYPTUSECTRL, "yes");

			} else {
				SetCheck (m_chkdecctrl, false);
				m_busedecctrl = false;
				m_registry.WriteStringSetting (UTEDECRYPTUSECTRL, "no");
			}
		}
		break;

		// Decryption ALT key
		case ID_UTEBTNHOTDECALT:
		{
			if (m_busedecalt == false) {
				SetCheck (m_chkdecalt, true);
				m_busedecalt = true;
				m_registry.WriteStringSetting (UTEDECRYPTUSEALT, "yes");

			} else {				
				SetCheck (m_chkdecalt, false);
				m_busedecalt = false;
				m_registry.WriteStringSetting (UTEDECRYPTUSEALT, "no");
			}
		}
		break;

		case ID_CHKAUTOUPDATECHECK:
		{
			//		SetCheck (m_chkautoupdate, true); // Default value
			//		m_buseautoupdate = true; // Default value
			if (m_buseautoupdate == true) {
				SetCheck (m_chkautoupdate, false);
				m_buseautoupdate = false;
				m_registry.WriteStringSetting (AUTOUPDATECHECK, "no");
			} else {
				SetCheck (m_chkautoupdate, true);
				m_buseautoupdate = true;
				m_registry.WriteStringSetting (AUTOUPDATECHECK, "yes");
			}
		}
		break;

		case ID_OPTALGCYBERCEDE:
		{

			SetAlgorithm (ALG_CYBERCEDE);
		}
		break;
		case ID_OPTALGAES256:
		{
			SetAlgorithm (ALG_AES256);
		}
		break;
		case ID_OPTALG3DES:
		{			
			SetAlgorithm (ALG_3DES);
		}
		break;
		case ID_OPTALGDES:
		{		
			SetAlgorithm (ALG_DES);
		}
		break;
	}
}
void ToolsOptionsWindow::ReadRegistrySettings ()
{
	if (m_registry.DoesSettingExist (PROTECTEDFOLDERSPROMPTPUP) == true) {
		if (strcmp (m_registry.ReadStringSetting (PROTECTEDFOLDERSPROMPTPUP), "yes") == 0) {
			SetCheck (m_pfolderspromptpowerup, true);
			m_bpfolderspromptpowerup = true;
		}
	}

	if (m_registry.DoesSettingExist (PROTECTEDFOLDERSPROMPTPDN) == true) {
		if (strcmp (m_registry.ReadStringSetting (PROTECTEDFOLDERSPROMPTPDN), "yes") == 0) {
			SetCheck (m_pfolderspromptpowerdown, true);
			m_bpfolderspromptpowerdown = true;
		}
	}

	// UNIVERSAL TEXT ENCRYPTION SETTINGS - ENCRYPTION
	// Use CTRL tickbox
	if (m_registry.DoesSettingExist (UTEENCRYPTUSECTRL) == true) {
		if (strcmp (m_registry.ReadStringSetting (UTEENCRYPTUSECTRL), "yes") == 0) {
			SetCheck (m_chkencctrl, true);
			m_buseencctrl = true;
		} else {
			SetCheck (m_chkencctrl, false);
			m_buseencctrl = false;
		}
	} else {
		SetCheck (m_chkencctrl, true); // Default Value
		m_buseencctrl = true;
	}

	// Use ALT tickbox
	if (m_registry.DoesSettingExist (UTEENCRYPTUSEALT) == true) {
		if (strcmp (m_registry.ReadStringSetting (UTEENCRYPTUSEALT), "yes") == 0) {
			SetCheck (m_chkencalt, true);
			m_buseencalt = true;
		} else {
			SetCheck (m_chkencalt, false);
			m_buseencalt = false;
		}
	} else {
		SetCheck (m_chkencalt, false); // Default Value
	}

	// Encrypt HotKey
	if (m_registry.DoesSettingExist (UTEENCRYPTHOTKEY) == true) {
		SetDlgItemText (m_hwnd, ID_UTETXTHOTENC, m_registry.ReadStringSetting (UTEENCRYPTHOTKEY));
	} else {
		SetDlgItemText (m_hwnd, ID_UTETXTHOTENC, "E");
	}

	// UNIVERSAL TEXT ENCRYPTION SETTINGS - DECRYPTION
	// Use CTRL tickbox
	if (m_registry.DoesSettingExist (UTEDECRYPTUSECTRL) == true) {
		if (strcmp (m_registry.ReadStringSetting (UTEDECRYPTUSECTRL), "yes") == 0) {
			SetCheck (m_chkdecctrl, true);
			m_busedecctrl = true;
		} else {
			SetCheck (m_chkdecctrl, false);
			m_busedecctrl = false;
		}
	} else {
		SetCheck (m_chkdecctrl, true); // Default Value
		m_busedecctrl = true;
	}

	// Use ALT tickbox
	if (m_registry.DoesSettingExist (UTEDECRYPTUSEALT) == true) {
		if (strcmp (m_registry.ReadStringSetting (UTEDECRYPTUSEALT), "yes") == 0) {
			SetCheck (m_chkdecalt, true);
			m_busedecalt = true;
		} else {
			SetCheck (m_chkdecalt, false);
			m_busedecalt = false;
		}
	} else {
		SetCheck (m_chkdecalt, false); // Default Value
	}

	// Decrypt HotKey
	if (m_registry.DoesSettingExist (UTEDECRYPTHOTKEY) == true) {
		SetDlgItemText (m_hwnd, ID_UTETXTHOTDEC, m_registry.ReadStringSetting (UTEDECRYPTHOTKEY));
	} else {
		SetDlgItemText (m_hwnd, ID_UTETXTHOTDEC, "D");
	}

	// Automatic Update setting
	if (m_registry.DoesSettingExist (AUTOUPDATECHECK) == true) {
		if (strcmp (m_registry.ReadStringSetting (AUTOUPDATECHECK), "yes") == 0) {
			SetCheck (m_chkautoupdate, true);
			m_buseautoupdate = true;
		} else {
			SetCheck (m_chkautoupdate, false);
			m_buseautoupdate = false;			
		}
	} else {
		SetCheck (m_chkautoupdate, true); // Default value
		m_buseautoupdate = true; // Default value
	}

	// CURRENT SELECTED ENCRYPTION ALGORITHM
	if (m_registry.DoesSettingExist (SELECTEDALGORITHM) == true) {

		if (strcmp (m_registry.ReadStringSetting (SELECTEDALGORITHM), "Cybercede") == 0) {
			SetAlgorithm (ALG_CYBERCEDE);
		}

		if (strcmp (m_registry.ReadStringSetting (SELECTEDALGORITHM), "AES256") == 0) {
			SetAlgorithm (ALG_AES256);
		}

		if (strcmp (m_registry.ReadStringSetting (SELECTEDALGORITHM), "3DES") == 0) {
			SetAlgorithm (ALG_3DES);
		}

		if (strcmp (m_registry.ReadStringSetting (SELECTEDALGORITHM), "DES") == 0) {
			SetAlgorithm (ALG_DES);
		}

	} else {
		SetAlgorithm (ALG_CYBERCEDE);
	}


}