Skip to content

Commit 3b67cb3

Browse files
committedSep 30, 2014
Merge pull request #12 from grondo/zcert_curve_new-fix
More keygen fixes
2 parents de50b17 + 995cb17 commit 3b67cb3

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed
 

‎src/cmd/flux-keygen.c

+1-9
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static const struct option longopts[] = {
4242
void usage (void)
4343
{
4444
fprintf (stderr,
45-
"Usage: flux-keygen [--force] [--plain|--curve]\n"
45+
"Usage: flux-keygen [--force] [--plain]\n"
4646
);
4747
exit (1);
4848
}
@@ -53,7 +53,6 @@ int main (int argc, char *argv[])
5353
flux_sec_t sec;
5454
bool force = false;
5555
bool plain = false;
56-
bool curve = false;
5756

5857
log_init ("flux-keygen");
5958

@@ -68,24 +67,17 @@ int main (int argc, char *argv[])
6867
case 'p': /* --plain */
6968
plain = true;
7069
break;
71-
case 'c': /* --curve */
72-
curve = true;
73-
break;
7470
default:
7571
usage ();
7672
break;
7773
}
7874
}
7975
if (optind < argc)
8076
usage ();
81-
if (plain && curve)
82-
usage ();
8377
if (!(sec = flux_sec_create ()))
8478
err_exit ("flux_sec_create");
8579
if (plain && flux_sec_enable (sec, FLUX_SEC_TYPE_PLAIN) < 0)
8680
msg_exit ("PLAIN security is not available");
87-
if (curve && flux_sec_enable (sec, FLUX_SEC_TYPE_CURVE) < 0)
88-
msg_exit ("CURVE security is not available");
8981
if (flux_sec_keygen (sec, force, true) < 0)
9082
msg_exit ("%s", flux_sec_errstr (sec));
9183
flux_sec_destroy (sec);

‎src/common/libflux/security.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,8 @@ static zcert_t *zcert_curve_new (flux_sec_t c)
528528
zcert_t *new;
529529
char sec[41];
530530
char pub[41];
531+
uint8_t s[32];
532+
uint8_t p[32];
531533

532534
if (zmq_curve_keypair (pub, sec) < 0) {
533535
if (errno == ENOTSUP)
@@ -539,7 +541,12 @@ static zcert_t *zcert_curve_new (flux_sec_t c)
539541
return NULL;
540542
}
541543

542-
if (!(new = zcert_new_from ((byte *)pub, (byte *)sec)))
544+
if (!zmq_z85_decode (s, sec) || !zmq_z85_decode (p, pub)) {
545+
seterrstr (c, "zcert_curve_new: Failed to decode keys");
546+
return NULL;
547+
}
548+
549+
if (!(new = zcert_new_from (p, s)))
543550
oom ();
544551

545552
return new;
@@ -672,8 +679,6 @@ static int genpasswd (flux_sec_t c, const char *user, bool force, bool verbose)
672679
done:
673680
if (passwds)
674681
zhash_destroy (&passwds);
675-
if (passwd)
676-
free (passwd);
677682
if (uuid)
678683
zuuid_destroy (&uuid);
679684
return rc;

0 commit comments

Comments
 (0)