Commit Graph

18 Commits

Author SHA1 Message Date
Jeffrey Altman 31d5c38976 lib/hcrypto: mpz2BN return NULL if mp_ubin_size(s) returns zero
If mp_ubin_size(s) returns zero then mp_to_ubin() will fail and
not return MP_OKAY.  If MP_OKAY is not returned, NULL is returned
to the caller of mpz2BN().

This change avoids the unnecessary memory allocation and function
calls.  It also removes a dereference after null warning from
coverity.

Change-Id: I52ff2c166964e41cb4eef1dac637904bf2bf13bf
2022-01-24 10:14:17 -05:00
Nicolas Williams 77392d5d9c hcrypto: Fix warnings 2022-01-14 12:48:32 -06:00
Andrew Bartlett 9ffbc17a0f Fix (deliberately) unused variable warning in rsa-ltm.c
Seen on Ubuntu 18.04 with
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
giving:

rsa-ltm.c: In function ‘ltm_rsa_private_calculate’:
rsa-ltm.c:135:9: error: variable ‘where’ set but not used [-Werror=unused-but-set-variable]
     int where = 0; /* Ignore the set-but-unused warning from this */
         ^~~~~
rsa-ltm.c: In function ‘gen_p’:
rsa-ltm.c:482:9: error: variable ‘where’ set but not used [-Werror=unused-but-set-variable]
     int where = 0; /* Ignore the set-but-unused warning from this */
         ^~~~~

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2020-05-28 11:10:57 -04:00
Nicolas Williams 001cf39374 hcrypto: Fix more warnings (rsa-ltm) 2020-04-27 17:56:59 -05:00
Nicolas Williams 32517c0627 hcrypto: Better RSA key generation (ltm) 2020-04-27 13:14:21 -05:00
Nicolas Williams e4d1a91c13 hcrypto: Fix warnings in LTM 2020-04-27 13:14:21 -05:00
Luke Howard dfb1e6fcf8 hcrypto: trim number of trials in prime number generation
Reduce the number of trials when generating RSA keys by calling
mp_prime_rabin_miller_trials() with the number of desired bits.

See libtom/libtommath#482.
2020-04-24 11:59:54 +10:00
Luke Howard 7eb397834e hcrypto: make libtommath v1.2.0 work with Heimdal 2020-04-24 11:59:54 +10:00
Jeffrey Altman 0f97855826 hcrypto: config/roken cleanup
All source files in lib/hcrypto should be built the same way.
Since this source directory is dependent on libroken then all source
files must be built using the roken.h declarations and included headers.

Also, there is no config.h in the local directory so angle brackets
include of quotes should be used.

Finally, because roken.h includes stdio.h, stdlib.h, stdarg.h, limits.h,
strings.h, sys/types.h, etc., do not include them separately.

Start all source files with

  #include <config.h>
  #include <roken.h>

Change-Id: I09ab47f8a5472018efe6c8b59a0e51fde8f24724
2016-04-10 17:05:07 -05:00
Love Hörnquist Åstrand 7d163f234b check that e have sane values 2013-10-30 22:29:19 -07:00
Jeffrey Altman 28051fa99c Convert mp_find_prime to use mp_prime_is_prime
Modify the signature of mp_find_prime() to permit the number of
Miller-Rabin rounds to be specified.  In addition, valid responses
now include MP_NO, MP_YES, and MP_VAL which is returned when
mp_prime_is_prime() fails.

Change-Id: I0195129a4dd75875e6dddb6d49a5ceb30afb1a17
2013-10-07 15:18:42 -05:00
Love Hornquist Astrand 0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Love Hornquist Astrand db7f598466 return size is a int, don't pretend. 2010-11-27 12:37:49 -08:00
Love Hornquist Astrand 5410614330 free more bn that was allocated 2010-09-28 22:12:20 -07:00
Love Hornquist Astrand 97d939d9af don't allocate n twice, indent 2010-09-28 22:08:00 -07:00
Love Hornquist Astrand 4f5390877a plug memory leaks 2010-08-23 22:02:10 -07:00
Love Hornquist Astrand 763a72b73a enable ltm, add key blinding, add remove tfm 2010-08-15 15:06:58 -07:00
Love Hornquist Astrand 6c0c936595 select add libtommath 2010-07-18 13:04:03 -07:00