diff options
author | Miloslav Trmač <mitr@redhat.com> | 2010-09-06 15:00:17 +0200 |
---|---|---|
committer | Miloslav Trmač <mitr@redhat.com> | 2010-09-06 15:00:17 +0200 |
commit | c61c13594953d462597ed18d6c77e736878ff9d9 (patch) | |
tree | 583b7cb956cb9fce6c630cc634e772942e3bbaf7 /crypto/userspace/ncr-dh.c | |
parent | 9cab3a1a9660ed5f798b063aa7e827eb0c95ba94 (diff) | |
parent | 8afc069c742f80d3e383ba3d0e38697aeeeb147b (diff) | |
download | kernel-crypto-ncr-standalone-rename.tar.gz kernel-crypto-ncr-standalone-rename.tar.xz kernel-crypto-ncr-standalone-rename.zip |
Merge branch 'standalone-master' into standalone-renamencr-standalone-rename
Conflicts:
crypto/userspace/libtomcrypt/misc/qsort.c
crypto/userspace/libtommath/bn_mp_and.c
crypto/userspace/libtommath/bn_mp_exteuclid.c
crypto/userspace/libtommath/bn_mp_jacobi.c
crypto/userspace/libtommath/bn_mp_or.c
crypto/userspace/libtommath/bn_mp_prime_fermat.c
crypto/userspace/libtommath/bn_mp_radix_size.c
crypto/userspace/libtommath/bn_mp_radix_smap.c
crypto/userspace/libtommath/bn_mp_read_radix.c
crypto/userspace/libtommath/bn_mp_sqrt.c
crypto/userspace/libtommath/bn_mp_toradix.c
crypto/userspace/libtommath/bn_mp_toradix_n.c
crypto/userspace/libtommath/bn_mp_xor.c
examples/Makefile
examples/ncr.c
examples/pk.c
Diffstat (limited to 'crypto/userspace/ncr-dh.c')
-rw-r--r-- | crypto/userspace/ncr-dh.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/crypto/userspace/ncr-dh.c b/crypto/userspace/ncr-dh.c index bc45723fe3e..501eaa399cb 100644 --- a/crypto/userspace/ncr-dh.c +++ b/crypto/userspace/ncr-dh.c @@ -92,20 +92,22 @@ int dh_generate_key(dh_key * key) return -ENOMEM; } - get_random_bytes(buf, size); + do { + get_random_bytes(buf, size); - if ((err = mp_read_unsigned_bin(&key->x, buf, size)) != CRYPT_OK) { - err(); - ret = _ncr_tomerr(err); - goto fail; - } + if ((err = mp_read_unsigned_bin(&key->x, buf, size)) != CRYPT_OK) { + err(); + ret = _ncr_tomerr(err); + goto fail; + } - err = mp_mod(&key->x, &key->p, &key->x); - if (err != CRYPT_OK) { - err(); - ret = _ncr_tomerr(err); - goto fail; - } + err = mp_mod(&key->x, &key->p, &key->x); + if (err != CRYPT_OK) { + err(); + ret = _ncr_tomerr(err); + goto fail; + } + } while(mp_cmp_d(&key->x, 0) == MP_EQ || mp_cmp_d(&key->x, 1) == MP_EQ); key->type = PK_PRIVATE; |