tls_srp.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. /* ssl/tls_srp.c */
  2. /*
  3. * Written by Christophe Renou (christophe.renou@edelweb.fr) with the
  4. * precious help of Peter Sylvester (peter.sylvester@edelweb.fr) for the
  5. * EdelKey project and contributed to the OpenSSL project 2004.
  6. */
  7. /* ====================================================================
  8. * Copyright (c) 2004-2011 The OpenSSL Project. All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. *
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. *
  17. * 2. Redistributions in binary form must reproduce the above copyright
  18. * notice, this list of conditions and the following disclaimer in
  19. * the documentation and/or other materials provided with the
  20. * distribution.
  21. *
  22. * 3. All advertising materials mentioning features or use of this
  23. * software must display the following acknowledgment:
  24. * "This product includes software developed by the OpenSSL Project
  25. * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
  26. *
  27. * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
  28. * endorse or promote products derived from this software without
  29. * prior written permission. For written permission, please contact
  30. * licensing@OpenSSL.org.
  31. *
  32. * 5. Products derived from this software may not be called "OpenSSL"
  33. * nor may "OpenSSL" appear in their names without prior written
  34. * permission of the OpenSSL Project.
  35. *
  36. * 6. Redistributions of any form whatsoever must retain the following
  37. * acknowledgment:
  38. * "This product includes software developed by the OpenSSL Project
  39. * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
  40. *
  41. * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
  42. * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  43. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  44. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
  45. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  46. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  47. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  48. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  49. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  50. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  51. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  52. * OF THE POSSIBILITY OF SUCH DAMAGE.
  53. * ====================================================================
  54. *
  55. * This product includes cryptographic software written by Eric Young
  56. * (eay@cryptsoft.com). This product includes software written by Tim
  57. * Hudson (tjh@cryptsoft.com).
  58. *
  59. */
  60. #include <openssl/crypto.h>
  61. #include <openssl/rand.h>
  62. #include <openssl/err.h>
  63. #include "ssl_locl.h"
  64. #ifndef OPENSSL_NO_SRP
  65. #include <openssl/srp.h>
  66. int SSL_CTX_SRP_CTX_free(struct ssl_ctx_st *ctx)
  67. {
  68. if (ctx == NULL)
  69. return 0;
  70. OPENSSL_free(ctx->srp_ctx.login);
  71. BN_free(ctx->srp_ctx.N);
  72. BN_free(ctx->srp_ctx.g);
  73. BN_free(ctx->srp_ctx.s);
  74. BN_free(ctx->srp_ctx.B);
  75. BN_free(ctx->srp_ctx.A);
  76. BN_free(ctx->srp_ctx.a);
  77. BN_free(ctx->srp_ctx.b);
  78. BN_free(ctx->srp_ctx.v);
  79. ctx->srp_ctx.TLS_ext_srp_username_callback = NULL;
  80. ctx->srp_ctx.SRP_cb_arg = NULL;
  81. ctx->srp_ctx.SRP_verify_param_callback = NULL;
  82. ctx->srp_ctx.SRP_give_srp_client_pwd_callback = NULL;
  83. ctx->srp_ctx.N = NULL;
  84. ctx->srp_ctx.g = NULL;
  85. ctx->srp_ctx.s = NULL;
  86. ctx->srp_ctx.B = NULL;
  87. ctx->srp_ctx.A = NULL;
  88. ctx->srp_ctx.a = NULL;
  89. ctx->srp_ctx.b = NULL;
  90. ctx->srp_ctx.v = NULL;
  91. ctx->srp_ctx.login = NULL;
  92. ctx->srp_ctx.info = NULL;
  93. ctx->srp_ctx.strength = SRP_MINIMAL_N;
  94. ctx->srp_ctx.srp_Mask = 0;
  95. return (1);
  96. }
  97. int SSL_SRP_CTX_free(struct ssl_st *s)
  98. {
  99. if (s == NULL)
  100. return 0;
  101. OPENSSL_free(s->srp_ctx.login);
  102. BN_free(s->srp_ctx.N);
  103. BN_free(s->srp_ctx.g);
  104. BN_free(s->srp_ctx.s);
  105. BN_free(s->srp_ctx.B);
  106. BN_free(s->srp_ctx.A);
  107. BN_free(s->srp_ctx.a);
  108. BN_free(s->srp_ctx.b);
  109. BN_free(s->srp_ctx.v);
  110. s->srp_ctx.TLS_ext_srp_username_callback = NULL;
  111. s->srp_ctx.SRP_cb_arg = NULL;
  112. s->srp_ctx.SRP_verify_param_callback = NULL;
  113. s->srp_ctx.SRP_give_srp_client_pwd_callback = NULL;
  114. s->srp_ctx.N = NULL;
  115. s->srp_ctx.g = NULL;
  116. s->srp_ctx.s = NULL;
  117. s->srp_ctx.B = NULL;
  118. s->srp_ctx.A = NULL;
  119. s->srp_ctx.a = NULL;
  120. s->srp_ctx.b = NULL;
  121. s->srp_ctx.v = NULL;
  122. s->srp_ctx.login = NULL;
  123. s->srp_ctx.info = NULL;
  124. s->srp_ctx.strength = SRP_MINIMAL_N;
  125. s->srp_ctx.srp_Mask = 0;
  126. return (1);
  127. }
  128. int SSL_SRP_CTX_init(struct ssl_st *s)
  129. {
  130. SSL_CTX *ctx;
  131. if ((s == NULL) || ((ctx = s->ctx) == NULL))
  132. return 0;
  133. s->srp_ctx.SRP_cb_arg = ctx->srp_ctx.SRP_cb_arg;
  134. /* set client Hello login callback */
  135. s->srp_ctx.TLS_ext_srp_username_callback =
  136. ctx->srp_ctx.TLS_ext_srp_username_callback;
  137. /* set SRP N/g param callback for verification */
  138. s->srp_ctx.SRP_verify_param_callback =
  139. ctx->srp_ctx.SRP_verify_param_callback;
  140. /* set SRP client passwd callback */
  141. s->srp_ctx.SRP_give_srp_client_pwd_callback =
  142. ctx->srp_ctx.SRP_give_srp_client_pwd_callback;
  143. s->srp_ctx.N = NULL;
  144. s->srp_ctx.g = NULL;
  145. s->srp_ctx.s = NULL;
  146. s->srp_ctx.B = NULL;
  147. s->srp_ctx.A = NULL;
  148. s->srp_ctx.a = NULL;
  149. s->srp_ctx.b = NULL;
  150. s->srp_ctx.v = NULL;
  151. s->srp_ctx.login = NULL;
  152. s->srp_ctx.info = ctx->srp_ctx.info;
  153. s->srp_ctx.strength = ctx->srp_ctx.strength;
  154. if (((ctx->srp_ctx.N != NULL) &&
  155. ((s->srp_ctx.N = BN_dup(ctx->srp_ctx.N)) == NULL)) ||
  156. ((ctx->srp_ctx.g != NULL) &&
  157. ((s->srp_ctx.g = BN_dup(ctx->srp_ctx.g)) == NULL)) ||
  158. ((ctx->srp_ctx.s != NULL) &&
  159. ((s->srp_ctx.s = BN_dup(ctx->srp_ctx.s)) == NULL)) ||
  160. ((ctx->srp_ctx.B != NULL) &&
  161. ((s->srp_ctx.B = BN_dup(ctx->srp_ctx.B)) == NULL)) ||
  162. ((ctx->srp_ctx.A != NULL) &&
  163. ((s->srp_ctx.A = BN_dup(ctx->srp_ctx.A)) == NULL)) ||
  164. ((ctx->srp_ctx.a != NULL) &&
  165. ((s->srp_ctx.a = BN_dup(ctx->srp_ctx.a)) == NULL)) ||
  166. ((ctx->srp_ctx.v != NULL) &&
  167. ((s->srp_ctx.v = BN_dup(ctx->srp_ctx.v)) == NULL)) ||
  168. ((ctx->srp_ctx.b != NULL) &&
  169. ((s->srp_ctx.b = BN_dup(ctx->srp_ctx.b)) == NULL))) {
  170. SSLerr(SSL_F_SSL_SRP_CTX_INIT, ERR_R_BN_LIB);
  171. goto err;
  172. }
  173. if ((ctx->srp_ctx.login != NULL) &&
  174. ((s->srp_ctx.login = OPENSSL_strdup(ctx->srp_ctx.login)) == NULL)) {
  175. SSLerr(SSL_F_SSL_SRP_CTX_INIT, ERR_R_INTERNAL_ERROR);
  176. goto err;
  177. }
  178. s->srp_ctx.srp_Mask = ctx->srp_ctx.srp_Mask;
  179. return (1);
  180. err:
  181. OPENSSL_free(s->srp_ctx.login);
  182. BN_free(s->srp_ctx.N);
  183. BN_free(s->srp_ctx.g);
  184. BN_free(s->srp_ctx.s);
  185. BN_free(s->srp_ctx.B);
  186. BN_free(s->srp_ctx.A);
  187. BN_free(s->srp_ctx.a);
  188. BN_free(s->srp_ctx.b);
  189. BN_free(s->srp_ctx.v);
  190. return (0);
  191. }
  192. int SSL_CTX_SRP_CTX_init(struct ssl_ctx_st *ctx)
  193. {
  194. if (ctx == NULL)
  195. return 0;
  196. ctx->srp_ctx.SRP_cb_arg = NULL;
  197. /* set client Hello login callback */
  198. ctx->srp_ctx.TLS_ext_srp_username_callback = NULL;
  199. /* set SRP N/g param callback for verification */
  200. ctx->srp_ctx.SRP_verify_param_callback = NULL;
  201. /* set SRP client passwd callback */
  202. ctx->srp_ctx.SRP_give_srp_client_pwd_callback = NULL;
  203. ctx->srp_ctx.N = NULL;
  204. ctx->srp_ctx.g = NULL;
  205. ctx->srp_ctx.s = NULL;
  206. ctx->srp_ctx.B = NULL;
  207. ctx->srp_ctx.A = NULL;
  208. ctx->srp_ctx.a = NULL;
  209. ctx->srp_ctx.b = NULL;
  210. ctx->srp_ctx.v = NULL;
  211. ctx->srp_ctx.login = NULL;
  212. ctx->srp_ctx.srp_Mask = 0;
  213. ctx->srp_ctx.info = NULL;
  214. ctx->srp_ctx.strength = SRP_MINIMAL_N;
  215. return (1);
  216. }
  217. /* server side */
  218. int SSL_srp_server_param_with_username(SSL *s, int *ad)
  219. {
  220. unsigned char b[SSL_MAX_MASTER_KEY_LENGTH];
  221. int al;
  222. *ad = SSL_AD_UNKNOWN_PSK_IDENTITY;
  223. if ((s->srp_ctx.TLS_ext_srp_username_callback != NULL) &&
  224. ((al =
  225. s->srp_ctx.TLS_ext_srp_username_callback(s, ad,
  226. s->srp_ctx.SRP_cb_arg)) !=
  227. SSL_ERROR_NONE))
  228. return al;
  229. *ad = SSL_AD_INTERNAL_ERROR;
  230. if ((s->srp_ctx.N == NULL) ||
  231. (s->srp_ctx.g == NULL) ||
  232. (s->srp_ctx.s == NULL) || (s->srp_ctx.v == NULL))
  233. return SSL3_AL_FATAL;
  234. if (RAND_bytes(b, sizeof(b)) <= 0)
  235. return SSL3_AL_FATAL;
  236. s->srp_ctx.b = BN_bin2bn(b, sizeof(b), NULL);
  237. OPENSSL_cleanse(b, sizeof(b));
  238. /* Calculate: B = (kv + g^b) % N */
  239. return ((s->srp_ctx.B =
  240. SRP_Calc_B(s->srp_ctx.b, s->srp_ctx.N, s->srp_ctx.g,
  241. s->srp_ctx.v)) !=
  242. NULL) ? SSL_ERROR_NONE : SSL3_AL_FATAL;
  243. }
  244. /*
  245. * If the server just has the raw password, make up a verifier entry on the
  246. * fly
  247. */
  248. int SSL_set_srp_server_param_pw(SSL *s, const char *user, const char *pass,
  249. const char *grp)
  250. {
  251. SRP_gN *GN = SRP_get_default_gN(grp);
  252. if (GN == NULL)
  253. return -1;
  254. s->srp_ctx.N = BN_dup(GN->N);
  255. s->srp_ctx.g = BN_dup(GN->g);
  256. BN_clear_free(s->srp_ctx.v);
  257. s->srp_ctx.v = NULL;
  258. BN_clear_free(s->srp_ctx.s);
  259. s->srp_ctx.s = NULL;
  260. if (!SRP_create_verifier_BN
  261. (user, pass, &s->srp_ctx.s, &s->srp_ctx.v, GN->N, GN->g))
  262. return -1;
  263. return 1;
  264. }
  265. int SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g,
  266. BIGNUM *sa, BIGNUM *v, char *info)
  267. {
  268. if (N != NULL) {
  269. if (s->srp_ctx.N != NULL) {
  270. if (!BN_copy(s->srp_ctx.N, N)) {
  271. BN_free(s->srp_ctx.N);
  272. s->srp_ctx.N = NULL;
  273. }
  274. } else
  275. s->srp_ctx.N = BN_dup(N);
  276. }
  277. if (g != NULL) {
  278. if (s->srp_ctx.g != NULL) {
  279. if (!BN_copy(s->srp_ctx.g, g)) {
  280. BN_free(s->srp_ctx.g);
  281. s->srp_ctx.g = NULL;
  282. }
  283. } else
  284. s->srp_ctx.g = BN_dup(g);
  285. }
  286. if (sa != NULL) {
  287. if (s->srp_ctx.s != NULL) {
  288. if (!BN_copy(s->srp_ctx.s, sa)) {
  289. BN_free(s->srp_ctx.s);
  290. s->srp_ctx.s = NULL;
  291. }
  292. } else
  293. s->srp_ctx.s = BN_dup(sa);
  294. }
  295. if (v != NULL) {
  296. if (s->srp_ctx.v != NULL) {
  297. if (!BN_copy(s->srp_ctx.v, v)) {
  298. BN_free(s->srp_ctx.v);
  299. s->srp_ctx.v = NULL;
  300. }
  301. } else
  302. s->srp_ctx.v = BN_dup(v);
  303. }
  304. s->srp_ctx.info = info;
  305. if (!(s->srp_ctx.N) ||
  306. !(s->srp_ctx.g) || !(s->srp_ctx.s) || !(s->srp_ctx.v))
  307. return -1;
  308. return 1;
  309. }
  310. int srp_generate_server_master_secret(SSL *s)
  311. {
  312. BIGNUM *K = NULL, *u = NULL;
  313. int ret = -1, tmp_len = 0;
  314. unsigned char *tmp = NULL;
  315. if (!SRP_Verify_A_mod_N(s->srp_ctx.A, s->srp_ctx.N))
  316. goto err;
  317. if ((u = SRP_Calc_u(s->srp_ctx.A, s->srp_ctx.B, s->srp_ctx.N)) == NULL)
  318. goto err;
  319. if ((K = SRP_Calc_server_key(s->srp_ctx.A, s->srp_ctx.v, u, s->srp_ctx.b,
  320. s->srp_ctx.N)) == NULL)
  321. goto err;
  322. tmp_len = BN_num_bytes(K);
  323. if ((tmp = OPENSSL_malloc(tmp_len)) == NULL)
  324. goto err;
  325. BN_bn2bin(K, tmp);
  326. ret = ssl_generate_master_secret(s, tmp, tmp_len, 1);
  327. err:
  328. BN_clear_free(K);
  329. BN_clear_free(u);
  330. return ret;
  331. }
  332. /* client side */
  333. int srp_generate_client_master_secret(SSL *s)
  334. {
  335. BIGNUM *x = NULL, *u = NULL, *K = NULL;
  336. int ret = -1, tmp_len = 0;
  337. char *passwd = NULL;
  338. unsigned char *tmp = NULL;
  339. /*
  340. * Checks if b % n == 0
  341. */
  342. if (SRP_Verify_B_mod_N(s->srp_ctx.B, s->srp_ctx.N) == 0)
  343. goto err;
  344. if ((u = SRP_Calc_u(s->srp_ctx.A, s->srp_ctx.B, s->srp_ctx.N)) == NULL)
  345. goto err;
  346. if (s->srp_ctx.SRP_give_srp_client_pwd_callback == NULL)
  347. goto err;
  348. if (!
  349. (passwd =
  350. s->srp_ctx.SRP_give_srp_client_pwd_callback(s,
  351. s->srp_ctx.SRP_cb_arg)))
  352. goto err;
  353. if ((x = SRP_Calc_x(s->srp_ctx.s, s->srp_ctx.login, passwd)) == NULL)
  354. goto err;
  355. if ((K = SRP_Calc_client_key(s->srp_ctx.N, s->srp_ctx.B, s->srp_ctx.g, x,
  356. s->srp_ctx.a, u)) == NULL)
  357. goto err;
  358. tmp_len = BN_num_bytes(K);
  359. if ((tmp = OPENSSL_malloc(tmp_len)) == NULL)
  360. goto err;
  361. BN_bn2bin(K, tmp);
  362. ret = ssl_generate_master_secret(s, tmp, tmp_len, 1);
  363. err:
  364. BN_clear_free(K);
  365. BN_clear_free(x);
  366. if (passwd != NULL)
  367. OPENSSL_clear_free(passwd, strlen(passwd));
  368. BN_clear_free(u);
  369. return ret;
  370. }
  371. int srp_verify_server_param(SSL *s, int *al)
  372. {
  373. SRP_CTX *srp = &s->srp_ctx;
  374. /*
  375. * Sanity check parameters: we can quickly check B % N == 0 by checking B
  376. * != 0 since B < N
  377. */
  378. if (BN_ucmp(srp->g, srp->N) >= 0 || BN_ucmp(srp->B, srp->N) >= 0
  379. || BN_is_zero(srp->B)) {
  380. *al = SSL3_AD_ILLEGAL_PARAMETER;
  381. return 0;
  382. }
  383. if (BN_num_bits(srp->N) < srp->strength) {
  384. *al = TLS1_AD_INSUFFICIENT_SECURITY;
  385. return 0;
  386. }
  387. if (srp->SRP_verify_param_callback) {
  388. if (srp->SRP_verify_param_callback(s, srp->SRP_cb_arg) <= 0) {
  389. *al = TLS1_AD_INSUFFICIENT_SECURITY;
  390. return 0;
  391. }
  392. } else if (!SRP_check_known_gN_param(srp->g, srp->N)) {
  393. *al = TLS1_AD_INSUFFICIENT_SECURITY;
  394. return 0;
  395. }
  396. return 1;
  397. }
  398. int SRP_Calc_A_param(SSL *s)
  399. {
  400. unsigned char rnd[SSL_MAX_MASTER_KEY_LENGTH];
  401. if (RAND_bytes(rnd, sizeof(rnd)) <= 0)
  402. return 0;
  403. s->srp_ctx.a = BN_bin2bn(rnd, sizeof(rnd), s->srp_ctx.a);
  404. OPENSSL_cleanse(rnd, sizeof(rnd));
  405. if (!
  406. (s->srp_ctx.A = SRP_Calc_A(s->srp_ctx.a, s->srp_ctx.N, s->srp_ctx.g)))
  407. return 0;
  408. return 1;
  409. }
  410. BIGNUM *SSL_get_srp_g(SSL *s)
  411. {
  412. if (s->srp_ctx.g != NULL)
  413. return s->srp_ctx.g;
  414. return s->ctx->srp_ctx.g;
  415. }
  416. BIGNUM *SSL_get_srp_N(SSL *s)
  417. {
  418. if (s->srp_ctx.N != NULL)
  419. return s->srp_ctx.N;
  420. return s->ctx->srp_ctx.N;
  421. }
  422. char *SSL_get_srp_username(SSL *s)
  423. {
  424. if (s->srp_ctx.login != NULL)
  425. return s->srp_ctx.login;
  426. return s->ctx->srp_ctx.login;
  427. }
  428. char *SSL_get_srp_userinfo(SSL *s)
  429. {
  430. if (s->srp_ctx.info != NULL)
  431. return s->srp_ctx.info;
  432. return s->ctx->srp_ctx.info;
  433. }
  434. # define tls1_ctx_ctrl ssl3_ctx_ctrl
  435. # define tls1_ctx_callback_ctrl ssl3_ctx_callback_ctrl
  436. int SSL_CTX_set_srp_username(SSL_CTX *ctx, char *name)
  437. {
  438. return tls1_ctx_ctrl(ctx, SSL_CTRL_SET_TLS_EXT_SRP_USERNAME, 0, name);
  439. }
  440. int SSL_CTX_set_srp_password(SSL_CTX *ctx, char *password)
  441. {
  442. return tls1_ctx_ctrl(ctx, SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD, 0, password);
  443. }
  444. int SSL_CTX_set_srp_strength(SSL_CTX *ctx, int strength)
  445. {
  446. return tls1_ctx_ctrl(ctx, SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH, strength,
  447. NULL);
  448. }
  449. int SSL_CTX_set_srp_verify_param_callback(SSL_CTX *ctx,
  450. int (*cb) (SSL *, void *))
  451. {
  452. return tls1_ctx_callback_ctrl(ctx, SSL_CTRL_SET_SRP_VERIFY_PARAM_CB,
  453. (void (*)(void))cb);
  454. }
  455. int SSL_CTX_set_srp_cb_arg(SSL_CTX *ctx, void *arg)
  456. {
  457. return tls1_ctx_ctrl(ctx, SSL_CTRL_SET_SRP_ARG, 0, arg);
  458. }
  459. int SSL_CTX_set_srp_username_callback(SSL_CTX *ctx,
  460. int (*cb) (SSL *, int *, void *))
  461. {
  462. return tls1_ctx_callback_ctrl(ctx, SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB,
  463. (void (*)(void))cb);
  464. }
  465. int SSL_CTX_set_srp_client_pwd_callback(SSL_CTX *ctx,
  466. char *(*cb) (SSL *, void *))
  467. {
  468. return tls1_ctx_callback_ctrl(ctx, SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB,
  469. (void (*)(void))cb);
  470. }
  471. #endif