You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SSecurityRSAAES.cxx 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. /* Copyright (C) 2022 Dinglan Peng
  2. *
  3. * This is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This software is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this software; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  16. * USA.
  17. */
  18. #ifdef HAVE_CONFIG_H
  19. #include <config.h>
  20. #endif
  21. #ifndef HAVE_NETTLE
  22. #error "This source should not be compiled without HAVE_NETTLE defined"
  23. #endif
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <assert.h>
  27. #include <nettle/bignum.h>
  28. #include <nettle/sha1.h>
  29. #include <nettle/sha2.h>
  30. #include <nettle/base64.h>
  31. #include <nettle/asn1.h>
  32. #include <rfb/SSecurityRSAAES.h>
  33. #include <rfb/SConnection.h>
  34. #include <rfb/LogWriter.h>
  35. #include <rfb/Exception.h>
  36. #include <rdr/AESInStream.h>
  37. #include <rdr/AESOutStream.h>
  38. #include <rdr/types.h>
  39. #if !defined(WIN32) && !defined(__APPLE__)
  40. #include <rfb/UnixPasswordValidator.h>
  41. #endif
  42. #ifdef WIN32
  43. #include <rfb/WinPasswdValidator.h>
  44. #endif
  45. #include <rfb/SSecurityVncAuth.h>
  46. enum {
  47. SendPublicKey,
  48. ReadPublicKey,
  49. ReadRandom,
  50. ReadHash,
  51. ReadCredentials,
  52. };
  53. const int MinKeyLength = 1024;
  54. const int MaxKeyLength = 8192;
  55. const size_t MaxKeyFileSize = 32 * 1024;
  56. using namespace rfb;
  57. StringParameter SSecurityRSAAES::keyFile
  58. ("RSAKey", "Path to the RSA key for the RSA-AES security types in "
  59. "PEM format", "", ConfServer);
  60. BoolParameter SSecurityRSAAES::requireUsername
  61. ("RequireUsername", "Require username for the RSA-AES security types",
  62. false, ConfServer);
  63. SSecurityRSAAES::SSecurityRSAAES(SConnection* sc, uint32_t _secType,
  64. int _keySize, bool _isAllEncrypted)
  65. : SSecurity(sc), state(SendPublicKey),
  66. keySize(_keySize), isAllEncrypted(_isAllEncrypted), secType(_secType),
  67. serverKey(), clientKey(),
  68. serverKeyN(NULL), serverKeyE(NULL), clientKeyN(NULL), clientKeyE(NULL),
  69. accessRights(SConnection::AccessDefault),
  70. rais(NULL), raos(NULL), rawis(NULL), rawos(NULL)
  71. {
  72. assert(keySize == 128 || keySize == 256);
  73. }
  74. SSecurityRSAAES::~SSecurityRSAAES()
  75. {
  76. cleanup();
  77. }
  78. void SSecurityRSAAES::cleanup()
  79. {
  80. if (serverKeyN)
  81. delete[] serverKeyN;
  82. if (serverKeyE)
  83. delete[] serverKeyE;
  84. if (clientKeyN)
  85. delete[] clientKeyN;
  86. if (clientKeyE)
  87. delete[] clientKeyE;
  88. if (serverKey.size)
  89. rsa_private_key_clear(&serverKey);
  90. if (clientKey.size)
  91. rsa_public_key_clear(&clientKey);
  92. if (isAllEncrypted && rawis && rawos)
  93. sc->setStreams(rawis, rawos);
  94. if (rais)
  95. delete rais;
  96. if (raos)
  97. delete raos;
  98. }
  99. static inline ssize_t findSubstr(uint8_t* data, size_t size, const char *pattern)
  100. {
  101. size_t patternLength = strlen(pattern);
  102. for (size_t i = 0; i + patternLength < size; ++i) {
  103. for (size_t j = 0; j < patternLength; ++j)
  104. if (data[i + j] != pattern[j])
  105. goto next;
  106. return i;
  107. next:
  108. continue;
  109. }
  110. return -1;
  111. }
  112. static bool loadPEM(uint8_t* data, size_t size, const char *begin,
  113. const char *end, uint8_t** der, size_t *derSize)
  114. {
  115. ssize_t pos1 = findSubstr(data, size, begin);
  116. if (pos1 == -1)
  117. return false;
  118. pos1 += strlen(begin);
  119. ssize_t base64Size = findSubstr(data + pos1, size - pos1, end);
  120. if (base64Size == -1)
  121. return false;
  122. char *derBase64 = (char *)data + pos1;
  123. if (!base64Size)
  124. return false;
  125. *der = new uint8_t[BASE64_DECODE_LENGTH(base64Size)];
  126. struct base64_decode_ctx ctx;
  127. base64_decode_init(&ctx);
  128. if (!base64_decode_update(&ctx, derSize, *der, base64Size, derBase64))
  129. return false;
  130. if (!base64_decode_final(&ctx))
  131. return false;
  132. return true;
  133. }
  134. void SSecurityRSAAES::loadPrivateKey()
  135. {
  136. FILE* file = fopen(keyFile.getData(), "rb");
  137. if (!file)
  138. throw ConnFailedException("failed to open key file");
  139. fseek(file, 0, SEEK_END);
  140. size_t size = ftell(file);
  141. if (size == 0 || size > MaxKeyFileSize) {
  142. fclose(file);
  143. throw ConnFailedException("size of key file is zero or too big");
  144. }
  145. fseek(file, 0, SEEK_SET);
  146. rdr::U8Array data(size);
  147. if (fread(data.buf, 1, size, file) != size) {
  148. fclose(file);
  149. throw ConnFailedException("failed to read key");
  150. }
  151. fclose(file);
  152. rdr::U8Array der;
  153. size_t derSize;
  154. if (loadPEM(data.buf, size, "-----BEGIN RSA PRIVATE KEY-----\n",
  155. "-----END RSA PRIVATE KEY-----", &der.buf, &derSize)) {
  156. loadPKCS1Key(der.buf, derSize);
  157. return;
  158. }
  159. if (der.buf)
  160. delete[] der.takeBuf();
  161. if (loadPEM(data.buf, size, "-----BEGIN PRIVATE KEY-----\n",
  162. "-----END PRIVATE KEY-----", &der.buf, &derSize)) {
  163. loadPKCS8Key(der.buf, derSize);
  164. return;
  165. }
  166. throw ConnFailedException("failed to import key");
  167. }
  168. void SSecurityRSAAES::loadPKCS1Key(const uint8_t* data, size_t size)
  169. {
  170. struct rsa_public_key pub;
  171. rsa_private_key_init(&serverKey);
  172. rsa_public_key_init(&pub);
  173. if (!rsa_keypair_from_der(&pub, &serverKey, 0, size, data)) {
  174. rsa_private_key_clear(&serverKey);
  175. rsa_public_key_clear(&pub);
  176. throw ConnFailedException("failed to import key");
  177. }
  178. serverKeyLength = serverKey.size * 8;
  179. serverKeyN = new uint8_t[serverKey.size];
  180. serverKeyE = new uint8_t[serverKey.size];
  181. nettle_mpz_get_str_256(serverKey.size, serverKeyN, pub.n);
  182. nettle_mpz_get_str_256(serverKey.size, serverKeyE, pub.e);
  183. rsa_public_key_clear(&pub);
  184. }
  185. void SSecurityRSAAES::loadPKCS8Key(const uint8_t* data, size_t size)
  186. {
  187. struct asn1_der_iterator i, j;
  188. uint32_t version;
  189. const char* rsaIdentifier = "\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01";
  190. const size_t rsaIdentifierLength = 9;
  191. enum asn1_iterator_result res = asn1_der_iterator_first(&i, size, data);
  192. if (res != ASN1_ITERATOR_CONSTRUCTED)
  193. goto failed;
  194. if (i.type != ASN1_SEQUENCE)
  195. goto failed;
  196. if (asn1_der_decode_constructed_last(&i) != ASN1_ITERATOR_PRIMITIVE)
  197. goto failed;
  198. if (!(i.type == ASN1_INTEGER &&
  199. asn1_der_get_uint32(&i, &version) &&
  200. version == 0))
  201. goto failed;
  202. if (!(asn1_der_iterator_next(&i) == ASN1_ITERATOR_CONSTRUCTED &&
  203. i.type == ASN1_SEQUENCE &&
  204. asn1_der_decode_constructed(&i, &j) == ASN1_ITERATOR_PRIMITIVE &&
  205. j.type == ASN1_IDENTIFIER &&
  206. j.length == rsaIdentifierLength &&
  207. memcmp(j.data, rsaIdentifier, rsaIdentifierLength) == 0))
  208. goto failed;
  209. if (!(asn1_der_iterator_next(&i) == ASN1_ITERATOR_PRIMITIVE &&
  210. i.type == ASN1_OCTETSTRING && i.length))
  211. goto failed;
  212. loadPKCS1Key(i.data, i.length);
  213. return;
  214. failed:
  215. throw ConnFailedException("failed to import key");
  216. }
  217. bool SSecurityRSAAES::processMsg()
  218. {
  219. switch (state) {
  220. case SendPublicKey:
  221. loadPrivateKey();
  222. writePublicKey();
  223. state = ReadPublicKey;
  224. /* fall through */
  225. case ReadPublicKey:
  226. if (!readPublicKey())
  227. return false;
  228. writeRandom();
  229. state = ReadRandom;
  230. /* fall through */
  231. case ReadRandom:
  232. if (!readRandom())
  233. return false;
  234. setCipher();
  235. writeHash();
  236. state = ReadHash;
  237. /* fall through */
  238. case ReadHash:
  239. if (!readHash())
  240. return false;
  241. clearSecrets();
  242. writeSubtype();
  243. state = ReadCredentials;
  244. /* fall through */
  245. case ReadCredentials:
  246. if (!readCredentials())
  247. return false;
  248. if (requireUsername)
  249. verifyUserPass();
  250. else
  251. verifyPass();
  252. return true;
  253. }
  254. assert(!"unreachable");
  255. return false;
  256. }
  257. void SSecurityRSAAES::writePublicKey()
  258. {
  259. rdr::OutStream* os = sc->getOutStream();
  260. os->writeU32(serverKeyLength);
  261. os->writeBytes(serverKeyN, serverKey.size);
  262. os->writeBytes(serverKeyE, serverKey.size);
  263. os->flush();
  264. }
  265. bool SSecurityRSAAES::readPublicKey()
  266. {
  267. rdr::InStream* is = sc->getInStream();
  268. if (!is->hasData(4))
  269. return false;
  270. is->setRestorePoint();
  271. clientKeyLength = is->readU32();
  272. if (clientKeyLength < MinKeyLength)
  273. throw ConnFailedException("client key is too short");
  274. if (clientKeyLength > MaxKeyLength)
  275. throw ConnFailedException("client key is too long");
  276. size_t size = (clientKeyLength + 7) / 8;
  277. if (!is->hasDataOrRestore(size * 2))
  278. return false;
  279. is->clearRestorePoint();
  280. clientKeyE = new uint8_t[size];
  281. clientKeyN = new uint8_t[size];
  282. is->readBytes(clientKeyN, size);
  283. is->readBytes(clientKeyE, size);
  284. rsa_public_key_init(&clientKey);
  285. nettle_mpz_set_str_256_u(clientKey.n, size, clientKeyN);
  286. nettle_mpz_set_str_256_u(clientKey.e, size, clientKeyE);
  287. if (!rsa_public_key_prepare(&clientKey))
  288. throw ConnFailedException("client key is invalid");
  289. return true;
  290. }
  291. static void random_func(void* ctx, size_t length, uint8_t* dst)
  292. {
  293. rdr::RandomStream* rs = (rdr::RandomStream*)ctx;
  294. if (!rs->hasData(length))
  295. throw ConnFailedException("failed to encrypt random");
  296. rs->readBytes(dst, length);
  297. }
  298. void SSecurityRSAAES::writeRandom()
  299. {
  300. rdr::OutStream* os = sc->getOutStream();
  301. if (!rs.hasData(keySize / 8))
  302. throw ConnFailedException("failed to generate random");
  303. rs.readBytes(serverRandom, keySize / 8);
  304. mpz_t x;
  305. mpz_init(x);
  306. int res;
  307. try {
  308. res = rsa_encrypt(&clientKey, &rs, random_func, keySize / 8,
  309. serverRandom, x);
  310. } catch (...) {
  311. mpz_clear(x);
  312. throw;
  313. }
  314. if (!res) {
  315. mpz_clear(x);
  316. throw ConnFailedException("failed to encrypt random");
  317. }
  318. uint8_t* buffer = new uint8_t[clientKey.size];
  319. nettle_mpz_get_str_256(clientKey.size, buffer, x);
  320. mpz_clear(x);
  321. os->writeU16(clientKey.size);
  322. os->writeBytes(buffer, clientKey.size);
  323. os->flush();
  324. delete[] buffer;
  325. }
  326. bool SSecurityRSAAES::readRandom()
  327. {
  328. rdr::InStream* is = sc->getInStream();
  329. if (!is->hasData(2))
  330. return false;
  331. is->setRestorePoint();
  332. size_t size = is->readU16();
  333. if (size != serverKey.size)
  334. throw ConnFailedException("server key length doesn't match");
  335. if (!is->hasDataOrRestore(size))
  336. return false;
  337. is->clearRestorePoint();
  338. uint8_t* buffer = new uint8_t[size];
  339. is->readBytes(buffer, size);
  340. size_t randomSize = keySize / 8;
  341. mpz_t x;
  342. nettle_mpz_init_set_str_256_u(x, size, buffer);
  343. delete[] buffer;
  344. if (!rsa_decrypt(&serverKey, &randomSize, clientRandom, x) ||
  345. randomSize != (size_t)keySize / 8) {
  346. mpz_clear(x);
  347. throw ConnFailedException("failed to decrypt client random");
  348. }
  349. mpz_clear(x);
  350. return true;
  351. }
  352. void SSecurityRSAAES::setCipher()
  353. {
  354. rawis = sc->getInStream();
  355. rawos = sc->getOutStream();
  356. uint8_t key[32];
  357. if (keySize == 128) {
  358. struct sha1_ctx ctx;
  359. sha1_init(&ctx);
  360. sha1_update(&ctx, 16, serverRandom);
  361. sha1_update(&ctx, 16, clientRandom);
  362. sha1_digest(&ctx, 16, key);
  363. rais = new rdr::AESInStream(rawis, key, 128);
  364. sha1_init(&ctx);
  365. sha1_update(&ctx, 16, clientRandom);
  366. sha1_update(&ctx, 16, serverRandom);
  367. sha1_digest(&ctx, 16, key);
  368. raos = new rdr::AESOutStream(rawos, key, 128);
  369. } else {
  370. struct sha256_ctx ctx;
  371. sha256_init(&ctx);
  372. sha256_update(&ctx, 32, serverRandom);
  373. sha256_update(&ctx, 32, clientRandom);
  374. sha256_digest(&ctx, 32, key);
  375. rais = new rdr::AESInStream(rawis, key, 256);
  376. sha256_init(&ctx);
  377. sha256_update(&ctx, 32, clientRandom);
  378. sha256_update(&ctx, 32, serverRandom);
  379. sha256_digest(&ctx, 32, key);
  380. raos = new rdr::AESOutStream(rawos, key, 256);
  381. }
  382. if (isAllEncrypted)
  383. sc->setStreams(rais, raos);
  384. }
  385. void SSecurityRSAAES::writeHash()
  386. {
  387. uint8_t hash[32];
  388. size_t len = serverKeyLength;
  389. uint8_t lenServerKey[4] = {
  390. (uint8_t)((len & 0xff000000) >> 24),
  391. (uint8_t)((len & 0xff0000) >> 16),
  392. (uint8_t)((len & 0xff00) >> 8),
  393. (uint8_t)(len & 0xff)
  394. };
  395. len = clientKeyLength;
  396. uint8_t lenClientKey[4] = {
  397. (uint8_t)((len & 0xff000000) >> 24),
  398. (uint8_t)((len & 0xff0000) >> 16),
  399. (uint8_t)((len & 0xff00) >> 8),
  400. (uint8_t)(len & 0xff)
  401. };
  402. int hashSize;
  403. if (keySize == 128) {
  404. hashSize = 20;
  405. struct sha1_ctx ctx;
  406. sha1_init(&ctx);
  407. sha1_update(&ctx, 4, lenServerKey);
  408. sha1_update(&ctx, serverKey.size, serverKeyN);
  409. sha1_update(&ctx, serverKey.size, serverKeyE);
  410. sha1_update(&ctx, 4, lenClientKey);
  411. sha1_update(&ctx, clientKey.size, clientKeyN);
  412. sha1_update(&ctx, clientKey.size, clientKeyE);
  413. sha1_digest(&ctx, hashSize, hash);
  414. } else {
  415. hashSize = 32;
  416. struct sha256_ctx ctx;
  417. sha256_init(&ctx);
  418. sha256_update(&ctx, 4, lenServerKey);
  419. sha256_update(&ctx, serverKey.size, serverKeyN);
  420. sha256_update(&ctx, serverKey.size, serverKeyE);
  421. sha256_update(&ctx, 4, lenClientKey);
  422. sha256_update(&ctx, clientKey.size, clientKeyN);
  423. sha256_update(&ctx, clientKey.size, clientKeyE);
  424. sha256_digest(&ctx, hashSize, hash);
  425. }
  426. raos->writeBytes(hash, hashSize);
  427. raos->flush();
  428. }
  429. bool SSecurityRSAAES::readHash()
  430. {
  431. uint8_t hash[32];
  432. uint8_t realHash[32];
  433. int hashSize = keySize == 128 ? 20 : 32;
  434. if (!rais->hasData(hashSize))
  435. return false;
  436. rais->readBytes(hash, hashSize);
  437. size_t len = serverKeyLength;
  438. uint8_t lenServerKey[4] = {
  439. (uint8_t)((len & 0xff000000) >> 24),
  440. (uint8_t)((len & 0xff0000) >> 16),
  441. (uint8_t)((len & 0xff00) >> 8),
  442. (uint8_t)(len & 0xff)
  443. };
  444. len = clientKeyLength;
  445. uint8_t lenClientKey[4] = {
  446. (uint8_t)((len & 0xff000000) >> 24),
  447. (uint8_t)((len & 0xff0000) >> 16),
  448. (uint8_t)((len & 0xff00) >> 8),
  449. (uint8_t)(len & 0xff)
  450. };
  451. if (keySize == 128) {
  452. struct sha1_ctx ctx;
  453. sha1_init(&ctx);
  454. sha1_update(&ctx, 4, lenClientKey);
  455. sha1_update(&ctx, clientKey.size, clientKeyN);
  456. sha1_update(&ctx, clientKey.size, clientKeyE);
  457. sha1_update(&ctx, 4, lenServerKey);
  458. sha1_update(&ctx, serverKey.size, serverKeyN);
  459. sha1_update(&ctx, serverKey.size, serverKeyE);
  460. sha1_digest(&ctx, hashSize, realHash);
  461. } else {
  462. struct sha256_ctx ctx;
  463. sha256_init(&ctx);
  464. sha256_update(&ctx, 4, lenClientKey);
  465. sha256_update(&ctx, clientKey.size, clientKeyN);
  466. sha256_update(&ctx, clientKey.size, clientKeyE);
  467. sha256_update(&ctx, 4, lenServerKey);
  468. sha256_update(&ctx, serverKey.size, serverKeyN);
  469. sha256_update(&ctx, serverKey.size, serverKeyE);
  470. sha256_digest(&ctx, hashSize, realHash);
  471. }
  472. if (memcmp(hash, realHash, hashSize) != 0)
  473. throw ConnFailedException("hash doesn't match");
  474. return true;
  475. }
  476. void SSecurityRSAAES::clearSecrets()
  477. {
  478. rsa_private_key_clear(&serverKey);
  479. rsa_public_key_clear(&clientKey);
  480. serverKey.size = 0;
  481. clientKey.size = 0;
  482. delete[] serverKeyN;
  483. delete[] serverKeyE;
  484. delete[] clientKeyN;
  485. delete[] clientKeyE;
  486. serverKeyN = NULL;
  487. serverKeyE = NULL;
  488. clientKeyN = NULL;
  489. clientKeyE = NULL;
  490. memset(serverRandom, 0, sizeof(serverRandom));
  491. memset(clientRandom, 0, sizeof(clientRandom));
  492. }
  493. void SSecurityRSAAES::writeSubtype()
  494. {
  495. if (requireUsername)
  496. raos->writeU8(secTypeRA2UserPass);
  497. else
  498. raos->writeU8(secTypeRA2Pass);
  499. raos->flush();
  500. }
  501. bool SSecurityRSAAES::readCredentials()
  502. {
  503. rais->setRestorePoint();
  504. if (!rais->hasData(1))
  505. return false;
  506. uint8_t lenUsername = rais->readU8();
  507. if (!rais->hasDataOrRestore(lenUsername + 1))
  508. return false;
  509. if (!username.buf) {
  510. username.replaceBuf(new char[lenUsername + 1]);
  511. rais->readBytes(username.buf, lenUsername);
  512. username.buf[lenUsername] = 0;
  513. } else {
  514. rais->skip(lenUsername);
  515. }
  516. uint8_t lenPassword = rais->readU8();
  517. if (!rais->hasDataOrRestore(lenPassword))
  518. return false;
  519. password.replaceBuf(new char[lenPassword + 1]);
  520. rais->readBytes(password.buf, lenPassword);
  521. password.buf[lenPassword] = 0;
  522. rais->clearRestorePoint();
  523. return true;
  524. }
  525. void SSecurityRSAAES::verifyUserPass()
  526. {
  527. #ifndef __APPLE__
  528. #ifdef WIN32
  529. WinPasswdValidator* valid = new WinPasswdValidator();
  530. #elif !defined(__APPLE__)
  531. UnixPasswordValidator *valid = new UnixPasswordValidator();
  532. #endif
  533. if (!valid->validate(sc, username.buf, password.buf)) {
  534. delete valid;
  535. throw AuthFailureException("invalid password or username");
  536. }
  537. delete valid;
  538. #else
  539. throw AuthFailureException("No password validator configured");
  540. #endif
  541. }
  542. void SSecurityRSAAES::verifyPass()
  543. {
  544. VncAuthPasswdGetter* pg = &SSecurityVncAuth::vncAuthPasswd;
  545. PlainPasswd passwd, passwdReadOnly;
  546. pg->getVncAuthPasswd(&passwd, &passwdReadOnly);
  547. if (!passwd.buf)
  548. throw AuthFailureException("No password configured for VNC Auth");
  549. if (strcmp(password.buf, passwd.buf) == 0) {
  550. accessRights = SConnection::AccessDefault;
  551. return;
  552. }
  553. if (passwdReadOnly.buf && strcmp(password.buf, passwdReadOnly.buf) == 0) {
  554. accessRights = SConnection::AccessView;
  555. return;
  556. }
  557. throw AuthFailureException();
  558. }
  559. const char* SSecurityRSAAES::getUserName() const
  560. {
  561. return username.buf;
  562. }