From: "cron2 (Code Review)" Date: Fri, 18 Oct 2024 07:03:47 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <857ac5d40a49aba11915c4c6969c531c547f0822-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="bqvspbaVtoo="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: Remove unused methods write_key/read_key List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --bqvspbaVtoo= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#2) to the change originally created by= plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/784?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: Remove unused methods write_key/read_key ...................................................................... Remove unused methods write_key/read_key These were used in the key-method 1 that we remove by commit 36bef1b52 in 2020. That commit unfortunately missed that these methods were only used for directly sending/receiving key material over the control channel. Change-Id: Ib480e57b62ea33f2aea52bee895badaf5607b72d Signed-off-by: Arne Schwabe Acked-by: Gert Doering Message-Id: <20241018063123.11631-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29= 595.html Signed-off-by: Gert Doering --- M src/openvpn/crypto.c M src/openvpn/crypto.h 2 files changed, 0 insertions(+), 86 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/84/784/2 diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c index 064e59e..8f34eaa 100644 --- a/src/openvpn/crypto.c +++ b/src/openvpn/crypto.c @@ -1540,87 +1540,6 @@ } } -/* given a key and key_type, write key to buffer */ -bool -write_key(const struct key *key, const struct key_type *kt, - struct buffer *buf) -{ - ASSERT(cipher_kt_key_size(kt->cipher) <=3D MAX_CIPHER_KEY_LENGTH - && md_kt_size(kt->digest) <=3D MAX_HMAC_KEY_LENGTH); - - const uint8_t cipher_length =3D (uint8_t)cipher_kt_key_size(kt->cipher= ); - if (!buf_write(buf, &cipher_length, 1)) - { - return false; - } - - uint8_t hmac_length =3D (uint8_t)md_kt_size(kt->digest); - - if (!buf_write(buf, &hmac_length, 1)) - { - return false; - } - if (!buf_write(buf, key->cipher, cipher_kt_key_size(kt->cipher))) - { - return false; - } - if (!buf_write(buf, key->hmac, hmac_length)) - { - return false; - } - - return true; -} - -/* - * Given a key_type and buffer, read key from buffer. - * Return: 1 on success - * -1 read failure - * 0 on key length mismatch - */ -int -read_key(struct key *key, const struct key_type *kt, struct buffer *buf) -{ - uint8_t cipher_length; - uint8_t hmac_length; - - CLEAR(*key); - if (!buf_read(buf, &cipher_length, 1)) - { - goto read_err; - } - if (!buf_read(buf, &hmac_length, 1)) - { - goto read_err; - } - - if (cipher_length !=3D cipher_kt_key_size(kt->cipher) || hmac_length != =3D md_kt_size(kt->digest)) - { - goto key_len_err; - } - - if (!buf_read(buf, key->cipher, cipher_length)) - { - goto read_err; - } - if (!buf_read(buf, key->hmac, hmac_length)) - { - goto read_err; - } - - return 1; - -read_err: - msg(D_TLS_ERRORS, "TLS Error: error reading key from remote"); - return -1; - -key_len_err: - msg(D_TLS_ERRORS, - "TLS Error: key length mismatch, local cipher/hmac %d/%d, remote c= ipher/hmac %d/%d", - cipher_kt_key_size(kt->cipher), md_kt_size(kt->digest), cipher_len= gth, hmac_length); - return 0; -} - void prng_bytes(uint8_t *output, int len) { diff --git a/src/openvpn/crypto.h b/src/openvpn/crypto.h index d91de74..074dad6 100644 --- a/src/openvpn/crypto.h +++ b/src/openvpn/crypto.h @@ -313,11 +313,6 @@ bool check_key(struct key *key, const struct key_type *kt); -bool write_key(const struct key *key, const struct key_type *kt, - struct buffer *buf); - -int read_key(struct key *key, const struct key_type *kt, struct buffer *bu= f); - /** * Initialize a key_type structure with. * -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/784?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: Ib480e57b62ea33f2aea52bee895badaf5607b72d Gerrit-Change-Number: 784 Gerrit-PatchSet: 2 Gerrit-Owner: plaisthos Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --bqvspbaVtoo= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #2 to the change originally cr= eated by plaisthos.

View Change

The following approvals got outdated= and were removed: Code-Review+2 by cron2

Remove unused methods write_key/read_key

Thes= e were used in the key-method 1 that we remove by commit
36bef1b52 in 20= 20. That commit unfortunately missed that these
methods were only used = for directly sending/receiving key material
over the control channel.
Change-Id: Ib480e57b62ea33f2aea52bee895badaf5607b72d
Signed-off-by:= Arne Schwabe <arne@...1227...>
Acked-by: Gert Doering <gert@...1186...= .1296...>
Message-Id: <20241018063123.11631-1-gert@...1296...><= br>URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/ms= g29595.html
Signed-off-by: Gert Doering <gert@...1296...>
---M src/openvpn/crypto.c
M src/openvpn/crypto.h
2 files changed, 0 in= sertions(+), 86 deletions(-)

git pull ssh://gerrit.openvpn.net:29=
418/openvpn refs/changes/84/784/2
diff --git a/src/openvpn/crypto.c=
 b/src/openvpn/crypto.c
index 064e59e..8f34eaa 100644
--- a/src/openvpn/crypto.c
+++ b/src/openvpn/cry= pto.c
@@ -1540,87 +1540,6 @@
}<= br> }

-/* given a key and key_type, write key to buffer */
-bool

-write_key(const struct key *key, const struct key_type= *kt,
- struct= buffer *buf)
-{=
- ASSERT(cipher_kt_key_siz= e(kt->cipher) <=3D MAX_CIPHER_KEY_LENGTH
- && md_kt_size(kt->digest) &l= t;=3D MAX_HMAC_KEY_LENGTH);
-
- const uint8= _t cipher_length =3D (uint8_t)cipher_kt_key_size(kt->cipher);
= - if (!buf_write(buf, &cip= her_length, 1))
- {<= /span>
- return false;<= /span>
- }
-
- uint8_t hmac_length =3D (uint8_t)md_kt_size(kt->dige= st);
-
- if (!buf_write(buf, &hmac_leng= th, 1))
- {- return false;- }
- if (!buf_write(buf, key->cipher, cipher= _kt_key_size(kt->cipher)))
- {
- = return false;
- }
- if (!buf_write(buf, = key->hmac, hmac_length))
- {
- re= turn false;
- }
-
- return true;
-}
-/*
- * Given a key_type and buffer, read = key from buffer.

- * Re= turn: 1 on success
- * = -1 read failure
= - * 0 on key length mismatch
- */
-int=
-read_key(struct key *= key, const struct key_type *kt, struct buffer *buf)
-{
- uint8_t cipher_length;
- uint8_t hmac_length;
-
- = CLEAR(*key);
- if= (!buf_read(buf, &cipher_length, 1))
- {
- }
- if (!buf= _read(buf, &hmac_length, 1))
- {
- = goto read_err;
- = }
-
- if (cipher_length !=3D cipher_kt_key_= size(kt->cipher) || hmac_length !=3D md_kt_size(kt->digest))- {
- goto key_len_err;
- }
-
- = if (!buf_read(buf, key->cipher, cipher_length))
- {
- goto read_err;
- }
- = if (!buf_read(buf, key->hmac, hmac_length))
- {
- goto read_err;
- }
-
- return 1;
<= span style=3D"color: hsl(0, 100%, 40%);">-

-read_err:
- msg(D_TLS_ERRORS, "TLS Error: error reading key from remo= te");
- return = -1;
-
-key_len_err:
- msg(D_TLS_ERRORS,
- "TLS Error: key length mismatch, lo= cal cipher/hmac %d/%d, remote cipher/hmac %d/%d",
- cipher_kt_key_size(kt->cipher),= md_kt_size(kt->digest), cipher_length, hmac_length);
- return 0;
-}
-
void
prng_bytes(uint8_t *output, = int len)
{
diff --git a/src/openvpn/crypto= .h b/src/openvpn/crypto.h
index d91de74..074dad6 100644
--- a/src/openvpn/crypto.h
+++ b/src/openvpn/c= rypto.h
@@ -313,11 +313,6 @@

bool check_key(struct key *key, const struct key_type *kt);

=
-bool write_key= (const struct key *key, const struct key_type *kt,
- struct buffer *buf);
= -
-int read_key(struct key *key, const struct key_type *= kt, struct buffer *buf);
chang= e 784. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib480e57b62ea33f2aea52bee895= badaf5607b72d
Gerrit-Change-Number: 784
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--bqvspbaVtoo=--