Libgcrypt: How to implement ECIES encryption (ECC + AES)

Stephan Mueller smueller at chronox.de
Mon Nov 12 13:47:48 CET 2018


Am Montag, 12. November 2018, 13:24:01 CET schrieb Yann Garcia:

Hi Yann,

> Dear All,
> 
> I want to implement ECIES encryption. To do it, I have to 1) generate ECDH
> secret key (the key agreement) and then 2) derive it using Key Derivation
> Function 2 (KDF2).
> 
> 1) For the key agreement, I need to generate a random number.

You need to have the local private ECDH key and the remote public ECDH key. A 
plain random number does not work as you need to send the local public ECDH 
key to your recipient as otherwise he cannot decrypt it.

> Can you
> indicate me the best way to generate this random number because in the
> help, clause 9.2 Retrieving random numbers, I found 3 different methods and
> I don't know which one is the best for my purpose?
> 
> 2) Is it correct to use the function gcry_kdf_derive() with GCRY_KDF_PBKDF2
> flag to do the Key Derivation Function 2?

Nope, PBKDF is not allowed. Key-based KDFs like SP800-108 or RFC5967 are ok. I 
am not sure libgcrypt offers a native implementation of those.
> 
> 3) Does the libgcrypt provides samples for ECIES encryption?
> 
> Many thanks in advance for your help,
> 
> Best regards,
> Yann Garcia
> Senior Software Engineer
> Microsoft MCAD.net Certified
> **************************************
> FSCOM SARL
> Le Montespan B2
> 6,
> <https://maps.google.com/?q=6,%C2%A0+Avenue+des+Alpes&entry=gmail&source=g>
> Avenue des Alpes
> <https://maps.google.com/?q=6,%C2%A0+Avenue+des+Alpes&entry=gmail&source=g>
> F-06600 Antibes, FRANCE
> ************************************************
> Tel: +33 (0)4 92 94 49 08
> Mobile: +33 (0)7 61 00 77 05
> Email: *yann.garcia at fscom.fr* <yann.garcia at fscom.fr>
>            Yann.Garcia_EXT at etsi.org
> Skype: yann.garcia
> Google+: garcia.yann at gmail.com



Ciao
Stephan





More information about the Gcrypt-devel mailing list