2
0

tls_srp.c 15 KB

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