summaryrefslogtreecommitdiffstats
path: root/crypto/userspace/ncr-dh.c
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-09-06 15:00:42 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-09-06 15:00:42 +0200
commit0f981ee35028602b9e60ac82b07d54972f6f7331 (patch)
treef8d6df4535fba1fd45dc8b33fb2c8ec03b3956f5 /crypto/userspace/ncr-dh.c
parent5d08c95e8a0101f156cf1afe8b2fae8487d1cfce (diff)
parentc61c13594953d462597ed18d6c77e736878ff9d9 (diff)
downloadkernel-crypto-ncr-userspace-crypto.tar.gz
kernel-crypto-ncr-userspace-crypto.tar.xz
kernel-crypto-ncr-userspace-crypto.zip
Merge branch 'standalone-rename' into userspace-cryptoncr-userspace-crypto
Diffstat (limited to 'crypto/userspace/ncr-dh.c')
-rw-r--r--crypto/userspace/ncr-dh.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/crypto/userspace/ncr-dh.c b/crypto/userspace/ncr-dh.c
index e743c4b8994..f6ab53afc07 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;