libtom / libtomcrypt

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.
https://www.libtom.net
Other
1.51k stars 449 forks source link

ECC_Encrypt_Key does not work properly. #643

Closed Allevon412 closed 3 months ago

Allevon412 commented 3 months ago

Prerequisites

Description

[Description of the issue]

Steps to Reproduce

establish the math provider description: image

create a PRNG state image

Use PRNG to create AES key. (Not super relevant for this issue)

Encrypt the AES Key using ECC: image

When calling ECC_Encrypt_key function the following code stream happens: ECC_Encrypt_Key calls ECC_Copy_Curve:

image

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.

image

Prime number: image

mp_copy calls copy function using improper vars?: image

see src value of a as prime number. destination value of b as address. image

Continuing exception occurs: image

Version

define SCRYPT "1.18.2-develop"

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

Allevon412 commented 3 months ago

nvm. I was using the library incorrectly. I didn't create a ecc_key variable and import my public key to it.