Using elgamal encryption with a specific (multiplicative) group.

D. Brentjes d.brentjes at gmail.com
Mon Oct 24 15:34:23 CEST 2016


Hi all,

I've been looking at the library and am trying to use it for elgamal
encryption and decryption. So first step is to generate a keypair.

	size_t parse_error_offset;
	gcry_error_t error;

	gcry_sexp_t key_generator;
	error = gcry_sexp_build(&key_generator, &parse_error_offset, "(genkey
(%s (nbits %s)))", "elg", "2048");
	check(error);
	
	gcry_sexp_t key_pair;
	error = gcry_pk_genkey(&key_pair, key_generator);
	check(error);

I took a quick peek in the code and this finds a prime and generator to
use for the encryption and decryption. But I want to supply my own.

So I found that you can use a s-expr "(genkey (algo (domain (p ...) (q
...) (g ...))))" with gcry_pk_genkey, but this only works on DSA

Now I have succesfully gcry_mpi_scan'ed my desired p,q and g (from
rfc5114), But I have no idea how to securely generate a private key for
this group using the gcrypt facilities.

And can I use the MPI facilty after that to calculate the public key (as
long as my private key is stored in secure memory)?

Kind regards,
Dennis.



More information about the Gcrypt-devel mailing list