diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2012-03-05 22:51:04 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2012-03-05 23:00:53 +0100 |
commit | 6afa51a52324f8d9bcb7271008a8b3b1d7adf7e3 (patch) | |
tree | 11807969ab22be7acafda8da25856d5c5831b716 /doc/cha-internals.texi | |
parent | 37791cbe4ed9bafbe6190d3b3429a664a90f8e82 (diff) | |
download | gnutls-6afa51a52324f8d9bcb7271008a8b3b1d7adf7e3.tar.gz |
Some updates on supplemental data handling.
Diffstat (limited to 'doc/cha-internals.texi')
-rw-r--r-- | doc/cha-internals.texi | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/doc/cha-internals.texi b/doc/cha-internals.texi index 2bdb6292bb..69ac8fa13d 100644 --- a/doc/cha-internals.texi +++ b/doc/cha-internals.texi @@ -203,7 +203,7 @@ will be called to deinitialize the extension's private parameters, if any. Note that the conditional @code{ENABLE_FOOBAR} definition should only be used if step 1 with the @code{configure} options has taken place. -@subsubheading Add new files that implement the extension. +@subsubheading Add new files that implement the extension. The functions you are responsible to add are those mentioned in the previous step. They should be added in a file such as @code{ext/@-foobar.c} @@ -324,8 +324,8 @@ API was introduced in. @subheading Adding a new Supplemental Data Handshake Message TLS handshake extensions allow to send so called supplemental data -handshake messages. This short section explains how to implement a -supplemental data handshake message for a given TLS extension. +handshake messages @xcite{RFC4680}. This short section explains how to +implement a supplemental data handshake message for a given TLS extension. First of all, modify your extension @code{foobar} in the way, the that flags @@ -360,25 +360,30 @@ and @funcintref{_foobar_supp_send_params} to @code{_foobar.h} and @example int -_foobar_supp_recv_params(gnutls_session_t session,const opaque *data,size_t _data_size) +_foobar_supp_recv_params(gnutls_session_t session, const opaque *data, size_t _data_size) @{ - uint8_t len = (int) _data_size; + uint8_t len = _data_size; unsigned char *msg; - msg = (unsigned char *)malloc(len*sizeof(unsigned char)); - memcpy(msg,data,len); + msg = gnutls_malloc(len); + if (msg == NULL) return GNUTLS_E_MEMORY_ERROR; + + memcpy(msg, data, len); msg[len]='\0'; + /* do something with msg */ + gnutls_free(msg); + return len; @} int -_foobar_supp_send_params(gnutls_session_t session,gnutls_buffer_st *buf) +_foobar_supp_send_params(gnutls_session_t session, gnutls_buffer_st *buf) @{ unsigned char *msg = "hello world"; int len = strlen(msg); - _gnutls_buffer_append_data_prefix(buf,8,msg,(uint8_t) len); + _gnutls_buffer_append_data_prefix(buf, 8, msg, len); return len; @} |