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. #if !defined(WIN32) && !defined(__APPLE__)
  39. #include <rfb/UnixPasswordValidator.h>
  40. #endif
  41. #ifdef WIN32
  42. #include <rfb/WinPasswdValidator.h>
  43. #endif
  44. #include <rfb/SSecurityVncAuth.h>
  45. enum {
  46. SendPublicKey,
  47. ReadPublicKey,
  48. ReadRandom,
  49. ReadHash,
  50. ReadCredentials,
  51. };
  52. const int MinKeyLength = 1024;
  53. const int MaxKeyLength = 8192;
  54. const size_t MaxKeyFileSize = 32 * 1024;
  55. using namespace rfb;
  56. StringParameter SSecurityRSAAES::keyFile
  57. ("RSAKey", "Path to the RSA key for the RSA-AES security types in "
  58. "PEM format", "", ConfServer);
  59. BoolParameter SSecurityRSAAES::requireUsername
  60. ("RequireUsername", "Require username for the RSA-AES security types",
  61. false, ConfServer);
  62. SSecurityRSAAES::SSecurityRSAAES(SConnection* sc, rdr::U32 _secType,
  63. int _keySize, bool _isAllEncrypted)
  64. : SSecurity(sc), state(SendPublicKey),
  65. keySize(_keySize), isAllEncrypted(_isAllEncrypted), secType(_secType),
  66. serverKey(), clientKey(),
  67. serverKeyN(NULL), serverKeyE(NULL), clientKeyN(NULL), clientKeyE(NULL),
  68. accessRights(SConnection::AccessDefault),
  69. rais(NULL), raos(NULL), rawis(NULL), rawos(NULL)
  70. {
  71. assert(keySize == 128 || keySize == 256);
  72. }
  73. SSecurityRSAAES::~SSecurityRSAAES()
  74. {
  75. cleanup();
  76. }
  77. void SSecurityRSAAES::cleanup()
  78. {
  79. if (serverKeyN)
  80. delete[] serverKeyN;
  81. if (serverKeyE)
  82. delete[] serverKeyE;
  83. if (clientKeyN)
  84. delete[] clientKeyN;
  85. if (clientKeyE)
  86. delete[] clientKeyE;
  87. if (serverKey.size)
  88. rsa_private_key_clear(&serverKey);
  89. if (clientKey.size)
  90. rsa_public_key_clear(&clientKey);
  91. if (isAllEncrypted && rawis && rawos)
  92. sc->setStreams(rawis, rawos);
  93. if (rais)
  94. delete rais;
  95. if (raos)
  96. delete raos;
  97. }
  98. static inline ssize_t findSubstr(rdr::U8* data, size_t size, const char *pattern)
  99. {
  100. size_t patternLength = strlen(pattern);
  101. for (size_t i = 0; i + patternLength < size; ++i) {
  102. for (size_t j = 0; j < patternLength; ++j)
  103. if (data[i + j] != pattern[j])
  104. goto next;
  105. return i;
  106. next:
  107. continue;
  108. }
  109. return -1;
  110. }
  111. static bool loadPEM(rdr::U8* data, size_t size, const char *begin,
  112. const char *end, rdr::U8** der, size_t *derSize)
  113. {
  114. ssize_t pos1 = findSubstr(data, size, begin);
  115. if (pos1 == -1)
  116. return false;
  117. pos1 += strlen(begin);
  118. ssize_t base64Size = findSubstr(data + pos1, size - pos1, end);
  119. if (base64Size == -1)
  120. return false;
  121. char *derBase64 = (char *)data + pos1;
  122. if (!base64Size)
  123. return false;
  124. *der = new rdr::U8[BASE64_DECODE_LENGTH(base64Size)];
  125. struct base64_decode_ctx ctx;
  126. base64_decode_init(&ctx);
  127. if (!base64_decode_update(&ctx, derSize, *der, base64Size, derBase64))
  128. return false;
  129. if (!base64_decode_final(&ctx))
  130. return false;
  131. return true;
  132. }
  133. void SSecurityRSAAES::loadPrivateKey()
  134. {
  135. FILE* file = fopen(keyFile.getData(), "rb");
  136. if (!file)
  137. throw ConnFailedException("failed to open key file");
  138. fseek(file, 0, SEEK_END);
  139. size_t size = ftell(file);
  140. if (size == 0 || size > MaxKeyFileSize) {
  141. fclose(file);
  142. throw ConnFailedException("size of key file is zero or too big");
  143. }
  144. fseek(file, 0, SEEK_SET);
  145. rdr::U8Array data(size);
  146. if (fread(data.buf, 1, size, file) != size) {
  147. fclose(file);
  148. throw ConnFailedException("failed to read key");
  149. }
  150. fclose(file);
  151. rdr::U8Array der;
  152. size_t derSize;
  153. if (loadPEM(data.buf, size, "-----BEGIN RSA PRIVATE KEY-----\n",
  154. "-----END RSA PRIVATE KEY-----", &der.buf, &derSize)) {
  155. loadPKCS1Key(der.buf, derSize);
  156. return;
  157. }
  158. if (der.buf)
  159. delete[] der.takeBuf();
  160. if (loadPEM(data.buf, size, "-----BEGIN PRIVATE KEY-----\n",
  161. "-----END PRIVATE KEY-----", &der.buf, &derSize)) {
  162. loadPKCS8Key(der.buf, derSize);
  163. return;
  164. }
  165. throw ConnFailedException("failed to import key");
  166. }
  167. void SSecurityRSAAES::loadPKCS1Key(const rdr::U8* data, size_t size)
  168. {
  169. struct rsa_public_key pub;
  170. rsa_private_key_init(&serverKey);
  171. rsa_public_key_init(&pub);
  172. if (!rsa_keypair_from_der(&pub, &serverKey, 0, size, data)) {
  173. rsa_private_key_clear(&serverKey);
  174. rsa_public_key_clear(&pub);
  175. throw ConnFailedException("failed to import key");
  176. }
  177. serverKeyLength = serverKey.size * 8;
  178. serverKeyN = new rdr::U8[serverKey.size];
  179. serverKeyE = new rdr::U8[serverKey.size];
  180. nettle_mpz_get_str_256(serverKey.size, serverKeyN, pub.n);
  181. nettle_mpz_get_str_256(serverKey.size, serverKeyE, pub.e);
  182. rsa_public_key_clear(&pub);
  183. }
  184. void SSecurityRSAAES::loadPKCS8Key(const rdr::U8* data, size_t size)
  185. {
  186. struct asn1_der_iterator i, j;
  187. uint32_t version;
  188. const char* rsaIdentifier = "\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01";
  189. const size_t rsaIdentifierLength = 9;
  190. enum asn1_iterator_result res = asn1_der_iterator_first(&i, size, data);
  191. if (res != ASN1_ITERATOR_CONSTRUCTED)
  192. goto failed;
  193. if (i.type != ASN1_SEQUENCE)
  194. goto failed;
  195. if (asn1_der_decode_constructed_last(&i) != ASN1_ITERATOR_PRIMITIVE)
  196. goto failed;
  197. if (!(i.type == ASN1_INTEGER &&
  198. asn1_der_get_uint32(&i, &version) &&
  199. version == 0))
  200. goto failed;
  201. if (!(asn1_der_iterator_next(&i) == ASN1_ITERATOR_CONSTRUCTED &&
  202. i.type == ASN1_SEQUENCE &&
  203. asn1_der_decode_constructed(&i, &j) == ASN1_ITERATOR_PRIMITIVE &&
  204. j.type == ASN1_IDENTIFIER &&
  205. j.length == rsaIdentifierLength &&
  206. memcmp(j.data, rsaIdentifier, rsaIdentifierLength) == 0))
  207. goto failed;
  208. if (!(asn1_der_iterator_next(&i) == ASN1_ITERATOR_PRIMITIVE &&
  209. i.type == ASN1_OCTETSTRING && i.length))
  210. goto failed;
  211. loadPKCS1Key(i.data, i.length);
  212. return;
  213. failed:
  214. throw ConnFailedException("failed to import key");
  215. }
  216. bool SSecurityRSAAES::processMsg()
  217. {
  218. switch (state) {
  219. case SendPublicKey:
  220. loadPrivateKey();
  221. writePublicKey();
  222. state = ReadPublicKey;
  223. // fall through
  224. case ReadPublicKey:
  225. if (readPublicKey()) {
  226. writeRandom();
  227. state = ReadRandom;
  228. }
  229. return false;
  230. case ReadRandom:
  231. if (readRandom()) {
  232. setCipher();
  233. writeHash();
  234. state = ReadHash;
  235. }
  236. return false;
  237. case ReadHash:
  238. if (readHash()) {
  239. clearSecrets();
  240. writeSubtype();
  241. state = ReadCredentials;
  242. }
  243. return false;
  244. case ReadCredentials:
  245. if (readCredentials()) {
  246. if (requireUsername)
  247. verifyUserPass();
  248. else
  249. verifyPass();
  250. return true;
  251. }
  252. return false;
  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 rdr::U8[size];
  281. clientKeyN = new rdr::U8[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. rdr::U8* buffer = new rdr::U8[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. rdr::U8* buffer = new rdr::U8[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. rdr::U8 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. rdr::U8 hash[32];
  388. size_t len = serverKeyLength;
  389. rdr::U8 lenServerKey[4] = {
  390. (rdr::U8)((len & 0xff000000) >> 24),
  391. (rdr::U8)((len & 0xff0000) >> 16),
  392. (rdr::U8)((len & 0xff00) >> 8),
  393. (rdr::U8)(len & 0xff)
  394. };
  395. len = clientKeyLength;
  396. rdr::U8 lenClientKey[4] = {
  397. (rdr::U8)((len & 0xff000000) >> 24),
  398. (rdr::U8)((len & 0xff0000) >> 16),
  399. (rdr::U8)((len & 0xff00) >> 8),
  400. (rdr::U8)(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. rdr::U8 hash[32];
  432. rdr::U8 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. rdr::U8 lenServerKey[4] = {
  439. (rdr::U8)((len & 0xff000000) >> 24),
  440. (rdr::U8)((len & 0xff0000) >> 16),
  441. (rdr::U8)((len & 0xff00) >> 8),
  442. (rdr::U8)(len & 0xff)
  443. };
  444. len = clientKeyLength;
  445. rdr::U8 lenClientKey[4] = {
  446. (rdr::U8)((len & 0xff000000) >> 24),
  447. (rdr::U8)((len & 0xff0000) >> 16),
  448. (rdr::U8)((len & 0xff00) >> 8),
  449. (rdr::U8)(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. rdr::U8 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. rdr::U8 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. }