TaleTN / libtomcrypt-rsa-howto

LibTomCrypt RSA digital signatures how-to
Other
9 stars 4 forks source link

Sorry but can you tell me how to use it? #1

Open Serobegi opened 2 years ago

Serobegi commented 2 years ago

I came across your git while doing a google search to use libtomcrypt on an embedded system.

I want to use libtomcrypt in windows environment.

However, even if I download it from git, I do not have the Visual Studio 2008 version. Also, other visual studios do not have a version.

I want to get a lib and run it in another program... I'm not sure from your kind explanation.

GETTING STARTED

1. Get LibTomMath and LibTomCrypt - Success √

git clone https://github.com/TaleTN/libtommath.git git clone https://github.com/TaleTN/libtomcrypt.git

  1. Remove unused source files (optional) - Fail...

    perl remove_unused.pl --force

  2. Build LibTomMath and LibTomCrypt

    [n]make [-f makefile.msvc]

  3. Generate public/private key pair

    [n]make [-f makefile.msvc] key

  4. Run sign and verify examples

    [n]make [-f makefile.msvc] test

  5. Have fun! :(

Can you explain a little more?

I proceeded with step 1 below, and additionally downloaded your git and unzipped it.

The folders I currently have are "libtomcrypt", "libtommath", and "libtomcrypt-rsa-howto".

If you execute "perl remove_unused.pl --force" in step 2, the following error appears.

Can't stat libtommath: No such file or directory at remove_unused.pl line 54. Can't stat libtomcrypt: No such file or directory at remove_unused.pl line 54.

how can i solve it...

TaleTN commented 2 years ago

The README assumes the following directrory structure:

If you then run the Perl script and other commands from within the libtomcrypt-rsa-howto directory, it should work. Do note that running the Perl script is optional (it just removes all LibTom source files you don't need for RSA signatures), so you could also skip it.

Serobegi commented 2 years ago

The optional feature is what I was looking for. Thank you so much for providing.

And I'm sorry for asking such a rudimentary question, but I have a few more questions to ask.

  1. Build LibTomMath and LibTomCrypt make -f makefile.msvc

If I write as above in item 3 and proceed with make, can I know where the lib or dll files that can be used in other projects are created?

TaleTN commented 2 years ago

You will find the relative paths of the library files in makefile.msvc (look for LTM_LIBNAME and LTC_LIBNAME), but I will post them here as well:

Serobegi commented 2 years ago

thank you.

I checked the path, but if there is no lib file, what should I do? Please help. . ├── LICENSE ├── README ├── dertoh.cpp ├── dertopem.sh ├── error.h ├── libtomcrypt │   ├── LICENSE │   ├── changes │   └── src │   ├── hashes │   │   ├── md2.c │   │   ├── md5.c │   │   ├── sha1.c │   │   └── sha2 │   │   ├── sha224.c │   │   ├── sha256.c │   │   ├── sha384.c │   │   └── sha512.c │   ├── headers │   │   ├── tomcrypt.h │   │   ├── tomcrypt_argchk.h │   │   ├── tomcrypt_cfg.h │   │   ├── tomcrypt_cipher.h │   │   ├── tomcrypt_custom.h │   │   ├── tomcrypt_hash.h │   │   ├── tomcrypt_mac.h │   │   ├── tomcrypt_macros.h │   │   ├── tomcrypt_math.h │   │   ├── tomcrypt_misc.h │   │   ├── tomcrypt_pk.h │   │   ├── tomcrypt_pkcs.h │   │   └── tomcrypt_prng.h │   ├── math │   │   ├── ltm_desc.c │   │   ├── multi.c │   │   └── rand_prime.c │   ├── misc │   │   ├── base64 │   │   │   ├── base64_decode.c │   │   │   └── base64_encode.c │   │   ├── compare_testvector.c │   │   ├── crypt │   │   │   ├── crypt_argchk.c │   │   │   ├── crypt_hash_descriptor.c │   │   │   ├── crypt_hash_is_valid.c │   │   │   ├── crypt_ltc_mp_descriptor.c │   │   │   ├── crypt_prng_descriptor.c │   │   │   ├── crypt_prng_is_valid.c │   │   │   ├── crypt_register_hash.c │   │   │   └── crypt_register_prng.c │   │   ├── error_to_string.c │   │   ├── mem_neq.c │   │   ├── pk_get_oid.c │   │   └── zeromem.c │   ├── pk │   │   ├── asn1 │   │   │   └── der │   │   │   ├── bit │   │   │   │   ├── der_decode_bit_string.c │   │   │   │   ├── der_decode_raw_bit_string.c │   │   │   │   ├── der_encode_bit_string.c │   │   │   │   ├── der_encode_raw_bit_string.c │   │   │   │   └── der_length_bit_string.c │   │   │   ├── boolean │   │   │   │   ├── der_decode_boolean.c │   │   │   │   ├── der_encode_boolean.c │   │   │   │   └── der_length_boolean.c │   │   │   ├── choice │   │   │   │   └── der_decode_choice.c │   │   │   ├── generalizedtime │   │   │   │   ├── der_decode_generalizedtime.c │   │   │   │   ├── der_encode_generalizedtime.c │   │   │   │   └── der_length_generalizedtime.c │   │   │   ├── ia5 │   │   │   │   ├── der_decode_ia5_string.c │   │   │   │   ├── der_encode_ia5_string.c │   │   │   │   └── der_length_ia5_string.c │   │   │   ├── integer │   │   │   │   ├── der_decode_integer.c │   │   │   │   ├── der_encode_integer.c │   │   │   │   └── der_length_integer.c │   │   │   ├── object_identifier │   │   │   │   ├── der_decode_object_identifier.c │   │   │   │   ├── der_encode_object_identifier.c │   │   │   │   └── der_length_object_identifier.c │   │   │   ├── octet │   │   │   │   ├── der_decode_octet_string.c │   │   │   │   ├── der_encode_octet_string.c │   │   │   │   └── der_length_octet_string.c │   │   │   ├── printable_string │   │   │   │   ├── der_decode_printable_string.c │   │   │   │   ├── der_encode_printable_string.c │   │   │   │   └── der_length_printable_string.c │   │   │   ├── sequence │   │   │   │   ├── der_decode_sequence_ex.c │   │   │   │   ├── der_decode_sequence_multi.c │   │   │   │   ├── der_decode_subject_public_key_info.c │   │   │   │   ├── der_encode_sequence_ex.c │   │   │   │   ├── der_encode_sequence_multi.c │   │   │   │   ├── der_encode_subject_public_key_info.c │   │   │   │   └── der_length_sequence.c │   │   │   ├── set │   │   │   │   ├── der_encode_set.c │   │   │   │   └── der_encode_setof.c │   │   │   ├── short_integer │   │   │   │   ├── der_decode_short_integer.c │   │   │   │   ├── der_encode_short_integer.c │   │   │   │   └── der_length_short_integer.c │   │   │   ├── teletex_string │   │   │   │   ├── der_decode_teletex_string.c │   │   │   │   └── der_length_teletex_string.c │   │   │   ├── utctime │   │   │   │   ├── der_decode_utctime.c │   │   │   │   ├── der_encode_utctime.c │   │   │   │   └── der_length_utctime.c │   │   │   └── utf8 │   │   │   ├── der_decode_utf8_string.c │   │   │   ├── der_encode_utf8_string.c │   │   │   └── der_length_utf8_string.c │   │   ├── ecc │   │   │   ├── ltc_ecc_map.c │   │   │   ├── ltc_ecc_mul2add.c │   │   │   ├── ltc_ecc_mulmod.c │   │   │   ├── ltc_ecc_mulmod_timing.c │   │   │   ├── ltc_ecc_points.c │   │   │   ├── ltc_ecc_projective_add_point.c │   │   │   └── ltc_ecc_projective_dbl_point.c │   │   ├── pkcs1 │   │   │   ├── pkcs_1_mgf1.c │   │   │   ├── pkcs_1_pss_decode.c │   │   │   ├── pkcs_1_pss_encode.c │   │   │   ├── pkcs_1_v1_5_decode.c │   │   │   └── pkcs_1_v1_5_encode.c │   │   └── rsa │   │   ├── rsa_export.c │   │   ├── rsa_exptmod.c │   │   ├── rsa_free.c │   │   ├── rsa_import.c │   │   ├── rsa_make_key.c │   │   ├── rsa_sign_hash.c │   │   └── rsa_verify_hash.c │   └── prngs │   ├── rng_get_bytes.c │   └── sprng.c ├── libtommath │   ├── LICENSE │   ├── bn_cutoffs.c │   ├── bn_deprecated.c │   ├── bn_mp_2expt.c │   ├── bn_mp_abs.c │   ├── bn_mp_add.c │   ├── bn_mp_add_d.c │   ├── bn_mp_addmod.c │   ├── bn_mp_and.c │   ├── bn_mp_clamp.c │   ├── bn_mp_clear.c │   ├── bn_mp_clear_multi.c │   ├── bn_mp_cmp.c │   ├── bn_mp_cmp_d.c │   ├── bn_mp_cmp_mag.c │   ├── bn_mp_cnt_lsb.c │   ├── bn_mp_copy.c │   ├── bn_mp_count_bits.c │   ├── bn_mp_div.c │   ├── bn_mp_div_2.c │   ├── bn_mp_div_2d.c │   ├── bn_mp_div_3.c │   ├── bn_mp_div_d.c │   ├── bn_mp_dr_is_modulus.c │   ├── bn_mp_dr_reduce.c │   ├── bn_mp_dr_setup.c │   ├── bn_mp_exch.c │   ├── bn_mp_expt_u32.c │   ├── bn_mp_exptmod.c │   ├── bn_mp_from_sbin.c │   ├── bn_mp_from_ubin.c │   ├── bn_mp_gcd.c │   ├── bn_mp_get_i32.c │   ├── bn_mp_get_mag_u32.c │   ├── bn_mp_get_mag_ul.c │   ├── bn_mp_get_mag_ull.c │   ├── bn_mp_grow.c │   ├── bn_mp_init.c │   ├── bn_mp_init_copy.c │   ├── bn_mp_init_multi.c │   ├── bn_mp_init_set.c │   ├── bn_mp_init_size.c │   ├── bn_mp_init_u32.c │   ├── bn_mp_invmod.c │   ├── bn_mp_is_square.c │   ├── bn_mp_kronecker.c │   ├── bn_mp_lcm.c │   ├── bn_mp_lshd.c │   ├── bn_mp_mod.c │   ├── bn_mp_mod_2d.c │   ├── bn_mp_mod_d.c │   ├── bn_mp_montgomery_calc_normalization.c │   ├── bn_mp_montgomery_reduce.c │   ├── bn_mp_montgomery_setup.c │   ├── bn_mp_mul.c │   ├── bn_mp_mul_2.c │   ├── bn_mp_mul_2d.c │   ├── bn_mp_mul_d.c │   ├── bn_mp_mulmod.c │   ├── bn_mp_neg.c │   ├── bn_mp_or.c │   ├── bn_mp_pack.c │   ├── bn_mp_pack_count.c │   ├── bn_mp_prime_is_prime.c │   ├── bn_mp_prime_miller_rabin.c │   ├── bn_mp_prime_rand.c │   ├── bn_mp_prime_strong_lucas_selfridge.c │   ├── bn_mp_radix_smap.c │   ├── bn_mp_rand.c │   ├── bn_mp_read_radix.c │   ├── bn_mp_reduce.c │   ├── bn_mp_reduce_2k.c │   ├── bn_mp_reduce_2k_l.c │   ├── bn_mp_reduce_2k_setup.c │   ├── bn_mp_reduce_2k_setup_l.c │   ├── bn_mp_reduce_is_2k.c │   ├── bn_mp_reduce_is_2k_l.c │   ├── bn_mp_reduce_setup.c │   ├── bn_mp_root_u32.c │   ├── bn_mp_rshd.c │   ├── bn_mp_sbin_size.c │   ├── bn_mp_set.c │   ├── bn_mp_set_i32.c │   ├── bn_mp_set_u32.c │   ├── bn_mp_set_u64.c │   ├── bn_mp_signed_rsh.c │   ├── bn_mp_sqr.c │   ├── bn_mp_sqrmod.c │   ├── bn_mp_sqrt.c │   ├── bn_mp_sub.c │   ├── bn_mp_sub_d.c │   ├── bn_mp_submod.c │   ├── bn_mp_to_radix.c │   ├── bn_mp_to_sbin.c │   ├── bn_mp_to_ubin.c │   ├── bn_mp_ubin_size.c │   ├── bn_mp_unpack.c │   ├── bn_mp_xor.c │   ├── bn_mp_zero.c │   ├── bn_prime_tab.c │   ├── bn_s_mp_add.c │   ├── bn_s_mp_balance_mul.c │   ├── bn_s_mp_exptmod.c │   ├── bn_s_mp_exptmod_fast.c │   ├── bn_s_mp_get_bit.c │   ├── bn_s_mp_invmod_fast.c │   ├── bn_s_mp_invmod_slow.c │   ├── bn_s_mp_karatsuba_mul.c │   ├── bn_s_mp_karatsuba_sqr.c │   ├── bn_s_mp_montgomery_reduce_fast.c │   ├── bn_s_mp_mul_digs.c │   ├── bn_s_mp_mul_digs_fast.c │   ├── bn_s_mp_mul_high_digs.c │   ├── bn_s_mp_mul_high_digs_fast.c │   ├── bn_s_mp_prime_is_divisible.c │   ├── bn_s_mp_rand_platform.c │   ├── bn_s_mp_reverse.c │   ├── bn_s_mp_sqr.c │   ├── bn_s_mp_sqr_fast.c │   ├── bn_s_mp_sub.c │   ├── bn_s_mp_toom_mul.c │   ├── bn_s_mp_toom_sqr.c │   ├── changes.txt │   ├── tommath.h │   ├── tommath_class.h │   ├── tommath_cutoffs.h │   ├── tommath_private.h │   └── tommath_superclass.h ├── makefile ├── makefile.msvc ├── remove_unused.pl ├── rsa_make_key.cpp ├── rsa_sign.cpp └── rsa_verify.cpp

TaleTN commented 2 years ago

After running 'nmake -f makefile.msvc' the LIB files should be there, but there should also be lots of OBJ files everywhere, so I guess you haven't run nmake yet, or maybe it didn't work somehow.

Serobegi commented 2 years ago

Sorry, I don't know nmake, so I typed 'make -f makefile.msvc'. Actually I don't know what nmake is. I'll search and try it out. Thank you.

I found that nmake can be done in visual studio powershell!! The command below failed, but ' nmake -f makefile.msvc' succeeded and was able to create the lib. Thank you very much!

PS D:\visual_workspace\test\libtomcrypt-rsa-howto> perl remove_unused.pl --force

Can't locate strict.pm in @INC (@INC contains: /usr/lib/perl5/5.8/msys /usr/lib/perl5/5.8 /usr/lib/perl5/site_perl/5.8/msys /usr/lib/perl5/site_perl/5.8 /usr/lib/perl5/site_perl/5.8 /usr/lib/perl5/vendor_perl/5.8/msys /usr/lib/perl5/vendor_perl/5.8 /usr/lib/perl5/vendor_perl/5.8 .) at remove_unused.pl line 8. BEGIN failed--compilation aborted at remove_unused.pl line 8.

TaleTN commented 2 years ago

It looks like your Perl is from MSYS, but you are calling it from the Vistal Studio prompt. It would probably work if you would run the Perl script from the MSYS terminal, or if you would install a Perl version that can be run from the VS prompt.

Serobegi commented 2 years ago

Perl commands were processed and applied in linux. If there is a problem, I will try again by installing an MSYS terminal that can run Perl. I will now work by uploading the lib and header file. It is all thanks to you that I have been able to come this far. :D