Issue with RSA function calls from the Ubuntu package libhogweed5

Asked by Christopher Coppola

From the package manager, I installed the Nettle libraries libnettle7, libhogweed5, nettle-bin, and nettle-dev, which appear to be based on Nettle 3.5.1. I am using Ubuntu 20.04. After this, I was able to write two programs using AES and SHA algorithms, which worked fine, so I know that the header pathing is correct.

However, I could not call RSA functions without getting compiler errors.

$ make rsa_test
/usr/bin/ld: /tmp/ccaqGeCe.o: in function `main':
rsa_test.cc:(.text+0x36): undefined reference to `nettle_rsa_public_key_init'
/usr/bin/ld: rsa_test.cc:(.text+0x42): undefined reference to `nettle_rsa_private_key_init'
collect2: error: ld returned 1 exit status
make: *** [Makefile:9: rsa_test] Error 1
Here is minimal code that produces the error:

#include <stdlib.h>
#include <stdio.h>
#include <nettle/rsa.h>
using namespace std;
int main(int argc, char **argv) {
  struct rsa_public_key pub;
  struct rsa_private_key priv;
  rsa_public_key_init(&pub);
  rsa_private_key_init(&priv);
}

The file rsa.h is present in /usr/include/nettle, and contains the functions rsa_public_key_init and rsa_public_key_init. How can I install the RSA functions and call them?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu nettle Edit question
Assignee:
No assignee Edit question
Solved by:
Christopher Coppola
Solved:
Last query:
Last reply:
Revision history for this message
Christopher Coppola (cecoppola) said :
#1

I believe this is due to the linker requiring a second library location.