4

I recently started working with the LibTomCrypt Library because it claimed to be a well documented C Library to get started with Elliptic Curve Cryptography.

In my first little program I created an ECC key which I afterwards tried to print out. Therefore I used ecc_make_key and the ecc_export function.

unsigned char buf[4][4096]

// I do this for the private and public Key
ecc_export(keyBufPriv[0]  /*keyBufPublic[0]*/, &x, PK_PRIVATE /* PK_PUBLIC */, &keyA)
for (int i = 0; i < x; i++) {
    printf(" %d ", keyBuf[0][i]);
}

Printing them out I wondered why the public Key and the private Key seem to be very similar. There are a some test programs delivered with the library which show the same behavior. I added some printf lines similar to those above in the test program.

output from my program :

output from my short program

output from testprogram :

output from the test program

Due to the similarity between the private and public Key I am asking myself if everything of the libtomcryp library runs as it should to make a secure ECC-Crypto.

1
  • Please next time use a code fragment instead of a screen shot. We cannot parse screen shots. Oct 19, 2015 at 18:13

1 Answer 1

5

As you can see from https://github.com/libtom/libtomcrypt/blob/develop/src/pk/ecc/ecc_export.c it's ASN.1/DER encoded data you're printing, which contains the same data besides the 'k' parameter.

So yes, it's normal that private and public key look similar.

To decode this you can install dumpasn1 which can parse and display the ASN.1 data.

If you want more information on how to use the ecc API, you can have a look at https://github.com/DCIT/perl-CryptX/blob/master/lib/CryptX_PK_ECC.xs.inc

It's not very obvious AND it's not the exact same API as not all of karel's changes are merged into main libtomcrypt (yet), but it should give you an idea.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .