Skip to contentSkip to conversation

package/openssh: fix build with LibreSSL

PATCH Applied Thomas Perale via buildroot 1 participant 2 messages Nov 2 – Nov 6

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/openssh: fix build with LibreSSL

Building the OpenSSH package with LibreSSL would fail with the following error message:

```
...
/home/buildroot/instance-0/output-1/host/lib/gcc/aarch64-buildroot-linux-gnu/13.4.0/../../../../aarch64-buildroot-linux-gnu/bin/ld: sshkey.c:(.text+0x61d8): undefined reference to `EC_METHOD_get_field_type'
/home/buildroot/instance-0/output-1/host/lib/gcc/aarch64-buildroot-linux-gnu/13.4.0/../../../../aarch64-buildroot-linux-gnu/bin/ld: ./libssh.a(sshkey.o): in function `sshkey_dump_ec_point':
sshkey.c:(.text+0x6598): undefined reference to `EC_GROUP_method_of'
/home/buildroot/instance-0/output-1/host/lib/gcc/aarch64-buildroot-linux-gnu/13.4.0/../../../../aarch64-buildroot-linux-gnu/bin/ld: sshkey.c:(.text+0x659c): undefined reference to `EC_METHOD_get_field_type'
```

This can be reproduced with the following defconfig:

```
BR2_aarch64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_LIBRESSL=y
BR2_PACKAGE_OPENSSH=y
```

The LibreSSL bump to 4.3.2 in Buildroot [1] made OpenSSH build fail. This has been the case since LibreSSL upstream commit [2].

This error is not present on the master branch as the upstream commit
[3] is already present since OpenSSH v10.0.0.

Backport the upstream commit removing the use of EC_GROUP_method_of() and EC_METHOD_get_field_type(), which are no longer provided by newer LibreSSL releases.

[1] d2423524b9 package/libressl: security bump version to 4.3.2
[2] https://github.com/libressl/openbsd/commit/aea3014df333871d02dc263a69746399371b2009
[3] https://github.com/openssh/openssh-portable/commit/30c746265ebde29806dba77c92fb1fd3803cbf5c

---
 ...-redundant-field-of-definition-check.patch | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 package/openssh/0020-remove-redundant-field-of-definition-check.patch
package/openssh/0020-remove-redundant-field-of-definition-check.patch new file +47 -0
new file mode 100644
index 0000000000..dde0338fff
@@ -0,0 +1,47 @@
+From 30c746265ebde29806dba77c92fb1fd3803cbf5c Mon Sep 17 00:00:00 2001
+From: "[email protected]" <[email protected]>
+Date: Tue, 3 Dec 2024 15:53:51 +0000
+Subject: [PATCH] upstream: Remove redundant field of definition check
+
+This will allow us to get rid of EC_GROUP_method_of() in the near future.
+
+ok djm
+
+OpenBSD-Commit-ID: b4a3d2e00990cf5c2ec6881c21ddca67327c2df8
+Upstream: https://github.com/openssh/openssh-portable/commit/30c746265ebde29806dba77c92fb1fd3803cbf5c
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ sshkey.c | 13 -------------
+ 1 file changed, 13 deletions(-)
+
+diff --git a/sshkey.c b/sshkey.c
+index 73fb89ac27ed..ab80752b8d0b 100644
+--- a/sshkey.c
++++ b/sshkey.c
+@@ -2705,14 +2705,6 @@ sshkey_ec_validate_public(const EC_GROUP *group, const EC_POINT *public)
+ 	 * EC_POINT_oct2point then the caller will need to explicitly check.
+ 	 */
+ 
+-	/*
+-	 * We shouldn't ever hit this case because bignum_get_ecpoint()
+-	 * refuses to load GF2m points.
+-	 */
+-	if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) !=
+-	    NID_X9_62_prime_field)
+-		goto out;
+-
+ 	/* Q != infinity */
+ 	if (EC_POINT_is_at_infinity(group, public))
+ 		goto out;
+@@ -2812,11 +2804,6 @@ sshkey_dump_ec_point(const EC_GROUP *group, const EC_POINT *point)
+ 		fprintf(stderr, "%s: BN_new failed\n", __func__);
+ 		goto out;
+ 	}
+-	if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) !=
+-	    NID_X9_62_prime_field) {
+-		fprintf(stderr, "%s: group is not a prime field\n", __func__);
+-		goto out;
+-	}
+ 	if (EC_POINT_get_affine_coordinates_GFp(group, point,
+ 	    x, y, NULL) != 1) {
+ 		fprintf(stderr, "%s: EC_POINT_get_affine_coordinates_GFp\n",
Signature · 6 lines
2.56.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

In reply of:

Quoted 31 lines

Building the OpenSSH package with LibreSSL would fail with the following error message:

```
...
/home/buildroot/instance-0/output-1/host/lib/gcc/aarch64-buildroot-linux-gnu/13.4.0/../../../../aarch64-buildroot-linux-gnu/bin/ld: sshkey.c:(.text+0x61d8): undefined reference to `EC_METHOD_get_field_type'
/home/buildroot/instance-0/output-1/host/lib/gcc/aarch64-buildroot-linux-gnu/13.4.0/../../../../aarch64-buildroot-linux-gnu/bin/ld: ./libssh.a(sshkey.o): in function `sshkey_dump_ec_point':
sshkey.c:(.text+0x6598): undefined reference to `EC_GROUP_method_of'
/home/buildroot/instance-0/output-1/host/lib/gcc/aarch64-buildroot-linux-gnu/13.4.0/../../../../aarch64-buildroot-linux-gnu/bin/ld: sshkey.c:(.text+0x659c): undefined reference to `EC_METHOD_get_field_type'
```

This can be reproduced with the following defconfig:

```
BR2_aarch64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_LIBRESSL=y
BR2_PACKAGE_OPENSSH=y
```

The LibreSSL bump to 4.3.2 in Buildroot [1] made OpenSSH build fail. This has been the case since LibreSSL upstream commit [2].

This error is not present on the master branch as the upstream commit
[3] is already present since OpenSSH v10.0.0.

Backport the upstream commit removing the use of EC_GROUP_method_of() and EC_METHOD_get_field_type(), which are no longer provided by newer LibreSSL releases.

Quoted 7 lines

[1] d2423524b9 package/libressl: security bump version to 4.3.2
[2] https://github.com/libressl/openbsd/commit/aea3014df333871d02dc263a69746399371b2009
[3] https://github.com/openssh/openssh-portable/commit/30c746265ebde29806dba77c92fb1fd3803cbf5c

Applied to 2025.02.x. Thanks

Quoted 48 lines
---
 ...-redundant-field-of-definition-check.patch | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 package/openssh/0020-remove-redundant-field-of-definition-check.patch
package/openssh/0020-remove-redundant-field-of-definition-check.patch new file +37 -0
new file mode 100644
index 0000000000..dde0338fff
@@ -0,0 +1,47 @@
+From 30c746265ebde29806dba77c92fb1fd3803cbf5c Mon Sep 17 00:00:00 2001
+From: "[email protected]" <[email protected]>
+Date: Tue, 3 Dec 2024 15:53:51 +0000
+Subject: [PATCH] upstream: Remove redundant field of definition check
+
+This will allow us to get rid of EC_GROUP_method_of() in the near future.
+
+ok djm
+
+OpenBSD-Commit-ID: b4a3d2e00990cf5c2ec6881c21ddca67327c2df8
+Upstream: https://github.com/openssh/openssh-portable/commit/30c746265ebde29806dba77c92fb1fd3803cbf5c
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ sshkey.c | 13 -------------
+ 1 file changed, 13 deletions(-)
+
+diff --git a/sshkey.c b/sshkey.c
+index 73fb89ac27ed..ab80752b8d0b 100644
+--- a/sshkey.c
++++ b/sshkey.c
+@@ -2705,14 +2705,6 @@ sshkey_ec_validate_public(const EC_GROUP *group, const EC_POINT *public)
+ 	 * EC_POINT_oct2point then the caller will need to explicitly check.
+ 	 */
+ 
+-	/*
+-	 * We shouldn't ever hit this case because bignum_get_ecpoint()
+-	 * refuses to load GF2m points.
+-	 */
+-	if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) !=
+-	    NID_X9_62_prime_field)
+-		goto out;
+-
+ 	/* Q != infinity */
+ 	if (EC_POINT_is_at_infinity(group, public))
+ 		goto out;
+@@ -2812,11 +2804,6 @@ sshkey_dump_ec_point(const EC_GROUP *group, const EC_POINT *point)
+ 		fprintf(stderr, "%s: BN_new failed\n", __func__);

package/openssh/0020-remove-redundant-field-of-definition-check.patch line 47

Quoted 10 lines
package/openssh/0020-remove-redundant-field-of-definition-check.patch new file +10 -0
+ 		goto out;
+ 	}
+-	if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) !=
+-	    NID_X9_62_prime_field) {
+-		fprintf(stderr, "%s: group is not a prime field\n", __func__);
+-		goto out;
+-	}
+ 	if (EC_POINT_get_affine_coordinates_GFp(group, point,
+ 	    x, y, NULL) != 1) {
+ 		fprintf(stderr, "%s: EC_POINT_get_affine_coordinates_GFp\n",

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot