tls_srp.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  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 "ssl_locl.h"
  61. #ifndef OPENSSL_NO_SRP
  62. # include <openssl/rand.h>
  63. # include <openssl/srp.h>
  64. # include <openssl/err.h>
  65. int SSL_CTX_SRP_CTX_free(struct ssl_ctx_st *ctx)
  66. {
  67. if (ctx == NULL)
  68. return 0;
  69. OPENSSL_free(ctx->srp_ctx.login);
  70. BN_free(ctx->srp_ctx.N);
  71. BN_free(ctx->srp_ctx.g);
  72. BN_free(ctx->srp_ctx.s);
  73. BN_free(ctx->srp_ctx.B);
  74. BN_free(ctx->srp_ctx.A);
  75. BN_free(ctx->srp_ctx.a);
  76. BN_free(ctx->srp_ctx.b);
  77. BN_free(ctx->srp_ctx.v);
  78. ctx->srp_ctx.TLS_ext_srp_username_callback = NULL;
  79. ctx->srp_ctx.SRP_cb_arg = NULL;
  80. ctx->srp_ctx.SRP_verify_param_callback = NULL;
  81. ctx->srp_ctx.SRP_give_srp_client_pwd_callback = NULL;
  82. ctx->srp_ctx.N = NULL;
  83. ctx->srp_ctx.g = NULL;
  84. ctx->srp_ctx.s = NULL;
  85. ctx->srp_ctx.B = NULL;
  86. ctx->srp_ctx.A = NULL;
  87. ctx->srp_ctx.a = NULL;
  88. ctx->srp_ctx.b = NULL;
  89. ctx->srp_ctx.v = NULL;
  90. ctx->srp_ctx.login = NULL;
  91. ctx->srp_ctx.info = NULL;
  92. ctx->srp_ctx.strength = SRP_MINIMAL_N;
  93. ctx->srp_ctx.srp_Mask = 0;
  94. return (1);
  95. }
  96. int SSL_SRP_CTX_free(struct ssl_st *s)
  97. {
  98. if (s == NULL)
  99. return 0;
  100. OPENSSL_free(s->srp_ctx.login);
  101. BN_free(s->srp_ctx.N);
  102. BN_free(s->srp_ctx.g);
  103. BN_free(s->srp_ctx.s);
  104. BN_free(s->srp_ctx.B);
  105. BN_free(s->srp_ctx.A);
  106. BN_free(s->srp_ctx.a);
  107. BN_free(s->srp_ctx.b);
  108. BN_free(s->srp_ctx.v);
  109. s->srp_ctx.TLS_ext_srp_username_callback = NULL;
  110. s->srp_ctx.SRP_cb_arg = NULL;
  111. s->srp_ctx.SRP_verify_param_callback = NULL;
  112. s->srp_ctx.SRP_give_srp_client_pwd_callback = NULL;
  113. s->srp_ctx.N = NULL;
  114. s->srp_ctx.g = NULL;
  115. s->srp_ctx.s = NULL;
  116. s->srp_ctx.B = NULL;
  117. s->srp_ctx.A = NULL;
  118. s->srp_ctx.a = NULL;
  119. s->srp_ctx.b = NULL;
  120. s->srp_ctx.v = NULL;
  121. s->srp_ctx.login = NULL;
  122. s->srp_ctx.info = NULL;
  123. s->srp_ctx.strength = SRP_MINIMAL_N;
  124. s->srp_ctx.srp_Mask = 0;
  125. return (1);
  126. }
  127. int SSL_SRP_CTX_init(struct ssl_st *s)
  128. {
  129. SSL_CTX *ctx;
  130. if ((s == NULL) || ((ctx = s->ctx) == NULL))
  131. return 0;
  132. s->srp_ctx.SRP_cb_arg = ctx->srp_ctx.SRP_cb_arg;
  133. /* set client Hello login callback */
  134. s->srp_ctx.TLS_ext_srp_username_callback =
  135. ctx->srp_ctx.TLS_ext_srp_username_callback;
  136. /* set SRP N/g param callback for verification */
  137. s->srp_ctx.SRP_verify_param_callback =
  138. ctx->srp_ctx.SRP_verify_param_callback;
  139. /* set SRP client passwd callback */
  140. s->srp_ctx.SRP_give_srp_client_pwd_callback =
  141. ctx->srp_ctx.SRP_give_srp_client_pwd_callback;
  142. s->srp_ctx.N = NULL;
  143. s->srp_ctx.g = NULL;
  144. s->srp_ctx.s = NULL;
  145. s->srp_ctx.B = NULL;
  146. s->srp_ctx.A = NULL;
  147. s->srp_ctx.a = NULL;
  148. s->srp_ctx.b = NULL;
  149. s->srp_ctx.v = NULL;
  150. s->srp_ctx.login = NULL;
  151. s->srp_ctx.info = ctx->srp_ctx.info;
  152. s->srp_ctx.strength = ctx->srp_ctx.strength;
  153. if (((ctx->srp_ctx.N != NULL) &&
  154. ((s->srp_ctx.N = BN_dup(ctx->srp_ctx.N)) == NULL)) ||
  155. ((ctx->srp_ctx.g != NULL) &&
  156. ((s->srp_ctx.g = BN_dup(ctx->srp_ctx.g)) == NULL)) ||
  157. ((ctx->srp_ctx.s != NULL) &&
  158. ((s->srp_ctx.s = BN_dup(ctx->srp_ctx.s)) == NULL)) ||
  159. ((ctx->srp_ctx.B != NULL) &&
  160. ((s->srp_ctx.B = BN_dup(ctx->srp_ctx.B)) == NULL)) ||
  161. ((ctx->srp_ctx.A != NULL) &&
  162. ((s->srp_ctx.A = BN_dup(ctx->srp_ctx.A)) == NULL)) ||
  163. ((ctx->srp_ctx.a != NULL) &&
  164. ((s->srp_ctx.a = BN_dup(ctx->srp_ctx.a)) == NULL)) ||
  165. ((ctx->srp_ctx.v != NULL) &&
  166. ((s->srp_ctx.v = BN_dup(ctx->srp_ctx.v)) == NULL)) ||
  167. ((ctx->srp_ctx.b != NULL) &&
  168. ((s->srp_ctx.b = BN_dup(ctx->srp_ctx.b)) == NULL))) {
  169. SSLerr(SSL_F_SSL_SRP_CTX_INIT, ERR_R_BN_LIB);
  170. goto err;
  171. }
  172. if ((ctx->srp_ctx.login != NULL) &&
  173. ((s->srp_ctx.login = BUF_strdup(ctx->srp_ctx.login)) == NULL)) {
  174. SSLerr(SSL_F_SSL_SRP_CTX_INIT, ERR_R_INTERNAL_ERROR);
  175. goto err;
  176. }
  177. s->srp_ctx.srp_Mask = ctx->srp_ctx.srp_Mask;
  178. return (1);
  179. err:
  180. OPENSSL_free(s->srp_ctx.login);
  181. BN_free(s->srp_ctx.N);
  182. BN_free(s->srp_ctx.g);
  183. BN_free(s->srp_ctx.s);
  184. BN_free(s->srp_ctx.B);
  185. BN_free(s->srp_ctx.A);
  186. BN_free(s->srp_ctx.a);
  187. BN_free(s->srp_ctx.b);
  188. BN_free(s->srp_ctx.v);
  189. return (0);
  190. }
  191. int SSL_CTX_SRP_CTX_init(struct ssl_ctx_st *ctx)
  192. {
  193. if (ctx == NULL)
  194. return 0;
  195. ctx->srp_ctx.SRP_cb_arg = NULL;
  196. /* set client Hello login callback */
  197. ctx->srp_ctx.TLS_ext_srp_username_callback = NULL;
  198. /* set SRP N/g param callback for verification */
  199. ctx->srp_ctx.SRP_verify_param_callback = NULL;
  200. /* set SRP client passwd callback */
  201. ctx->srp_ctx.SRP_give_srp_client_pwd_callback = NULL;
  202. ctx->srp_ctx.N = NULL;
  203. ctx->srp_ctx.g = NULL;
  204. ctx->srp_ctx.s = NULL;
  205. ctx->srp_ctx.B = NULL;
  206. ctx->srp_ctx.A = NULL;
  207. ctx->srp_ctx.a = NULL;
  208. ctx->srp_ctx.b = NULL;
  209. ctx->srp_ctx.v = NULL;
  210. ctx->srp_ctx.login = NULL;
  211. ctx->srp_ctx.srp_Mask = 0;
  212. ctx->srp_ctx.info = NULL;
  213. ctx->srp_ctx.strength = SRP_MINIMAL_N;
  214. return (1);
  215. }
  216. /* server side */
  217. int SSL_srp_server_param_with_username(SSL *s, int *ad)
  218. {
  219. unsigned char b[SSL_MAX_MASTER_KEY_LENGTH];
  220. int al;
  221. *ad = SSL_AD_UNKNOWN_PSK_IDENTITY;
  222. if ((s->srp_ctx.TLS_ext_srp_username_callback != NULL) &&
  223. ((al =
  224. s->srp_ctx.TLS_ext_srp_username_callback(s, ad,
  225. s->srp_ctx.SRP_cb_arg)) !=
  226. SSL_ERROR_NONE))
  227. return al;
  228. *ad = SSL_AD_INTERNAL_ERROR;
  229. if ((s->srp_ctx.N == NULL) ||
  230. (s->srp_ctx.g == NULL) ||
  231. (s->srp_ctx.s == NULL) || (s->srp_ctx.v == NULL))
  232. return SSL3_AL_FATAL;
  233. if (RAND_bytes(b, sizeof(b)) <= 0)
  234. return SSL3_AL_FATAL;
  235. s->srp_ctx.b = BN_bin2bn(b, sizeof(b), NULL);
  236. OPENSSL_cleanse(b, sizeof(b));
  237. /* Calculate: B = (kv + g^b) % N */
  238. return ((s->srp_ctx.B =
  239. SRP_Calc_B(s->srp_ctx.b, s->srp_ctx.N, s->srp_ctx.g,
  240. s->srp_ctx.v)) !=
  241. NULL) ? SSL_ERROR_NONE : SSL3_AL_FATAL;
  242. }
  243. /*
  244. * If the server just has the raw password, make up a verifier entry on the
  245. * fly
  246. */
  247. int SSL_set_srp_server_param_pw(SSL *s, const char *user, const char *pass,
  248. const char *grp)
  249. {
  250. SRP_gN *GN = SRP_get_default_gN(grp);
  251. if (GN == NULL)
  252. return -1;
  253. s->srp_ctx.N = BN_dup(GN->N);
  254. s->srp_ctx.g = BN_dup(GN->g);
  255. if (s->srp_ctx.v != NULL) {
  256. BN_clear_free(s->srp_ctx.v);
  257. s->srp_ctx.v = NULL;
  258. }
  259. if (s->srp_ctx.s != NULL) {
  260. BN_clear_free(s->srp_ctx.s);
  261. s->srp_ctx.s = NULL;
  262. }
  263. if (!SRP_create_verifier_BN
  264. (user, pass, &s->srp_ctx.s, &s->srp_ctx.v, GN->N, GN->g))
  265. return -1;
  266. return 1;
  267. }
  268. int SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g,
  269. BIGNUM *sa, BIGNUM *v, char *info)
  270. {
  271. if (N != NULL) {
  272. if (s->srp_ctx.N != NULL) {
  273. if (!BN_copy(s->srp_ctx.N, N)) {
  274. BN_free(s->srp_ctx.N);
  275. s->srp_ctx.N = NULL;
  276. }
  277. } else
  278. s->srp_ctx.N = BN_dup(N);
  279. }
  280. if (g != NULL) {
  281. if (s->srp_ctx.g != NULL) {
  282. if (!BN_copy(s->srp_ctx.g, g)) {
  283. BN_free(s->srp_ctx.g);
  284. s->srp_ctx.g = NULL;
  285. }
  286. } else
  287. s->srp_ctx.g = BN_dup(g);
  288. }
  289. if (sa != NULL) {
  290. if (s->srp_ctx.s != NULL) {
  291. if (!BN_copy(s->srp_ctx.s, sa)) {
  292. BN_free(s->srp_ctx.s);
  293. s->srp_ctx.s = NULL;
  294. }
  295. } else
  296. s->srp_ctx.s = BN_dup(sa);
  297. }
  298. if (v != NULL) {
  299. if (s->srp_ctx.v != NULL) {
  300. if (!BN_copy(s->srp_ctx.v, v)) {
  301. BN_free(s->srp_ctx.v);
  302. s->srp_ctx.v = NULL;
  303. }
  304. } else
  305. s->srp_ctx.v = BN_dup(v);
  306. }
  307. s->srp_ctx.info = info;
  308. if (!(s->srp_ctx.N) ||
  309. !(s->srp_ctx.g) || !(s->srp_ctx.s) || !(s->srp_ctx.v))
  310. return -1;
  311. return 1;
  312. }
  313. int SRP_generate_server_master_secret(SSL *s, unsigned char *master_key)
  314. {
  315. BIGNUM *K = NULL, *u = NULL;
  316. int ret = -1, tmp_len;
  317. unsigned char *tmp = NULL;
  318. if (!SRP_Verify_A_mod_N(s->srp_ctx.A, s->srp_ctx.N))
  319. goto err;
  320. if (!(u = SRP_Calc_u(s->srp_ctx.A, s->srp_ctx.B, s->srp_ctx.N)))
  321. goto err;
  322. if (!
  323. (K =
  324. SRP_Calc_server_key(s->srp_ctx.A, s->srp_ctx.v, u, s->srp_ctx.b,
  325. s->srp_ctx.N)))
  326. goto err;
  327. tmp_len = BN_num_bytes(K);
  328. if ((tmp = OPENSSL_malloc(tmp_len)) == NULL)
  329. goto err;
  330. BN_bn2bin(K, tmp);
  331. ret =
  332. s->method->ssl3_enc->generate_master_secret(s, master_key, tmp,
  333. tmp_len);
  334. err:
  335. if (tmp) {
  336. OPENSSL_cleanse(tmp, tmp_len);
  337. OPENSSL_free(tmp);
  338. }
  339. BN_clear_free(K);
  340. BN_clear_free(u);
  341. return ret;
  342. }
  343. /* client side */
  344. int SRP_generate_client_master_secret(SSL *s, unsigned char *master_key)
  345. {
  346. BIGNUM *x = NULL, *u = NULL, *K = NULL;
  347. int ret = -1, tmp_len;
  348. char *passwd = NULL;
  349. unsigned char *tmp = NULL;
  350. /*
  351. * Checks if b % n == 0
  352. */
  353. if (SRP_Verify_B_mod_N(s->srp_ctx.B, s->srp_ctx.N) == 0)
  354. goto err;
  355. if (!(u = SRP_Calc_u(s->srp_ctx.A, s->srp_ctx.B, s->srp_ctx.N)))
  356. goto err;
  357. if (s->srp_ctx.SRP_give_srp_client_pwd_callback == NULL)
  358. goto err;
  359. if (!
  360. (passwd =
  361. s->srp_ctx.SRP_give_srp_client_pwd_callback(s,
  362. s->srp_ctx.SRP_cb_arg)))
  363. goto err;
  364. if (!(x = SRP_Calc_x(s->srp_ctx.s, s->srp_ctx.login, passwd)))
  365. goto err;
  366. if (!
  367. (K =
  368. SRP_Calc_client_key(s->srp_ctx.N, s->srp_ctx.B, s->srp_ctx.g, x,
  369. s->srp_ctx.a, u)))
  370. goto err;
  371. tmp_len = BN_num_bytes(K);
  372. if ((tmp = OPENSSL_malloc(tmp_len)) == NULL)
  373. goto err;
  374. BN_bn2bin(K, tmp);
  375. ret =
  376. s->method->ssl3_enc->generate_master_secret(s, master_key, tmp,
  377. tmp_len);
  378. err:
  379. if (tmp) {
  380. OPENSSL_cleanse(tmp, tmp_len);
  381. OPENSSL_free(tmp);
  382. }
  383. BN_clear_free(K);
  384. BN_clear_free(x);
  385. if (passwd) {
  386. OPENSSL_cleanse(passwd, strlen(passwd));
  387. OPENSSL_free(passwd);
  388. }
  389. BN_clear_free(u);
  390. return ret;
  391. }
  392. int srp_verify_server_param(SSL *s, int *al)
  393. {
  394. SRP_CTX *srp = &s->srp_ctx;
  395. /*
  396. * Sanity check parameters: we can quickly check B % N == 0 by checking B
  397. * != 0 since B < N
  398. */
  399. if (BN_ucmp(srp->g, srp->N) >= 0 || BN_ucmp(srp->B, srp->N) >= 0
  400. || BN_is_zero(srp->B)) {
  401. *al = SSL3_AD_ILLEGAL_PARAMETER;
  402. return 0;
  403. }
  404. if (BN_num_bits(srp->N) < srp->strength) {
  405. *al = TLS1_AD_INSUFFICIENT_SECURITY;
  406. return 0;
  407. }
  408. if (srp->SRP_verify_param_callback) {
  409. if (srp->SRP_verify_param_callback(s, srp->SRP_cb_arg) <= 0) {
  410. *al = TLS1_AD_INSUFFICIENT_SECURITY;
  411. return 0;
  412. }
  413. } else if (!SRP_check_known_gN_param(srp->g, srp->N)) {
  414. *al = TLS1_AD_INSUFFICIENT_SECURITY;
  415. return 0;
  416. }
  417. return 1;
  418. }
  419. int SRP_Calc_A_param(SSL *s)
  420. {
  421. unsigned char rnd[SSL_MAX_MASTER_KEY_LENGTH];
  422. if (RAND_bytes(rnd, sizeof(rnd)) <= 0)
  423. return -1;
  424. s->srp_ctx.a = BN_bin2bn(rnd, sizeof(rnd), s->srp_ctx.a);
  425. OPENSSL_cleanse(rnd, sizeof(rnd));
  426. if (!
  427. (s->srp_ctx.A = SRP_Calc_A(s->srp_ctx.a, s->srp_ctx.N, s->srp_ctx.g)))
  428. return -1;
  429. return 1;
  430. }
  431. BIGNUM *SSL_get_srp_g(SSL *s)
  432. {
  433. if (s->srp_ctx.g != NULL)
  434. return s->srp_ctx.g;
  435. return s->ctx->srp_ctx.g;
  436. }
  437. BIGNUM *SSL_get_srp_N(SSL *s)
  438. {
  439. if (s->srp_ctx.N != NULL)
  440. return s->srp_ctx.N;
  441. return s->ctx->srp_ctx.N;
  442. }
  443. char *SSL_get_srp_username(SSL *s)
  444. {
  445. if (s->srp_ctx.login != NULL)
  446. return s->srp_ctx.login;
  447. return s->ctx->srp_ctx.login;
  448. }
  449. char *SSL_get_srp_userinfo(SSL *s)
  450. {
  451. if (s->srp_ctx.info != NULL)
  452. return s->srp_ctx.info;
  453. return s->ctx->srp_ctx.info;
  454. }
  455. # define tls1_ctx_ctrl ssl3_ctx_ctrl
  456. # define tls1_ctx_callback_ctrl ssl3_ctx_callback_ctrl
  457. int SSL_CTX_set_srp_username(SSL_CTX *ctx, char *name)
  458. {
  459. return tls1_ctx_ctrl(ctx, SSL_CTRL_SET_TLS_EXT_SRP_USERNAME, 0, name);
  460. }
  461. int SSL_CTX_set_srp_password(SSL_CTX *ctx, char *password)
  462. {
  463. return tls1_ctx_ctrl(ctx, SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD, 0, password);
  464. }
  465. int SSL_CTX_set_srp_strength(SSL_CTX *ctx, int strength)
  466. {
  467. return tls1_ctx_ctrl(ctx, SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH, strength,
  468. NULL);
  469. }
  470. int SSL_CTX_set_srp_verify_param_callback(SSL_CTX *ctx,
  471. int (*cb) (SSL *, void *))
  472. {
  473. return tls1_ctx_callback_ctrl(ctx, SSL_CTRL_SET_SRP_VERIFY_PARAM_CB,
  474. (void (*)(void))cb);
  475. }
  476. int SSL_CTX_set_srp_cb_arg(SSL_CTX *ctx, void *arg)
  477. {
  478. return tls1_ctx_ctrl(ctx, SSL_CTRL_SET_SRP_ARG, 0, arg);
  479. }
  480. int SSL_CTX_set_srp_username_callback(SSL_CTX *ctx,
  481. int (*cb) (SSL *, int *, void *))
  482. {
  483. return tls1_ctx_callback_ctrl(ctx, SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB,
  484. (void (*)(void))cb);
  485. }
  486. int SSL_CTX_set_srp_client_pwd_callback(SSL_CTX *ctx,
  487. char *(*cb) (SSL *, void *))
  488. {
  489. return tls1_ctx_callback_ctrl(ctx, SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB,
  490. (void (*)(void))cb);
  491. }
  492. #endif