public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/ocaml-ocamlnet] rawhide: Add patch for nettle v4 support (RHBZ#2535189)
@ 2026-09-17  7:30 Richard W.M. Jones
  0 siblings, 0 replies; only message in thread
From: Richard W.M. Jones @ 2026-09-17  7:30 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/ocaml-ocamlnet
Branch : rawhide
Commit : d695da51cdea3a09096ba35889b48834c448dbdc
Author : Richard W.M. Jones <rjones@redhat.com>
Date   : 2026-09-16T21:17:12+01:00
Stats  : +386/-1 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/ocaml-ocamlnet/c/d695da51cdea3a09096ba35889b48834c448dbdc?branch=rawhide

Log:
Add patch for nettle v4 support (RHBZ#2535189)

---
diff --git a/0009-Support-nettle-v4.patch b/0009-Support-nettle-v4.patch
new file mode 100644
index 0000000..4787721
--- /dev/null
+++ b/0009-Support-nettle-v4.patch
@@ -0,0 +1,378 @@
+--- a/code/src/nettls-gnutls/nettle.c
++++ b/code/src/nettls-gnutls/nettle.c
+@@ -6,6 +6,7 @@
+ #include <nettle/nettle-meta.h>
+ #include <nettle/des.h>
+ #include <nettle/blowfish.h>
++#include <nettle/version.h>
+ 
+ #ifdef HAVE_NETTLE_GCM_H
+ #include <nettle/gcm.h>
+@@ -17,7 +18,9 @@ void nettls_init(void);
+ 
+ typedef struct nettle_cipher *net_nettle_cipher_t;
+ typedef void *net_nettle_cipher_ctx_t;
+-typedef void *net_nettle_gcm_aes_ctx_t;
++typedef void *net_nettle_gcm_aes128_ctx_t;
++typedef void *net_nettle_gcm_aes192_ctx_t;
++typedef void *net_nettle_gcm_aes256_ctx_t;
+ 
+ typedef struct nettle_hash *net_nettle_hash_t;
+ typedef void *net_nettle_hash_ctx_t;
+@@ -290,16 +293,52 @@ static void net_ext_ciphers(net_nettle_c
+    nettle-meta.h
+ */
+ 
+-static net_nettle_gcm_aes_ctx_t net_nettle_gcm_aes_init(void) {
++static net_nettle_gcm_aes128_ctx_t net_nettle_gcm_aes128_init(void) {
+ #ifdef HAVE_NETTLE_GCM_H
+-    return caml_stat_alloc(sizeof(struct gcm_aes_ctx));
++    return caml_stat_alloc(sizeof(struct gcm_aes128_ctx));
+ #else
+     return NULL;
+ #endif
+ }
+ 
+ 
+-static int net_have_gcm_aes(void) {
++static int net_have_gcm_aes128(void) {
++#ifdef HAVE_NETTLE_GCM_H
++    return 1;
++#else
++    return 0;
++#endif
++}
++
++
++static net_nettle_gcm_aes192_ctx_t net_nettle_gcm_aes192_init(void) {
++#ifdef HAVE_NETTLE_GCM_H
++    return caml_stat_alloc(sizeof(struct gcm_aes192_ctx));
++#else
++    return NULL;
++#endif
++}
++
++
++static int net_have_gcm_aes192(void) {
++#ifdef HAVE_NETTLE_GCM_H
++    return 1;
++#else
++    return 0;
++#endif
++}
++
++
++static net_nettle_gcm_aes256_ctx_t net_nettle_gcm_aes256_init(void) {
++#ifdef HAVE_NETTLE_GCM_H
++    return caml_stat_alloc(sizeof(struct gcm_aes256_ctx));
++#else
++    return NULL;
++#endif
++}
++
++
++static int net_have_gcm_aes256(void) {
+ #ifdef HAVE_NETTLE_GCM_H
+     return 1;
+ #else
+@@ -341,7 +380,13 @@ static void net_nettle_hash_digest(net_n
+                                    net_nettle_hash_ctx_t ctx,
+                                    unsigned int length,
+                                    uint8_t *dst) {
++#if NETTLE_VERSION_MAJOR >= 4
++    if (length == hash->digest_size) {
++        hash->digest(ctx, dst);
++    }
++#else
+     hash->digest(ctx, length, dst);
++#endif
+ }
+ 
+ #ifndef HAVE_FUN_nettle_get_hashes
+--- a/code/src/nettls-gnutls/nettle.descr
++++ b/code/src/nettls-gnutls/nettle.descr
+@@ -7,7 +7,9 @@
+ let types =
+   [ "net_nettle_cipher_t",          abstract_ptr "net_nettle_destroy_cipher";
+     "net_nettle_cipher_ctx_t",      abstract_ptr "net_nettle_free";
+-    "net_nettle_gcm_aes_ctx_t",     abstract_ptr "net_nettle_free";
++    "net_nettle_gcm_aes128_ctx_t",  abstract_ptr "net_nettle_free";
++    "net_nettle_gcm_aes192_ctx_t",  abstract_ptr "net_nettle_free";
++    "net_nettle_gcm_aes256_ctx_t",  abstract_ptr "net_nettle_free";
+     "net_nettle_hash_t",            abstract_ptr "net_nettle_destroy_hash";
+     "net_nettle_hash_ctx_t",        abstract_ptr "net_nettle_free";
+   ]
+@@ -67,42 +69,110 @@ let functions =
+           1 bigarray dst, \
+           1 bigarray src)";
+     standard
+-      "net_nettle_gcm_aes_ctx_t net_nettle_gcm_aes_init \
++      "net_nettle_gcm_aes128_ctx_t net_nettle_gcm_aes128_init \
+          ()";
+     standard ~optional:true
+-      "void nettle_gcm_aes_set_key \
+-         (net_nettle_gcm_aes_ctx_t ctx, \
+-          1 stringbuf_size key_length, \
++      "void nettle_gcm_aes128_set_key \
++         (net_nettle_gcm_aes128_ctx_t ctx, \
+           1 stringbuf key)";
+     standard ~optional:true
+-      "void nettle_gcm_aes_set_iv \
+-         (net_nettle_gcm_aes_ctx_t ctx, \
++      "void nettle_gcm_aes128_set_iv \
++         (net_nettle_gcm_aes128_ctx_t ctx, \
+           1 stringbuf_size iv_length, \
+           1 stringbuf iv)";
+     standard ~optional:true
+-      "void nettle_gcm_aes_update \
+-         (net_nettle_gcm_aes_ctx_t ctx, \
++      "void nettle_gcm_aes128_update \
++         (net_nettle_gcm_aes128_ctx_t ctx, \
+           1 stringbuf_size data_length, \
+           1 stringbuf data)";
+     standard ~optional:true
+-      "void nettle_gcm_aes_encrypt \
+-         (net_nettle_gcm_aes_ctx_t ctx, \
++      "void nettle_gcm_aes128_encrypt \
++         (net_nettle_gcm_aes128_ctx_t ctx, \
+           uint length, \
+           1 bigarray dst, \
+           1 bigarray src)";
+     standard ~optional:true
+-      "void nettle_gcm_aes_decrypt \
+-         (net_nettle_gcm_aes_ctx_t ctx, \
++      "void nettle_gcm_aes128_decrypt \
++         (net_nettle_gcm_aes128_ctx_t ctx, \
+           uint length, \
+           1 bigarray dst, \
+           1 bigarray src)";
+     standard ~optional:true
+-      "void nettle_gcm_aes_digest \
+-         (net_nettle_gcm_aes_ctx_t ctx, \
+-          1 stringbuf_size length, \
++      "void nettle_gcm_aes128_digest \
++         (net_nettle_gcm_aes128_ctx_t ctx, \
+           1 stringbuf mac)";
+     standard
+-      "bool net_have_gcm_aes()";
++      "bool net_have_gcm_aes128()";
++    standard
++      "net_nettle_gcm_aes192_ctx_t net_nettle_gcm_aes192_init \
++         ()";
++    standard ~optional:true
++      "void nettle_gcm_aes192_set_key \
++         (net_nettle_gcm_aes192_ctx_t ctx, \
++          1 stringbuf key)";
++    standard ~optional:true
++      "void nettle_gcm_aes192_set_iv \
++         (net_nettle_gcm_aes192_ctx_t ctx, \
++          1 stringbuf_size iv_length, \
++          1 stringbuf iv)";
++    standard ~optional:true
++      "void nettle_gcm_aes192_update \
++         (net_nettle_gcm_aes192_ctx_t ctx, \
++          1 stringbuf_size data_length, \
++          1 stringbuf data)";
++    standard ~optional:true
++      "void nettle_gcm_aes192_encrypt \
++         (net_nettle_gcm_aes192_ctx_t ctx, \
++          uint length, \
++          1 bigarray dst, \
++          1 bigarray src)";
++    standard ~optional:true
++      "void nettle_gcm_aes192_decrypt \
++         (net_nettle_gcm_aes192_ctx_t ctx, \
++          uint length, \
++          1 bigarray dst, \
++          1 bigarray src)";
++    standard ~optional:true
++      "void nettle_gcm_aes192_digest \
++         (net_nettle_gcm_aes192_ctx_t ctx, \
++          1 stringbuf mac)";
++    standard
++      "bool net_have_gcm_aes192()";
++    standard
++      "net_nettle_gcm_aes256_ctx_t net_nettle_gcm_aes256_init \
++         ()";
++    standard ~optional:true
++      "void nettle_gcm_aes256_set_key \
++         (net_nettle_gcm_aes256_ctx_t ctx, \
++          1 stringbuf key)";
++    standard ~optional:true
++      "void nettle_gcm_aes256_set_iv \
++         (net_nettle_gcm_aes256_ctx_t ctx, \
++          1 stringbuf_size iv_length, \
++          1 stringbuf iv)";
++    standard ~optional:true
++      "void nettle_gcm_aes256_update \
++         (net_nettle_gcm_aes256_ctx_t ctx, \
++          1 stringbuf_size data_length, \
++          1 stringbuf data)";
++    standard ~optional:true
++      "void nettle_gcm_aes256_encrypt \
++         (net_nettle_gcm_aes256_ctx_t ctx, \
++          uint length, \
++          1 bigarray dst, \
++          1 bigarray src)";
++    standard ~optional:true
++      "void nettle_gcm_aes256_decrypt \
++         (net_nettle_gcm_aes256_ctx_t ctx, \
++          uint length, \
++          1 bigarray dst, \
++          1 bigarray src)";
++    standard ~optional:true
++      "void nettle_gcm_aes256_digest \
++         (net_nettle_gcm_aes256_ctx_t ctx, \
++          1 stringbuf mac)";
++    standard
++      "bool net_have_gcm_aes256()";
+     standard
+       "void net_nettle_hashes \
+          (OUT net_nettle_hash_t array hash_list, \
+--- a/code/src/nettls-gnutls/nettle.ml
++++ b/code/src/nettls-gnutls/nettle.ml
+@@ -1,5 +1,96 @@
+ (* This file is included into nettls_nettle_bindings.ml *)
+ 
++type net_nettle_gcm_aesX_ctx_t =
++  | GCM_AES_NO_KEY
++  | GCM_AES128 of net_nettle_gcm_aes128_ctx_t
++  | GCM_AES192 of net_nettle_gcm_aes192_ctx_t
++  | GCM_AES256 of net_nettle_gcm_aes256_ctx_t
++
++type net_nettle_gcm_aes_ctx_t =
++  { mutable context : net_nettle_gcm_aesX_ctx_t }
++
++let net_nettle_gcm_aes_init() =
++  { context = GCM_AES_NO_KEY }
++
++let nettle_gcm_aes_set_key ctx by =
++  match Bytes.length by with
++    | 16 ->
++        let c = net_nettle_gcm_aes128_init() in
++        nettle_gcm_aes128_set_key c by;
++        ctx.context <- GCM_AES128 c
++    | 24 ->
++        let c = net_nettle_gcm_aes192_init() in
++        nettle_gcm_aes192_set_key c by;
++        ctx.context <- GCM_AES192 c
++    | 32 ->
++        let c = net_nettle_gcm_aes256_init() in
++        nettle_gcm_aes256_set_key c by;
++        ctx.context <- GCM_AES256 c
++    | _ ->
++        failwith "Nettls_nettle_bindings.nettle_gcm_aes_set_key: bad length"
++
++let nettle_gcm_aes_set_iv ctx by =
++  if Bytes.length by <> 12 then
++    failwith "Nettls_nettle_bindings.nettle_gcm_aes_set_iv: bad length";
++  match ctx.context with
++    | GCM_AES_NO_KEY ->
++        failwith "Nettls_nettle_bindings.nettle_gcm_aes_set_iv: you need to set the key before the initialization vector"
++    | GCM_AES128 c ->
++        nettle_gcm_aes128_set_iv c by
++    | GCM_AES192 c ->
++        nettle_gcm_aes192_set_iv c by
++    | GCM_AES256 c ->
++        nettle_gcm_aes256_set_iv c by
++
++let nettle_gcm_aes_update ctx by =
++  match ctx.context with
++    | GCM_AES_NO_KEY ->
++        failwith "Nettls_nettle_bindings.nettle_gcm_aes_update: you need to set the key before the update"
++    | GCM_AES128 c ->
++        nettle_gcm_aes128_update c by
++    | GCM_AES192 c ->
++        nettle_gcm_aes192_update c by
++    | GCM_AES256 c ->
++        nettle_gcm_aes256_update c by
++
++let nettle_gcm_aes_encrypt ctx n mem1 mem2 =
++  match ctx.context with
++    | GCM_AES_NO_KEY ->
++        failwith "Nettls_nettle_bindings.nettle_gcm_aes_encrypt: you need to set the key before encrypting"
++    | GCM_AES128 c ->
++        nettle_gcm_aes128_encrypt c n mem1 mem2
++    | GCM_AES192 c ->
++        nettle_gcm_aes192_encrypt c n mem1 mem2
++    | GCM_AES256 c ->
++        nettle_gcm_aes256_encrypt c n mem1 mem2
++
++let nettle_gcm_aes_decrypt ctx n mem1 mem2 =
++  match ctx.context with
++    | GCM_AES_NO_KEY ->
++        failwith "Nettls_nettle_bindings.nettle_gcm_aes_decrypt: you need to set the key before devrypting"
++    | GCM_AES128 c ->
++        nettle_gcm_aes128_decrypt c n mem1 mem2
++    | GCM_AES192 c ->
++        nettle_gcm_aes192_decrypt c n mem1 mem2
++    | GCM_AES256 c ->
++        nettle_gcm_aes256_decrypt c n mem1 mem2
++
++let nettle_gcm_aes_digest ctx by =
++  if Bytes.length by <> 16 then
++    failwith "Nettls_nettle_bindings.nettle_gcm_aes_digest: bad length";
++  match ctx.context with
++    | GCM_AES_NO_KEY ->
++        failwith "Nettls_nettle_bindings.nettle_gcm_aes_digest: you need to set the key before digesting"
++    | GCM_AES128 c ->
++        nettle_gcm_aes128_digest c by
++    | GCM_AES192 c ->
++        nettle_gcm_aes192_digest c by
++    | GCM_AES256 c ->
++        nettle_gcm_aes256_digest c by
++
++let net_have_gcm_aes() = net_have_gcm_aes128()
++
++
+ exception Null_pointer = Nettls_gnutls_bindings.Null_pointer
+ 
+ let () =
+--- a/code/src/nettls-gnutls/nettle.mli
++++ b/code/src/nettls-gnutls/nettle.mli
+@@ -1,2 +1,16 @@
+ (* This file is included into nettls_nettle_bindings.mli *)
+ 
++type net_nettle_gcm_aes_ctx_t
++
++val net_nettle_gcm_aes_init : unit -> net_nettle_gcm_aes_ctx_t
++val nettle_gcm_aes_set_key : net_nettle_gcm_aes_ctx_t -> bytes -> unit
++val nettle_gcm_aes_set_iv : net_nettle_gcm_aes_ctx_t -> bytes -> unit
++val nettle_gcm_aes_update : net_nettle_gcm_aes_ctx_t -> bytes -> unit
++val nettle_gcm_aes_digest : net_nettle_gcm_aes_ctx_t -> bytes -> unit
++val nettle_gcm_aes_encrypt : net_nettle_gcm_aes_ctx_t ->
++                             int -> Netsys_mem.memory ->
++                             Netsys_mem.memory -> unit
++val nettle_gcm_aes_decrypt : net_nettle_gcm_aes_ctx_t ->
++                             int -> Netsys_mem.memory ->
++                             Netsys_mem.memory -> unit
++val net_have_gcm_aes : unit -> bool
+--- a/code/tools/stubgen.ml
++++ b/code/tools/stubgen.ml
+@@ -1029,7 +1029,7 @@ let gen_fun c mli ml name args directive
+                   
+              | `Stringbuf id ->
+                   let code1 =
+-                    [ sprintf "%s = String_val(%s);" n1 n ] in
++                    [ sprintf "%s = (void *) String_val(%s);" n1 n ] in
+                   c_code_pre := List.rev code1 @ !c_code_pre;
+              | `Stringbuf_size id ->
+                   let (n_array,_,_,_,_) =
+@@ -1050,7 +1050,7 @@ let gen_fun c mli ml name args directive
+ 
+              | `ZTStringbuf id ->
+                   let code1 =
+-                    [ sprintf "%s = String_val(%s);" n1 n ] in
++                    [ sprintf "%s = (void *) String_val(%s);" n1 n ] in
+                   c_code_pre := List.rev code1 @ !c_code_pre;
+ 
+              | `ZTStringbuf_size id ->
+@@ -1373,7 +1373,7 @@ let gen_fun c mli ml name args directive
+               ret_var ret_var;
+       fprintf c "    %s = caml_alloc_string(%s__c);\n"
+               n_strbuf n_strbuf_size;
+-      fprintf c "    %s__c = String_val(%s);\n" n_strbuf n_strbuf;
++      fprintf c "    %s__c = (char *) String_val(%s);\n" n_strbuf n_strbuf;
+       fprintf c "    ";
+       emit_call();
+       fprintf c "  };\n";

diff --git a/ocaml-ocamlnet.spec b/ocaml-ocamlnet.spec
index 5492d9e..cecc9b6 100644
--- a/ocaml-ocamlnet.spec
+++ b/ocaml-ocamlnet.spec
@@ -3,7 +3,7 @@ ExcludeArch: %{ix86}
 
 Name:           ocaml-ocamlnet
 Version:        4.1.9
-Release:        35%{?dist}
+Release:        36%{?dist}
 Summary:        Network protocols for OCaml
 License:        BSD-3-Clause
 
@@ -32,6 +32,10 @@ Patch:          0006-Further-OCaml-5-changes.patch
 Patch:          0007-netsys_c.h-Don-t-redefine-caml_ba_element_size.patch
 Patch:          0008-configure-Assume-we-have-the-Bytes-type-immutable-st.patch
 
+# Support for nettle v4
+# https://bugzilla.redhat.com/show_bug.cgi?id=2535189#c2
+Patch:          0009-Support-nettle-v4.patch
+
 BuildRequires:  make
 BuildRequires:  ocaml >= 4.07.0
 BuildRequires:  ocaml-ocamldoc
@@ -264,6 +268,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/rpc-generator/dummy.mli
 
 
 %changelog
+* Wed Sep 16 2026 Richard W.M. Jones <rjones@redhat.com> - 4.1.9-36
+- Add patch for nettle v4 support (RHBZ#2535189)
+
 * Tue Sep 15 2026 Richard W.M. Jones <rjones@redhat.com> - 4.1.9-35
 - OCaml 5.5.1 rebuild
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-17  7:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17  7:30 [rpms/ocaml-ocamlnet] rawhide: Add patch for nettle v4 support (RHBZ#2535189) Richard W.M. Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox