From: "plaisthos (Code Review)"
Date: Wed, 20 Nov 2024 19:56:59 +0000
In-Reply-To:
References:
Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net,
frank@...2641..., max@...2606...
Message-ID: <75c1c258dac39b864977eb43f57ef620f15278a3-EmailReviewComments-HTML@...2715...>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="qCSUov47g3U="; charset=UTF-8
Subject: [Openvpn-devel] [L] Change in openvpn[master]: Implement HKDF
expand function based on RFC 8446
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Cc: MaxF , flichtenheld , openvpn-devel
--qCSUov47g3U=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is currently required from: MaxF, flichtenheld.
plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c=
/openvpn/+/798?usp=3Demail )
Change subject: Implement HKDF expand function based on RFC 8446
......................................................................
Patch Set 4:
(5 comments)
Patchset:
PS4:
Thanks for the review.
File src/openvpn/crypto_epoch.h:
http://gerrit.openvpn.net/c/openvpn/+/798/comment/d8777d7c_f373c906 :
PS4, Line 32: * - salt is always assumed to be zero length (ie not suppor=
ted)
: * - IKM (secret) is assumed to be always 32 bytes
> salt and IKM are arguments for HKDF-Extract, not HKDF-Expand.
You are right. I will remove those as they are not even parameters and we d=
on't use HDKF-Extract at all.
File src/openvpn/crypto_epoch.c:
http://gerrit.openvpn.net/c/openvpn/+/798/comment/496fe9e5_57694e82 :
PS4, Line 67: hmac_ctx_cleanup(hmac_ctx);
: hmac_ctx_free(hmac_ctx);
> Not exactly about this commit itself, but looking at these functions, it'=
s not clear to me why we ne [=E2=80=A6]
mbed TLS needs both:
void
md_ctx_cleanup(mbedtls_md_context_t *ctx)
{
mbedtls_md_free(ctx);
}
void
hmac_ctx_free(mbedtls_md_context_t *ctx)
{
free(ctx);
}
They do different things and you need both otherwise you leave memory behin=
d.
http://gerrit.openvpn.net/c/openvpn/+/798/comment/38a2fb96_8e7628d3 :
PS4, Line 83: }
> We could check label_len and context_len too: [=E2=80=A6]
Acknowledged
http://gerrit.openvpn.net/c/openvpn/+/798/comment/5ded05ce_c4d2d7a5 :
PS4, Line 86: /* 2 byte for the outlen encoded as uint16, 5 bytes for "=
ovpn " */
: int hkdf_label_len =3D 2 + 5 + label_len + context_len;
: struct buffer hkdf_label =3D alloc_buf_gc(hkdf_label_len,=
&gc);
:
:
: buf_write_u16(&hkdf_label, out_len);
: buf_write(&hkdf_label, "ovpn ", 5);
: buf_write(&hkdf_label, label, label_len);
: if (context_len > 0)
: {
: buf_write(&hkdf_label, context, context_len);
: }
> That's not exactly how this works. [=E2=80=A6]
Hm, I know what you are saying, at the same time, TLS 1.3 also doesn't add =
that extra byte for the context length:
https://datatracker.ietf.org/doc/html/rfc8446#section-7.1
I think the label and context is rather theorectical since we a) always hav=
e the same label and b) don't use context at all.
So I can just remove the possibility to use context from this function if t=
hat function if that makes things better. This was intended to do the same =
as TLS 1.3 just with "ovpn " instead of "tls13 "
I think what TLS RFC fails to mention and I also fail to mention is that yo=
u this label construction is a bit brittle in the sense that you have descr=
ibed, ie. you need to ensure that all the labels you are using this functio=
n with are not prefixes of each other.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/798?usp=3Demail
To unsubscribe, or for help writing mail filters, visit http://gerrit.openv=
pn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3a1c6561f4d9a69e2a441d49dff620b4258a1bcc
Gerrit-Change-Number: 798
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos
Gerrit-Reviewer: MaxF
Gerrit-Reviewer: flichtenheld
Gerrit-CC: openvpn-devel
Gerrit-Attention: flichtenheld
Gerrit-Attention: MaxF
Gerrit-Comment-Date: Wed, 20 Nov 2024 19:56:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: MaxF
Gerrit-MessageType: comment
--qCSUov47g3U=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is currently required from: MaxF, flichtenheld.
View C=
hange
5 comments:
salt and IKM are arguments for HKDF-Extract, not HKDF-E=
xpand.
You are right. I will remove those as they are not even parameters a=
nd we don't use HDKF-Extract at all.
File src/openvpn/crypto_epoch.c:
- =
Patch Set #4, Line 67:
hmac_ctx_cleanup(hmac_ctx);
hmac_ctx_free(hmac_ctx);
Not exactly about this commit itself, but loo=
king at these functions, it's not clear to me why we ne [=E2=80=A6]mbe=
d TLS needs both:
void
md_ctx_cleanup(mbedtls_md_context_t *ctx)
{
mbedtls_md_free(ctx);
}
void
hmac_ctx_free(mbedtls_md_cont=
ext_t *ctx)
{
free(ctx);
}
They do different things and you need both=
otherwise you leave memory behind.
Patch Set #4, Line 83:=
}
We could check label_len and context_len too: [=E2=80=A6]
Acknowledge=
d
Patch Set #4, Line 86:
/* 2 byte fo=
r the outlen encoded as uint16, 5 bytes for "ovpn " */
int=
hkdf_label_len =3D 2 + 5 + label_len + context_len;
struct buffer h=
kdf_label =3D alloc_buf_gc(hkdf_label_len, &gc);
buf_wri=
te_u16(&hkdf_label, out_len);
buf_write(&hkdf_label, "o=
vpn ", 5);
buf_write(&hkdf_label, label, label_len);
=
if (context_len > 0)
{
buf_write(&hkdf_label, con=
text, context_len);
}
That'=
;s not exactly how this works. [=E2=80=A6]
Hm, I know what you are saying, =
at the same time, TLS 1.3 also doesn't add that extra byte for the cont=
ext length:
h=
ttps://datatracker.ietf.org/doc/html/rfc8446#section-7.1
I think the label and context i=
s rather theorectical since we a) always have the same label and b) don'=
;t use context at all.
So I can just remove the possibility to use context from this fun=
ction if that function if that makes things better. This was intended to do=
the same as TLS 1.3 just with "ovpn " instead of "tls13 &qu=
ot;
I think w=
hat TLS RFC fails to mention and I also fail to mention is that you this la=
bel construction is a bit brittle in the sense that you have described, ie.=
you need to ensure that all the labels you are using this function with ar=
e not prefixes of each other.
To view, visit change 798. To unsubscribe, or for help writing mail filters, visit settings.
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3a1c6561f4d9a69e2a441d49dff=
620b4258a1bcc
Gerrit-Change-Number: 798
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <arne-openvpn@...1711...=
27...>
Gerrit-Reviewer: MaxF <max@...2606...> <=
/div>
Gerrit-Reviewer: flichtenheld <frank@...2716...=
1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...=
ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...=
41...>
Gerrit-Attention: MaxF <max@...2606...> =
Gerrit-Comment-Date: Wed, 20 Nov 2024 19:56:59=
+0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: MaxF <max@...2606...&g=
t;
Gerrit-MessageType: comment
--qCSUov47g3U=--