| 1361 | } |
| 1362 | |
| 1363 | bool rem_port::tryKeyType(const KnownServerKey& srvKey, InternalCryptKey* cryptKey) |
| 1364 | { |
| 1365 | if (port_crypt_complete) |
| 1366 | { |
| 1367 | return true; |
| 1368 | } |
| 1369 | |
| 1370 | if (srvKey.type != cryptKey->keyName) |
| 1371 | { |
| 1372 | return false; |
| 1373 | } |
| 1374 | |
| 1375 | if (getPortConfig()->getWireCrypt(WC_CLIENT) == WIRE_CRYPT_DISABLED) |
| 1376 | { |
| 1377 | port_crypt_complete = true; |
| 1378 | return true; |
| 1379 | } |
| 1380 | |
| 1381 | // we got correct key's type pair |
| 1382 | // check what about crypt plugin for it |
| 1383 | ParsedList clientPlugins(getPortConfig()->getPlugins(IPluginManager::TYPE_WIRE_CRYPT)); |
| 1384 | for (unsigned n = 0; n < clientPlugins.getCount(); ++n) |
| 1385 | { |
| 1386 | PathName p(clientPlugins[n]); |
| 1387 | WIRECRYPT_DEBUG(fprintf(stderr, "tryKeyType, client plugin %s\n", p.c_str())); |
| 1388 | if (srvKey.plugins.find(" " + p + " ") != PathName::npos) |
| 1389 | { |
| 1390 | WIRECRYPT_DEBUG(fprintf(stderr, "tryKeyType, server listed plugin %s\n", p.c_str())); |
| 1391 | GetPlugins<IWireCryptPlugin> |
| 1392 | cp(IPluginManager::TYPE_WIRE_CRYPT, p.c_str()); |
| 1393 | if (cp.hasData()) |
| 1394 | { |
| 1395 | WIRECRYPT_DEBUG(fprintf(stderr, "tryKeyType, client loaded plugin %s\n", p.c_str())); |
| 1396 | LocalStatus st; |
| 1397 | CheckStatusWrapper statusWrapper(&st); |
| 1398 | |
| 1399 | // Pass IV to plugin |
| 1400 | //const UCharBuffer* specificData = srvKey.findSpecificData(p); |
| 1401 | auto* specificData = srvKey.findSpecificData(p); |
| 1402 | if (specificData) |
| 1403 | { |
| 1404 | cp.plugin()->setSpecificData(&statusWrapper, srvKey.type.c_str(), |
| 1405 | specificData->getCount(), specificData->begin()); |
| 1406 | check(&st, isc_wish_list); |
| 1407 | } |
| 1408 | |
| 1409 | // Pass key to plugin |
| 1410 | cp.plugin()->setKey(&statusWrapper, cryptKey); |
| 1411 | if (st.getState() & IStatus::STATE_ERRORS) |
| 1412 | { |
| 1413 | status_exception::raise(&st); |
| 1414 | } |
| 1415 | |
| 1416 | // Looks like we've found correct crypt plugin and key for it |
| 1417 | port_crypt_plugin = cp.plugin(); |
| 1418 | port_crypt_plugin->addRef(); |
| 1419 | |
| 1420 | // Now it's time to notify server about choice done |
nothing calls this directly
no test coverage detected