srp.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. /*
  2. * Copyright 2004-2021 The OpenSSL Project Authors. All Rights Reserved.
  3. * Copyright (c) 2004, EdelKey Project. All Rights Reserved.
  4. *
  5. * Licensed under the Apache License 2.0 (the "License"). You may not use
  6. * this file except in compliance with the License. You can obtain a copy
  7. * in the file LICENSE in the source distribution or at
  8. * https://www.openssl.org/source/license.html
  9. *
  10. * Originally written by Christophe Renou and Peter Sylvester,
  11. * for the EdelKey project.
  12. */
  13. /* SRP is deprecated, so we're going to have to use some deprecated APIs */
  14. #define OPENSSL_SUPPRESS_DEPRECATED
  15. #include <openssl/opensslconf.h>
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <openssl/conf.h>
  20. #include <openssl/bio.h>
  21. #include <openssl/err.h>
  22. #include <openssl/txt_db.h>
  23. #include <openssl/buffer.h>
  24. #include <openssl/srp.h>
  25. #include "apps.h"
  26. #include "progs.h"
  27. #define BASE_SECTION "srp"
  28. #define CONFIG_FILE "openssl.cnf"
  29. #define ENV_DATABASE "srpvfile"
  30. #define ENV_DEFAULT_SRP "default_srp"
  31. static int get_index(CA_DB *db, char *id, char type)
  32. {
  33. char **pp;
  34. int i;
  35. if (id == NULL)
  36. return -1;
  37. if (type == DB_SRP_INDEX) {
  38. for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) {
  39. pp = sk_OPENSSL_PSTRING_value(db->db->data, i);
  40. if (pp[DB_srptype][0] == DB_SRP_INDEX
  41. && strcmp(id, pp[DB_srpid]) == 0)
  42. return i;
  43. }
  44. } else {
  45. for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) {
  46. pp = sk_OPENSSL_PSTRING_value(db->db->data, i);
  47. if (pp[DB_srptype][0] != DB_SRP_INDEX
  48. && strcmp(id, pp[DB_srpid]) == 0)
  49. return i;
  50. }
  51. }
  52. return -1;
  53. }
  54. static void print_entry(CA_DB *db, int indx, int verbose, char *s)
  55. {
  56. if (indx >= 0 && verbose) {
  57. int j;
  58. char **pp = sk_OPENSSL_PSTRING_value(db->db->data, indx);
  59. BIO_printf(bio_err, "%s \"%s\"\n", s, pp[DB_srpid]);
  60. for (j = 0; j < DB_NUMBER; j++) {
  61. BIO_printf(bio_err, " %d = \"%s\"\n", j, pp[j]);
  62. }
  63. }
  64. }
  65. static void print_index(CA_DB *db, int indexindex, int verbose)
  66. {
  67. print_entry(db, indexindex, verbose, "g N entry");
  68. }
  69. static void print_user(CA_DB *db, int userindex, int verbose)
  70. {
  71. if (verbose > 0) {
  72. char **pp = sk_OPENSSL_PSTRING_value(db->db->data, userindex);
  73. if (pp[DB_srptype][0] != 'I') {
  74. print_entry(db, userindex, verbose, "User entry");
  75. print_entry(db, get_index(db, pp[DB_srpgN], 'I'), verbose,
  76. "g N entry");
  77. }
  78. }
  79. }
  80. static int update_index(CA_DB *db, char **row)
  81. {
  82. char **irow;
  83. int i;
  84. irow = app_malloc(sizeof(*irow) * (DB_NUMBER + 1), "row pointers");
  85. for (i = 0; i < DB_NUMBER; i++)
  86. irow[i] = row[i];
  87. irow[DB_NUMBER] = NULL;
  88. if (!TXT_DB_insert(db->db, irow)) {
  89. BIO_printf(bio_err, "failed to update srpvfile\n");
  90. BIO_printf(bio_err, "TXT_DB error number %ld\n", db->db->error);
  91. OPENSSL_free(irow);
  92. return 0;
  93. }
  94. return 1;
  95. }
  96. static char *lookup_conf(const CONF *conf, const char *section, const char *tag)
  97. {
  98. char *entry = NCONF_get_string(conf, section, tag);
  99. if (entry == NULL)
  100. BIO_printf(bio_err, "variable lookup failed for %s::%s\n", section, tag);
  101. return entry;
  102. }
  103. static char *srp_verify_user(const char *user, const char *srp_verifier,
  104. char *srp_usersalt, const char *g, const char *N,
  105. const char *passin, int verbose)
  106. {
  107. char password[1025];
  108. PW_CB_DATA cb_tmp;
  109. char *verifier = NULL;
  110. char *gNid = NULL;
  111. int len;
  112. cb_tmp.prompt_info = user;
  113. cb_tmp.password = passin;
  114. len = password_callback(password, sizeof(password)-1, 0, &cb_tmp);
  115. if (len > 0) {
  116. password[len] = 0;
  117. if (verbose)
  118. BIO_printf(bio_err,
  119. "Validating\n user=\"%s\"\n srp_verifier=\"%s\"\n srp_usersalt=\"%s\"\n g=\"%s\"\n N=\"%s\"\n",
  120. user, srp_verifier, srp_usersalt, g, N);
  121. if (verbose > 1)
  122. BIO_printf(bio_err, "Pass %s\n", password);
  123. OPENSSL_assert(srp_usersalt != NULL);
  124. if ((gNid = SRP_create_verifier(user, password, &srp_usersalt,
  125. &verifier, N, g)) == NULL) {
  126. BIO_printf(bio_err, "Internal error validating SRP verifier\n");
  127. } else {
  128. if (strcmp(verifier, srp_verifier))
  129. gNid = NULL;
  130. OPENSSL_free(verifier);
  131. }
  132. OPENSSL_cleanse(password, len);
  133. }
  134. return gNid;
  135. }
  136. static char *srp_create_user(char *user, char **srp_verifier,
  137. char **srp_usersalt, char *g, char *N,
  138. char *passout, int verbose)
  139. {
  140. char password[1025];
  141. PW_CB_DATA cb_tmp;
  142. char *gNid = NULL;
  143. char *salt = NULL;
  144. int len;
  145. cb_tmp.prompt_info = user;
  146. cb_tmp.password = passout;
  147. len = password_callback(password, sizeof(password)-1, 1, &cb_tmp);
  148. if (len > 0) {
  149. password[len] = 0;
  150. if (verbose)
  151. BIO_printf(bio_err, "Creating\n user=\"%s\"\n g=\"%s\"\n N=\"%s\"\n",
  152. user, g, N);
  153. if ((gNid = SRP_create_verifier(user, password, &salt,
  154. srp_verifier, N, g)) == NULL) {
  155. BIO_printf(bio_err, "Internal error creating SRP verifier\n");
  156. } else {
  157. *srp_usersalt = salt;
  158. }
  159. OPENSSL_cleanse(password, len);
  160. if (verbose > 1)
  161. BIO_printf(bio_err, "gNid=%s salt =\"%s\"\n verifier =\"%s\"\n",
  162. gNid, salt, *srp_verifier);
  163. }
  164. return gNid;
  165. }
  166. typedef enum OPTION_choice {
  167. OPT_COMMON,
  168. OPT_VERBOSE, OPT_CONFIG, OPT_NAME, OPT_SRPVFILE, OPT_ADD,
  169. OPT_DELETE, OPT_MODIFY, OPT_LIST, OPT_GN, OPT_USERINFO,
  170. OPT_PASSIN, OPT_PASSOUT, OPT_ENGINE, OPT_R_ENUM, OPT_PROV_ENUM
  171. } OPTION_CHOICE;
  172. const OPTIONS srp_options[] = {
  173. {OPT_HELP_STR, 1, '-', "Usage: %s [options] [user...]\n"},
  174. OPT_SECTION("General"),
  175. {"help", OPT_HELP, '-', "Display this summary"},
  176. {"verbose", OPT_VERBOSE, '-', "Talk a lot while doing things"},
  177. {"config", OPT_CONFIG, '<', "A config file"},
  178. {"name", OPT_NAME, 's', "The particular srp definition to use"},
  179. #ifndef OPENSSL_NO_ENGINE
  180. {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
  181. #endif
  182. OPT_SECTION("Action"),
  183. {"add", OPT_ADD, '-', "Add a user and SRP verifier"},
  184. {"modify", OPT_MODIFY, '-', "Modify the SRP verifier of an existing user"},
  185. {"delete", OPT_DELETE, '-', "Delete user from verifier file"},
  186. {"list", OPT_LIST, '-', "List users"},
  187. OPT_SECTION("Configuration"),
  188. {"srpvfile", OPT_SRPVFILE, '<', "The srp verifier file name"},
  189. {"gn", OPT_GN, 's', "Set g and N values to be used for new verifier"},
  190. {"userinfo", OPT_USERINFO, 's', "Additional info to be set for user"},
  191. {"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
  192. {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
  193. OPT_R_OPTIONS,
  194. OPT_PROV_OPTIONS,
  195. OPT_PARAMETERS(),
  196. {"user", 0, 0, "Username(s) to process (optional)"},
  197. {NULL}
  198. };
  199. int srp_main(int argc, char **argv)
  200. {
  201. ENGINE *e = NULL;
  202. CA_DB *db = NULL;
  203. CONF *conf = NULL;
  204. int gNindex = -1, maxgN = -1, ret = 1, errors = 0, verbose = 0, i;
  205. int doupdatedb = 0, mode = OPT_ERR;
  206. char *user = NULL, *passinarg = NULL, *passoutarg = NULL;
  207. char *passin = NULL, *passout = NULL, *gN = NULL, *userinfo = NULL;
  208. char *section = NULL;
  209. char **gNrow = NULL, *configfile = NULL;
  210. char *srpvfile = NULL, **pp, *prog;
  211. OPTION_CHOICE o;
  212. prog = opt_init(argc, argv, srp_options);
  213. while ((o = opt_next()) != OPT_EOF) {
  214. switch (o) {
  215. case OPT_EOF:
  216. case OPT_ERR:
  217. opthelp:
  218. BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
  219. goto end;
  220. case OPT_HELP:
  221. opt_help(srp_options);
  222. ret = 0;
  223. goto end;
  224. case OPT_VERBOSE:
  225. verbose++;
  226. break;
  227. case OPT_CONFIG:
  228. configfile = opt_arg();
  229. break;
  230. case OPT_NAME:
  231. section = opt_arg();
  232. break;
  233. case OPT_SRPVFILE:
  234. srpvfile = opt_arg();
  235. break;
  236. case OPT_ADD:
  237. case OPT_DELETE:
  238. case OPT_MODIFY:
  239. case OPT_LIST:
  240. if (mode != OPT_ERR) {
  241. BIO_printf(bio_err,
  242. "%s: Only one of -add/-delete/-modify/-list\n",
  243. prog);
  244. goto opthelp;
  245. }
  246. mode = o;
  247. break;
  248. case OPT_GN:
  249. gN = opt_arg();
  250. break;
  251. case OPT_USERINFO:
  252. userinfo = opt_arg();
  253. break;
  254. case OPT_PASSIN:
  255. passinarg = opt_arg();
  256. break;
  257. case OPT_PASSOUT:
  258. passoutarg = opt_arg();
  259. break;
  260. case OPT_ENGINE:
  261. e = setup_engine(opt_arg(), 0);
  262. break;
  263. case OPT_R_CASES:
  264. if (!opt_rand(o))
  265. goto end;
  266. break;
  267. case OPT_PROV_CASES:
  268. if (!opt_provider(o))
  269. goto end;
  270. break;
  271. }
  272. }
  273. /* Optional parameters are usernames. */
  274. argc = opt_num_rest();
  275. argv = opt_rest();
  276. if (!app_RAND_load())
  277. goto end;
  278. if (srpvfile != NULL && configfile != NULL) {
  279. BIO_printf(bio_err,
  280. "-srpvfile and -configfile cannot be specified together.\n");
  281. goto end;
  282. }
  283. if (mode == OPT_ERR) {
  284. BIO_printf(bio_err,
  285. "Exactly one of the options -add, -delete, -modify -list must be specified.\n");
  286. goto opthelp;
  287. }
  288. if (mode == OPT_DELETE || mode == OPT_MODIFY || mode == OPT_ADD) {
  289. if (argc == 0) {
  290. BIO_printf(bio_err, "Need at least one user.\n");
  291. goto opthelp;
  292. }
  293. user = *argv++;
  294. }
  295. if ((passinarg != NULL || passoutarg != NULL) && argc != 1) {
  296. BIO_printf(bio_err,
  297. "-passin, -passout arguments only valid with one user.\n");
  298. goto opthelp;
  299. }
  300. if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
  301. BIO_printf(bio_err, "Error getting passwords\n");
  302. goto end;
  303. }
  304. if (srpvfile == NULL) {
  305. if (configfile == NULL)
  306. configfile = default_config_file;
  307. conf = app_load_config_verbose(configfile, verbose);
  308. if (conf == NULL)
  309. goto end;
  310. if (configfile != default_config_file && !app_load_modules(conf))
  311. goto end;
  312. /* Lets get the config section we are using */
  313. if (section == NULL) {
  314. if (verbose)
  315. BIO_printf(bio_err,
  316. "trying to read " ENV_DEFAULT_SRP
  317. " in " BASE_SECTION "\n");
  318. section = lookup_conf(conf, BASE_SECTION, ENV_DEFAULT_SRP);
  319. if (section == NULL)
  320. goto end;
  321. }
  322. app_RAND_load_conf(conf, BASE_SECTION);
  323. if (verbose)
  324. BIO_printf(bio_err,
  325. "trying to read " ENV_DATABASE " in section \"%s\"\n",
  326. section);
  327. srpvfile = lookup_conf(conf, section, ENV_DATABASE);
  328. if (srpvfile == NULL)
  329. goto end;
  330. }
  331. if (verbose)
  332. BIO_printf(bio_err, "Trying to read SRP verifier file \"%s\"\n",
  333. srpvfile);
  334. db = load_index(srpvfile, NULL);
  335. if (db == NULL) {
  336. BIO_printf(bio_err, "Problem with index file: %s (could not load/parse file)\n", srpvfile);
  337. goto end;
  338. }
  339. /* Lets check some fields */
  340. for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) {
  341. pp = sk_OPENSSL_PSTRING_value(db->db->data, i);
  342. if (pp[DB_srptype][0] == DB_SRP_INDEX) {
  343. maxgN = i;
  344. if ((gNindex < 0) && (gN != NULL) && strcmp(gN, pp[DB_srpid]) == 0)
  345. gNindex = i;
  346. print_index(db, i, verbose > 1);
  347. }
  348. }
  349. if (verbose)
  350. BIO_printf(bio_err, "Database initialised\n");
  351. if (gNindex >= 0) {
  352. gNrow = sk_OPENSSL_PSTRING_value(db->db->data, gNindex);
  353. print_entry(db, gNindex, verbose > 1, "Default g and N");
  354. } else if (maxgN > 0 && !SRP_get_default_gN(gN)) {
  355. BIO_printf(bio_err, "No g and N value for index \"%s\"\n", gN);
  356. goto end;
  357. } else {
  358. if (verbose)
  359. BIO_printf(bio_err, "Database has no g N information.\n");
  360. gNrow = NULL;
  361. }
  362. if (verbose > 1)
  363. BIO_printf(bio_err, "Starting user processing\n");
  364. while (mode == OPT_LIST || user != NULL) {
  365. int userindex = -1;
  366. if (user != NULL && verbose > 1)
  367. BIO_printf(bio_err, "Processing user \"%s\"\n", user);
  368. if ((userindex = get_index(db, user, 'U')) >= 0)
  369. print_user(db, userindex, (verbose > 0) || mode == OPT_LIST);
  370. if (mode == OPT_LIST) {
  371. if (user == NULL) {
  372. BIO_printf(bio_err, "List all users\n");
  373. for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++)
  374. print_user(db, i, 1);
  375. } else if (userindex < 0) {
  376. BIO_printf(bio_err,
  377. "user \"%s\" does not exist, ignored. t\n", user);
  378. errors++;
  379. }
  380. } else if (mode == OPT_ADD) {
  381. if (userindex >= 0) {
  382. /* reactivation of a new user */
  383. char **row =
  384. sk_OPENSSL_PSTRING_value(db->db->data, userindex);
  385. BIO_printf(bio_err, "user \"%s\" reactivated.\n", user);
  386. row[DB_srptype][0] = 'V';
  387. doupdatedb = 1;
  388. } else {
  389. char *row[DB_NUMBER];
  390. char *gNid;
  391. row[DB_srpverifier] = NULL;
  392. row[DB_srpsalt] = NULL;
  393. row[DB_srpinfo] = NULL;
  394. if (!
  395. (gNid =
  396. srp_create_user(user, &(row[DB_srpverifier]),
  397. &(row[DB_srpsalt]),
  398. gNrow ? gNrow[DB_srpsalt] : gN,
  399. gNrow ? gNrow[DB_srpverifier] : NULL,
  400. passout, verbose))) {
  401. BIO_printf(bio_err,
  402. "Cannot create srp verifier for user \"%s\", operation abandoned .\n",
  403. user);
  404. errors++;
  405. goto end;
  406. }
  407. row[DB_srpid] = OPENSSL_strdup(user);
  408. row[DB_srptype] = OPENSSL_strdup("v");
  409. row[DB_srpgN] = OPENSSL_strdup(gNid);
  410. if ((row[DB_srpid] == NULL)
  411. || (row[DB_srpgN] == NULL)
  412. || (row[DB_srptype] == NULL)
  413. || (row[DB_srpverifier] == NULL)
  414. || (row[DB_srpsalt] == NULL)
  415. || (userinfo
  416. && ((row[DB_srpinfo] = OPENSSL_strdup(userinfo)) == NULL))
  417. || !update_index(db, row)) {
  418. OPENSSL_free(row[DB_srpid]);
  419. OPENSSL_free(row[DB_srpgN]);
  420. OPENSSL_free(row[DB_srpinfo]);
  421. OPENSSL_free(row[DB_srptype]);
  422. OPENSSL_free(row[DB_srpverifier]);
  423. OPENSSL_free(row[DB_srpsalt]);
  424. goto end;
  425. }
  426. doupdatedb = 1;
  427. }
  428. } else if (mode == OPT_MODIFY) {
  429. if (userindex < 0) {
  430. BIO_printf(bio_err,
  431. "user \"%s\" does not exist, operation ignored.\n",
  432. user);
  433. errors++;
  434. } else {
  435. char **row =
  436. sk_OPENSSL_PSTRING_value(db->db->data, userindex);
  437. char type = row[DB_srptype][0];
  438. if (type == 'v') {
  439. BIO_printf(bio_err,
  440. "user \"%s\" already updated, operation ignored.\n",
  441. user);
  442. errors++;
  443. } else {
  444. char *gNid;
  445. if (row[DB_srptype][0] == 'V') {
  446. int user_gN;
  447. char **irow = NULL;
  448. if (verbose)
  449. BIO_printf(bio_err,
  450. "Verifying password for user \"%s\"\n",
  451. user);
  452. if ((user_gN =
  453. get_index(db, row[DB_srpgN], DB_SRP_INDEX)) >= 0)
  454. irow =
  455. sk_OPENSSL_PSTRING_value(db->db->data,
  456. userindex);
  457. if (!srp_verify_user
  458. (user, row[DB_srpverifier], row[DB_srpsalt],
  459. irow ? irow[DB_srpsalt] : row[DB_srpgN],
  460. irow ? irow[DB_srpverifier] : NULL, passin,
  461. verbose)) {
  462. BIO_printf(bio_err,
  463. "Invalid password for user \"%s\", operation abandoned.\n",
  464. user);
  465. errors++;
  466. goto end;
  467. }
  468. }
  469. if (verbose)
  470. BIO_printf(bio_err, "Password for user \"%s\" ok.\n",
  471. user);
  472. if (!
  473. (gNid =
  474. srp_create_user(user, &(row[DB_srpverifier]),
  475. &(row[DB_srpsalt]),
  476. gNrow ? gNrow[DB_srpsalt] : NULL,
  477. gNrow ? gNrow[DB_srpverifier] : NULL,
  478. passout, verbose))) {
  479. BIO_printf(bio_err,
  480. "Cannot create srp verifier for user \"%s\", operation abandoned.\n",
  481. user);
  482. errors++;
  483. goto end;
  484. }
  485. row[DB_srptype][0] = 'v';
  486. row[DB_srpgN] = OPENSSL_strdup(gNid);
  487. if (row[DB_srpid] == NULL
  488. || row[DB_srpgN] == NULL
  489. || row[DB_srptype] == NULL
  490. || row[DB_srpverifier] == NULL
  491. || row[DB_srpsalt] == NULL
  492. || (userinfo
  493. && ((row[DB_srpinfo] = OPENSSL_strdup(userinfo))
  494. == NULL)))
  495. goto end;
  496. doupdatedb = 1;
  497. }
  498. }
  499. } else if (mode == OPT_DELETE) {
  500. if (userindex < 0) {
  501. BIO_printf(bio_err,
  502. "user \"%s\" does not exist, operation ignored. t\n",
  503. user);
  504. errors++;
  505. } else {
  506. char **xpp = sk_OPENSSL_PSTRING_value(db->db->data, userindex);
  507. BIO_printf(bio_err, "user \"%s\" revoked. t\n", user);
  508. xpp[DB_srptype][0] = 'R';
  509. doupdatedb = 1;
  510. }
  511. }
  512. user = *argv++;
  513. if (user == NULL) {
  514. /* no more processing in any mode if no users left */
  515. break;
  516. }
  517. }
  518. if (verbose)
  519. BIO_printf(bio_err, "User procession done.\n");
  520. if (doupdatedb) {
  521. /* Lets check some fields */
  522. for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) {
  523. pp = sk_OPENSSL_PSTRING_value(db->db->data, i);
  524. if (pp[DB_srptype][0] == 'v') {
  525. pp[DB_srptype][0] = 'V';
  526. print_user(db, i, verbose);
  527. }
  528. }
  529. if (verbose)
  530. BIO_printf(bio_err, "Trying to update srpvfile.\n");
  531. if (!save_index(srpvfile, "new", db))
  532. goto end;
  533. if (verbose)
  534. BIO_printf(bio_err, "Temporary srpvfile created.\n");
  535. if (!rotate_index(srpvfile, "new", "old"))
  536. goto end;
  537. if (verbose)
  538. BIO_printf(bio_err, "srpvfile updated.\n");
  539. }
  540. ret = (errors != 0);
  541. end:
  542. if (errors != 0)
  543. if (verbose)
  544. BIO_printf(bio_err, "User errors %d.\n", errors);
  545. if (verbose)
  546. BIO_printf(bio_err, "SRP terminating with code %d.\n", ret);
  547. OPENSSL_free(passin);
  548. OPENSSL_free(passout);
  549. if (ret)
  550. ERR_print_errors(bio_err);
  551. NCONF_free(conf);
  552. free_index(db);
  553. release_engine(e);
  554. return ret;
  555. }