Sto scrivendo un programma di messaggistica istantanea sicuro in C++ utilizzando la libreria C libtomcrypt per le sue funzioni RSA e SPRNG. Ho ottenuto libtomcrypt compilato come libreria statica e sono stato in grado di collegarlo ad esso ed eseguire le funzioni sprng e vedere e utilizzare i dati casuali che sta generando.Impossibile collegare tomsfastmath in libtomcrypt
Il problema che sto riscontrando è quello di provare a utilizzare la funzione rsa_make_key() che ha funzioni di dipendenza da una libreria matematica collegata.
In questo caso sto cercando di utilizzare Tomsfastmath (tfm) che sto anche cercando di collegare come libreria statica. Entrambe queste librerie risiedono nella loro cartella di progetto una directory dalla cartella del mio progetto (ie ../libtomcrypt)
Nel mio codice quando provo ad accedere al tomsfast descrittore di matematica "tfm_desc" ottengo l'errore test_crypt.cpp:8:11: error: 'tfm_desc' was not declared in this scope
. Il che mi fa pensare che tfm non viene collegato correttamente in libtomcrypt. Ho letto la documentazione per entrambe queste cose non è molto chiara.
Sono qui a fine di intelligenza. Cosa sto facendo di sbagliato?
Ecco il mio make file
CC:=gcC#C Compiler
CFLAGS:=-std=c99 -O0 -I/home/k3rb3ros/csci484-CMU-/libtomcrypt-1.17/src/headers -g - Wall -Wextra#C Compiler flags
CPP:=g++ #C++ Compiler
CPPFLAGS:=-std=gnu++0x -O0 -I/home/k3rb3ros/csci484/csci484-CMU-/libtomcrypt- 1.17/src/headers -L. -g -Wall -Wextra#C++ Compiler flags
#CPPFLAGS:=-std=gnu++0x -O0 -g -Wall -Wextra #C++ Compiler flags
LDFLAGS:= -lSDL -lSDL_net -ltfm -ltomcrypt
CSOURCES= #C files used in this program
CPPSOURCES=connection.cpp chat.cpp test_crypt.cpp #CPP files used in this prgram
#COBJECTS=$(CSOURCES:.c=.o)libtfm.a libtomcrypt.a
COBJECTS=$(CSOURCES:.c=.o)
CPPOBJECTS=$(CPPSOURCES:.cpp=.o)
BINARY=down_low
all: $(BINARY) $(COBJECTS) $(CPPOBJECTS)
.c.o:
$(CC) $(CFLAGS) -c $< -o [email protected]
.cpp.o:
$(CPP) $(CPPFLAGS) -c $< -o [email protected]
$(BINARY): $(COBJETS) $(CPPOBJECTS)
$(CPP) $(CPPFLAGS) $(COBJECTS) $(CPPOBJECTS) -o [email protected] $(LDFLAGS)
clean:
rm -rv $(BINARY) $(COBJECTS) $(CPPOBJECTS)
e qui è la mia funzione test_crypt
#include "headers/test_crypt.h"
using namespace std;
void test_crypt()
{
int err = 0;
int rng_idx = -1; //rng index, not sure if I need this
ltc_mp = tfm_desc; //tell tomcrypt to use toms fast math
rsa_key pub_key;
prng_state random_gen;
if((err = sprng_start(&random_gen)) != CRYPT_OK) //start the rng and check for errors
{
cout << "start error " << error_to_string(err) << endl;
}
rng_idx = find_prng("sprng");
if((err = sprng_ready(&random_gen)) != CRYPT_OK)
{
cout << "Ready error " << error_to_string(err) << endl;
}
//test toms fast math present and working
//fp_int test;
//fp_init(&test);
//sprng_read(entropy, size, &random_gen);
/*
if((err = rsa_make_key(NULL, //PRNG state
rng_idx, //PRNG idx
1024/8, //Size of key
65537, //e
&pub_key) //RSA key
) != CRYPT_OK) //if conditon test
{
cout << "RSA Key Generation error " << error_to_string(err) << endl;
}
rsa_free(&pub_key); //free the key when we are done with it;
*/
sprng_done(&random_gen); //done generating random numbers
}
Questo è un errore del compilatore, non un errore del linker. – melpomene