@@ -12759,7 +12759,6 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
1275912759 {
1276012760 int r = 0;
1276112761 SrpSide srp_side = SRP_CLIENT_SIDE;
12762- byte salt[SRP_SALT_SIZE];
1276312762
1276412763 WOLFSSL_ENTER("wolfSSL_CTX_set_srp_username");
1276512764 if (ctx == NULL || ctx->srp == NULL || username==NULL)
@@ -12788,37 +12787,11 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
1278812787 }
1278912788
1279012789 /* if wolfSSL_CTX_set_srp_password has already been called, */
12791- /* execute wc_SrpSetPassword here */
12790+ /* use saved password here */
1279212791 if (ctx->srp_password != NULL) {
12793- WC_RNG rng;
12794- if (wc_InitRng(&rng) < 0){
12795- WOLFSSL_MSG("wc_InitRng failed");
12796- return WOLFSSL_FAILURE;
12797- }
12798- XMEMSET(salt, 0, sizeof(salt)/sizeof(salt[0]));
12799- r = wc_RNG_GenerateBlock(&rng, salt, sizeof(salt)/sizeof(salt[0]));
12800- wc_FreeRng(&rng);
12801- if (r < 0) {
12802- WOLFSSL_MSG("wc_RNG_GenerateBlock failed");
12792+ if (ctx->srp->user == NULL)
1280312793 return WOLFSSL_FAILURE;
12804- }
12805-
12806- if (wc_SrpSetParams(ctx->srp, srp_N, sizeof(srp_N)/sizeof(srp_N[0]),
12807- srp_g, sizeof(srp_g)/sizeof(srp_g[0]),
12808- salt, sizeof(salt)/sizeof(salt[0])) < 0) {
12809- WOLFSSL_MSG("wc_SrpSetParam failed");
12810- return WOLFSSL_FAILURE;
12811- }
12812- r = wc_SrpSetPassword(ctx->srp,
12813- (const byte*)ctx->srp_password,
12814- (word32)XSTRLEN((char *)ctx->srp_password));
12815- if (r < 0) {
12816- WOLFSSL_MSG("fail to set srp password.");
12817- return WOLFSSL_FAILURE;
12818- }
12819-
12820- XFREE(ctx->srp_password, ctx->heap, DYNAMIC_TYPE_SRP);
12821- ctx->srp_password = NULL;
12794+ return wolfSSL_CTX_set_srp_password(ctx, (char*)ctx->srp_password);
1282212795 }
1282312796
1282412797 return WOLFSSL_SUCCESS;
0 commit comments