Skip to contentSkip to conversation

neatvnc: backport the nettle 4 port and its fixes

PATCH New Alex Kiernan 1 participant 2 messages Nov 24

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 neatvnc: backport the nettle 4 port and its fixes

neatvnc 1.0.4's nettle backend does not build against nettle 4.0, which oe-core now has. Upstream has ported it, and fixed two crashes the port
introduced: the WebSocket handshake passed the hash size where the hash type belongs (a SIGSEGV on every connection), and nettle 4 aborts the Apple Diffie-Hellman login because base16_decode_update() now takes the output buffer's size. None of this is in a release yet.

AI-Generated: Claude Opus 5.5 (Claude Code)

---
 .../0001-Use-nettle-hogweed-version-4.patch   |  83 +++++++++
 ...pto-Remove-hash-digest-size-argument.patch | 160 ++++++++++++++++++
 ...ake-Fix-crypto_hash_many-argument-mi.patch |  27 +++
 ...ypto-fix-base16-decode-buffer-length.patch |  29 ++++
 .../recipes-graphics/neatvnc/neatvnc_1.0.4.bb |   7 +-
 5 files changed, 305 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-graphics/neatvnc/neatvnc/0001-Use-nettle-hogweed-version-4.patch
 create mode 100644 meta-oe/recipes-graphics/neatvnc/neatvnc/0002-crypto-Remove-hash-digest-size-argument.patch
 create mode 100644 meta-oe/recipes-graphics/neatvnc/neatvnc/0003-stream-ws-handshake-Fix-crypto_hash_many-argument-mi.patch
 create mode 100644 meta-oe/recipes-graphics/neatvnc/neatvnc/0004-crypto-fix-base16-decode-buffer-length.patch
meta-oe/recipes-graphics/neatvnc/neatvnc/0001-Use-nettle-hogweed-version-4.patch new file +83 -0
new file mode 100644
index 000000000000..e5335080aaf9
@@ -0,0 +1,83 @@
+From 9056d5fc68c2a84bdbbf089fcbac9e2ba7d093cb Mon Sep 17 00:00:00 2001
+From: Andri Yngvason <[email protected]>
+Date: Sun, 17 May 2026 09:57:07 +0000
+Subject: [PATCH 1/4] Use nettle & hogweed version 4
+
+Upstream-Status: Backport [https://github.com/any1/neatvnc/commit/5b190f0fd9e6]
+Signed-off-by: Alex Kiernan <[email protected]>
+---
+ meson.build                | 6 ++++--
+ src/crypto/nettle/cipher.c | 8 ++++----
+ src/crypto/nettle/hash.c   | 2 +-
+ 3 files changed, 9 insertions(+), 7 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index cf8d67423f9c..b79606729e94 100644
+--- a/meson.build
++++ b/meson.build
+@@ -61,8 +61,10 @@ libm = cc.find_library('m', required: false)
+ pixman = dependency('pixman-1')
+ libturbojpeg = dependency('libturbojpeg', required: get_option('jpeg'))
+ gnutls = dependency('gnutls', required: get_option('tls'))
+-nettle = dependency('nettle', required: get_option('nettle'))
+-hogweed = dependency('hogweed', required: get_option('nettle'))
++nettle = dependency('nettle', required: get_option('nettle'),
++                    version: ['>=4.0', '<5.0'])
++hogweed = dependency('hogweed', required: get_option('nettle'),
++                     version: ['>=4.0', '<5.0'])
+ gmp = dependency('gmp', required: get_option('nettle'))
+ zlib = dependency('zlib')
+ gbm = dependency('gbm', required: get_option('gbm'))
+diff --git a/src/crypto/nettle/cipher.c b/src/crypto/nettle/cipher.c
+index 0dd2262f09cc..6eb8770f2119 100644
+--- a/src/crypto/nettle/cipher.c
++++ b/src/crypto/nettle/cipher.c
+@@ -119,7 +119,7 @@ static bool crypto_cipher_aes_eax_encrypt(struct crypto_cipher* self,
+ 			(uint8_t*)dst->data + dst->len, src);
+ 	dst->len += src_len;
+ 
+-	nettle_eax_aes128_digest(&self->enc_ctx.aes_eax.ctx, 16, mac);
++	nettle_eax_aes128_digest(&self->enc_ctx.aes_eax.ctx, mac);
+ 
+ 	return true;
+ }
+@@ -131,7 +131,7 @@ static ssize_t crypto_cipher_aes_eax_decrypt(struct crypto_cipher* self,
+ 	crypto_aes_eax_update_nonce(&self->dec_ctx.aes_eax);
+ 	nettle_eax_aes128_update(&self->dec_ctx.aes_eax.ctx, ad_len, ad);
+ 	nettle_eax_aes128_decrypt(&self->dec_ctx.aes_eax.ctx, len, dst, src);
+-	nettle_eax_aes128_digest(&self->dec_ctx.aes_eax.ctx, 16, mac);
++	nettle_eax_aes128_digest(&self->dec_ctx.aes_eax.ctx, mac);
+ 	return len;
+ }
+ 
+@@ -179,7 +179,7 @@ static bool crypto_cipher_aes256_eax_encrypt(struct crypto_cipher* self,
+ 			(uint8_t*)dst->data + dst->len, src);
+ 	dst->len += src_len;
+ 
+-	EAX_DIGEST(&self->enc_ctx.aes256_eax.ctx, aes256_encrypt, 16, mac);
++	EAX_DIGEST(&self->enc_ctx.aes256_eax.ctx, aes256_encrypt, mac);
+ 
+ 	return true;
+ }
+@@ -191,7 +191,7 @@ static ssize_t crypto_cipher_aes256_eax_decrypt(struct crypto_cipher* self,
+ 	crypto_aes256_eax_update_nonce(&self->dec_ctx.aes256_eax);
+ 	EAX_UPDATE(&self->dec_ctx.aes256_eax.ctx, aes256_encrypt, ad_len, ad);
+ 	EAX_DECRYPT(&self->dec_ctx.aes256_eax.ctx, aes256_encrypt, len, dst, src);
+-	EAX_DIGEST(&self->dec_ctx.aes256_eax.ctx, aes256_encrypt, 16, mac);
++	EAX_DIGEST(&self->dec_ctx.aes256_eax.ctx, aes256_encrypt, mac);
+ 	return len;
+ }
+ 
+diff --git a/src/crypto/nettle/hash.c b/src/crypto/nettle/hash.c
+index 71318f4a1c0b..9fbfe5f7c717 100644
+--- a/src/crypto/nettle/hash.c
++++ b/src/crypto/nettle/hash.c
+@@ -21,7 +21,7 @@
+ #include <stdlib.h>
+ #include <nettle/md5.h>
+ #include <nettle/sha1.h>
+-#include <nettle/sha.h>
++#include <nettle/sha2.h>
+ 
+ struct crypto_hash {
+ 	union {
meta-oe/recipes-graphics/neatvnc/neatvnc/0002-crypto-Remove-hash-digest-size-argument.patch new file +160 -0

160 lines not on this page · raw message

meta-oe/recipes-graphics/neatvnc/neatvnc/0003-stream-ws-handshake-Fix-crypto_hash_many-argument-mi.patch new file +27 -0
new file mode 100644
index 000000000000..4be9ac9c6d79
@@ -0,0 +1,27 @@
+From 0c1a96814ac70ae59905cfbb013c3d6e3147b703 Mon Sep 17 00:00:00 2001
+From: Andri Yngvason <[email protected]>
+Date: Thu, 30 Jul 2026 10:35:25 +0000
+Subject: [PATCH 3/4] stream: ws: handshake: Fix crypto_hash_many argument
+ mixup
+
+This fixes mistake in f97805deaaea489a1c8c851324163a92a3125195.
+
+Upstream-Status: Backport [https://github.com/any1/neatvnc/commit/8e0d226064d0]
+Signed-off-by: Alex Kiernan <[email protected]>
+---
+ src/stream/ws/handshake.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/stream/ws/handshake.c b/src/stream/ws/handshake.c
+index aa0db3f9f2c2..9cb6f1c58856 100644
+--- a/src/stream/ws/handshake.c
++++ b/src/stream/ws/handshake.c
+@@ -79,7 +79,7 @@ ssize_t ws_handshake(char* output, size_t output_maxlen, const char* input)
+ 		goto failure;
+ 
+ 	uint8_t hash[20];
+-	crypto_hash_many(hash, sizeof(hash), (struct crypto_data_entry[]){
++	crypto_hash_many(hash, CRYPTO_HASH_SHA1, (struct crypto_data_entry[]){
+ 		{ (uint8_t*)challenge, strlen(challenge) },
+ 		{ (uint8_t*)magic_uuid, strlen(magic_uuid) },
+ 		{}
meta-oe/recipes-graphics/neatvnc/neatvnc/0004-crypto-fix-base16-decode-buffer-length.patch new file +29 -0
new file mode 100644
index 000000000000..b550495b7a71
@@ -0,0 +1,29 @@
+From 556ea1d187a70c08c99d0871c8920e3f7874664f Mon Sep 17 00:00:00 2001
+From: Chad Voegele <[email protected]>
+Date: Thu, 11 Jun 2026 12:41:03 +0000
+Subject: [PATCH 4/4] crypto: fix base16 decode buffer length
+
+Upstream-Status: Backport [https://github.com/any1/neatvnc/commit/8057ec4ad673]
+Signed-off-by: Alex Kiernan <[email protected]>
+---
+ src/crypto/nettle/key.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/src/crypto/nettle/key.c b/src/crypto/nettle/key.c
+index 3b69de259436..45e53187fc22 100644
+--- a/src/crypto/nettle/key.c
++++ b/src/crypto/nettle/key.c
+@@ -91,7 +91,7 @@ static void initialise_p(mpz_t p)
+ 		"15728E5A8AACAA68FFFFFFFFFFFFFFFF";
+ 
+ 	char buf[256];
+-	size_t len = 0;
++	size_t len = sizeof(buf);
+ 	struct base16_decode_ctx ctx;
+ 	nettle_base16_decode_init(&ctx);
+ 	nettle_base16_decode_update(&ctx, &len, (uint8_t*)buf, sizeof(s) - 1, s);
+@@ -174,4 +174,3 @@ struct crypto_key* crypto_derive_shared_secret(
+ 
+ 	return shared;
+ }
+-
meta-oe/recipes-graphics/neatvnc/neatvnc_1.0.4.bb +6 -1
index 44e3b156f9b9..c341b21a6405 100644
@@ -4,7 +4,12 @@ HOMEPAGE = "https://github.com/any1/neatvnc"
 LICENSE = "ISC"
 LIC_FILES_CHKSUM = "file://COPYING;md5=94fc374e7174f41e3afe0f027ee59ff7"
 
-SRC_URI = "git://github.com/any1/neatvnc;branch=v1.0;protocol=https;tag=v${PV}"
+SRC_URI = "git://github.com/any1/neatvnc;branch=v1.0;protocol=https;tag=v${PV} \
+           file://0001-Use-nettle-hogweed-version-4.patch \
+           file://0002-crypto-Remove-hash-digest-size-argument.patch \
+           file://0003-stream-ws-handshake-Fix-crypto_hash_many-argument-mi.patch \
+           file://0004-crypto-fix-base16-decode-buffer-length.patch \
+           "
 
 SRCREV = "ffce32d6d04e702d5d8055e28e038c7f68a0caf4"
 
#1 lore raw

PATCH 2/2 neatvnc: drop hogweed from the nettle PACKAGECONFIG

hogweed is a library the nettle recipe builds (libhogweed), not a recipe of its own, so enabling the nettle PACKAGECONFIG failed with "Nothing PROVIDES 'hogweed'". nettle already provides it. With the nettle 4 port backported, neatvnc's nettle backend now builds and links against libnettle and libhogweed.

Fixes cd6cafd1040d ("neatvnc: add nettle PACKAGECONFIG, disabled by default")

AI-Generated: Claude Opus 5.5 (Claude Code)

---
 meta-oe/recipes-graphics/neatvnc/neatvnc_1.0.4.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-oe/recipes-graphics/neatvnc/neatvnc_1.0.4.bb +1 -1
index c341b21a6405..470a80f1152a 100644
@@ -18,7 +18,7 @@ DEPENDS = "libdrm pixman aml zlib"
 
 PACKAGECONFIG ??= ""
 PACKAGECONFIG[tls] = "-Dtls=enabled,-Dtls=disabled,gnutls"
-PACKAGECONFIG[nettle] = "-Dnettle=enabled,-Dnettle=disabled,nettle hogweed gmp"
+PACKAGECONFIG[nettle] = "-Dnettle=enabled,-Dnettle=disabled,nettle gmp"
 PACKAGECONFIG[jpeg] = "-Djpeg=enabled,-Djpeg=disabled,libjpeg-turbo"
 PACKAGECONFIG[examples] = "-Dexamples=true,-Dexamples=false,libpng"
 PACKAGECONFIG[benchmarks] = "-Dbenchmarks=true,-Dbenchmarks=false,libpng"