// Read public key void CertDecoder::GetKey() { if (source_.GetError().What()) return; GetSequence(); keyOID_ = GetAlgoId(); if (keyOID_ == RSAk) { byte b = source_.next(); if (b != BIT_STRING) { source_.SetError(BIT_STR_E); return; } b = source_.next(); // length, future b = source_.next(); while(b != 0) b = source_.next(); } else if (keyOID_ == DSAk) ; // do nothing else { source_.SetError(UNKNOWN_OID_E); return; } StoreKey(); if (keyOID_ == DSAk) AddDSA(); }
void CConfigShortcuts::SetupKey(int Key) { int Mod = (m_bShift ? MOD_SHIFT : 0) | (m_bControl ? MOD_CONTROL : 0) | (m_bAlt ? MOD_ALT : 0); StoreKey(m_iSelectedItem, Key, Mod); // Display key CStringW KeyStr = AssembleKeyString(Mod, Key); SetDlgItemTextW(IDC_KEY, KeyStr); SetModified(); }
void CConfigShortcuts::OnBnClickedDefault() { CAccelerator *pAccel = theApp.GetAccelerator(); int Key = pAccel->GetDefaultKey(m_iSelectedItem); int Mod = pAccel->GetDefaultMod(m_iSelectedItem); StoreKey(m_iSelectedItem, Key, Mod); CStringW KeyString = AssembleKeyString(Mod, Key); SetDlgItemTextW(IDC_KEY, KeyString); SetModified(); }
void CConfigShortcuts::OnBnClickedDefault() { CListCtrl *pListView = (CListCtrl*)GetDlgItem(IDC_SHORTCUTS); CAccelerator *pAccel = theApp.GetAccelerator(); int Key = pAccel->GetDefaultKey(m_iSelectedItem); int Mod = pAccel->GetDefaultMod(m_iSelectedItem); StoreKey(m_iSelectedItem, Key, Mod); CString KeyString = AssembleKeyString(Mod, Key); SetDlgItemText(IDC_KEY, KeyString); SetModified(); }
int CDbxKyoto::InitCrypt() { CRYPTO_PROVIDER *pProvider; bool bMissingKey = false; DBVARIANT dbv = { 0 }; dbv.type = DBVT_BLOB; if (GetContactSetting(NULL, "CryptoEngine", "Provider", &dbv)) { LBL_CreateProvider: CRYPTO_PROVIDER **ppProvs; int iNumProvs; Crypto_EnumProviders(&iNumProvs, &ppProvs); if (iNumProvs == 0) return 1; pProvider = ppProvs[0]; //!!!!!!!!!!!!!!!!!! DBCONTACTWRITESETTING dbcws = { "CryptoEngine", "Provider" }; dbcws.value.type = DBVT_BLOB; dbcws.value.pbVal = (PBYTE)pProvider->pszName; dbcws.value.cpbVal = (int)strlen(pProvider->pszName) + 1; WriteContactSetting(NULL, &dbcws); } else { if (dbv.type != DBVT_BLOB) { // old version, clean it up bMissingKey = true; goto LBL_CreateProvider; } pProvider = Crypto_GetProvider(LPCSTR(dbv.pbVal)); FreeVariant(&dbv); if (pProvider == NULL) goto LBL_CreateProvider; } if ((m_crypto = pProvider->pFactory()) == NULL) return 3; dbv.type = DBVT_BLOB; if (GetContactSetting(NULL, "CryptoEngine", "StoredKey", &dbv)) { bMissingKey = true; LBL_SetNewKey: m_crypto->generateKey(); // unencrypted key StoreKey(); } else { size_t iKeyLength = m_crypto->getKeyLength(); if (dbv.cpbVal != (WORD)iKeyLength) goto LBL_SetNewKey; if (!m_crypto->setKey(dbv.pbVal, iKeyLength)) if (!EnterPassword(dbv.pbVal, iKeyLength)) // password protected? return 4; FreeVariant(&dbv); } if (bMissingKey) EnumModuleNames(sttModuleEnum, this); dbv.type = DBVT_BYTE; if (!GetContactSetting(NULL, "CryptoEngine", "DatabaseEncryption", &dbv)) m_bEncrypted = dbv.bVal != 0; InitDialogs(); return 0; }
int CDb3Mmap::InitCrypt() { if (m_dbHeader.version == DB_OLD_VERSION) return 0; CRYPTO_PROVIDER *pProvider; bool bMissingKey = false; DBVARIANT dbv = { 0 }; dbv.type = DBVT_BLOB; if (GetContactSetting(NULL, "CryptoEngine", "Provider", &dbv)) { LBL_CreateProvider: CRYPTO_PROVIDER **ppProvs; int iNumProvs; Crypto_EnumProviders(&iNumProvs, &ppProvs); if (iNumProvs == 0) return 1; if (iNumProvs > 1) { CSelectCryptoDialog dlg(ppProvs, iNumProvs); dlg.DoModal(); pProvider = dlg.GetSelected(); } else pProvider = ppProvs[0]; DBCONTACTWRITESETTING dbcws = { "CryptoEngine", "Provider" }; dbcws.value.type = DBVT_BLOB; dbcws.value.pbVal = (PBYTE)pProvider->pszName; dbcws.value.cpbVal = (int)mir_strlen(pProvider->pszName) + 1; WriteContactSetting(NULL, &dbcws); } else { if (dbv.type != DBVT_BLOB) { // old version, clean it up bMissingKey = true; goto LBL_CreateProvider; } pProvider = Crypto_GetProvider(LPCSTR(dbv.pbVal)); FreeVariant(&dbv); if (pProvider == NULL) goto LBL_CreateProvider; } if ((m_crypto = pProvider->pFactory()) == NULL) return 3; dbv.type = DBVT_BLOB; if (GetContactSetting(NULL, "CryptoEngine", "StoredKey", &dbv)) { bMissingKey = true; LBL_SetNewKey: m_crypto->generateKey(); // unencrypted key StoreKey(); } else { size_t iKeyLength = m_crypto->getKeyLength(); if (dbv.cpbVal != (WORD)iKeyLength) goto LBL_SetNewKey; if (!m_crypto->setKey(dbv.pbVal, iKeyLength)) { if (memcmp(m_dbHeader.signature, &dbSignatureE, sizeof(m_dbHeader.signature))) goto LBL_SetNewKey; if (!EnterPassword(dbv.pbVal, iKeyLength)) { // password protected? if (m_dbHeader.version >= DB_094_VERSION) return 4; // one of the early used version of mmap was replaced then by mmap_sa // simply remove old badly generated key bMissingKey = true; goto LBL_SetNewKey; } } FreeVariant(&dbv); } if (bMissingKey) EnumModuleNames(sttModuleEnum, this); dbv.type = DBVT_BYTE; if (!GetContactSetting(NULL, "CryptoEngine", "DatabaseEncryption", &dbv)) m_bEncrypted = dbv.bVal != 0; InitDialogs(); return 0; }