ECC shared secret

Tyler Jowers jowerstc at gmail.com
Fri Sep 13 18:38:18 CEST 2019


Good Friday,

I'm using gcrypt_pk_genkey() to generate a public-key from a
private-key by supplying the d-mpi.

After that, I'm struggling to figure how the shared secret should be
generated using the same function.

In particular, I'm using NIST P-192 and my SEXP to generate the
initial public-key is "(genkey (ecc (curve "NIST P-192") (d %M)))"
supplied with the u8-pointer private-key converted to an MPI.

For the shared-secret, I've tried "(genkey (ecc (curve "NIST P-192")
%S (d %M)))" with the q-point of the other-party and the local
private-key as an MPI. I did this for both the client and server, and
unfortunately I don't get matching shared-secrets, and yes I made
certain to use the right public-key and private-key for server-side
and client-side.

Another attempt, was setting the other-party's q-point (public key) as
the generator point with the local d-mpi: gcry_pk_genkey(..., "(genkey
(ecc (curve "NIST P-192") (g %S) (d %M)))"
gcry_sexp_cdr(gcry_sexp_find_token(other_party_pubkeydata, "q", 1)),
local_privkey_mpi);  This gave me a public-key (q-point) that matched
the supplied q-point (supplied as the G parameter) verbatim.

How should I generate the shared secret after generating the public
keys on both sides?

Regards,

Tyler Jowers



More information about the Gcrypt-devel mailing list