From: "plaisthos (Code Review)" Date: Sat, 7 Oct 2023 13:59:55 +0000 In-Reply-To: References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="otMJG9HrNWk="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: Print server temp key details List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: openvpn-devel --otMJG9HrNWk= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld. Hello flichtenheld,=20 I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/364?usp=3Demail to look at the new patch set (#2). Change subject: Print server temp key details ...................................................................... Print server temp key details Change-Id: Iaf12bb51a2aac7bcf19070f0b56fa3b1a5863bc3 --- M src/openvpn/openssl_compat.h M src/openvpn/ssl_openssl.c 2 files changed, 45 insertions(+), 12 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/64/364/2 diff --git a/src/openvpn/openssl_compat.h b/src/openvpn/openssl_compat.h index efc85d4..ca52145 100644 --- a/src/openvpn/openssl_compat.h +++ b/src/openvpn/openssl_compat.h @@ -117,6 +117,7 @@ #define EVP_CIPHER_CTX_reset EVP_CIPHER_CTX_init #define X509_get0_notBefore X509_get_notBefore #define X509_get0_notAfter X509_get_notAfter +#define SSL_get_peer_tmp_key SSL_get_server_tmp_key /** * Reset a HMAC context diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c index b5cc9a7..b91ea07 100644 --- a/src/openvpn/ssl_openssl.c +++ b/src/openvpn/ssl_openssl.c @@ -2052,18 +2052,11 @@ return ret; } -/** - * Print human readable information about the certifcate into buf - * @param cert the certificate being used - * @param buf output buffer - * @param buflen output buffer length - */ static void -print_cert_details(X509 *cert, char *buf, size_t buflen) +print_pkey_details(EVP_PKEY *pkey, char *buf, size_t buflen) { const char *curve =3D ""; const char *type =3D "(error getting type)"; - EVP_PKEY *pkey =3D X509_get_pubkey(cert); if (pkey =3D=3D NULL) { @@ -2126,6 +2119,23 @@ #endif /* if OPENSSL_VERSION_NUMBER < 0x30000000L */ } + openvpn_snprintf(buf, buflen, "%d bits %s%s", + EVP_PKEY_bits(pkey), type, curve); +} + +/** + * Print human readable information about the certifcate into buf + * @param cert the certificate being used + * @param buf output buffer + * @param buflen output buffer length + */ +static void +print_cert_details(X509 *cert, char *buf, size_t buflen) +{ + EVP_PKEY *pkey =3D X509_get_pubkey(cert); + char pkeybuf[128] =3D { 0 }; + print_pkey_details(pkey, pkeybuf, sizeof(pkeybuf)); + char sig[128] =3D { 0 }; int signature_nid =3D X509_get_signature_nid(cert); if (signature_nid !=3D 0) @@ -2134,8 +2144,27 @@ OBJ_nid2sn(signature_nid)); } - openvpn_snprintf(buf, buflen, ", peer certificate: %d bit %s%s%s", - EVP_PKEY_bits(pkey), type, curve, sig); + openvpn_snprintf(buf, buflen, ", peer certificate: %s%s", + pkeybuf, sig); + + EVP_PKEY_free(pkey); +} + +static void +print_server_tempkey(SSL *ssl, char *buf, size_t buflen) +{ + EVP_PKEY *pkey =3D NULL; + SSL_get_peer_tmp_key(ssl, &pkey); + if (!pkey) + { + return; + } + + char pkeybuf[128] =3D { 0 }; + print_pkey_details(pkey, pkeybuf, sizeof(pkeybuf)); + + openvpn_snprintf(buf, buflen, ", server temp key: %s", + pkeybuf); EVP_PKEY_free(pkey); } @@ -2153,8 +2182,9 @@ const SSL_CIPHER *ciph; char s1[256]; char s2[256]; + char s3[256]; - s1[0] =3D s2[0] =3D 0; + s1[0] =3D s2[0] =3D s3[0] =3D 0; ciph =3D SSL_get_current_cipher(ks_ssl->ssl); openvpn_snprintf(s1, sizeof(s1), "%s %s, cipher %s %s", prefix, @@ -2168,7 +2198,9 @@ print_cert_details(cert, s2, sizeof(s2)); X509_free(cert); } - msg(D_HANDSHAKE, "%s%s", s1, s2); + print_server_tempkey(ks_ssl->ssl, s3, sizeof(s3)); + + msg(D_HANDSHAKE, "%s%s%s", s1, s2, s3); } void -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/364?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: Iaf12bb51a2aac7bcf19070f0b56fa3b1a5863bc3 Gerrit-Change-Number: 364 Gerrit-PatchSet: 2 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld Gerrit-MessageType: newpatchset --otMJG9HrNWk= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld.

plaisthos uploaded patch set #2 to this change.

<= a href=3D"http://gerrit.openvpn.net/c/openvpn/+/364?usp=3Demail">View Chang= e

Print server temp key details

Change-Id: Iaf12bb51a2aac7bcf190= 70f0b56fa3b1a5863bc3
---
M src/openvpn/openssl_compat.h
M src/open= vpn/ssl_openssl.c
2 files changed, 45 insertions(+), 12 deletions(-)
=
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/64/364/=
2
diff --git a/src/openvpn/openssl_compat.h b/src/openvpn/openssl_c=
ompat.h
index efc85d4..ca52145 100644
--- a= /src/openvpn/openssl_compat.h
+++ b/src/openvpn/openssl_com= pat.h
@@ -117,6 +117,7 @@
#define EVP_CIPH= ER_CTX_reset EVP_CIPHER_CTX_init
#define X509_get0_notBefo= re X509_get_notBefore
#define X509_get0_notAfter X509_get_= notAfter
+#define SSL= _get_peer_tmp_key SSL_get_server_tmp_key

= /**
* Reset a HMAC context
diff --git a/= src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c
index= b5cc9a7..b91ea07 100644
--- a/src/openvpn/ssl_openssl.c
+++ b/src/openvpn/ssl_openssl.c
@@ -2052,18 += 2052,11 @@
return ret;
}

-/**
- * Print human readable informatio= n about the certifcate into buf
- * @param cert the certificate being used
- * @param buf output buffer=
- * @param buflen output b= uffer length
- */
static void
-print_cert_details(X509 *cert, char *buf, size_t buflen)
+print_pkey_details(EVP_PKEY *pkey, c= har *buf, size_t buflen)
{
const char= *curve =3D "";
const char *type =3D "(= error getting type)";
- EVP_PKEY *pkey =3D X509_get_pubkey(cert);
=
if (pkey =3D=3D NULL)
{
@@ -2126,6 +2119,23 @@

#endif /* if OPENSSL_VERSION_NUMBE= R < 0x30000000L */
}

+ openvpn_snprintf(buf, buflen= , "%d bits %s%s",
+ EVP_PKEY_bits(pkey), type, curve);
<= span style=3D"color: hsl(120, 100%, 40%);">+}
+
+/**
+ * Print = human readable information about the certifcate into buf
+ * @param cert the certificate be= ing used
+ * @param b= uf output buffer
+ */
+static void
+= print_cert_details(X509 *cert, char *buf, size_t buflen)
+{
+ EVP_PKEY *pkey =3D X509_get_pubkey(cert);
= + char pkeybuf[128] =3D { 0 = };
+ print_pkey_de= tails(pkey, pkeybuf, sizeof(pkeybuf));
+
char sig[128] =3D { 0 }; int signature_nid =3D X509_get_signature_nid(cert);
<= span> if (signature_nid !=3D 0)
@@ -2134,8 +2144,27 @@<= /span>
OBJ_nid2sn(signature_nid));
}

- openvpn_snprintf(buf, buflen, ", peer certificate: %= d bit %s%s%s",
- = EVP_PKEY_bits(pkey), type, curve, sig);
+ openvpn_snprintf(buf, buflen, &q= uot;, peer certificate: %s%s",
+ pkeybuf, sig);
+
+ EVP_PKEY_free(pkey);
+}
+
+static void
+print_server_tempkey(SSL = *ssl, char *buf, size_t buflen)
+{
+ EV= P_PKEY *pkey =3D NULL;
+ if (!pkey)
+ {
+ return;
+ }
+
<= span style=3D"color: hsl(120, 100%, 40%);">+ char pkeybuf[128] =3D { 0 }= ;

+ print_pkey_det= ails(pkey, pkeybuf, sizeof(pkeybuf));
+
+ = openvpn_snprintf(buf, buflen, ", server temp key: %s",<= br>+ pkeybu= f);

EVP_PKEY_free(pkey);
<= span> }

@@ -2153,8 +2182,9 @@
const SS= L_CIPHER *ciph;
char s1[256];
cha= r s2[256];
+ char = s3[256];

- s1[0] =3D s2[0] =3D 0;
+ s1[0] =3D s2[0] =3D s3[0] =3D 0;
ciph = =3D SSL_get_current_cipher(ks_ssl->ssl);
openvpn_sn= printf(s1, sizeof(s1), "%s %s, cipher %s %s",
= prefix,
@@ -2168,7 +2198,9 @@
= print_cert_details(cert, s2, sizeof(s2));
= X509_free(cert);
}
- msg(D_HANDSHAKE, "%s%s", s1, s2);

+ print_server_tempk= ey(ks_ssl->ssl, s3, sizeof(s3));
+
+ = msg(D_HANDSHAKE, "%s%s%s", s1, s2, s3);
}

void

To v= iew, visit change 364. To unsubscribe, or for help writing mail filters, visit <= a href=3D"http://gerrit.openvpn.net/settings">settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iaf12bb51a2aac7bcf19070f0b56= fa3b1a5863bc3
Gerrit-Change-Number: 364
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newpatchset
--otMJG9HrNWk=--