LibTomCrypt is a fairly comprehensive, modular and portable cryptographic toolkit that provides developers with a vast array of well known published block ciphers, one-way hash functions, chaining modes, pseudo-random number generators, public key cryptography and a plethora of other routines.
[ x] Checked that your issue isn't due to the fact that you're using asymmetric cryptography and you forgot linking in and/or setting an MPI provider (usually this causes either random crashes or runtime errors like LTC_ARGCHK 'ltc_mp.name != NULL' failure ...). c.f. Ch. "Math Descriptors" of the developer manual.
[x ] Checked that your issue isn't related to TomsFastMath's limitation that PK operations can by default only be done with max. 2048bit keys
Description
[Description of the issue]
Steps to Reproduce
establish the math provider description:
create a PRNG state
Use PRNG to create AES key. (Not super relevant for this issue)
Encrypt the AES Key using ECC:
When calling ECC_Encrypt_key function the following code stream happens:
ECC_Encrypt_Key calls ECC_Copy_Curve:
Then ECC_Copy_Curve calls mp_copy using the srckey->dp.prime variable. However, I believe this is meant to be a pointer to the primer number for the src key and not the prime number itself. It appears that when the mp_copy function is called the parameter passed is the prime.
Prime number:
mp_copy calls copy function using improper vars?:
see src value of a as prime number. destination value of b as address.
Continuing exception occurs:
Version
define SCRYPT "1.18.2-develop"
Additional Information
Any additional information, configuration or data that might be necessary to reproduce the issue.
Prerequisites
LTC_ARGCHK 'ltc_mp.name != NULL' failure ...
). c.f. Ch. "Math Descriptors" of the developer manual.Description
[Description of the issue]
Steps to Reproduce
establish the math provider description:![image](https://github.com/libtom/libtomcrypt/assets/41178870/40dddb6c-6c6b-4c57-8e0a-b88b45a67ae4)
create a PRNG state![image](https://github.com/libtom/libtomcrypt/assets/41178870/5921f508-23ec-43cf-a7a7-e042a6463689)
Use PRNG to create AES key. (Not super relevant for this issue)
Encrypt the AES Key using ECC:![image](https://github.com/libtom/libtomcrypt/assets/41178870/6154006d-6860-4449-be5a-ccf09c0cf42a)
When calling ECC_Encrypt_key function the following code stream happens: ECC_Encrypt_Key calls ECC_Copy_Curve:
Then ECC_Copy_Curve calls mp_copy using the srckey->dp.prime variable. However, I believe this is meant to be a pointer to the primer number for the src key and not the prime number itself. It appears that when the mp_copy function is called the parameter passed is the prime.
Prime number:![image](https://github.com/libtom/libtomcrypt/assets/41178870/b2e19441-b330-456f-a4e8-0770d6cd457d)
mp_copy calls copy function using improper vars?:![image](https://github.com/libtom/libtomcrypt/assets/41178870/c9340898-e95a-4dc5-b806-cb25a1081aa2)
see src value of a as prime number. destination value of b as address.![image](https://github.com/libtom/libtomcrypt/assets/41178870/73aaf27f-0a5d-4899-af0d-da4dcca005df)
Continuing exception occurs:![image](https://github.com/libtom/libtomcrypt/assets/41178870/b97b50eb-5bb9-41d5-8066-9bac47da3805)
Version
define SCRYPT "1.18.2-develop"
Additional Information
Any additional information, configuration or data that might be necessary to reproduce the issue.