kokke / tiny-ECDH-c

Small portable Elliptic-Curve Diffie-Hellman in C
The Unlicense
254 stars 65 forks source link

Unable to run tiny-ECDH-c on Contiki OS #3

Closed varsharaghav23 closed 6 years ago

varsharaghav23 commented 6 years ago

I tried running the code on Contiki -2.7.. unable to run getting error related to assert.Please help me I am new to this..

kokke commented 6 years ago

Hi @varsharaghav23 and thanks for trying out this project :)

I need more information from you in order to be able to help. Which assertion is failing?

It should not make a difference whether or not the code is running on contiki or directly on the metal.

varsharaghav23 commented 6 years ago

Hi, Thanks for your help. see i have contiki-2.7 and i am trying to run this code on it.Please view the atachment for detailed error.Just let me know if anything else you require ti figure this out.

Thanks & Regards,

Varsha Raghav

On Wed, Jan 31, 2018 at 2:05 PM, kokke notifications@github.com wrote:

Hi @varsharaghav23 https://github.com/varsharaghav23 and thanks for trying out this project :)

I need more information from you in order to be able to help. Which assertion is failing?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kokke/tiny-ECDH-c/issues/3#issuecomment-361860723, or mute the thread https://github.com/notifications/unsubscribe-auth/Ah2kzuSdma_DFv4llFo462uZRrP6pPPWks5tQCXsgaJpZM4Rze6U .

kokke commented 6 years ago

Hi @varsharaghav23 - you cannot attach files to me via Github.

You need to upload your file somewhere and send a link to it instead.

varsharaghav23 commented 6 years ago

Alright.If you can tell me the procedure that would be great.

I am running this code on contiki-2.7 and i am getting this error.

Error

/home/user/Desktop/contiki-2.7/core/tiny-ECDH-c-master/ecdh_example.c:98: undefined reference to `ecdh_generate_keys'

/home/user/Desktop/contiki-2.7/core/tiny-ECDH-c-master/ecdh_example.c:98: undefined reference to `_xassert'

/home/user/Desktop/contiki-2.7/core/tiny-ECDH-c-master/ecdh_example.c:105: undefined reference to `ecdh_generate_keys'

/home/user/Desktop/contiki-2.7/core/tiny-ECDH-c-master/ecdh_example.c:105: undefined reference to `_xassert'

/home/user/Desktop/contiki-2.7/core/tiny-ECDH-c-master/ecdh_example.c:108: undefined reference to `ecdh_shared_secret'

/home/user/Desktop/contiki-2.7/core/tiny-ECDH-c-master/ecdh_example.c:108: undefined reference to `_xassert'

/home/user/Desktop/contiki-2.7/core/tiny-ECDH-c-master/ecdh_example.c:111: undefined reference to `ecdh_shared_secret'

/home/user/Desktop/contiki-2.7/core/tiny-ECDH-c-master/ecdh_example.c:111: undefined reference to `_xassert'

/home/user/Desktop/contiki-2.7/core/tiny-ECDH-c-master/ecdh_example.c:116: undefined reference to `_xassert'

collect2: ld returned 1 exit status

make: *** [ecdh_example.native] Error 1

rm ecdh_example.co

Thanks & Regards,

Varsha Raghav Phone Number 9990179605

On Mon, Feb 5, 2018 at 3:07 AM, kokke notifications@github.com wrote:

Hi Varsha - you cannot attach files to me via Github.

You need to upload your file somewhere and send a link to it instead.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kokke/tiny-ECDH-c/issues/3#issuecomment-362941969, or mute the thread https://github.com/notifications/unsubscribe-auth/Ah2kzk2F6apyusn0M8zUEZiNUyCHdUREks5tRiMPgaJpZM4Rze6U .

kokke commented 6 years ago

From the look of it, you are experiencing a linker error. It looks like you are only compiling 'ecdh_example.c' and you need to add 'ecdh.c' as well.

The errors occur because the example file is calling functions that are defined in 'ecdh.c'. You need to include all the code to be able to build the project :)

varsharaghav23 commented 6 years ago

Sir I have added both the files in the Makefile code. The code is given below

CONTIKI_PROJECT = ecdh ecdh_example

all: $(CONTIKI_PROJECT)

CONTIKI = /home/user/Desktop/contiki-2.7

include $(CONTIKI)/Makefile.include

still i am getting this error..

On Mon, Feb 5, 2018 at 12:34 PM, kokke notifications@github.com wrote:

From the look of it, you are experiencing a linker error. It looks like you are only compiling 'ecdh_example.c' and you need to add 'ecdh.c' as well.

The errors occur because the example file is calling functions that are defined in 'ecdh.c'. You need to include all the code to be able to build the project :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kokke/tiny-ECDH-c/issues/3#issuecomment-362998275, or mute the thread https://github.com/notifications/unsubscribe-auth/Ah2kzspAWWgE5NETAN_qW3MVumXQjGi3ks5tRqgagaJpZM4Rze6U .

kokke commented 6 years ago

I don't know the Contiki project and its Makefiles well enough to tell what is needed to add files to the project.

I am however 100% certain that your problem is that ecdh.c is not being compiled along with the rest of the code, because you are getting linker errors.

varsharaghav23 commented 6 years ago

Alright contiki I will try to figure that out by myself.One more thing these two file ecdh.c and ecdh_example.c are in C programming language right.I am trying to run this in turbo C then also m getting huge list of errors. few errors are: typedef struct { uint32_t a; uint32_t b; uint32_t c; uint32_t d; } prng_t; multiple declaration error

static uint32_t prng_rotate(uint32_t x, uint32_t k) syntax error

Can you help me with that..

On Mon, Feb 5, 2018 at 1:59 PM, kokke notifications@github.com wrote:

I don't know the Contiki project and its Makefiles well enough to tell what is needed to add files to the project.

I am however 100% certain that your problem is that ecdh.c is not being compiled along with the rest of the code, because you are getting linker errors.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kokke/tiny-ECDH-c/issues/3#issuecomment-363013543, or mute the thread https://github.com/notifications/unsubscribe-auth/Ah2kzpWsDA6dK2YEBmxKU5Iq0pWkkWbqks5tRrv9gaJpZM4Rze6U .

kokke commented 6 years ago

uint32_t is defined in <stdint.h>.

It is a typedef for a 32 bit unsigned integer.

You may be able to replace with "unsigned int" or "unsigned long int" depending on your system.

If we call the type you select for T, just ensure that T is unsigned and that sizeof(T) == 4.

kokke commented 6 years ago

@varsharaghav23

Another thing: assert() is a function that makes the program crash if its input is 0. It is used to check the code while it is running and make the program crash if something is not as expected.

You can disable assertions by defining the macro DISABLE_ASSERT in ecdh.c - but I will advise against that until the code is working.

varsharaghav23 commented 6 years ago

Hi Sir, Thankyou Sir for your help.I tried changing uint_32 to unsigned int. I am running ecdh_example file getting error

static void ecdh_demo(void) { static unsigned int puba[ECC_PUB_KEY_SIZE]; static unsigned int prva[ECC_PRV_KEY_SIZE]; static unsigned int seca[ECC_PUB_KEY_SIZE]; static unsigned int pubb[ECC_PUB_KEY_SIZE]; static unsigned int prvb[ECC_PRV_KEY_SIZE]; static unsigned int secb[ECC_PUB_KEY_SIZE];

Error Undefined symbol ECC_PUB_KEY_SIZE ECC_PRV_KEY_SIZE

What should I do?

Thanks & Regards,

Varsha Raghav Phone Number 9990179605

On Mon, Feb 5, 2018 at 3:09 PM, kokke notifications@github.com wrote:

@varsharaghav23 https://github.com/varsharaghav23

Another thing: assert() is a function that makes the program crash if its input is 0. It is used to check the code while it is running and make the program crash if something is not as expected.

You can disable assertions by defining the macro DISABLE_ASSERT in ecdh.c

  • but I will advise against that until the code is working.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kokke/tiny-ECDH-c/issues/3#issuecomment-363030251, or mute the thread https://github.com/notifications/unsubscribe-auth/Ah2kzkpUePjnrNfMHkLzbr6MJf05Am63ks5tRsw6gaJpZM4Rze6U .

kokke commented 6 years ago

The macros ECC_PUB_KEY_SIZE and ECC_PRV_KEY_SIZE are defined in ecdh.h.

kokke commented 6 years ago

Hi @varsharaghav23 - did you get the code to compile successfully? :)

I am closing this issue, because it doesn't seem to revolve around a problem with the code, rather it seems to be related to a non-C99 compatible compiler (A Turbo C compiler?).

Feel free to keep asking questions, regardless that the issue is closed.

varsharaghav23 commented 6 years ago

Hi Sir, Yeah some linking error is there for sure.Thanks for your help.I am figuring that out.Thankyou

On Thu, Feb 8, 2018 at 10:04 PM, kokke notifications@github.com wrote:

Closed #3 https://github.com/kokke/tiny-ECDH-c/issues/3.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kokke/tiny-ECDH-c/issues/3#event-1464962907, or mute the thread https://github.com/notifications/unsubscribe-auth/Ah2kzrEJWS0LZ_ayj5Ji6eePsU_bwLHJks5tSyIngaJpZM4Rze6U .

varsharaghav23 commented 6 years ago

Hi Sir, Code is error free I am trying to execute this in turbo C.I am not getting any output on black screen.why is this so? what thing I am doing wrong can you Please guide me with this.

Thanks

On Fri, Feb 9, 2018 at 9:57 AM, varsha raghav varsharaghav23@gmail.com wrote:

Hi Sir, Yeah some linking error is there for sure.Thanks for your help.I am figuring that out.Thankyou

On Thu, Feb 8, 2018 at 10:04 PM, kokke notifications@github.com wrote:

Closed #3 https://github.com/kokke/tiny-ECDH-c/issues/3.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kokke/tiny-ECDH-c/issues/3#event-1464962907, or mute the thread https://github.com/notifications/unsubscribe-auth/Ah2kzrEJWS0LZ_ayj5Ji6eePsU_bwLHJks5tSyIngaJpZM4Rze6U .

kokke commented 6 years ago

Hi @varsharaghav23

You are compiling a modified version of the code in this project, so I would need to read your code to be able to help you.

varsharaghav23 commented 6 years ago

Please go through with this once and let me know why m not able to decrypt it.

user@instant-contiki:~$ su root Password: root@instant-contiki:/home/user# cd /home/user/Desktop/contiki-2.7/core root@instant-contiki:/home/user/Desktop/contiki-2.7/core# ls cfs contiki-net.h example net contiki-default-conf.h contiki-version.h example1 sys contiki.h ctk lib tiny-ECDH-c-master contiki-lib.h dev loader tiny-ECDH-c-master_Arm root@instant-contiki:/home/user/Desktop/contiki-2.7/core# cd tiny-ECDH-c-master root@instant-contiki:/home/user/Desktop/contiki-2.7/core/tiny-ECDH-c-master# ls Build_GCC.sh ecdh.c ecdh_example.c ecdh.h LICENSE README.md root@instant-contiki:/home/user/Desktop/contiki-2.7/core/tiny-ECDH-c-master# ./Build_GCC.sh ON cleaning up files.......... Files cleaned up......... Now building the Tiny ECDH Project so just Get Ready... cleaning intermediate build files Build is successful .. Executable File Name is KdUrAwsum root@instant-contiki:/home/user/Desktop/contiki-2.7/core/tiny-ECDH-c-master# ls Build_GCC.sh ecdh_example.c ecdh.h KdUrAwsum README.md ecdh.c ecdh_example.o ecdh.o LICENSE root@instant-contiki:/home/user/Desktop/contiki-2.7/core/tiny-ECDH-c-master# ./KdUrAwsum KdUrAwsum: ecdh_example.c:111: ecdh_demo: Assertion `ecdh_shared_secret(prvb, puba, secb)' failed. Aborted (core dumped) root@instant-contiki:/home/user/Desktop/contiki-2.7/core/tiny-ECDH-c-master# gedit ./ecdh_example.c

(gedit:18574): WARNING : The connection is closed

(gedit:18574): EggSMClient-WARNING **: Failed to connect to the session manager: None of the authentication protocols specified are supported

(gedit:18574): WARNING : Could not connect to session bus root@instant-contiki:/home/user/Desktop/contiki-2.7/core/tiny-ECDH-c-master# ./Build_GCC.sh ON cleaning up files.......... Files cleaned up......... Now building the Tiny ECDH Project so just Get Ready... cleaning intermediate build files Build is successful .. Executable File Name is KdUrAwsum root@instant-contiki:/home/user/Desktop/contiki-2.7/core/tiny-ECDH-c-master# ./KdUrAwsum

Failed to decrypt the code seca[i] = 75 secb[i] = 0 Failed to decrypt the code seca[i] = 54 secb[i] = 0 Failed to decrypt the code seca[i] = 204 secb[i] = 0 Failed to decrypt the code seca[i] = 172 secb[i] = 0 Failed to decrypt the code seca[i] = 138 secb[i] = 0 Failed to decrypt the code seca[i] = 206 secb[i] = 0 Failed to decrypt the code seca[i] = 18 secb[i] = 0 Failed to decrypt the code seca[i] = 36 secb[i] = 0 Failed to decrypt the code seca[i] = 82 secb[i] = 0 Failed to decrypt the code seca[i] = 19 secb[i] = 0 Failed to decrypt the code seca[i] = 208 secb[i] = 0 Failed to decrypt the code seca[i] = 32 secb[i] = 0 Failed to decrypt the code seca[i] = 87 secb[i] = 0 Failed to decrypt the code seca[i] = 236 secb[i] = 0 Failed to decrypt the code seca[i] = 103 secb[i] = 0 Failed to decrypt the code seca[i] = 198 secb[i] = 0 Failed to decrypt the code seca[i] = 132 secb[i] = 0 Failed to decrypt the code seca[i] = 205 secb[i] = 0 Failed to decrypt the code seca[i] = 38 secb[i] = 0 Failed to decrypt the code seca[i] = 4 secb[i] = 0 Failed to decrypt the code seca[i] = 4 secb[i] = 0 Successfully decrypted seca[i] = 0 secb[i] = 0 Successfully decrypted seca[i] = 0 secb[i] = 0 Successfully decrypted seca[i] = 0 secb[i] = 0 Failed to decrypt the code seca[i] = 236 secb[i] = 0 Failed to decrypt the code seca[i] = 235 secb[i] = 0 Failed to decrypt the code seca[i] = 66 secb[i] = 0 Failed to decrypt the code seca[i] = 84 secb[i] = 0 Failed to decrypt the code seca[i] = 101 secb[i] = 0 Failed to decrypt the code seca[i] = 61 secb[i] = 0 Failed to decrypt the code seca[i] = 243 secb[i] = 0 Failed to decrypt the code seca[i] = 171 secb[i] = 0 Failed to decrypt the code seca[i] = 181 secb[i] = 0 Failed to decrypt the code seca[i] = 121 secb[i] = 0 Failed to decrypt the code seca[i] = 228 secb[i] = 0 Failed to decrypt the code seca[i] = 211 secb[i] = 0 Failed to decrypt the code seca[i] = 188 secb[i] = 0 Failed to decrypt the code seca[i] = 90 secb[i] = 0 Failed to decrypt the code seca[i] = 72 secb[i] = 0 Failed to decrypt the code seca[i] = 113 secb[i] = 0 Failed to decrypt the code seca[i] = 254 secb[i] = 0 Failed to decrypt the code seca[i] = 58 secb[i] = 0

On Tue, Feb 13, 2018 at 7:07 PM, kokke notifications@github.com wrote:

Hi @varsharaghav23 https://github.com/varsharaghav23

You are compiling a modified version of the code in this project, so I would need to read your code to be able to help you.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kokke/tiny-ECDH-c/issues/3#issuecomment-365268558, or mute the thread https://github.com/notifications/unsubscribe-auth/Ah2kzvLkqHd4cP2SHRdIUAclTXl6uLWlks5tUZANgaJpZM4Rze6U .

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Virus-free. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

kokke commented 6 years ago

Hi @varsharaghav23

I would need to see the code itself, not the output from compiling and running it.

It seems something is not done correctly when trying to create the shared secret, since the assertion error occurs there.

varsharaghav23 commented 6 years ago

I have not modified the code,just took the exact same files.I wanted to execute the ECDH algorithm for my project.Can you tell me what would be the specified output of your code? even I tried to execute this in turbo C there also no error was there m getting the blank screen?

On Tue, Feb 13, 2018 at 9:24 PM, kokke notifications@github.com wrote:

Hi @varsharaghav23 https://github.com/varsharaghav23

I would need to see the code itself, not the output from compiling and running it.

It seems something is not done correctly when trying to create the shared secret, since the assertion error occurs there.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kokke/tiny-ECDH-c/issues/3#issuecomment-365309691, or mute the thread https://github.com/notifications/unsubscribe-auth/Ah2kzpOOLSV_iRojWGCi71R3juuQ5h8wks5tUbA8gaJpZM4Rze6U .

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Virus-free. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

kokke commented 6 years ago

Okay then I would need to see your build script to be able to replicate the issue or be able to guess what is wrong,

varsharaghav23 commented 6 years ago

hi Sir, You Please let me know what input to be taken and what would be the output ? Thanks for your help sir

On Wed, Feb 14, 2018 at 2:13 AM, kokke notifications@github.com wrote:

Okay then I would need to see your build script to be able to replicate the issue or be able to guess what is wrong,

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kokke/tiny-ECDH-c/issues/3#issuecomment-365397741, or mute the thread https://github.com/notifications/unsubscribe-auth/Ah2kztM0Ob2UefaD6ss-wXrO4EtxFuveks5tUfPrgaJpZM4Rze6U .

kokke commented 6 years ago

No I cannot do that, because that depends on which curve you have selected, what your private key is etc. I cannot guess what you are doing before you show it to me.

I need to see the code and the build-script to have any chance of helping you. If you are not willing to provide that, I can't help you.

varsharaghav23 commented 6 years ago

Hi Sir, See that I know it asks us to enter the curve and what private key we are selecting.. the problem is that when I tried to run this in turbo C ,m not able to enter anything[curve or private key].I have not changed the code.I m simple running this...Not getting any errors also..just getting blank screen which i am unable to figure out.

On Mon, Feb 19, 2018 at 11:45 PM, kokke notifications@github.com wrote:

No I cannot do that, because that depends on which curve you have selected, what your private key is etc. I cannot guess what you are doing before you show it to me.

I need to see the code and the build-script to have any chance of helping you. If you are not willing to provide that, I can't help you.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kokke/tiny-ECDH-c/issues/3#issuecomment-366769253, or mute the thread https://github.com/notifications/unsubscribe-auth/Ah2kzhZDaUx4eVZDqjG1HHss_7C15Xyuks5tWbotgaJpZM4Rze6U .