supplemental data handshake message

Simon Josefsson simon at josefsson.org
Fri Apr 30 17:08:12 CEST 2010


Carolin Latze <carolin.latze at unifr.ch> writes:

> Hi everybody,
>
> since there seems to be no documentation about how to implement a new
> supplemental data handshake message (except for some comments in
> lib/gnutls_supplemental.c), I have to come up with a new question:
>
> According to lib/gnutls_supplemental.c, an extension that wants to send
> supplemental data has to set the do_send_supplemental flag. Furthermore
> the party expecting supplemental data has to set do_recv_supplemental.
> For my little helloworld extension, I did that in lib/ext_helloworld.c
> in the extension's send and recv method. That seems to work, since the
> debug out tells me, gnutls expects supplemental data. Furthermore, I add
> those two methods to ext_helloworld.c:
>
> int _gnutls_helloworld_supp_recv_params(gnutls_session_t session,const
> opaque *data,size_t _data_size)
> {
>         uint8_t len;
>         ssize_t data_size = _data_size;
>         unsigned char *msg;
>
>         if (data_size > 0)
>         {
>           len = data[0];
>           DECR_LEN (data_size, len);
>           msg=(unsigned char*)malloc(len*sizeof(unsigned char));
>           memcpy(msg,&data[1],len);
>           msg[len]='\0';
>           printf("supp data: %s\n",msg);
>         }
>
>         return 0;


Shouldn't you return the length of parsed data here?  Look at
gnutls_supplemental.c, the function _gnutls_parse_supplemental trusts
your function to return the proper length for incrementing the length
pointer for its parsing code.

Just a quick response, haven't looked into this in detail.

/Simon

>
> }
>
> int _gnutls_helloworld_supp_send_params(gnutls_session_t
> session,gnutls_buffer *buf)
> {
>
>         unsigned char *msg = "supp hello";
>         int len = strlen(msg);
>
>         _gnutls_buffer_init(buf);
>         _gnutls_buffer_append(buf,msg,(uint8_t) len);
>
>         return len;
>
> }
>
> I am sure, I missed something since my GnuTLS client crashes:
>
> EXT[0x8c30378]: Found extension 'SAFE_RENEGOTIATION/65281'
> EXT[0x8c30378]: Found extension 'HELLOWORLD/40'
> received msg: Hello little one
> Safe renegotiation succeeded.
> EXT[0x8c30378]: Expecting supplemental data
> REC[0x8c30378]: Expected Packet[1] Handshake(22) with length: 1
> REC[0x8c30378]: Received Packet[1] Handshake(22) with length: 7
> REC[0x8c30378]: Decrypted Packet[1] Handshake(22) with length: 7
> HSK[0x8c30378]: SUPPLEMENTAL was received [7 bytes]
> ASSERT: gnutls_supplemental.c:183
> ASSERT: gnutls_handshake.c:2650
> ASSERT: gnutls_handshake.c:2783
> ERROR: Handshake failed
>
> Why does he expect a message with length 1? I suspect, that is the
> problem here, right? Any ideas or hints?
>
> Carolin





More information about the Gnutls-help mailing list