Bug 231 - ssh-keygen has fatal error while updating comment in RSA1 key
Summary: ssh-keygen has fatal error while updating comment in RSA1 key
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh-keygen (show other bugs)
Version: -current
Hardware: HPPA HP-UX
: P2 normal
Assignee: OpenSSH Bugzilla mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-05-02 06:05 AEST by rusr
Modified: 2004-04-14 12:24 AEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description rusr 2002-05-02 06:05:35 AEST
ssh-keygen reports a fatal error while trying to update the comment field of
an RSA1 key. The error reported is 
"Couldn't obtain random bytes (error 604389476)"

This happens because somewhere between 3.0.2p1 and 3.1p1 (the two versions I 
examined), the calls to the init_rng() and seed_rng() in the main function got 
moved from near the beginning of the function to after where all the options 
are processed. The function do_change_comment() handles the comment changing 
and is called during option processing. do_change_comment() calls a function 
save the key file, which uses the random number generator, which has not been 
initialized or seeded and therefore the random number generator reports an 
error.

The simplest fix, in my opinion, is to move the calls to init_rng() and seed_rng
() back to the beginning of the main function so the random number generator is 
always ready to be used. Since this program is not often called, the 
performance impact is negligible.
Comment 1 Kevin Steves 2002-05-12 05:31:23 AEST
the error is not seen in current i believe due to the fix to arc4random()
to call seed_rng() correctly.

is there a way we can reduce the diff in terms of moving function calls
around due to delaying RNG seeding?

http://www.eviladmin.org/cgi-bin/cvsweb.cgi/ssh-keygen.c.diff?r1=1.87&r2=1.88
http://www.eviladmin.org/cgi-bin/cvsweb.cgi/ssh-keygen.c.diff?r1=1.91&r2=1.92



Comment 2 Damien Miller 2002-05-13 11:04:58 AEST
We can just put the call to seed_rng() above all the actions. That is safe and
"future-proof" at the cost of some extraneous processing for some options which
don't need it.

Alternately we can just move the chance comment call to below the seed_rng call
Comment 3 Kevin Steves 2002-07-21 05:05:50 AEST
fixed:
 - (stevesk) [ssh-keygen.c] bug #231: always init/seed_rng().
Comment 4 Damien Miller 2004-04-14 12:24:18 AEST
Mass change of RESOLVED bugs to CLOSED