[gnutls-devel] GnuTLS | Add compress_certificate extension (RFC8879) (!1512)
Read-only notification of GnuTLS library development activities
gnutls-devel at lists.gnutls.org
Tue Feb 22 14:23:23 CET 2022
Daiki Ueno started a new discussion on lib/ext/compress_certificate.c: https://gitlab.com/gnutls/gnutls/-/merge_requests/1512#note_851179706
> + return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
> +
> + for (unsigned i = 0; i < methods_len; ++i) {
> + tmp = _gnutls_compress_certificate_method2num(methods[i]);
> + if (tmp == GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER ||
> + gnutls_compression_get_name(tmp) == NULL)
> + return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
> + _gnutls_write_uint16(tmp, (uint8_t *)(algs + i));
> + }
> +
> + _gnutls_hello_ext_unset_priv(session, GNUTLS_EXTENSION_COMPRESS_CERTIFICATE);
> +
> + priv.data = (unsigned char *)algs;
> + priv.size = methods_len * sizeof(uint16_t);
> +
> + ret = _gnutls_hello_ext_set_datum(session, GNUTLS_EXTENSION_COMPRESS_CERTIFICATE, &priv);
I would suggest using `_gnutls_hello_ext_set_priv` instead of `_gnutls_hello_ext_set_datum`, in a similar manner to `gnutls_alpn_set_protocols`:
```c
typedef struct {
gnutls_compression_method_t methods[MAX_COMPRESS_CERTIFICATE_METHODS];
size_t methods_len;
} compress_certificate_ext_st;
...
compress_certificate_ext_st *priv;
priv = gnutls_malloc(sizeof(*priv));
...
memcpy(priv->methods, ...);
_gnutls_hello_ext_set_priv(..., priv);
```
That way, the conversiosn between `uint8_t *` and `gnutls_compression_method_t *` will be unnecessary.
--
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/merge_requests/1512#note_851179706
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20220222/5ecf1d4b/attachment.html>
More information about the Gnutls-devel
mailing list