Skip to content

fix build with Botan 3.11#2381

Open
thillux wants to merge 1 commit intornpgp:mainfrom
thillux:mtheil/fix-botan-3.11-build
Open

fix build with Botan 3.11#2381
thillux wants to merge 1 commit intornpgp:mainfrom
thillux:mtheil/fix-botan-3.11-build

Conversation

@thillux
Copy link
Copy Markdown

@thillux thillux commented Mar 16, 2026

Fixes:

[ 40%] Building CXX object src/lib/CMakeFiles/librnp-obj.dir/sig_material.cpp.o
[ 40%] Building CXX object src/lib/CMakeFiles/librnp-obj.dir/pass-provider.cpp.o
[ 40%] Building CXX object src/lib/CMakeFiles/librnp-obj.dir/keygen.cpp.o
[ 41%] Building CXX object src/lib/CMakeFiles/librnp-obj.dir/key.cpp.o
[ 41%] Built target man_librnp
[ 41%] Built target man_rnpkeys
/build/source/src/lib/crypto/mem.cpp: In function 'size_t rnp::hex_decode(const char*, uint8_t*, size_t)':
/build/source/src/lib/crypto/mem.cpp:55:21: error: 'strlen' was not declared in this scope
   55 |     size_t hexlen = strlen(hex);
      |                     ^~~~~~
/build/source/src/lib/crypto/mem.cpp:30:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   29 | #include "logging.h"
  +++ |+#include <cstring>
   30 | #include <botan/ffi.h>

Signed-off-by: Markus Theil <markus.theil@secunet.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.46%. Comparing base (83a987a) to head (fb7e040).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2381   +/-   ##
=======================================
  Coverage   85.46%   85.46%           
=======================================
  Files         126      126           
  Lines       22711    22711           
=======================================
  Hits        19409    19409           
  Misses       3302     3302           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ronaldtse
Copy link
Copy Markdown
Contributor

Thank you @thillux !

@ni4 could you help review this? Thanks!

@juippis
Copy link
Copy Markdown

juippis commented Apr 4, 2026

This wasn't enough to make it compile for me. The build errored out to:

/var/tmp/portage/dev-util/librnp-0.18.1/work/rnp-0.18.1/src/lib/crypto/ec.cpp: In function 'rnp_result_t ec_generate_generic_native(rnp::RNG*, std::vector<unsigned char>&, std::vector<unsigned char>&, pgp_curve_t, pgp_pubkey_alg_t)':
/var/tmp/portage/dev-util/librnp-0.18.1/work/rnp-0.18.1/src/lib/crypto/ec.cpp:202:92: error: invalid use of incomplete type 'class Botan::EC_Group'
  202 |     Botan::ECDH_PrivateKey privkey_botan(*(rng->obj()), Botan::EC_Group(ec_desc->botan_name));
      |                                                                                            ^
In file included from /usr/include/botan-3/botan/ecdsa.h:13,
                 from /var/tmp/portage/dev-util/librnp-0.18.1/work/rnp-0.18.1/src/lib/crypto/exdsa_ecdhkem.h:38:
/usr/include/botan-3/botan/ecc_key.h:21:7: note: forward declaration of 'class Botan::EC_Group'
   21 | class EC_Group;
      |       ^~~~~~~~
/var/tmp/portage/dev-util/librnp-0.18.1/work/rnp-0.18.1/src/lib/crypto/ec.cpp:203:62: warning: 'const Botan::EC_Point& Botan::EC_PublicKey::public_point() const' is deprecated: Avoid accessing the point directly [-Wdeprecated-declarations]
  203 |     Botan::BigInt          pub_x = privkey_botan.public_point().get_affine_x();
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/botan-3/botan/ecc_key.h:51:78: note: declared here
   51 |       BOTAN_DEPRECATED("Avoid accessing the point directly") const EC_Point& public_point() const;
      |                                                                              ^~~~~~~~~~~~
/var/tmp/portage/dev-util/librnp-0.18.1/work/rnp-0.18.1/src/lib/crypto/ec.cpp:203:62: error: invalid use of incomplete type 'const class Botan::EC_Point'
  203 |     Botan::BigInt          pub_x = privkey_botan.public_point().get_affine_x();
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/botan-3/botan/ecc_key.h:20:7: note: forward declaration of 'class Botan::EC_Point'
   20 | class EC_Point;
      |       ^~~~~~~~
/var/tmp/portage/dev-util/librnp-0.18.1/work/rnp-0.18.1/src/lib/crypto/ec.cpp:204:62: warning: 'const Botan::EC_Point& Botan::EC_PublicKey::public_point() const' is deprecated: Avoid accessing the point directly [-Wdeprecated-declarations]
  204 |     Botan::BigInt          pub_y = privkey_botan.public_point().get_affine_y();
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/botan-3/botan/ecc_key.h:51:78: note: declared here
   51 |       BOTAN_DEPRECATED("Avoid accessing the point directly") const EC_Point& public_point() const;
      |                                                                              ^~~~~~~~~~~~
/var/tmp/portage/dev-util/librnp-0.18.1/work/rnp-0.18.1/src/lib/crypto/ec.cpp:204:62: error: invalid use of incomplete type 'const class Botan::EC_Point'
  204 |     Botan::BigInt          pub_y = privkey_botan.public_point().get_affine_y();
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/botan-3/botan/ecc_key.h:20:7: note: forward declaration of 'class Botan::EC_Point'
   20 | class EC_Point;
      |       ^~~~~~~~

and afterwards to:

/var/tmp/portage/dev-util/librnp-0.18.1/work/rnp-0.18.1/src/lib/crypto/exdsa_ecdhkem.cpp: In member function 'Botan::ECDH_PrivateKey ecdh_kem_private_key_t::botan_key_ecdh(rnp::RNG*) const':
/var/tmp/portage/dev-util/librnp-0.18.1/work/rnp-0.18.1/src/lib/crypto/exdsa_ecdhkem.cpp:74:57: error: invalid use of incomplete type 'class Botan::EC_Group'
   74 |       *(rng->obj()), Botan::EC_Group(ec_desc->botan_name), Botan::BigInt(key_));
      |                                                         ^
In file included from /usr/include/botan-3/botan/ecdsa.h:13,
                 from /var/tmp/portage/dev-util/librnp-0.18.1/work/rnp-0.18.1/src/lib/crypto/exdsa_ecdhkem.h:38:
/usr/include/botan-3/botan/ecc_key.h:21:7: note: forward declaration of 'class Botan::EC_Group'
   21 | class EC_Group;
      |       ^~~~~~~~
/var/tmp/portage/dev-util/librnp-0.18.1/work/rnp-0.18.1/src/lib/crypto/exdsa_ecdhkem.cpp:74:78: error: invalid use of incomplete type 'class Botan::BigInt'
   74 |       *(rng->obj()), Botan::EC_Group(ec_desc->botan_name), Botan::BigInt(key_));
      |                                                                              ^
In file included from /usr/include/botan-3/botan/pubkey.h:11,
                 from /var/tmp/portage/dev-util/librnp-0.18.1/work/rnp-0.18.1/src/lib/crypto/exdsa_ecdhkem.h:37:
/usr/include/botan-3/botan/pk_keys.h:23:7: note: forward declaration of 'class Botan::BigInt'
   23 | class BigInt;
      |       ^~~~~~
/var/tmp/portage/dev-util/librnp-0.18.1/work/rnp-0.18.1/src/lib/crypto/exdsa_ecdhkem.cpp: In member function 'Botan::ECDH_PublicKey ecdh_kem_public_key_t::botan_key_ecdh(rnp::RNG*) const':
/var/tmp/portage/dev-util/librnp-0.18.1/work/rnp-0.18.1/src/lib/crypto/exdsa_ecdhkem.cpp:83:27: error: variable 'Botan::EC_Group group' has initializer but incomplete type
   83 |     Botan::EC_Group group(ec_desc->botan_name);
      |                           ^~~~~~~
/var/tmp/portage/dev-util/librnp-0.18.1/work/rnp-0.18.1/src/lib/crypto/exdsa_ecdhkem.cpp:85:23: error: variable 'Botan::BigInt x' has initializer but incomplete type
   85 |     Botan::BigInt   x(key_.data() + 1, curve_order);
      |                       ^~~~
/var/tmp/portage/dev-util/librnp-0.18.1/work/rnp-0.18.1/src/lib/crypto/exdsa_ecdhkem.cpp:86:23: error: variable 'Botan::BigInt y' has initializer but incomplete type
   86 |     Botan::BigInt   y(key_.data() + 1 + curve_order, curve_order);

However I found a similar problem from keepassxreboot/keepassxc#13161 and applying that fix made it compile successfully:

diff '--color=auto' -Naur a/src/lib/crypto/ec.cpp b/src/lib/crypto/ec.cpp
--- a/src/lib/crypto/ec.cpp     2025-11-21 15:12:02.000000000 +0200
+++ b/src/lib/crypto/ec.cpp     2026-04-04 08:22:12.502593507 +0300
@@ -40,6 +40,10 @@
 #include "botan/ecdh.h"
 #include <cassert>
 #endif
+#include <botan/version.h>
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(3, 11, 0)
+#include <botan/ec_group.h>
+#endif
 
 namespace pgp {
 namespace ec {
diff '--color=auto' -Naur a/src/lib/crypto/exdsa_ecdhkem.cpp b/src/lib/crypto/exdsa_ecdhkem.cpp
--- a/src/lib/crypto/exdsa_ecdhkem.cpp  2025-11-21 15:12:02.000000000 +0200
+++ b/src/lib/crypto/exdsa_ecdhkem.cpp  2026-04-04 08:34:49.684582995 +0300
@@ -34,6 +34,10 @@
 #include "string.h"
 #include "utils.h"
 #include <cassert>
+#include <botan/version.h>
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(3, 11, 0)
+#include <botan/ec_group.h>
+#endif
 
 ec_key_t::~ec_key_t()
 {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants