Home GnuPG

Fix a special case bug in mpi_powm for e==0.
6e1adb05d290Unpublished

Unpublished Commit · Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

Fix a special case bug in mpi_powm for e==0.

* mpi/mpi-pow.c (gcry_mpi_powm): For a zero exponent, make sure that
the result has been allocated.

This code triggered the problem:

modulus = gcry_mpi_set_ui(NULL, 100);
generator = gcry_mpi_set_ui(NULL, 3);
exponent = gcry_mpi_set_ui(NULL, 0);
result = gcry_mpi_new(0);
gcry_mpi_powm(result, generator, exponent, modulus);

gcry_mpi_new(0) does not allocate the limb space thus it is not
possible to write even into the first limb. Workaround was to use
gcry_mpi_new (1) but a real fix is better.

  • Reported-by: Ian Goldberg
  • Signed-off-by: Werner Koch <wk@gnupg.org>

Details

Provenance
wernerAuthored on Jul 17 2013, 10:18 AM
Parents
rC61b44812728d: Register DCO for Dmitry Kasatkin.
Branches
Unknown
Tags
Unknown

Event Timeline

Werner Koch <wk@gnupg.org> committed rC6e1adb05d290: Fix a special case bug in mpi_powm for e==0. (authored by Werner Koch <wk@gnupg.org>).Jul 17 2013, 10:18 AM