Open mg262 opened 6 years ago
Agreed, was bitten by this as well when trying out LibTomCrypt for the first time.
Sorry, it true... you're not the first ones who had those problems... but I don't really know how to describe what is missing as information. Now that you've figured out what is missing, could you please make a proposal? I'll happily update the README & documentation!
I really struggled as well to understand this. For me the main thing I didn't see/understand was that i had to set the ltc_mp actively. For me this was especially hard to grasp as SHA256 worked without (I later read in the manual that the MP is only needed for the PK crypto, which makes totally sense). It may already explicitly stated in the manual and I simply overread it, but if not, this is something I think is valuable for someone being unfamiliar with ltc.
My minimal dummy working example using libtomcrypt with tomsfastmath is:
libtomcrypt-minimal/
├── build.sh
├── libtomcrypt
├── main.c
└── tomsfastmath
build.sh
cd tomsfastmath
make
cd ..
cd libtomcrypt
make CFLAGS="-DLTC_EASY -DTFM_DESC -I../tomsfastmath/src/headers" EXTRALIBS="../tomsfastmath/libtfm.a"
cd ..
gcc main.c -g -DTFM_DESC -DUSE_TFM -o main -Ilibtomcrypt/src/headers -Llibtomcrypt/libtomcrypt -Itomsfastmath/src/headers libtomcrypt/libtomcrypt.a tomsfastmath/libtfm.a
main.c
#include <stdio.h>
#include "tomcrypt.h"
const unsigned char pk[] = {0x00, 0x00, 0x00, 0x00};
unsigned long pk_len = 4;
void main(void) {
ltc_mp = tfm_desc;
printf("Start\n");
hash_state md;
sha256_init(&md);
printf("SHA256 done\n");
rsa_key key;
rsa_import(pk, pk_len, &key);
printf("RSA done\n");
}
Hi,
Thanks for the great library! The docs say:
This bit isn't clear from the README -- when first playing with the library, I wasn't sure whether the math libs were optional or not. If you had a chance to add a sentence on that, I think it could help new users.