X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=ssl%2Ft1_lib.c;h=ed6518166cfacdde6bbf86ea0b3f911ef777d60a;hp=ce9b505dd12b23fe37c824fc66c5ab728dc96d39;hb=a149b2466e8adb97b1fe855d189bac58d3b654dd;hpb=8c93c4dd42e65ef907d012d7be304cec5d2faa12 diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c index ce9b505dd1..ed6518166c 100644 --- a/ssl/t1_lib.c +++ b/ssl/t1_lib.c @@ -341,6 +341,30 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *p, unsigned cha ret += el; } +#ifndef OPENSSL_NO_SRP +#define MIN(x,y) (((x)<(y))?(x):(y)) + /* we add SRP username the first time only if we have one! */ + if (s->srp_ctx.login != NULL) + {/* Add TLS extension SRP username to the Client Hello message */ + int login_len = MIN(strlen(s->srp_ctx.login) + 1, 255); + long lenmax; + + if ((lenmax = limit - ret - 5) < 0) return NULL; + if (login_len > lenmax) return NULL; + if (login_len > 255) + { + SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); + return NULL; + } + s2n(TLSEXT_TYPE_srp,ret); + s2n(login_len+1,ret); + + (*ret++) = (unsigned char) MIN(strlen(s->srp_ctx.login), 254); + memcpy(ret, s->srp_ctx.login, MIN(strlen(s->srp_ctx.login), 254)); + ret+=login_len; + } +#endif + #ifndef OPENSSL_NO_EC if (s->tlsext_ecpointformatlist != NULL && s->version != DTLS1_VERSION) @@ -762,6 +786,19 @@ int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, in } } +#ifndef OPENSSL_NO_SRP + else if (type == TLSEXT_TYPE_srp) + { + if (size > 0) + { + len = data[0]; + if ((s->srp_ctx.login = OPENSSL_malloc(len+1)) == NULL) + return -1; + memcpy(s->srp_ctx.login, &data[1], len); + s->srp_ctx.login[len]='\0'; + } + } +#endif #ifndef OPENSSL_NO_EC else if (type == TLSEXT_TYPE_ec_point_formats &&